Uecko_ERP/modules/customer-invoices/src/api/domain/entities/item-taxes/item-taxes.ts
2025-09-10 13:57:15 +02:00

26 lines
666 B
TypeScript

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<ItemTax> {
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)
);
}
}