/
Credit Debit Summarization

Credit Debit Summarization

Search the P2 Workflow Wiki
 

 Back to Tips and Tricks



As the user enters amounts for each record, the dynaform will determine whether the amount is a credit or a debit and sum them accordingly. The net total and totals of the debits and credits will be displayed below the grid. This is done using the following JavaScript:

//Set values to 0 when page first loads. $(document).ready(function() { $('#netAmount').setValue(0); $('#debitAmount').setValue(0); $('#creditAmount').setValue(0); }); //Sum whenever a new record is made/edited $(document).on('change', function() { var net = 0; var debits = 0; var credits = 0; var size = $('#details').getNumberRows(); for (var i = 1; i <= size; i++) { var amount = parseInt($('#details').getValue(i, 5)); if (amount >= 0) { debits += amount; } else { credits += amount; } net += amount; } $('#netAmount').setValue(net); $('#debitAmount').setValue(debits); $('#creditAmount').setValue(credits); });





 


Copyright© 2024 IFS AB. Copying prohibited. All rights reserved.