Banana.Document (Base)

Deze documentatie is verouderd

De meest volledige en bijgewerkte documentatie is die van Banana Boekhouding Plus: Probeer het nu

In this article

Banana.Document is the interface to a document in Banana Accounting. The current opened document can be accessed through the property Banana.document. A document can be also opened with the method Banana.application.openDocument.

Properties

cursor

Return a Cursor object with the current position of the cursor and the range of the selected rows.

var currentCursor = Banana.document.cursor;

locale

Return the locale of the document in the form of "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.

var locale = Banana.document.locale;

rounding

Return the rounding context of the current file that can be used with the SDecimal math functions.

var rounding = Banana.document.rounding;

tableNames

Return an array with the xml names of the tables in the document.

var tableNames = Banana.document.tableNames;

 

Methods

addMessage(msg[, idMsg])

Add the message msg to the document. The message is showed in the pane "Messages", and in a dialog if the application option "Show Messages" is turned on.
If idMsg is not empty, the help button calls an url with script's id and message's id (idMsg) as parameters.

See also: Application.AddMessage, Table.AddMessage, Row.AddMessage.

Banana.document.addMessage("Message text");

clearMessages()

Clear all the document's messages showed in the pane "Messages".

Banana.document.clearMessages();

getScriptSettings()

Get the settings of the script saved in the document. You use this method to get settings that are private to the running script. It is possible to save the settings of the script through the method "setScriptSettings". 

With this method Settings are saved and restored under the script id, If you change the script's id you will lose the saved settings.

Example:

// Initialise parameter
param = {
   "searchText": "",
   "matchCase": "false",
   "wholeText": "false"
};

// Readscript settings
var strData = Banana.document.getScriptSettings();
if (strData.length > 0) {
   var objData = JSON.parse(strData);
   if (objData)
      param = objData;
}

Since Banana 8.0.8

getScriptSettings(id)

Return the settings saved in the document under the id 'id'.

You use this method to get settings that are shared between scripts. As id we recommend to use a substring of the script's id. For example if you have the scripts 'ch.banana.vat.montlyreport' and 'ch.banana.vat.endofyearreport', then you can use as id 'ch.banana.vat'.

Example:

// Initialise parameter
param = {
   "searchText": "",
   "matchCase": "false",
   "wholeText": "false"
};

// Readscript settings
var strData = Banana.document.getScriptSettings('ch.banana.vat');
if (strData.length > 0) {
   var objData = JSON.parse(strData);
   if (objData)
      param = objData;
}

Since Banana 8.0.8

info(section, id)

Return the info value of the document referenced by section and id. Section and Id correspond to the xml name listed in the Info table, see command File info in menu "Tools" and set the view to complete to see the XML columns. If the value referenced by section and id doesn't exist, an object of type undefined is returned.

Example:

// Get some value of the accounting file 
var FileName = Banana.document.info("Base","FileName");
var DecimalsAmounts = Banana.document.info("Base","DecimalsAmounts");
var HeaderLeft = Banana.document.info("Base","HeaderLeft");
var HeaderRight = Banana.document.info("Base","HeaderRight");
var BasicCurrency = Banana.document.info("AccountingDataBase","BasicCurrency");

// For openingDate and closureDate use instead startDate and endDate
var openingDate = Banana.document.info("AccountingDataBase","OpeningDate");
var closureDate = Banana.document.info("AccountingDataBase","ClosureDate");

// For file accounting type
var FileType = Banana.document.info("Base","FileType");
var FileGroup = Banana.document.info("Base","FileTypeGroup");
var FileNumber = Banana.document.info("Base","FileTypeNumber");

FileTypeGroup / FileTypeNumber combinations:

  • 100 Double entry accounting
    • 100 No VAT
    • 110 With VAT
    • 120 Multi Currency
    • 130 Multi Currency with VAT
  • 110 Income and Expense accounting
    • 100 No VAT
    • 110 With VAT
  • 130 Cash Book
    • 100 No VAT
    • 110 With VAT
  • 400 Address / Labels
    • 110 Labels
    • 120 Address

scriptSaveSettings(string)

Save the settings of the script in the document. The next time the script is run, it si possible to read the saved settings with "scriptReadSettings".

With this method Settings are saved and restored under the script id, If you change the script's id you will lose the saved settings.

Example:

// Save script settings
var paramString = JSON.stringify(param);
var value = Banana.document.scriptSaveSettings(paramString);

Deprecated since Banana 8.0.8. Use setScriptSettings instead.

scriptReadSettings()

Return the saved settings of the script.

With this method Settings are saved and restored under the script id, If you change the script's id you will lose the saved settings.

Example:

// Initialise parameter
param = {
   "searchText": "",
   "matchCase": "false",
   "wholeText": "false"
};

// Readscript settings
var strData = Banana.document.scriptReadSettings();
if (strData.length > 0) {
   var objData = JSON.parse(strData);
   if (objData)
      param = objData;
}

Deprecated since Banana 8.0.8. Use getScriptSettings instead.

setScriptSettings(value)

Save the settings of the script in the document. It is possible to read the saved settings of the script with the method "getScriptSettings". 

With this method Settings are saved and restored under the script id, If you change the script's id you will lose the saved settings.

Example:

// Save script settings
var paramString = JSON.stringify(param);
var value = Banana.document.setScriptSettings(paramString);

Since Banana 8.0.8.

setScriptSettings(id, value)

Save the settings in the document under the id 'id'. It is possible to read the saved settings with "getScriptSettings(id)".

You use this method to set settings that are shared between scripts. As id we recommend to use a substring of the script's id. For example if you have the scripts 'ch.banana.vat.montlyreport' and 'ch.banana.vat.endofyearreport', then you can use as id 'ch.banana.vat'.

Example:

// Save script settings
var paramString = JSON.stringify(param);
var value = Banana.document.setScriptSettings('ch.banana.vat', paramString);

Since Banana 8.0.8.

table(xmlTableName)

Return the table referenced by the name xmlTableName as a Table object, or undefined if it doesn't exist.

Banana.document.table("Accounts");

table(xmlTableName, xmlListName)

Return the table referenced by the name xmlTableName with the rows of the list xmlListName as a Table object, or undefined if the table or the list don't exist. The default list is the 'Data' list.

Banana.document.table("Transactions", "Examples");
Banana.document.table("Transactions").list("Examples");  // alternative way

See also: Table.list, Table.listNames.

Since Banana 8.0.5

value(tableName, rowNr, columnName)

Return the value in table tableName, row rowNr and column columnName as string. If the table, row or column are not founds it return an object of type undefined.

Banana.document.value("Accounts", 5, "Description")

 

 

Share this article: Twitter | Facebook | LinkedIn | Email