fix: wrong price
This commit is contained in:
parent
033251c79d
commit
5df57063cd
1 changed files with 14 additions and 16 deletions
|
|
@ -105,26 +105,24 @@ function getPrice(
|
|||
) {
|
||||
return list.reduce(
|
||||
(a, c, i) => {
|
||||
const pricePerUnit =
|
||||
refProductExpansion.value?.calcPricePerUnit(c.product) ?? 0;
|
||||
const price = precisionRound(pricePerUnit * c.list.length);
|
||||
const disc =
|
||||
const pricePerUnit = c.product.serviceCharge;
|
||||
const amount = c.list.length;
|
||||
const discount =
|
||||
taskProduct.value.find((v) => v.productId === c.product.id)?.discount ||
|
||||
0;
|
||||
const vat =
|
||||
precisionRound(
|
||||
(pricePerUnit * (disc ? c.list.length : 1) - disc) *
|
||||
(config.value?.vat || 0.07),
|
||||
) * (!disc ? c.list.length : 1);
|
||||
const priceNoVat = c.product.vatIncluded
|
||||
? pricePerUnit / (1 + (config.value?.vat || 0.07))
|
||||
: pricePerUnit;
|
||||
const priceDiscountNoVat = priceNoVat * amount - discount;
|
||||
|
||||
a.totalPrice = precisionRound(a.totalPrice + price);
|
||||
a.totalDiscount = precisionRound(a.totalDiscount + Number(disc));
|
||||
a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat;
|
||||
a.vatExcluded = c.product.calcVat
|
||||
? a.vatExcluded
|
||||
: precisionRound(a.vat + vat);
|
||||
a.finalPrice = precisionRound(a.totalPrice - a.totalDiscount + a.vat);
|
||||
const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07);
|
||||
// const rawVat = rawVatTotal / amount;
|
||||
|
||||
a.totalPrice = a.totalPrice + priceDiscountNoVat;
|
||||
a.totalDiscount = a.totalDiscount + Number(discount);
|
||||
a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat;
|
||||
a.vatExcluded = c.product.calcVat ? a.vatExcluded : a.vat + rawVatTotal;
|
||||
a.finalPrice = a.totalPrice - a.totalDiscount + a.vat;
|
||||
return a;
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue