658496320b
- Added new DTOs for correction requests and responses in `nama-provider.dto.ts`. - Updated `nama-provider.adapter.ts` to include `originalSend` and `correctionSend` methods. - Enhanced `nama-provider.util.ts` with mapping functions for correction requests. - Created operational guidelines for agents in `AGENT.md`. - Updated Prisma migrations to support new invoice types and relationships. - Introduced new service and DTO for creating sales invoices in `sale-invoice-create.service.ts` and `sale-invoice-create.dto.ts`. - Added utility for handling Prisma errors in `prisma-error.util.ts`.
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { translateEnumValue } from '../enum-translator.util'
|
|
|
|
export default (consumer: any) => {
|
|
const { legal, individual, activation, type, status, _count, ...rest } = consumer
|
|
|
|
const { business_activities: business_counts } = _count || { business_activities: 0 }
|
|
const partner = legal?.partner || individual?.partner
|
|
delete legal?.partner
|
|
delete individual?.partner
|
|
|
|
return {
|
|
...rest,
|
|
partner,
|
|
type: translateEnumValue('ConsumerType', type),
|
|
status: translateEnumValue('ConsumerStatus', consumer.status),
|
|
legal: legal ? { ...legal } : null,
|
|
individual: individual
|
|
? { ...individual, fullname: `${individual?.first_name} ${individual?.last_name}` }
|
|
: null,
|
|
name: legal ? legal.name : `${individual?.first_name} ${individual?.last_name}`,
|
|
business_counts,
|
|
// license_info: prepareLicenseInfo(activation),
|
|
}
|
|
}
|
|
|
|
function prepareLicenseInfo(latestLicense: any) {
|
|
if (!latestLicense) return null
|
|
const { license, ...rest } = latestLicense
|
|
|
|
return {
|
|
...rest,
|
|
}
|
|
}
|