import { ITransactionManager } from "@erp/core/api"; import { Criteria } from "@repo/rdx-criteria/server"; import { Collection, Result } from "@repo/rdx-utils"; import { Transaction } from "sequelize"; import { ICustomerInvoiceService, CustomerInvoice } from "../domain"; export class ListCustomerInvoicesUseCase { constructor( private readonly customerCustomerInvoiceService: ICustomerInvoiceService, private readonly transactionManager: ITransactionManager ) {} public execute(criteria: Criteria): Promise, Error>> { return this.transactionManager.complete(async (transaction: Transaction) => { try { return await this.customerCustomerInvoiceService.findCustomerInvoices(criteria, transaction); } catch (error: unknown) { return Result.fail(error as Error); } }); } }