diff --git a/modules/customer-invoices/src/api/application/helpers/map-dto-to-customer-invoice-props.ts b/modules/customer-invoices/src/api/application/helpers/map-dto-to-customer-invoice-props.ts index 8d1947a2..02c561c8 100644 --- a/modules/customer-invoices/src/api/application/helpers/map-dto-to-customer-invoice-props.ts +++ b/modules/customer-invoices/src/api/application/helpers/map-dto-to-customer-invoice-props.ts @@ -33,12 +33,12 @@ export function mapDTOToCustomerInvoiceProps(dto: CreateCustomerInvoiceRequestDT const invoiceId = extractOrPushError(UniqueID.create(dto.id), "id", errors); const invoiceNumber = extractOrPushError( - CustomerInvoiceNumber.create(dto.invoice_number), + maybeFromNullableVO(dto.invoice_number, (value) => CustomerInvoiceNumber.create(value)), "invoice_number", errors ); const invoiceSeries = extractOrPushError( - maybeFromNullableVO(dto.invoice_series, (value) => CustomerInvoiceSerie.create(value)), + maybeFromNullableVO(dto.series, (value) => CustomerInvoiceSerie.create(value)), "invoice_series", errors ); diff --git a/modules/customer-invoices/src/api/application/presenters/queries/list-customer-invoices.presenter.ts b/modules/customer-invoices/src/api/application/presenters/queries/list-customer-invoices.presenter.ts index 7e1a872a..ec274f77 100644 --- a/modules/customer-invoices/src/api/application/presenters/queries/list-customer-invoices.presenter.ts +++ b/modules/customer-invoices/src/api/application/presenters/queries/list-customer-invoices.presenter.ts @@ -14,7 +14,7 @@ export class ListCustomerInvoicesPresenter extends Presenter { company_id: invoice.companyId.toString(), customer_id: invoice.customerId.toString(), - invoice_number: invoice.invoiceNumber.toString(), + invoice_number: toEmptyString(invoice.invoiceNumber, (value) => value.toString()), status: invoice.status.toPrimitive(), series: toEmptyString(invoice.series, (value) => value.toString()), diff --git a/modules/customer-invoices/src/api/domain/aggregates/customer-invoice.ts b/modules/customer-invoices/src/api/domain/aggregates/customer-invoice.ts index 5c8d5aeb..75ba904b 100644 --- a/modules/customer-invoices/src/api/domain/aggregates/customer-invoice.ts +++ b/modules/customer-invoices/src/api/domain/aggregates/customer-invoice.ts @@ -34,6 +34,7 @@ export interface CustomerInvoiceProps { recipient: Maybe; reference: Maybe; + description: Maybe; notes: Maybe; languageCode: LanguageCode; @@ -144,6 +145,10 @@ export class CustomerInvoice return this.props.reference; } + public get description(): Maybe { + return this.props.description; + } + public get notes(): Maybe { return this.props.notes; } diff --git a/modules/customer-invoices/src/api/infrastructure/mappers/domain/customer-invoice.mapper.ts b/modules/customer-invoices/src/api/infrastructure/mappers/domain/customer-invoice.mapper.ts index 77604846..99dbf7f5 100644 --- a/modules/customer-invoices/src/api/infrastructure/mappers/domain/customer-invoice.mapper.ts +++ b/modules/customer-invoices/src/api/infrastructure/mappers/domain/customer-invoice.mapper.ts @@ -149,6 +149,12 @@ export class CustomerInvoiceDomainMapper errors ); + const description = extractOrPushError( + maybeFromNullableVO(source.description, (value) => Result.ok(String(value))), + "description", + errors + ); + const notes = extractOrPushError( maybeFromNullableVO(source.notes, (value) => TextValue.create(value)), "notes", @@ -187,6 +193,7 @@ export class CustomerInvoiceDomainMapper invoiceDate, operationDate, reference, + description, notes, languageCode, currencyCode, @@ -267,7 +274,9 @@ export class CustomerInvoiceDomainMapper // 5) Si hubo errores de mapeo, devolvemos colección de validación if (errors.length > 0) { - return Result.fail(new ValidationErrorCollection("Customer mapping failed", errors)); + return Result.fail( + new ValidationErrorCollection("Customer invoice mapping failed [mapToDomain]", errors) + ); } // 6) Construcción del agregado (Dominio) @@ -295,6 +304,7 @@ export class CustomerInvoiceDomainMapper recipient: recipient, reference: attributes.reference!, + description: attributes.description!, notes: attributes.notes!, languageCode: attributes.languageCode!, @@ -391,6 +401,7 @@ export class CustomerInvoiceDomainMapper currency_code: source.currencyCode.toPrimitive(), reference: toNullable(source.reference, (reference) => reference), + description: toNullable(source.description, (description) => description), notes: toNullable(source.notes, (notes) => notes.toPrimitive()), subtotal_amount_value: allAmounts.subtotalAmount.value, diff --git a/modules/customer-invoices/src/api/infrastructure/mappers/queries/customer-invoice.list.mapper.ts b/modules/customer-invoices/src/api/infrastructure/mappers/queries/customer-invoice.list.mapper.ts index 8263cd26..495a5470 100644 --- a/modules/customer-invoices/src/api/infrastructure/mappers/queries/customer-invoice.list.mapper.ts +++ b/modules/customer-invoices/src/api/infrastructure/mappers/queries/customer-invoice.list.mapper.ts @@ -31,13 +31,15 @@ export type CustomerInvoiceListDTO = { companyId: UniqueID; isProforma: boolean; - invoiceNumber: CustomerInvoiceNumber; + invoiceNumber: Maybe; status: CustomerInvoiceStatus; series: Maybe; invoiceDate: UtcDate; operationDate: Maybe; + description: Maybe; + customerId: UniqueID; recipient: InvoiceRecipient; @@ -97,7 +99,9 @@ export class CustomerInvoiceListMapper // 5) Si hubo errores de mapeo, devolvemos colección de validación if (errors.length > 0) { - return Result.fail(new ValidationErrorCollection("Customer invoice mapping failed", errors)); + return Result.fail( + new ValidationErrorCollection("Customer invoice mapping failed [mapToDTO]", errors) + ); } return Result.ok({ @@ -110,6 +114,8 @@ export class CustomerInvoiceListMapper invoiceDate: attributes.invoiceDate!, operationDate: attributes.operationDate!, + description: attributes.description!, + customerId: attributes.customerId!, recipient: recipientResult.data, @@ -148,7 +154,7 @@ export class CustomerInvoiceListMapper ); const invoiceNumber = extractOrPushError( - CustomerInvoiceNumber.create(raw.invoice_number), + maybeFromNullableVO(raw.invoice_number, (value) => CustomerInvoiceNumber.create(value)), "invoice_number", errors ); @@ -165,6 +171,12 @@ export class CustomerInvoiceListMapper errors ); + const description = extractOrPushError( + maybeFromNullableVO(raw.description, (value) => value), + "description", + errors + ); + const languageCode = extractOrPushError( LanguageCode.create(raw.language_code), "language_code", @@ -241,6 +253,7 @@ export class CustomerInvoiceListMapper invoiceNumber, invoiceDate, operationDate, + description, languageCode, currencyCode, discountPercentage, diff --git a/modules/customers/src/api/infrastructure/mappers/queries/customer.list.mapper.ts b/modules/customers/src/api/infrastructure/mappers/queries/customer.list.mapper.ts index 59ece247..88678b54 100644 --- a/modules/customers/src/api/infrastructure/mappers/queries/customer.list.mapper.ts +++ b/modules/customers/src/api/infrastructure/mappers/queries/customer.list.mapper.ts @@ -209,7 +209,9 @@ export class CustomerListMapper // Si hubo errores de mapeo, devolvemos colección de validación if (errors.length > 0) { - return Result.fail(new ValidationErrorCollection("Customer invoice mapping failed", errors)); + return Result.fail( + new ValidationErrorCollection("Customer mapping failed [mapToDTO]", errors) + ); } return Result.ok({