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