import { Invoice } from "@/contexts/invoices/domain";
import { ICreateInvoiceResponseDTO } from "../../../dto";

export interface ICreateInvoicePresenter {
  toDTO: (invoice: Invoice) => ICreateInvoiceResponseDTO;
}

export const createInvoicePresenter: ICreateInvoicePresenter = {
  toDTO: (invoice: Invoice): ICreateInvoiceResponseDTO => ({
    id: invoice.id.toString(),

    invoice_status: invoice.status.toString(),
    invoice_number: invoice.invoiceNumber.toString(),
    invoice_series: invoice.invoiceSeries.toString(),
    issue_date: invoice.issueDate.toDateString(),
    operation_date: invoice.operationDate.toDateString(),
    language_code: "es",
    currency: invoice.invoiceCurrency || "EUR",
    subtotal: invoice.calculateSubtotal().toPrimitive(),
    total: invoice.calculateTotal().toPrimitive(),

    //sender: {}, //await InvoiceParticipantPresenter(invoice.senderId, context),

    //customer: InvoiceParticipantPresenter(invoice.recipient, context),

    //items: invoiceItemPresenter(invoice.items, context),
  }),
};
