In diesem Artikel
Import Extensions read a custom format and convert in an import format suitable for using with the command "Import to accounting".
- For details of the formats see Import data from a txt file.
- For examples see the Github.com template page.
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 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 = Banana.ch SA // @pubdate = 2015-06-21 // @outputformat = transactions.simple // @inputdatasource = openfiledialog // @inputfilefilter = Text files (*.txt *.csv);;All files (*.*) // @inputfilefilter.de = Text (*.txt *.csv);;Alle Dateien (*.*) // @inputfilefilter.fr = Texte (*.txt *.csv);;Tous (*.*) // @inputfilefilter.it = 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; }