From 23d9f0054ca809ca577a13785823b78ff99b0a71 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:08:25 +0700 Subject: [PATCH] fix: price different by 0.01 --- src/controllers/05-quotation-controller.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 65e2c3b..3cdb9bb 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -419,7 +419,9 @@ export class QuotationController extends Controller { const price = body.agentPrice ? p.agentPrice : p.price; const pricePerUnit = p.vatIncluded ? precisionRound(price / (1 + VAT_DEFAULT)) : price; const vat = p.calcVat - ? precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT) + ? precisionRound( + (pricePerUnit * (v.discount ? v.amount : 1) - (v.discount || 0)) * VAT_DEFAULT, + ) * (!v.discount ? v.amount : 1) : 0; return { @@ -667,7 +669,9 @@ export class QuotationController extends Controller { const price = record.agentPrice ? p.agentPrice : p.price; const pricePerUnit = p.vatIncluded ? precisionRound(price / (1 + VAT_DEFAULT)) : price; const vat = p.calcVat - ? precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT) + ? precisionRound( + (pricePerUnit * (v.discount ? v.amount : 1) - (v.discount || 0)) * VAT_DEFAULT, + ) * (!v.discount ? v.amount : 1) : 0; return { order: i + 1,