2025-09-09 18:13:54 +00:00
|
|
|
import { Collection } from "@repo/rdx-utils";
|
2025-09-10 18:14:19 +00:00
|
|
|
import { InvoiceAmount } from "../../value-objects";
|
2025-09-09 18:13:54 +00:00
|
|
|
import { InvoiceTax } from "./invoice-tax";
|
|
|
|
|
|
|
|
|
|
export interface InvoiceTaxesProps {
|
|
|
|
|
items?: InvoiceTax[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class InvoiceTaxes extends Collection<InvoiceTax> {
|
|
|
|
|
constructor(props: InvoiceTaxesProps) {
|
|
|
|
|
const { items = [] } = props;
|
|
|
|
|
super(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static create(props: InvoiceTaxesProps): InvoiceTaxes {
|
|
|
|
|
return new InvoiceTaxes(props);
|
|
|
|
|
}
|
2025-09-10 18:14:19 +00:00
|
|
|
|
|
|
|
|
public getTaxesAmount(taxableAmount: InvoiceAmount): InvoiceAmount {
|
|
|
|
|
return this.getAll().reduce(
|
|
|
|
|
(total, tax) => total.add(tax.getTaxAmount(taxableAmount)),
|
|
|
|
|
InvoiceAmount.zero(taxableAmount.currencyCode)
|
|
|
|
|
) as InvoiceAmount;
|
|
|
|
|
}
|
2025-09-09 18:13:54 +00:00
|
|
|
}
|