import { ITransactionManager } from "@/core/common/infrastructure/database";
import { Collection, Result } from "@repo/rdx-utils";
import { CustomerInvoice, ICustomerInvoiceService } from "../domain";

export class ListCustomerInvoicesUseCase {
  constructor(
    private readonly invoiceService: ICustomerInvoiceService,
    private readonly transactionManager: ITransactionManager
  ) {}

  public execute(): Promise<Result<Collection<CustomerInvoice>, Error>> {
    return this.transactionManager.complete((transaction) => {
      return this.invoiceService.findCustomerInvoices(transaction);
    });
  }
}
