File Creator Extensions

Dokumentation •
In diesem Artikel

The File Create extensions transforms allow to create Banana file, by importing a data formats (like audit files, bank statements or invoices files) . 

For example of File Creator Extensions, see the Menu Tools > Create file from external data.

Extension Package

The Create extension must be published as sbaa package and contains at least the following two files:

  • manifest.json
    The description of the package
  • createlocate.json
    This file specify to which file the conversion apply, and the resource used for converting and creating a file.
  • createinit.js
    A javascript file that analyse the data and return a Json text, that specify what script is used to convert the data and what document Banana Accounting will create.

Example on Github.com

createlocate.json

The text file createlocate.json associates a specific file format  to an extension. When opening a text file, whose format is defined in createlocate.json, Banana Accounting will create a new accounting file and import the content of the text file.
In the following example, opening an XML file with namespace 'http:://ivaservizi.agenziaentrate.gov....', Banana Accounting will look for the extension to be executed defined in the createlocate.json file. 

{
	"country":"italy",
	"countryCode":"it",
	"description": "Importazione e-fatture ordinarie v1.2 (xml)",
	"docUri": "",
	"fileExtension": "xml",
	"mimeType": "text/xml",
	"script": {
		"function": "exec",
		"uri": "ch.banana.it.import.efattura.sbaa/createinit.js"
	},
	"xml": {
		"namespace": "http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2",
		"rootItem": "FatturaElettronica"
	},
	"type": "text/json",
	"version": "1.0"
}

Example of XML Data

This example will be imported according to the instructions  contained in the createlocate.js file 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type='text/xsl' href='fatturaPA_v1.2.1.xsl'?>
<p:FatturaElettronica versione="FPR12" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <FatturaElettronicaHeader>
        <DatiTrasmissione>
            <IdTrasmittente><IdPaese>IT</IdPaese><IdCodice>09009900999</IdCodice></IdTrasmittente>
        ...
        </DatiTrasmissione>
    </FatturaElettronicaHeader>
</p:FatturaElettronica>

createinit.js

This is a script file with the attribute @task create.init.
The script returns a json object which defines the type of accounting file to create and the extension to execute for importing data.
The argument of the exec function (inData) is the data to be imported.

// @id = createinit
// @api = 1.0
// @pubdate = 2021-07-28
// @publisher = Banana.ch SA
// @description = Create Init for importing Italy's XML Invoices
// @task = create.init
// @doctype = *

function exec(inData) {

var jsonData = {
	"fileType": {
		"accountingType" : {
			"docGroup" : "100",
			"docApp" : "110",
			"decimals" : "2"
			
		},
		"template" : "https://github.com/BananaAccounting/Italia/raw/master/templates/contabilita_doppia/cd_commerciale.ac2",
	},
	"scriptImport": {
		"function": "exec",
		"uri": "ch.banana.it.import.efattura.sbaa/ch.banana.it.import.efattura"
	},		
	"scriptSetup": {
		"function": "setup",
		"uri": "ch.banana.it.import.efattura.sbaa/ch.banana.it.import.efattura"
	},		
};
return jsonData;
}
  • fileType: the ac2 file which will contain the imported data
    • accountingType: if template is empty, a new empty accounting file will be created. You can decide which type to create:

      docGroup 100 double entry accounting
      docGroup 110 simple accounting (income - expenses accounting)
      docGroup 130 cash book accounting

      docApp 100 without VAT
      docApp 110 with V AT
      docApp 120 multicurrency without VAT
      docApp 130 multicurrency with VAT
       
    • template: url of an ac2 file. You can download ac2 files from our website (resources). If template is empty a new empty file will be created.
       
  • scriptImport:
    function is the method which will be called when importing data. uri is the name of the file which contains the javascript with this method.
     
  • scriptSetup:
    function is the method which will be called when setting up the script. uri is the name of the file which contains the javascript with this method.

 

Wie können wir Ihnen besser helfen?
Wenn die Informationen auf dieser Seite nicht das sind, was Sie suchen, nicht klar genug sind oder nicht aktuell sind, lassen Sie es uns wissen.

Diesen Artikel teilen: Twitter | Facebook | LinkedIn | Email