Retrieve and Modify Data

Documentação •
Neste artigo

The Accounting files content can be accessed and be modified using specific API functions.

Retrieving data

The accounting file contains file properties and tables. 

  • Banana.Application
    Information regarding the program, API version, messages.
  • Banana.Document (Base) 
    Is the main class that give access to the content of the  accounting file.
    Some properties and functions:
    • Banana.document.tableNames
      Return a list of the tableNames in the file.
    • Banana.document.table(xmlTableName)
      Return a table object of the specified table.
  • Banana.Document (Accounting)
    Additional properties and functions specific to accounting files.
    For examples:
    • budgetBalance()
      Calculate the balance of an account using the budget data.
    • currentBalance()
      Calculate the balance of an account using the current data.
  • Banana.Document (Invoice & Estimate)
    Additional properties and functions for Invoice & Estimates files.
    • calculateInvoice() 
      Calculate the invoice and return the filled Json.
    • printInvoice() 
      Call the dialog for printing and previewing Invoices.
  • Banana.document 
    Is the object of the current open accounting file. 
  • Banana.Document.Table
    It the class that provide access to the table content.
    Some properties and functions:
    • columnNames
      A property with the list of columns.
    • column(columnName)
      Return the Column with the given name in the given view as Column Object.
    • rows
      Return the rows of the table as an array of Row objects.
  • Banana.Document.Column
    Provide information about the column.
    Some properties are:
    • alignment
    • header
    • dataType
  • Banana.Document.Row
    Access to the content of the single row.
    • value(columnName)
      Return the cell content of the specified column.

 

Changing data

Contrary to Excel script that makes available functions that allow to instantly change data, in Banana Accounting the data change need to be approved by the user first. 

So the process is the following: 

  • The extension create a DocumentChange JSon object that contains the information regarding the change:
    • Add news rows. 
    • Modify existing rows.
    • Delete rows.
    • Modify File properties data.
  • The exec() function return the DocumentChange Object.
  • The user can see a preview of the data that will be changed. 
  • The user need to confirm the change. 
  • The will be added to the undo/redo mechanism. 
    The user can therefore undo the change.

Extension setting and oata

Data specific to the extension can be saved within the accounting file and later retrieved with the specific Banana.Document functions:

  • Banana.document.getScriptSettings()
  • Banana.document.setScriptSettings()

Data conversion 

For manipulating data you can use the Javascript native functions. 

Banana API makes available some function that make it easy to convert from and to Banana format: 

  • Banana.Converter
    A collection of methods useful to convert various formats to and from data tables (array of arrays).
  • Banana.SDecimal
    Provides functions to do precise decimal math calculation with up to 34 decimal. 
    It overcomes the rounding problem typical of Javasctipt float type. 
  • Banana.Xml
    A convenient class to access and create XML content.

 

 

Tell us how we can help you better
If the information on this page is not what you're looking for, is not clear enough, or is not up-to-date, let us know.

Share this article: Twitter | Facebook | LinkedIn | Email