diff --git a/src/pages/05_quotation/QuotationFormInfo.vue b/src/pages/05_quotation/QuotationFormInfo.vue
index bbd5881b..0664f46f 100644
--- a/src/pages/05_quotation/QuotationFormInfo.vue
+++ b/src/pages/05_quotation/QuotationFormInfo.vue
@@ -138,12 +138,15 @@ watch(
const totalAmount = summaryPrice.value.finalPrice;
if (newCount > oldCount) {
- const installmentAmount = totalAmount / newCount;
+ // Calculate the base installment amount for all except the last installment
+ const installmentAmount = +(totalAmount / newCount).toFixed(2);
- paySplit.value.forEach((payment, index) => {
+ // Update existing installments
+ paySplit.value.forEach((payment) => {
payment.amount = installmentAmount;
});
+ // Add new installments
for (let i = oldCount; i < newCount; i++) {
paySplit.value.push({
no: i + 1,
@@ -152,13 +155,27 @@ watch(
});
}
} else if (newCount < oldCount) {
+ // Remove extra installments
paySplit.value.splice(newCount, oldCount - newCount);
- const installmentAmount = totalAmount / newCount;
+ // Recalculate the base installment amount for remaining installments
+ const installmentAmount = +(totalAmount / newCount).toFixed(2);
paySplit.value.forEach((payment) => {
payment.amount = installmentAmount;
});
}
+
+ // Calculate the amount for the last installment
+ if (paySplit.value.length > 0) {
+ const totalPreviousPayments = paySplit.value
+ .slice(0, -1)
+ .reduce((sum, payment) => sum + payment.amount, 0);
+
+ // Set the last installment to cover the remaining balance, rounded to 2 decimal places
+ const remainingAmount = totalAmount - totalPreviousPayments;
+ paySplit.value[paySplit.value.length - 1].amount =
+ +remainingAmount.toFixed(2);
+ }
}
},
{ deep: true },
@@ -349,7 +366,7 @@ watch(
:label="$t('quotation.callDueDate')"
/>
-