Introduction to Extension for Banana Accounting

En este artículo

Extension (previously BananaApps) are JavaScript programs that extend the Banana Accounting functionalities. Other names are add-ins, add-on, scripts, apps.

Extensions file format

Extensions can be packed in different format:

  • Embedded in the accounting file: the Extension is saved in the Documents table of the accounting file.
  • Included in a JavaScript plain text file: the Extension is saved within a file that is stored on the local disk. Banana reads the file and executes it.
  • Included in a packaged file: a packaged file can contain different JavaScript files and also other files, like images.

Extension file structure

Extension files have two parts:

  • Extension Attributes
    Apps Attributes are special formatted JavaScript comment lines, at the beginning of the file. The apps attributes have a left part (name of the attribute) and right part, with the value. Attributes give information about the script, like its purpose, description and so on. For more information, see Apps Attributes documentation.
  • JavaScript code
    The code must be included within functions. Functions are divided in startup functions, settings functions and normal functions.
    • Startup functions
      Are called by Banana software when the script is executed.
      The name of the function called depend on the type of the App.
      • exec() for following types:
        • app.command
        • export.file
        • export.rows
        • export.transactions
        • import.transactions
        • import.rows
        • import.accounts
        • import.categories
        • import.exchangerates
        • import.vatcodes
        • report.general
      • printDocument() for the following types:
        • report.customer.invoice
        • report.customer.statement
        • report.customer.reminder
    • settingsDialog() function 
      It is called by the Banana Software when the user click on the Setting button, relative to the specific app.
      The setting data is saved within the Accounting file.
    • Other JavaScript functions
      You can write any functions that is necessary.

Extensions types, startup functions and how to run them

The Extension type is defined within the attribute @task.
There are many types, and some of them are started in different ways.

app.command

Is a general application. It can contain any command.

  • Types: app.command, export.file, export.rows, export.transactions, report.general
  • Startup function: exec()
  • How to run it: 
    • File based Apps are started from the menu App.
    • Embedded Apps are run with the button within the Document table

import

The purpose is to translate the content of a file to a Banana Compatible format.
It is used in Import to Accounting.

  • import.transactions
    • Type: import.transactions
    • Startup function: excec(fileContent) with the content of the file as parameter. The function should return a comma separated file.
    • How to run it:
      • Select from the menu Account1 the command Import to accounting...
      • As Import type select Transactions
      • Select an import app from the list
      • Click Browse to select the file with the data to import in Banana
  • import.rows
  • import.accounts
  • import.categories
  • import.exchangerates
  • import.vatcodes

report

The purpose of this app is to create a report.
The report is run by the specific function in Banana, for example the print invoice function.
The result is displayed on the preview windows.
The function should return a Banana.Report document.

  • report.customer.invoice
    • Type: report.customer.invoice
    • Startup function printDocument(jsonInvoice, repDocObj, repStyleObj)
    • How to run it:
      • Select from the menu Account2 > Customers the command Print invoices...
  • report.customer.statement
    • Type: report.customer.statement
    • Startup function printDocument(jsonInvoice, repDocObj, repStyleObj)
    • How to run it:
      • Select from the menu Account2 > Customers the command Print statements...
  • report.customer.reminder
    • Type: report.customer.reminder
    • Startup function printDocument(jsonInvoice, repDocObj, repStyleObj)
    • How to run it:
      • Select from the menu Account2 > Customers the command Print reminders...

Installing file based Extensions

Before using an Extension you need to install it through the ManageApps menu.

If you develop a new app, you have to Install the BananaApp from a local file.

 

 

 

This documentation is outdated

The most complete and up-to-date documentation is the one of Banana Accounting Plus: Try it now

Share this article: Twitter | Facebook | LinkedIn | Email