refactor: use function for correct decimal number
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s

This commit is contained in:
HAM 2025-09-16 09:53:03 +07:00
parent 6776188f7b
commit 4e71343af7

View file

@ -4,6 +4,7 @@ import { CustomerType, PayCondition } from "@prisma/client";
import { convertTemplate } from "../utils/string-template";
import { htmlToText } from "html-to-text";
import { JsonObject } from "@prisma/client/runtime/library";
import { precisionRound } from "../utils/arithmetic";
if (!process.env.FLOW_ACCOUNT_URL) throw new Error("Require FLOW_ACCOUNT_URL");
if (!process.env.FLOW_ACCOUNT_CLIENT_ID) throw new Error("Require FLOW_ACCOUNT_CLIENT_ID");
@ -185,6 +186,8 @@ const flowAccountAPI = {
data.paymentDate = `${year}-${String(month).padStart(2, "0")}-${String(date).padStart(2, "0")}`;
} */
console.log(JSON.stringify(data, null, 2));
const res = await fetch(
api + "/upgrade/receipts/inline" + (withPayment ? "/with-payment" : ""),
{
@ -327,7 +330,6 @@ const flowAccount = {
dueDate: quotation.dueDate,
salesName: [quotation.createdBy?.firstName, quotation.createdBy?.lastName].join(" "),
useInlineVat: true,
isVatInclusive: true,
isVat: true,
@ -372,7 +374,7 @@ const flowAccount = {
items: product.map((v) => ({
type: ProductAndServiceType.ProductNonInv,
name: v.product.name,
pricePerUnit: Math.round(v.pricePerUnit * 100) / 100,
pricePerUnit: precisionRound(v.pricePerUnit),
quantity: v.amount,
discountAmount: v.discount,
total: (v.pricePerUnit - (v.discount || 0)) * v.amount + v.vat,