64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
|
|
import { GetCustomerInvoiceByIdResponseDTO } from "@erp/customer-invoices/common/dto";
|
||
|
|
import { CustomerInvoice } from "../../../domain";
|
||
|
|
|
||
|
|
export class GetCustomerInvoiceAssembler {
|
||
|
|
toDTO(customerInvoice: CustomerInvoice): GetCustomerInvoiceByIdResponseDTO {
|
||
|
|
return {
|
||
|
|
id: customerInvoice.id.toPrimitive(),
|
||
|
|
|
||
|
|
invoice_status: customerInvoice.status.toString(),
|
||
|
|
invoice_number: customerInvoice.invoiceNumber.toString(),
|
||
|
|
invoice_series: customerInvoice.invoiceSeries.toString(),
|
||
|
|
issue_date: customerInvoice.issueDate.toDateString(),
|
||
|
|
operation_date: customerInvoice.operationDate.toDateString(),
|
||
|
|
language_code: "ES",
|
||
|
|
currency: customerInvoice.currency,
|
||
|
|
|
||
|
|
metadata: {
|
||
|
|
entity: "customer-invoices",
|
||
|
|
},
|
||
|
|
|
||
|
|
//subtotal: customerInvoice.calculateSubtotal().toPrimitive(),
|
||
|
|
|
||
|
|
//total: customerInvoice.calculateTotal().toPrimitive(),
|
||
|
|
|
||
|
|
/*items:
|
||
|
|
customerInvoice.items.size() > 0
|
||
|
|
? customerInvoice.items.map((item: CustomerInvoiceItem) => ({
|
||
|
|
description: item.description.toString(),
|
||
|
|
quantity: item.quantity.toPrimitive(),
|
||
|
|
unit_measure: "",
|
||
|
|
unit_price: item.unitPrice.toPrimitive(),
|
||
|
|
subtotal: item.calculateSubtotal().toPrimitive(),
|
||
|
|
//tax_amount: item.calculateTaxAmount().toPrimitive(),
|
||
|
|
total: item.calculateTotal().toPrimitive(),
|
||
|
|
}))
|
||
|
|
: [],*/
|
||
|
|
|
||
|
|
//sender: {}, //await CustomerInvoiceParticipantAssembler(customerInvoice.senderId, context),
|
||
|
|
|
||
|
|
/*recipient: await CustomerInvoiceParticipantAssembler(customerInvoice.recipient, context),
|
||
|
|
items: customerInvoiceItemAssembler(customerInvoice.items, context),
|
||
|
|
|
||
|
|
payment_term: {
|
||
|
|
payment_type: "",
|
||
|
|
due_date: "",
|
||
|
|
},
|
||
|
|
|
||
|
|
due_amount: {
|
||
|
|
currency: customerInvoice.currency.toString(),
|
||
|
|
precision: 2,
|
||
|
|
amount: 0,
|
||
|
|
},
|
||
|
|
|
||
|
|
custom_fields: [],
|
||
|
|
|
||
|
|
metadata: {
|
||
|
|
create_time: "",
|
||
|
|
last_updated_time: "",
|
||
|
|
delete_time: "",
|
||
|
|
},*/
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|