OL Learn

Calculate Subtotal in table overflowing more than one page

Hello,

we have a problem with the calculation of the subtotals in our reminders which overflows more than one page.
We use a database dataMapper and within the mapper we get for every position the total sum for each reminder. A reminder can include more than one invoice. We only calculate the subtotal if the invoice-number is changing.
This works for the complete sum of a reminder without problems, this sum is always correct.
Only with subtotal our calculation takes the first position from the next page and add it to the subtotal from the previous page.
So, the subtotal is alway to much.

What can we do to resolve this?

Thank your for answers.

Our code is:

var accumulator_1 = 0;
var reNr1="", reNr2="";

results.each(function(index) {
if (index===0)
{
reNr1 = record.tables[“detail”][index].fields[“reNr”].toString();
reNr2 = record.tables[“detail”][index].fields[“reNr”].toString();
sum = parseFloat(record.tables[“detail”][index].fields[“DRM_OFFEN_D”]);
}

if (index>0)
{
// reNr1 ist die vorherige ReNr
reNr1 = record.tables[“detail”][index-1].fields[“reNr”].toString();
// reNr2 ist die aktuelle ReNr
reNr2 = record.tables[“detail”][index].fields[“reNr”].toString();
}

// Die Rechnungsnummer hat sich geändert => neuer Betrag aufaddieren
if (!reNr1.equals(reNr2))
{
// erste Position der neuen Rechnung wird auffaddiert! Egal ob Rate oder nicht
sum += parseFloat(record.tables[“detail”][index].fields[“DRM_OFFEN_D”]);
}

// Bei gleicher Rechnungsnummer noch die Raten auffaddieren
if (reNr1.equals(reNr2))
{
var mahnst = record.fields.Mahnstufe;
if (mahnst[4].equals(“3”) && (index!=0))
{
if (record.tables[“detail”][index].fields.ArtikelBez.includes(‘Raten’) == true)
{
/if(index == results.length)
sum -= parseFloat(record.tables[“detail”][index].fields[“DRM_OFFEN_D”]);
else
/
sum += parseFloat(record.tables[“detail”][index].fields[“DRM_OFFEN_D”]);
}
}
}

//sum = formatter.currencyNoSymbol(sum);
this.html(formatter.currencyNoSymbol(sum));
});

Which Connect version are you using and do you know if you use the newer dynamic table feature? (do you have User Scripts to populate the table cells or is this handled via the data-field attribute)

Hello Erik,
we are using PlanetPress Designer in version 2020.2.1.67630, and the old detailed tables feature, because the table was built before the update with the new table feature was installed.