Banana (Objects)

This documentation is outdated

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

In this article

Banana is the namespace (object) through which all Banana script's methods, class and objects are accessible.

Banana.application

The object Banana.application represent the running application.

Banana.console

The object Banana.console is used to sent message to the debug the script.

Banana.Converter

The class Banana.Converter contains methods useful to convert data from and to various formats.

Banana.document

The object Banana.document represent the current document opened in the application. It contains base properties and methods, see Banana.Document (Base), and if the document represent an accounting document it contains additional accounting's properties and methods, see Banana.Document (Accounting). If any document is opened this object is of type Undefined.

Banana.IO

The class Banana.IO is used to read and write files.

Banana.Report

The class Banana.Report enable you to create reports, preview and print them in Banana Accounting.

Banana.script

The object Banana.script is used to get informations about the running script.

Banana.SDecimal

The class Banana.SDecimal contains methods useful to do decimal math calculation.

Banana.Ui

The class Banana.Ui contains predefined dialogs to interact with the user, and methods to load dialogs from .ui or .qml files.

Banana.Xml

The class Banana.Xml contains methods to parse and access Xml data.

Banana Methods

Banana.compareVersion(v1, v2)

Compare two version strings. Versions string are in the form of "x.y.w.z". Returns 0 if v1 and v2 are equal, -1 if v2 is later and 1 if v1 is later.

Since: Banana Accounting 8.0.5

var requiredVersion = "8.0.5";
if (Banana.compareVersion && Banana.compareVersion(Banana.application.version, requiredVersion) >= 0)
   Banana.Ui.showInformation("Message", "More recent or equal than version " + requiredVersion);
else
   Banana.Ui.showInformation("Message", "Older than version " + requiredVersion);

Banana.include(path)

The method Banana.include(path) include a javascript file evaluating it.
If an error occour, i.e. the file is not found or is not valid, the method throws an exception.

The path is relative to the current script being executed, if no protocol is specified. Otherwise depending on the protocol it can be relative to the main script's folder, the document's folder or the name of a document attacched to the current file.
- <relative_path_to_current_script>/<file_name>
- file:script/<relative_path_to_main_script>/<file_name>
- file:document/<relative_path_to_file>/<file_name>
- documents:<attachment_name>

Scripst included though the method Banana.include(path) can include other scripts trhough the method Banana.include(path), but not via the script's attibute @includejs. The method Banana.include(path) garantees that each distinct script is evaluated once, even if it is included more than one time from differents scripts. Path can contain ".." (parent folder), in the case the destination path is outside the main script's folder, the method will throw a security exception.

Since: Banana Accounting 8.0.5

Banana.include("cashflowlib.js");
Banana.include("folder/cashflowlib.js");

 

Share this article: Twitter | Facebook | LinkedIn | Email