60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
|
|
import { IGetCustomerInvoiceResponseDTO } from "../../../../../common/dto";
|
||
|
|
import { CustomerInvoice, CustomerInvoiceItem } from "../../../../domain";
|
||
|
|
|
||
|
|
export interface IGetCustomerInvoicePresenter {
|
||
|
|
toDTO: (customerCustomerInvoice: CustomerInvoice) => IGetCustomerInvoiceResponseDTO;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const getCustomerInvoicePresenter: IGetCustomerInvoicePresenter = {
|
||
|
|
toDTO: (customerCustomerInvoice: CustomerInvoice): IGetCustomerInvoiceResponseDTO => ({
|
||
|
|
id: customerCustomerInvoice.id.toPrimitive(),
|
||
|
|
|
||
|
|
customerCustomerInvoice_status: customerCustomerInvoice.status.toString(),
|
||
|
|
customerCustomerInvoice_number: customerCustomerInvoice.customerCustomerInvoiceNumber.toString(),
|
||
|
|
customerCustomerInvoice_series: customerCustomerInvoice.customerCustomerInvoiceSeries.toString(),
|
||
|
|
issue_date: customerCustomerInvoice.issueDate.toDateString(),
|
||
|
|
operation_date: customerCustomerInvoice.operationDate.toDateString(),
|
||
|
|
language_code: "ES",
|
||
|
|
currency: customerCustomerInvoice.customerCustomerInvoiceCurrency.toString(),
|
||
|
|
subtotal: customerCustomerInvoice.calculateSubtotal().toPrimitive(),
|
||
|
|
total: customerCustomerInvoice.calculateTotal().toPrimitive(),
|
||
|
|
|
||
|
|
items:
|
||
|
|
customerCustomerInvoice.items.size() > 0
|
||
|
|
? customerCustomerInvoice.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 CustomerInvoiceParticipantPresenter(customerCustomerInvoice.senderId, context),
|
||
|
|
|
||
|
|
/*recipient: await CustomerInvoiceParticipantPresenter(customerCustomerInvoice.recipient, context),
|
||
|
|
items: customerCustomerInvoiceItemPresenter(customerCustomerInvoice.items, context),
|
||
|
|
|
||
|
|
payment_term: {
|
||
|
|
payment_type: "",
|
||
|
|
due_date: "",
|
||
|
|
},
|
||
|
|
|
||
|
|
due_amount: {
|
||
|
|
currency: customerCustomerInvoice.currency.toString(),
|
||
|
|
precision: 2,
|
||
|
|
amount: 0,
|
||
|
|
},
|
||
|
|
|
||
|
|
custom_fields: [],
|
||
|
|
|
||
|
|
metadata: {
|
||
|
|
create_time: "",
|
||
|
|
last_updated_time: "",
|
||
|
|
delete_time: "",
|
||
|
|
},*/
|
||
|
|
}),
|
||
|
|
};
|