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:
2026-04-24 23:02:05 +03:30
parent 9b652a3603
commit 12506de863
43 changed files with 4645 additions and 2196 deletions
@@ -1,7 +1,8 @@
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
import { PartnerInfo } from '@/common/decorators/partnerInfo.decorator'
import { Body, Controller, Get, Param, Patch } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { AccountsService } from './accounts.service'
import { CreateConsumerAccountDto, UpdateAccountDto } from './dto/account.dto'
import { UpdateAccountDto } from './dto/account.dto'
@ApiTags('PartnerConsumerAccounts')
@Controller('partner/consumers/:consumerId/accounts')
@@ -9,26 +10,39 @@ export class AccountsController {
constructor(private readonly accountsService: AccountsService) {}
@Get()
async findAll(@Param('consumerId') consumerId: string) {
return this.accountsService.findAll(consumerId)
async findAll(
@PartnerInfo('id') partnerId: string,
@Param('consumerId') consumerId: string,
) {
return this.accountsService.findAll(partnerId, consumerId)
}
@Get(':id')
async findOne(@Param('id') id: string) {
return this.accountsService.findOne(id)
async findOne(
@PartnerInfo('id') partnerId: string,
@Param('consumerId') consumerId: string,
@Param('id') id: string,
) {
return this.accountsService.findOne(partnerId, consumerId, id)
}
@Post()
async create(
@Param('consumerId') consumerId: string,
@Body() data: CreateConsumerAccountDto,
) {
return this.accountsService.create(consumerId, data)
}
// @Post()
// async create(
// @PartnerInfo('id') partnerId: string,
// @Param('consumerId') consumerId: string,
// @Body() data: CreateConsumerAccountDto,
// ) {
// return this.accountsService.create(partnerId, consumerId, data)
// }
@Patch(':id')
async update(@Param('id') id: string, @Body() data: UpdateAccountDto) {
return this.accountsService.update(id, data)
async update(
@PartnerInfo('id') partnerId: string,
@Param('consumerId') consumerId: string,
@Param('id') id: string,
@Body() data: UpdateAccountDto,
) {
return this.accountsService.update(partnerId, consumerId, id, data)
}
// @Delete(':id')