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