feat(partners): add utility functions for partner business activity allocation limits and remaining licenses
- Implemented `getPartnerBusinessActivityAllocationLimits` to retrieve allocation limits for a partner's business activity. - Added `ensurePartnerBusinessActivityHasRemainingAllocation` to validate remaining allocation credits. - Created `getPartnerRemainingLicenses` to count remaining licenses for a partner. - Developed `getPartnerFirstRemainingLicense` to fetch the first unused license for a partner. - Introduced `ensurePartnerHasRemainingLicense` to ensure a partner has at least one unused license.
This commit is contained in:
@@ -31,11 +31,11 @@ export class BusinessActivityComplexesService {
|
||||
})
|
||||
|
||||
async findAll(partner_id: string, consumer_id: string, business_activity_id: string) {
|
||||
const accounts = await this.prisma.complex.findMany({
|
||||
const complexes = await this.prisma.complex.findMany({
|
||||
where: this.defaultWhere(partner_id, consumer_id, business_activity_id),
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.list(accounts)
|
||||
return ResponseMapper.list(complexes)
|
||||
}
|
||||
|
||||
async findOne(
|
||||
@@ -44,18 +44,18 @@ export class BusinessActivityComplexesService {
|
||||
business_activity_id: string,
|
||||
id: string,
|
||||
) {
|
||||
const account = await this.prisma.complex.findUnique({
|
||||
const complex = await this.prisma.complex.findUnique({
|
||||
where: {
|
||||
...this.defaultWhere(partner_id, consumer_id, business_activity_id),
|
||||
id,
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.single(account)
|
||||
return ResponseMapper.single(complex)
|
||||
}
|
||||
|
||||
async create(business_id: string, data: CreateComplexDto) {
|
||||
const account = await this.prisma.complex.create({
|
||||
async create(partner_id: string, business_id: string, data: CreateComplexDto) {
|
||||
const complex = await this.prisma.complex.create({
|
||||
data: {
|
||||
...data,
|
||||
business_activity: {
|
||||
@@ -65,7 +65,7 @@ export class BusinessActivityComplexesService {
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.create(account)
|
||||
return ResponseMapper.create(complex)
|
||||
}
|
||||
|
||||
async update(
|
||||
@@ -75,11 +75,11 @@ export class BusinessActivityComplexesService {
|
||||
id: string,
|
||||
data: UpdateComplexDto,
|
||||
) {
|
||||
const account = await this.prisma.complex.update({
|
||||
const complex = await this.prisma.complex.update({
|
||||
where: { ...this.defaultWhere(partner_id, consumer_id, business_activity_id), id },
|
||||
data,
|
||||
})
|
||||
return ResponseMapper.update(account)
|
||||
return ResponseMapper.update(complex)
|
||||
}
|
||||
|
||||
// async delete(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user