import { PercentageDTO } from "@erp/core";
import { Percentage } from "@repo/rdx-ddd";

export function formatPercentageDTO(Percentage_value: PercentageDTO, locale: string) {
  if (Percentage_value.value === "0" || Percentage_value.value === "") {
    return null;
  }

  const value = Percentage.create({
    value: Number(Percentage_value.value),
    scale: Number(Percentage_value.scale),
  }).data;

  return value.format(locale);
}
