fix: apply last-row rounding correction to Excel export
This commit is contained in:
@@ -454,13 +454,16 @@ function exportExcel() {
|
|||||||
let cumDays = 0, cumTotal = 0, cumNgpm = 0, cumNook = 0;
|
let cumDays = 0, cumTotal = 0, cumNgpm = 0, cumNook = 0;
|
||||||
|
|
||||||
installments.forEach((inst, i) => {
|
installments.forEach((inst, i) => {
|
||||||
const days = parseFloat(inst.days) || 0;
|
const days = parseFloat(inst.days) || 0;
|
||||||
const pct = parseFloat(inst.percent) || 0;
|
const pct = parseFloat(inst.percent) || 0;
|
||||||
|
const isLast = i === installments.length - 1;
|
||||||
cumDays += days;
|
cumDays += days;
|
||||||
const total = Math.round(contract * pct / 100);
|
|
||||||
const ngpm = Math.round(total * ngpmPct / 100);
|
const total = isLast ? (contract - cumTotal) : Math.round(contract * pct / 100);
|
||||||
const nook = total - ngpm;
|
const ngpm = isLast ? (Math.round(contract * ngpmPct / 100) - cumNgpm) : Math.round(total * ngpmPct / 100);
|
||||||
|
const nook = total - ngpm;
|
||||||
cumTotal += total; cumNgpm += ngpm; cumNook += nook;
|
cumTotal += total; cumNgpm += ngpm; cumNook += nook;
|
||||||
|
|
||||||
const delivery = toThaiDate(addDays(startDate, cumDays));
|
const delivery = toThaiDate(addDays(startDate, cumDays));
|
||||||
rows.push([i+1, days, pct, delivery, total, ngpm, nook, cumTotal, cumNgpm, cumNook]);
|
rows.push([i+1, days, pct, delivery, total, ngpm, nook, cumTotal, cumNgpm, cumNook]);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user