Uecko_ERP/modules/customer-invoices/src/api/application/list-customer-invoices.use-case.ts
2025-06-11 17:13:44 +02:00

23 lines
865 B
TypeScript

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<Result<Collection<CustomerInvoice>, 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);
}
});
}
}