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(
|
return list.reduce(
|
||||||
(a, c, i) => {
|
(a, c, i) => {
|
||||||
const pricePerUnit =
|
const pricePerUnit = c.product.serviceCharge;
|
||||||
refProductExpansion.value?.calcPricePerUnit(c.product) ?? 0;
|
const amount = c.list.length;
|
||||||
const price = precisionRound(pricePerUnit * c.list.length);
|
const discount =
|
||||||
const disc =
|
|
||||||
taskProduct.value.find((v) => v.productId === c.product.id)?.discount ||
|
taskProduct.value.find((v) => v.productId === c.product.id)?.discount ||
|
||||||
0;
|
0;
|
||||||
const vat =
|
const priceNoVat = c.product.vatIncluded
|
||||||
precisionRound(
|
? pricePerUnit / (1 + (config.value?.vat || 0.07))
|
||||||
(pricePerUnit * (disc ? c.list.length : 1) - disc) *
|
: pricePerUnit;
|
||||||
(config.value?.vat || 0.07),
|
const priceDiscountNoVat = priceNoVat * amount - discount;
|
||||||
) * (!disc ? c.list.length : 1);
|
|
||||||
|
|
||||||
a.totalPrice = precisionRound(a.totalPrice + price);
|
const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07);
|
||||||
a.totalDiscount = precisionRound(a.totalDiscount + Number(disc));
|
// const rawVat = rawVatTotal / amount;
|
||||||
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);
|
|
||||||
|
|
||||||
|
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;
|
return a;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue