feat: Refactor accounts service and related DTOs to enhance consumer account management
- Updated AccountsService to filter out OWNER roles in findAll method. - Removed CreateConsumerAccountDto and its role property from account creation logic. - Enhanced BusinessActivitiesService to include complex counts in responses. - Modified ComplexesController and ComplexesService to handle consumer-specific logic. - Introduced CreateConsumerComplexDto and UpdateConsumerComplexDto for complex management. - Updated PosesController and PosesService to manage POS creation and updates with consumer context. - Added utility function to calculate remaining accounts for business activities. - Updated Prisma migration to add account_id to poses and enforce unique constraints.
This commit is contained in:
@@ -8,6 +8,10 @@ export class BusinessActivitiesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
defaultSelect: BusinessActivitySelect = {
|
||||
id: true,
|
||||
name: true,
|
||||
economic_code: true,
|
||||
created_at: true,
|
||||
guild: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -15,9 +19,15 @@ export class BusinessActivitiesService {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
id: true,
|
||||
name: true,
|
||||
created_at: true,
|
||||
complexes: {
|
||||
select: {
|
||||
_count: {
|
||||
select: {
|
||||
pos_list: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
license_activation: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -38,7 +48,7 @@ export class BusinessActivitiesService {
|
||||
}
|
||||
|
||||
private readonly prepareBusinessActivityResponse = (businessActivity: any) => {
|
||||
const { license_activation, ...rest } = businessActivity
|
||||
const { license_activation, complexes, ...rest } = businessActivity
|
||||
const { license, ...license_activation_rest } = license_activation
|
||||
const { accounts_limit, _count } = license
|
||||
|
||||
@@ -47,6 +57,10 @@ export class BusinessActivitiesService {
|
||||
license_info: {
|
||||
...license_activation_rest,
|
||||
accounts_limit: accounts_limit + _count.account_allocations,
|
||||
allocated_account_count: complexes.reduce(
|
||||
(acc: number, complex: any) => acc + complex._count.pos_list,
|
||||
0,
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user