fix: price calc on update installments
This commit is contained in:
parent
c07efa7318
commit
67cde37e34
1 changed files with 17 additions and 29 deletions
|
|
@ -715,19 +715,13 @@ function handleUpdateProductTable(
|
|||
// handleChangePayType(quotationFormData.value.payCondition);
|
||||
// calc price
|
||||
const calc = (c: QuotationPayload['productServiceList'][number]) => {
|
||||
const originalPrice = c.pricePerUnit || 0;
|
||||
const finalPriceWithVat = precisionRound(
|
||||
originalPrice * (1 + (config.value?.vat || 0.07)),
|
||||
);
|
||||
const finalPriceNoVat =
|
||||
finalPriceWithVat / (1 + (config.value?.vat || 0.07));
|
||||
|
||||
const price = finalPriceNoVat * c.amount;
|
||||
const vat = c.product.calcVat
|
||||
? (finalPriceNoVat * c.amount - (c.discount || 0)) *
|
||||
(config.value?.vat || 0.07)
|
||||
: 0;
|
||||
return precisionRound(price + vat);
|
||||
const calcVat =
|
||||
c.product[agentPrice.value ? 'agentPriceCalcVat' : 'calcVat'];
|
||||
const vatFactor = calcVat ? (config.value?.vat ?? 0.07) : 0;
|
||||
const pricePerUnit =
|
||||
precisionRound(c.pricePerUnit * (1 + vatFactor)) / (1 + vatFactor);
|
||||
const price = pricePerUnit * c.amount * (1 + vatFactor) - c.discount;
|
||||
return precisionRound(price);
|
||||
};
|
||||
|
||||
// installment
|
||||
|
|
@ -780,21 +774,16 @@ function toggleDeleteProduct(index: number) {
|
|||
|
||||
// cal curr amount
|
||||
if (currPaySplit && currTempPaySplit) {
|
||||
const price = agentPrice.value
|
||||
? currProduct.product.agentPrice
|
||||
: currProduct.product.price;
|
||||
const pricePerUnit = currProduct.product.vatIncluded
|
||||
? price / (1 + (config.value?.vat || 0.07))
|
||||
: price;
|
||||
const vat =
|
||||
(pricePerUnit * currProduct.amount - currProduct.discount) *
|
||||
(config.value?.vat || 0.07);
|
||||
const finalPrice =
|
||||
pricePerUnit * currProduct.amount +
|
||||
vat -
|
||||
Number(currProduct.discount || 0);
|
||||
const calcVat =
|
||||
currProduct.product[agentPrice.value ? 'agentPriceCalcVat' : 'calcVat'];
|
||||
const vatFactor = calcVat ? (config.value?.vat ?? 0.07) : 0;
|
||||
|
||||
currTempPaySplit.amount = currPaySplit.amount - finalPrice;
|
||||
const price = precisionRound(
|
||||
currProduct.pricePerUnit * currProduct.amount * (1 + vatFactor) -
|
||||
currProduct.discount,
|
||||
);
|
||||
|
||||
currTempPaySplit.amount = currPaySplit.amount - price;
|
||||
currPaySplit.amount = currTempPaySplit.amount;
|
||||
}
|
||||
|
||||
|
|
@ -849,8 +838,7 @@ function convertToTable(nodes: Node[]) {
|
|||
tempTableProduct.value = JSON.parse(JSON.stringify(list));
|
||||
|
||||
if (nodes.length > 0) {
|
||||
quotationFormData.value.paySplit = Array.apply(
|
||||
null,
|
||||
quotationFormData.value.paySplit = Array.from(
|
||||
new Array(quotationFormData.value.paySplitCount),
|
||||
).map((_, i) => ({
|
||||
no: i + 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue