2025-09-05 11:23:45 +00:00
|
|
|
import { MoneyValue, MoneyValueProps } from "@repo/rdx-ddd";
|
|
|
|
|
|
|
|
|
|
type ItemAmountProps = Pick<MoneyValueProps, "value" | "currency_code">;
|
|
|
|
|
|
|
|
|
|
export class ItemAmount extends MoneyValue {
|
|
|
|
|
public static DEFAULT_SCALE = 4;
|
|
|
|
|
|
|
|
|
|
static create({ value, currency_code }: ItemAmountProps) {
|
|
|
|
|
const props = {
|
|
|
|
|
value: Number(value),
|
|
|
|
|
scale: ItemAmount.DEFAULT_SCALE,
|
|
|
|
|
currency_code,
|
|
|
|
|
};
|
|
|
|
|
return MoneyValue.create(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static zero(currency_code: string) {
|
|
|
|
|
const props = {
|
|
|
|
|
value: 0,
|
|
|
|
|
currency_code,
|
|
|
|
|
};
|
2025-09-10 11:57:15 +00:00
|
|
|
return ItemAmount.create(props).data;
|
2025-09-05 11:23:45 +00:00
|
|
|
}
|
|
|
|
|
}
|