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);
|
// handleChangePayType(quotationFormData.value.payCondition);
|
||||||
// calc price
|
// calc price
|
||||||
const calc = (c: QuotationPayload['productServiceList'][number]) => {
|
const calc = (c: QuotationPayload['productServiceList'][number]) => {
|
||||||
const originalPrice = c.pricePerUnit || 0;
|
const calcVat =
|
||||||
const finalPriceWithVat = precisionRound(
|
c.product[agentPrice.value ? 'agentPriceCalcVat' : 'calcVat'];
|
||||||
originalPrice * (1 + (config.value?.vat || 0.07)),
|
const vatFactor = calcVat ? (config.value?.vat ?? 0.07) : 0;
|
||||||
);
|
const pricePerUnit =
|
||||||
const finalPriceNoVat =
|
precisionRound(c.pricePerUnit * (1 + vatFactor)) / (1 + vatFactor);
|
||||||
finalPriceWithVat / (1 + (config.value?.vat || 0.07));
|
const price = pricePerUnit * c.amount * (1 + vatFactor) - c.discount;
|
||||||
|
return precisionRound(price);
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// installment
|
// installment
|
||||||
|
|
@ -780,21 +774,16 @@ function toggleDeleteProduct(index: number) {
|
||||||
|
|
||||||
// cal curr amount
|
// cal curr amount
|
||||||
if (currPaySplit && currTempPaySplit) {
|
if (currPaySplit && currTempPaySplit) {
|
||||||
const price = agentPrice.value
|
const calcVat =
|
||||||
? currProduct.product.agentPrice
|
currProduct.product[agentPrice.value ? 'agentPriceCalcVat' : 'calcVat'];
|
||||||
: currProduct.product.price;
|
const vatFactor = calcVat ? (config.value?.vat ?? 0.07) : 0;
|
||||||
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);
|
|
||||||
|
|
||||||
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;
|
currPaySplit.amount = currTempPaySplit.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -849,8 +838,7 @@ function convertToTable(nodes: Node[]) {
|
||||||
tempTableProduct.value = JSON.parse(JSON.stringify(list));
|
tempTableProduct.value = JSON.parse(JSON.stringify(list));
|
||||||
|
|
||||||
if (nodes.length > 0) {
|
if (nodes.length > 0) {
|
||||||
quotationFormData.value.paySplit = Array.apply(
|
quotationFormData.value.paySplit = Array.from(
|
||||||
null,
|
|
||||||
new Array(quotationFormData.value.paySplitCount),
|
new Array(quotationFormData.value.paySplitCount),
|
||||||
).map((_, i) => ({
|
).map((_, i) => ({
|
||||||
no: i + 1,
|
no: i + 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue