import { NullOr } from "../../../../utilities"; import { MoneyValue } from "./MoneyValue"; import { Result } from "./Result"; export interface IUnitPriceProps { amount: NullOr; currencyCode?: string; scale: number; } export class UnitPrice extends MoneyValue { public static create(props: IUnitPriceProps) { const { amount, currencyCode, scale = 4 } = props; const _unitPriceOrError = MoneyValue.create({ amount, currencyCode, scale, }); if (_unitPriceOrError.isFailure) { return _unitPriceOrError; } const _unitPrice = _unitPriceOrError.object.convertScale(4); return Result.ok(_unitPrice); } }