import { Result, ValueObject } from '@modules/shared';

interface PriceProps {
  amountVND: bigint;
}

export class Price extends ValueObject<PriceProps> {
  get amountVND(): bigint { return this.props.amountVND; }

  static create(amountVND: bigint): Result<Price, string> {
    if (amountVND <= 0n) {
      return Result.err('Giá phải lớn hơn 0');
    }
    return Result.ok(new Price({ amountVND }));
  }

  calculatePerM2(areaM2: number): number {
    if (areaM2 <= 0) return 0;
    return Number(this.props.amountVND) / areaM2;
  }
}
