Import Extensions

In this article

Import Extensions read a custom format and convert in an import format suitable for using with the command "Import to accounting".

Import Extensions

Imports Extensions are JavaScript program that read the data to import and transform and return them as text, in a format compatible with Banana.

Import BananaApps have:

  • the attribute @task defined as one of the import for example //@task = import.transactions (for more information, see Apps attributes documentation)
  • the attribute @outputformat defines the format of the imported data:
    • For a Double-entry accounting use the value //@outputformat = tablewithheaders.
    • For an Income/Expenses accounting use the value //@outputformat = transactions.simple.
  • The parameter in the function exec contains the import data (the content of the file specified in the input box)
  • You can specify that the data is read from the file specified on the input box or that the user can select the file with "// @inputdatasource = openfiledialog"  
  • The import text is returned as a String in the function exec with the return statement
// @api = 1.0
// @id = ch.banana.scripts.import.creditsuisse
// @description = Credit Suisse bank (*.csv)
// @task = import.transactions
// @doctype = nodocument
// @publisher = SA
// @pubdate = 2015-06-21
// @outputformat = transactions.simple
// @inputdatasource = openfiledialog
// @inputfilefilter = Text files (*.txt *.csv);;All files (*.*)
// = Text (*.txt *.csv);;Alle Dateien (*.*)
// = Texte (*.txt *.csv);;Tous (*.*)
// = Testo (*.txt *.csv);;Tutti i files (*.*)

* Parse the data and return the data to be imported as a tab separated file.
function exec(inText) {
  // parse the inText and set to outText
  // in the return text the data is tab separated
  var outText = "";
  outText += "Date\tDescription\tIncome\tExpenses\n";
  outText += "2015-01-01\tIncome text\t100.25\t\n";
  outText += "2015-01-02\tExpense text\t\t73.50\n";  
  return outText;

Help us improve the documentation

We welcome feedback on how to improve this page.

Tell us what theme needs a better explanation or how to clarify a topic.

Share this article: Twitter | Facebook | LinkedIn | Email