fix: wrong price
This commit is contained in:
parent
34ede08244
commit
033251c79d
1 changed files with 10 additions and 14 deletions
|
|
@ -55,7 +55,7 @@ function openList(index: number) {
|
||||||
|
|
||||||
function calcPricePerUnit(product: RequestWork['productService']['product']) {
|
function calcPricePerUnit(product: RequestWork['productService']['product']) {
|
||||||
return product.vatIncluded
|
return product.vatIncluded
|
||||||
? precisionRound(product.serviceCharge / (1 + (config.value?.vat || 0.07)))
|
? product.serviceCharge / (1 + (config.value?.vat || 0.07))
|
||||||
: product.serviceCharge;
|
: product.serviceCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,21 +63,17 @@ function calcPrice(
|
||||||
product: RequestWork['productService']['product'],
|
product: RequestWork['productService']['product'],
|
||||||
amount: number,
|
amount: number,
|
||||||
) {
|
) {
|
||||||
const disc =
|
const pricePerUnit = product.serviceCharge;
|
||||||
|
const discount =
|
||||||
taskProduct.value.find((v) => v.productId === product.id)?.discount || 0;
|
taskProduct.value.find((v) => v.productId === product.id)?.discount || 0;
|
||||||
const pricePerUnit = calcPricePerUnit(product);
|
const priceNoVat = product.vatIncluded
|
||||||
|
? pricePerUnit / (1 + (config.value?.vat || 0.07))
|
||||||
|
: pricePerUnit;
|
||||||
|
const priceDiscountNoVat = priceNoVat * amount - discount;
|
||||||
|
|
||||||
return precisionRound(
|
const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07);
|
||||||
pricePerUnit * amount -
|
|
||||||
disc +
|
return precisionRound(priceNoVat * amount + rawVatTotal);
|
||||||
precisionRound(
|
|
||||||
product.calcVat
|
|
||||||
? (pricePerUnit * (disc ? amount : 1) - disc) *
|
|
||||||
(config.value?.vat || 0.07)
|
|
||||||
: 0,
|
|
||||||
) *
|
|
||||||
(!disc ? amount : 1),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue