fix: wrong decimal

This commit is contained in:
Methapon2001 2025-01-17 09:05:36 +07:00
parent 7cb8dd6000
commit 6d43d4e796
2 changed files with 11 additions and 16 deletions

View file

@ -57,17 +57,13 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([
]); ]);
function calcPrice(c: (typeof rows.value)[number]) { function calcPrice(c: (typeof rows.value)[number]) {
return precisionRound( const price = c.pricePerUnit * c.amount;
c.pricePerUnit * c.amount - const vat = c.product.calcVat
c.discount +
precisionRound(
c.product.calcVat
? (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) * ? (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
(config.value?.vat || 0.07) (config.value?.vat || 0.07) *
: 0, (!c.discount ? c.amount : 1)
) * : 0;
(!c.discount ? c.amount : 1), return precisionRound(price + vat);
);
} }
const discount4Show = ref<string[]>([]); const discount4Show = ref<string[]>([]);

View file

@ -242,12 +242,11 @@ function getPrice(
return a; return a;
} }
const price = precisionRound(c.pricePerUnit * c.amount); const price = c.pricePerUnit * c.amount;
const vat = const vat =
precisionRound(
(c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) * (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
(config.value?.vat || 0.07), (config.value?.vat || 0.07) *
) * (!c.discount ? c.amount : 1); (!c.discount ? c.amount : 1);
a.totalPrice = precisionRound(a.totalPrice + price); a.totalPrice = precisionRound(a.totalPrice + price);
a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount)); a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount));