diff --git a/modules/customer-invoices/src/api/application/use-cases/report/delete-customer-invoice.use-case.ts b/modules/customer-invoices/src/api/application/use-cases/report/delete-customer-invoice.use-case.ts deleted file mode 100644 index 332924fb..00000000 --- a/modules/customer-invoices/src/api/application/use-cases/report/delete-customer-invoice.use-case.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { EntityNotFoundError, ITransactionManager } from "@erp/core/api"; -import { UniqueID } from "@repo/rdx-ddd"; -import { Result } from "@repo/rdx-utils"; -import { CustomerInvoiceApplicationService } from "../../../domain"; - -type DeleteCustomerInvoiceUseCaseInput = { - companyId: UniqueID; - invoice_id: string; -}; - -export class DeleteCustomerInvoiceUseCase { - constructor( - private readonly service: CustomerInvoiceApplicationService, - private readonly transactionManager: ITransactionManager - ) {} - - public execute(params: DeleteCustomerInvoiceUseCaseInput) { - const { invoice_id, companyId } = params; - - const idOrError = UniqueID.create(invoice_id); - - if (idOrError.isFailure) { - return Result.fail(idOrError.error); - } - - const invoiceId = idOrError.data; - - return this.transactionManager.complete(async (transaction) => { - try { - const existsCheck = await this.service.existsByIdInCompany( - companyId, - invoiceId, - transaction - ); - - if (existsCheck.isFailure) { - return Result.fail(existsCheck.error); - } - - const invoiceExists = existsCheck.data; - - if (!invoiceExists) { - return Result.fail( - new EntityNotFoundError("Customer invoice", "id", invoiceId.toString()) - ); - } - - return await this.service.deleteInvoiceByIdInCompany(companyId, invoiceId, transaction); - } catch (error: unknown) { - return Result.fail(error as Error); - } - }); - } -} diff --git a/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.html.ts b/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.html.ts index 14cc5e35..5a55150c 100644 --- a/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.html.ts +++ b/modules/customer-invoices/src/api/application/use-cases/report/reporter/customer-invoice.report.html.ts @@ -3,19 +3,20 @@ import path from "node:path"; import { Presenter } from "@erp/core/api"; import * as handlebars from "handlebars"; import { CustomerInvoice } from "../../../../domain"; +import { CustomerInvoiceReportPresenter, CustomerInvoiceFullPresenter } from "../../../presenters"; export class CustomerInvoiceReportHTMLPresenter extends Presenter { toOutput(customerInvoice: CustomerInvoice): string { const dtoPresenter = this.presenterRegistry.getPresenter({ resource: "customer-invoice", projection: "FULL", - }); + }) as CustomerInvoiceFullPresenter; const prePresenter = this.presenterRegistry.getPresenter({ resource: "customer-invoice", projection: "REPORT", format: "JSON", - }); + }) as CustomerInvoiceReportPresenter; const invoiceDTO = dtoPresenter.toOutput(customerInvoice); const prettyDTO = prePresenter.toOutput(invoiceDTO);