feat: add response DTOs for various services across modules
- Created response DTOs for ConfigService, AppService, AuthService, CatalogsService, AccountsService, BusinessActivityComplexesService, ComplexPosesService, SalesInvoicesService, BusinessActivitiesService, ConsumerBusinessActivityGoodsService, and others. - Implemented Create, FindAll, FindOne, and Update response types for services in consumer, partners, and POS modules. - Added request DTOs for creating and updating goods in the consumer business activities module. - Introduced filtering DTO for partner licenses. - Enhanced response mapping for partner license activations.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
||||
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
|
||||
import { SalesInvoiceSelect, SalesInvoiceWhereInput } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
@@ -7,7 +9,7 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
export class CustomerSaleInvoicesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
defaultSelect: SalesInvoiceSelect = {
|
||||
private readonly defaultSelect: SalesInvoiceSelect = {
|
||||
id: true,
|
||||
code: true,
|
||||
invoice_date: true,
|
||||
@@ -36,8 +38,7 @@ export class CustomerSaleInvoicesService {
|
||||
role: true,
|
||||
consumer: {
|
||||
select: {
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
...QUERY_CONSTANTS.CONSUMER.infoSelect,
|
||||
},
|
||||
},
|
||||
account: {
|
||||
@@ -62,7 +63,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
const [accounts, total] = await this.prisma.$transaction(async tx => [
|
||||
const [saleInvoices, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.salesInvoice.findMany({
|
||||
where: salesWhere,
|
||||
select: {
|
||||
@@ -81,11 +82,17 @@ export class CustomerSaleInvoicesService {
|
||||
}),
|
||||
])
|
||||
|
||||
const mappedAccounts = accounts.map(account => {
|
||||
const { _count, ...rest } = account
|
||||
const mappedAccounts = saleInvoices.map(saleInvoice => {
|
||||
const { _count, consumer_account, ...rest } = saleInvoice
|
||||
const { consumer, ...restConsumerAccount } = consumer_account as any
|
||||
const mappedConsumer = consumer_mappersUtil(consumer)
|
||||
return {
|
||||
...rest,
|
||||
items_count: _count.items,
|
||||
consumer_account: {
|
||||
...restConsumerAccount,
|
||||
consumer: mappedConsumer,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -97,7 +104,7 @@ export class CustomerSaleInvoicesService {
|
||||
}
|
||||
|
||||
async findOne(consumer_id: string, customer_id: string, id: string) {
|
||||
const account = await this.prisma.salesInvoice.findUniqueOrThrow({
|
||||
const saleInvoice = await this.prisma.salesInvoice.findUniqueOrThrow({
|
||||
where: {
|
||||
id,
|
||||
customer_id,
|
||||
@@ -111,7 +118,6 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
select: {
|
||||
...this.defaultSelect,
|
||||
|
||||
items: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -147,6 +153,17 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.single(account)
|
||||
const { _count, consumer_account, ...rest } = saleInvoice
|
||||
const { consumer, ...restConsumerAccount } = consumer_account as any
|
||||
const mappedConsumer = consumer_mappersUtil(consumer)
|
||||
|
||||
return ResponseMapper.single({
|
||||
...rest,
|
||||
items_count: _count.items,
|
||||
consumer_account: {
|
||||
...restConsumerAccount,
|
||||
consumer: mappedConsumer,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user