refactor: use function for correct decimal number
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
This commit is contained in:
parent
6776188f7b
commit
4e71343af7
1 changed files with 4 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import { CustomerType, PayCondition } from "@prisma/client";
|
||||||
import { convertTemplate } from "../utils/string-template";
|
import { convertTemplate } from "../utils/string-template";
|
||||||
import { htmlToText } from "html-to-text";
|
import { htmlToText } from "html-to-text";
|
||||||
import { JsonObject } from "@prisma/client/runtime/library";
|
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_URL) throw new Error("Require FLOW_ACCOUNT_URL");
|
||||||
if (!process.env.FLOW_ACCOUNT_CLIENT_ID) throw new Error("Require FLOW_ACCOUNT_CLIENT_ID");
|
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")}`;
|
data.paymentDate = `${year}-${String(month).padStart(2, "0")}-${String(date).padStart(2, "0")}`;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
console.log(JSON.stringify(data, null, 2));
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
api + "/upgrade/receipts/inline" + (withPayment ? "/with-payment" : ""),
|
api + "/upgrade/receipts/inline" + (withPayment ? "/with-payment" : ""),
|
||||||
{
|
{
|
||||||
|
|
@ -327,7 +330,6 @@ const flowAccount = {
|
||||||
dueDate: quotation.dueDate,
|
dueDate: quotation.dueDate,
|
||||||
salesName: [quotation.createdBy?.firstName, quotation.createdBy?.lastName].join(" "),
|
salesName: [quotation.createdBy?.firstName, quotation.createdBy?.lastName].join(" "),
|
||||||
|
|
||||||
useInlineVat: true,
|
|
||||||
isVatInclusive: true,
|
isVatInclusive: true,
|
||||||
isVat: true,
|
isVat: true,
|
||||||
|
|
||||||
|
|
@ -372,7 +374,7 @@ const flowAccount = {
|
||||||
items: product.map((v) => ({
|
items: product.map((v) => ({
|
||||||
type: ProductAndServiceType.ProductNonInv,
|
type: ProductAndServiceType.ProductNonInv,
|
||||||
name: v.product.name,
|
name: v.product.name,
|
||||||
pricePerUnit: Math.round(v.pricePerUnit * 100) / 100,
|
pricePerUnit: precisionRound(v.pricePerUnit),
|
||||||
quantity: v.amount,
|
quantity: v.amount,
|
||||||
discountAmount: v.discount,
|
discountAmount: v.discount,
|
||||||
total: (v.pricePerUnit - (v.discount || 0)) * v.amount + v.vat,
|
total: (v.pricePerUnit - (v.discount || 0)) * v.amount + v.vat,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue