Extensions for importing data in Banana Accounting

In this article

Introduction

This walkthrough provides step-by-step guidance for creating a simple BananaApp to import income & expenses transactions in CSV format, that reads the data to import from a CSV file, trasform and then return them in a format comptatible with Banana Accounting.

The steps in order to experiment with import BananaApps are the following:

  1. Create a CSV file example
  2. Create the import BananaApp
  3. Install the BananaApp
  4. Run the import BananaApp

Create the CSV file

First we need a data source in order to import them in Banana Accounting, and for this example we want to use a CSV file.

Copy the following CSV example, paste it on your text editor and save it as csv_example.csv:

"Date","Description","Income","Expenses"
"2019-01-01","Income transaction text","100.00",""
"2019-02-02","Expense transaction text","","200.00"
  • First line is the fields header. Fields names are case sensitive and must correspond to the NameXml (English) of the columns in Banana Accounting.
  • Fields names and data values are between double quotes.
  • Fields and values are separated with a comma
  • Each line is a new record
  • The format for the Date fields is yyyy-mm-dd

Create the import BananaApp

Copy the following JavaScript code, paste it on your text editor and save it as import_transaction_example.js:

// @id = ch.banana.app.importtransactionexample
// @api = 1.0
// @pubdate = 2018-10-30
// @publisher = Banana.ch SA
// @description = Example Import Transactions (*.csv)
// @doctype = *
// @docproperties =
// @task = import.transactions
// @outputformat = transactions.simple
// @inputdatasource = openfiledialog
// @inputencoding = latin1
// @inputfilefilter = Text files (*.txt *.csv);;All files (*.*)

/* CSV file example:
"Date","Description","Income","Expenses"
"2019-01-01","Income transaction text","100.00",""
"2019-02-02","Expense transaction text","","200.00"
*/

// Parse the data and return the data to be imported as a tab separated file.
function exec(inText) {

   // Convert a csv file to an array of array.
   // Parameters are: text to convert, values separator, delimiter for text values
   var csvFile = Banana.Converter.csvToArray(inText, ',', '"');
   
   // Converts a table (array of array) to a tsv file (tabulator separated values)
   var tsvFile = Banana.Converter.arrayToTsv(csvFile);
   
   // Return the converted tsv file
   return tsvFile;

}

When it is used transaction.simple as @outputformat attribute in the script, it's important that CSV file includes "Income" and "Expenses" fields.

Install the BananaApp

For the installation of the BananaApp, see Install your BananaApp.

Run the import BananaApp

To run an import BananaApp follow the steps below:

  1. Open an accounting file in Banana Accounting.
  2. In Banana select from the menu Account1 the command Import to accounting...


     
  3. From the import type selection select Transactions.
  4. From the list select the Example Import Transactions (*.csv) BananaApp.
  5. Click on Browse and look for the csv_example.csv file, then click to Open.


     
  6. Click Ok to begin the import process.
  7. On the dialog window select a Destination account and click on Ok to terminate and import the data.


     

The data from the CSV file are imported into the Transactions table of your accounting file like the following examples.

  • For a Double-Entry accounting:



    You can now replace all the [CA] values with the appropriate contra-account, so that the Credit transactions will be balanced with the Debit transactions.
     
  • For an Income & Expenses accounting:



    For each transaction you can now enter an income or expense category, as defined in the Categories table.

 

More about Import BananaApps

 

 

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