19 lines
755 B
TypeScript
19 lines
755 B
TypeScript
import { ICustomerInvoiceService } from "@/contexts/customer-billing/domain";
|
|
import { CustomerInvoice } from "@/contexts/customer-billing/domain/aggregates";
|
|
import { UniqueID } from "@/core/common/domain";
|
|
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
|
import { Result } from "@repo/rdx-utils";
|
|
|
|
export class GetCustomerInvoiceUseCase {
|
|
constructor(
|
|
private readonly invoiceService: ICustomerInvoiceService,
|
|
private readonly transactionManager: ITransactionManager
|
|
) {}
|
|
|
|
public execute(invoiceId: UniqueID): Promise<Result<CustomerInvoice, Error>> {
|
|
return this.transactionManager.complete((transaction) => {
|
|
return this.invoiceService.findCustomerInvoiceById(invoiceId, transaction);
|
|
});
|
|
}
|
|
}
|