fix: price calc
This commit is contained in:
parent
09b51d601e
commit
ef4c84341c
4 changed files with 63 additions and 89 deletions
|
|
@ -58,16 +58,15 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([
|
|||
|
||||
function calcPrice(c: (typeof rows.value)[number]) {
|
||||
const originalPrice = c.pricePerUnit;
|
||||
const finalPriceWithVat = precisionRound(
|
||||
originalPrice + originalPrice * (config.value?.vat || 0.07),
|
||||
const finalPricePerUnit = precisionRound(
|
||||
originalPrice +
|
||||
(c.product[props.agentPrice ? 'agentPriceCalcVat' : 'calcVat']
|
||||
? originalPrice * (config.value?.vat || 0.07)
|
||||
: 0),
|
||||
);
|
||||
const finalPriceNoVat = finalPriceWithVat / (1 + (config.value?.vat || 0.07));
|
||||
const price = finalPricePerUnit * c.amount - c.discount;
|
||||
|
||||
const price = finalPriceNoVat * c.amount - c.discount;
|
||||
const vat = c.product[props.agentPrice ? 'agentPriceCalcVat' : 'calcVat']
|
||||
? (finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07)
|
||||
: 0;
|
||||
return precisionRound(price + vat);
|
||||
return precisionRound(price);
|
||||
}
|
||||
|
||||
const discount4Show = ref<string[]>([]);
|
||||
|
|
@ -435,8 +434,20 @@ watch(
|
|||
<q-td align="right">
|
||||
{{
|
||||
formatNumberDecimal(
|
||||
props.row.pricePerUnit * props.row.amount -
|
||||
props.row.discount,
|
||||
props.row.product[
|
||||
agentPrice ? 'agentPriceCalcVat' : 'calcVat'
|
||||
]
|
||||
? precisionRound(
|
||||
(props.row.pricePerUnit *
|
||||
(1 + (config?.vat || 0.07)) *
|
||||
props.row.amount -
|
||||
props.row.discount) /
|
||||
(1 + (config?.vat || 0.07)),
|
||||
)
|
||||
: precisionRound(
|
||||
props.row.pricePerUnit * props.row.amount -
|
||||
props.row.discount,
|
||||
),
|
||||
2,
|
||||
)
|
||||
}}
|
||||
|
|
@ -448,9 +459,12 @@ watch(
|
|||
agentPrice ? 'agentPriceCalcVat' : 'calcVat'
|
||||
]
|
||||
? precisionRound(
|
||||
(props.row.pricePerUnit * props.row.amount -
|
||||
props.row.discount) *
|
||||
(config?.vat || 0.07),
|
||||
((props.row.pricePerUnit *
|
||||
(1 + (config?.vat || 0.07)) *
|
||||
props.row.amount -
|
||||
props.row.discount) /
|
||||
(1 + (config?.vat || 0.07))) *
|
||||
0.07,
|
||||
)
|
||||
: 0,
|
||||
2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue