diff --git a/modules/customer-invoices/src/api/application/helpers/format-payment_method-dto.ts b/modules/customer-invoices/src/api/application/helpers/format-payment_method-dto.ts new file mode 100644 index 00000000..ab626de0 --- /dev/null +++ b/modules/customer-invoices/src/api/application/helpers/format-payment_method-dto.ts @@ -0,0 +1,13 @@ +export function formatPaymentMethodDTO(paymentMethod: object) { + if (!paymentMethod) { + return null; + } + + //Construir objeto paymentMethod para comprobar que existe + //const value = PaymentMethod.create( + // id: paymentMethod.payment_id), + //).data; + //return value.format(locale); + + return paymentMethod.payment_description; +} diff --git a/modules/customer-invoices/src/api/application/helpers/index.ts b/modules/customer-invoices/src/api/application/helpers/index.ts index 789c112f..8134db38 100644 --- a/modules/customer-invoices/src/api/application/helpers/index.ts +++ b/modules/customer-invoices/src/api/application/helpers/index.ts @@ -1,5 +1,6 @@ export * from "./format-date-dto"; export * from "./format-money-dto"; +export * from "./format-payment_method-dto"; export * from "./format-percentage-dto"; export * from "./format-quantity-dto"; export * from "./map-dto-to-customer-invoice-props"; diff --git a/modules/customer-invoices/src/api/application/presenters/domain/customer-invoice.full.presenter.ts b/modules/customer-invoices/src/api/application/presenters/domain/customer-invoice.full.presenter.ts index dffab74e..3b3b852a 100644 --- a/modules/customer-invoices/src/api/application/presenters/domain/customer-invoice.full.presenter.ts +++ b/modules/customer-invoices/src/api/application/presenters/domain/customer-invoice.full.presenter.ts @@ -24,6 +24,17 @@ export class CustomerInvoiceFullPresenter extends Presenter< const items = itemsPresenter.toOutput(invoice.items); const allAmounts = invoice.getAllAmounts(); + const payment = invoice.paymentMethod.match( + (payment) => { + const { id, payment_description } = payment.toObjectString(); + return { + payment_id: id, + payment_description, + }; + }, + () => undefined + ); + return { id: invoice.id.toString(), company_id: invoice.companyId.toString(), @@ -45,6 +56,8 @@ export class CustomerInvoiceFullPresenter extends Presenter< taxes: invoice.taxes.getCodesToString(), + payment_method: payment, + subtotal_amount: allAmounts.subtotalAmount.toObjectString(), discount_percentage: invoice.discountPercentage.toObjectString(), diff --git a/modules/customer-invoices/src/api/application/presenters/queries/customer-invoice.report.presenter.ts b/modules/customer-invoices/src/api/application/presenters/queries/customer-invoice.report.presenter.ts index 06185fd0..b944086b 100644 --- a/modules/customer-invoices/src/api/application/presenters/queries/customer-invoice.report.presenter.ts +++ b/modules/customer-invoices/src/api/application/presenters/queries/customer-invoice.report.presenter.ts @@ -6,6 +6,7 @@ import { formatMoneyDTO, formatPercentageDTO, } from "../../helpers"; +import { formatPaymentMethodDTO } from "../../helpers/format-payment_method-dto"; export class CustomerInvoiceReportPresenter extends Presenter< GetCustomerInvoiceByIdResponseDTO, @@ -40,6 +41,8 @@ export class CustomerInvoiceReportPresenter extends Presenter< taxable_amount: formatMoneyDTO(invoiceDTO.taxable_amount, moneyOptions), taxes_amount: formatMoneyDTO(invoiceDTO.taxes_amount, moneyOptions), total_amount: formatMoneyDTO(invoiceDTO.total_amount, moneyOptions), + + payment_method: formatPaymentMethodDTO(invoiceDTO.payment_method), }; } } diff --git a/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.pdf.ts b/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.pdf.ts index cc0ca951..19cb8ad1 100644 --- a/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.pdf.ts +++ b/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.pdf.ts @@ -45,14 +45,14 @@ export class CustomerInvoiceReportPDFPresenter extends Presenter< right: "10mm", top: "10mm", }, - // landscape: false, - // preferCSSPageSize: true, - // omitBackground: false, - // printBackground: true, - // displayHeaderFooter: false, - // headerTemplate: "
", - // footerTemplate: - // 'Forma de pago: {{payment_method}}
+Forma de pago: {{payment_method}}
Notas: {{notes}}