Skip to main content

Show a running balance with debit and credit

Add a column that shows the balance after each line, written the way the program writes balances everywhere. The example uses the Voucher document type, the running total function sumRunningSum and the ToBalance function.

Before you begin​

  • Open the designer from a saved voucher, on a template you may change. See Design an advanced report.
  • The template must list the voucher lines in the Detail band, with the fields VoucherItemDebit and VoucherItemCredit of the "Voucher Items" table of the field list. See Advanced printing data sources.
  • Choose how balances are written. In Program Options > Numbers, the Balance Display list offers Default (Credit in Negative), Abbreviation (D / C), Full Name (Debit/Credit) and Customized. With Customized, type the debit sign in Debit and the credit sign in Credit. The choice applies to every user of the company file, so it changes everyone's printouts. The function follows this choice when the voucher is printed.

Steps​

  1. Add a column to the table of the voucher lines. Its header text is Balance.

  2. Select the cell of the new column in the Detail band. In the Expressions tab of the Properties panel, set Text to:

    ToBalance(sumRunningSum([VoucherItemDebit] - [VoucherItemCredit]))

    The running total is debit minus credit. A positive balance is a debit balance and a negative one is a credit balance.

  3. Set Summary Running of the cell to the report.

  4. Click the Preview tab, then click Save.

Result​

Each line shows the balance after it. For a voucher with four lines, in a program set to Full Name (Debit/Credit) and two decimal places for Prices:

LineDebitCreditRunning totalPrinted balance
1500.000.00500.00500.00 Debit
2250.000.00750.00750.00 Debit
30.001,000.00-250.00250.00 Credit
4250.000.000.00The zero text, or 0.00

The other choices change only the words after the number:

Balance DisplayPrinted for line 3
Default (Credit in Negative)-250.00
Abbreviation (D / C)250.00 CR (in Arabic: م for debit, د for credit)
Full Name (Debit/Credit)250.00 Credit
Customized250.00 followed by the credit sign you typed

A balance that rounds to zero at the decimal places of Prices prints as the zero text when Print Zero as Symbol is chosen under Zero Values, with the text of Zero substitution. If Print Zero as Number is chosen, it prints 0.00. If Zero substitution is empty, the cell stays blank. Only an administrator can change these options.

If something goes wrong​

SituationWhy it happensWhat to do
Every line shows its own amount.Summary Running is not set to the report.Set Summary Running of the cell to the report.
The sign is the opposite of what you expect.The expression subtracts debit from credit.Use debit minus credit.
The balance has no debit or credit word.Default (Credit in Negative) is chosen, or Customized with the sign of that side empty. If you leave both signs empty with Customized, the program saves Default (Credit in Negative).Choose another Balance Display, or type the sign in the empty field.
The expression is refused.ToBalance accepts a number only.Do not wrap the total in text functions.

This page applies to alameen ERP 10, version 10.1.79.764.