import { QuantityDTO } from "@erp/core";
import { Quantity } from "@repo/rdx-ddd";

export function formatQuantityDTO(quantity_value: QuantityDTO) {
  if (quantity_value.value === "0" || quantity_value.value === "") {
    return null;
  }

  const value = Quantity.create({
    value: Number(quantity_value.value),
    scale: Number(quantity_value.scale),
  }).data;

  return value.format();
}
