Refactor Partner and POS models to replace 'serial' with 'serial_number' and update related services and DTOs
- Updated PartnerAccountQuotaAllocation model to change license relation. - Refactored Pos model to replace 'serial' with 'serial_number' across all references. - Modified BusinessActivitiesService to include license activation details in responses. - Adjusted ComplexPosesService to reflect changes in the Pos model. - Updated PartnerService to include a new method for updating partner profiles. - Created UpdatePartnerProfileDto for partner profile updates. - Added migration to drop 'serial' column and add unique 'serial_number' column in poses table.
This commit is contained in:
@@ -7,7 +7,7 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
export class BusinessActivitiesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
defaultSelect = {
|
||||
defaultSelect: BusinessActivitySelect = {
|
||||
guild: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -18,7 +18,38 @@ export class BusinessActivitiesService {
|
||||
id: true,
|
||||
name: true,
|
||||
created_at: true,
|
||||
} as BusinessActivitySelect
|
||||
license_activation: {
|
||||
select: {
|
||||
id: true,
|
||||
starts_at: true,
|
||||
expires_at: true,
|
||||
license: {
|
||||
select: {
|
||||
accounts_limit: true,
|
||||
_count: {
|
||||
select: {
|
||||
account_allocations: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
private readonly prepareBusinessActivityResponse = (businessActivity: any) => {
|
||||
const { license_activation, ...rest } = businessActivity
|
||||
const { license, ...license_activation_rest } = license_activation
|
||||
const { accounts_limit, _count } = license
|
||||
|
||||
return {
|
||||
...rest,
|
||||
license_info: {
|
||||
...license_activation_rest,
|
||||
accounts_limit: accounts_limit + _count.account_allocations,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string) {
|
||||
const businessActivities = await this.prisma.businessActivity.findMany({
|
||||
@@ -27,7 +58,9 @@ export class BusinessActivitiesService {
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.list(businessActivities)
|
||||
return ResponseMapper.list(
|
||||
businessActivities.map(this.prepareBusinessActivityResponse),
|
||||
)
|
||||
}
|
||||
|
||||
async findOne(consumer_id: string, id: string) {
|
||||
@@ -35,7 +68,7 @@ export class BusinessActivitiesService {
|
||||
where: { consumer_id, id },
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.single(businessActivity)
|
||||
return ResponseMapper.single(this.prepareBusinessActivityResponse(businessActivity))
|
||||
}
|
||||
|
||||
async update(consumer_id: string, id: string, data: any) {
|
||||
@@ -44,6 +77,6 @@ export class BusinessActivitiesService {
|
||||
data,
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.update(businessActivity)
|
||||
return ResponseMapper.update(this.prepareBusinessActivityResponse(businessActivity))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import { UpdateComplexDto } from './dto/complex.dto'
|
||||
export class BusinessActivityComplexesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
defaultSelect = {
|
||||
defaultSelect: ComplexSelect = {
|
||||
id: true,
|
||||
name: true,
|
||||
address: true,
|
||||
tax_id: true,
|
||||
branch_code: true,
|
||||
created_at: true,
|
||||
} as ComplexSelect
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, business_activity_id: string) {
|
||||
const accounts = await this.prisma.complex.findMany({
|
||||
|
||||
@@ -13,7 +13,7 @@ export class ComplexPosesService {
|
||||
id: true,
|
||||
name: true,
|
||||
model: true,
|
||||
serial: true,
|
||||
serial_number: true,
|
||||
status: true,
|
||||
created_at: true,
|
||||
pos_type: true,
|
||||
|
||||
Reference in New Issue
Block a user