Test case report example

Documentazione •
In questo articolo

To create a complete report, it is necessary to start with some operations that are integrated into the extension code.

This is a repository to begin your report example:

The operations are:

  • Create the structure and the logic of your report.
    • Create a structure of report (balance, profit-loss).
    • Validate the groups of the accounting.
    • Load your report values from the Balance Sheet.
    • Calculate the totals of the amounts.
    • Format amount values of the report.
    • Print the results of your report.
  • Create a function that contains all the tests you want to run.
  • Save the content of your file about test case.
  • Configure user parameters.

After these operations on the code side you can run your test as explained on this page.

Create a function for testing a report

In the javascript test file, you have to create a function that generates the report and adds it to the test results. Use the addReport() function defined in Banana.Test.Logger class.

You can see an example of how to create a test for a report:

Save the content of your file about test case

var bananaDocument = Banana.application.openDocument("file:script/../test/testcases/nameFileTestCases.ac2");

In this variable you save the content of your test case ac2 file. 

To learn more about the method openDocument and other methods:

Configure parameter of user

You can initialize the parameters to define some data like the period (start date and end date), the report title, and others.

The parameter column defines which column to use in order to create the report. By default is Gr1. In this column for each account is defined an ID used to regroup the accounts for the report sections.

Create structure of your report - Balance

For creation a base report, you can create an array that contain all information that you need as in example:

The information are: 

  • the group IDs.
  • Description of account.
  • Sum of the group of accounts.
  • Type of account (asset, liabilitie , cost, revenue).

Parameter explanation

  • id
    Is the unique parameter of column in Banana, the column name of id corresponds to Gr1, you can decide what to put as the id, as long as the id is the same as what you configure in the Gr1 column of Banana.
  • type
    Define what type of data is. The are three options: title, group and total.
    • Title: Normally used when a title or a description text without amount must be displayed.

      The "id" group starts with a "d" (description).


      {"id":"dABI", "type":"title", "indent":"1", "description":"I - Intangible assets"}

    • Group: Used when a group with text and amount must be displayed.


      {"id":"ABI1", "type":"group", "indent":"2", "bclass":"1", "description":"1) Installation and expansion costs"}
      {"id":"ABI2", "type":"group", "indent":"2", "bclass":"1", "description":"2) Development costs"}

    • Total: Used for the total of a group with and amount. The amount is the sum groups amounts. Use the property "sum" to indicate the list of all "id" groups that must be summed together, separated by a semicolon ";". To subtract amounts use the minus sign "-" before the group "id".


      {"id":"TC", "type":"total", "indent":"1", "description":"Total Costs", "sum":"C1;C2"}  →  sum = C1 + C2
      {"id":"AS", "type":"total", "indent":"1", "description":"Total Assets", "sum":"AS1;-C3"} →  sum = AS1 - C3

  • bclass 
    Corresponding of what is this account. In Banana bclass 1 is Assets, 2 is Liabilities, 3 Costs, 4 Revenues.
  • description
    Used to define the description text used for the print.
  • note
    This is used to provide more details in the report.
  • sum
    This is used to define how to calculate the total.

In this example, you create a simply configuration for creation a report of Balance Sheet, where contains the assets and the liabilities of short term:

function createReportStructure(){
//create an array where do you pass your parameter for creation your structure of Balance
var reportStructureBalance = [];

reportStructureBalance.push({ "id": "CashId", "type": "group", "note": "", "bclass": "1", "description": "Cash" });
reportStructureBalance.push({ "id": "BankId", "type": "group", "note": "", "bclass": "1", "description": "Bank" });
reportStructureBalance.push({ "id": "TotalLiquidityId", "type": "total", "note": "", "bclass": "1", "description": "Total liquidity", "sum":"CashId;BankId" });

reportStructureBalance.push({ "id": "SuppliersId", "type": "group", "note": "", "bclass": "2", "description": "Suppliers" });
reportStructureBalance.push({ "id": "DueBanksShortTermId", "type": "group", "note": "", "bclass": "2", "description": "Due to banks short/term" });
reportStructureBalance.push({ "id": "ShortTermOnorousDebtsId", "type": "total", "note": "", "bclass": "1", "description": "Short-term onorous debts", "sum":"SuppliersId;DueBanksShortTermId" });

Loads your values of report from the Balance Sheet

Before load your values of report, you have to create the next functions in the exentension and invoke this functions in the test file:

  1. validateGroupsBalance.
  2. loadBalances.
  3. calculateTotals.
  4. formatValues.
  5. excludeEntries.
  6. printBalanceSheet.

Repository that content the functions of operations 1 to 5:

Repository that content the function of operation 6:



The input of this function grColumn: is a prameter of id group of column (Example: Gr1).

This function have to check if the groups defined by user is valid or not.


This function load and calculate the current and previous balances of the report structure.


Calculates all totals of the reportStructure for the given list of fields.


Converts all the amounts to local format for the given list of field.


Entries preceded by Arabic numbers or lower case letters with zero amounts for two consecutive exercises, can be excluded from the print.

Dicci come possiamo aiutarti meglio
Se le informazioni contenute in questa pagina non sono quelle che cerchi, non sono sufficientemente chiare o non sono aggiornate, facci sapere.

Condividi questo articolo: Twitter | Facebook | LinkedIn | Email