Invoice Layout Extension

Documentazione •
In questo articolo

The Invoice Layout Extension is a report extension for printing invoices.

It is used on the 

  • Accounting file 
    • Menu Reports > Customers > Print invoices...
  • In the Estimate & Invoice
    • Menu Invoices > Print invoice...
    • Menu Invoices > Print estimate...

Structure of the extensions

The Invoice Layout Extension need to contains the following elements:

  • The extension attribute with 
    @task = report.customer.invoice.
  • printDocument(jsonContent, repDocObj, repStyleObj [, prefSelected])
    the main function that is called by the program
    Is use the content of the invoice json object to add element to the reportDocObj.
  • settingsDialog() (optional)
    called from user to set up parameters like colour or additional text.
  • getPrintPreferences() (optional)
    returns a JSON object with the available print options.
    Invoice Json Properties.

Extension attributes

// @id = scriptfilename.js
// @api = 1.0
// @pubdate = yyyy-mm-dd
// @publisher = yourName
// @description = script description
// @task = report.customer.statement

Function printDocument

The main function is printDocument(jsonStatement, repDocObj, repStyleObj [, format]). The  parameter jsonStatement object contains the data, repDocObj is the document object and repStyleObj is the stylesheet object where you can add styles.

function printDocument(jsonStatement, repDocObj, repStyleObj) {
  var param = initParam();
  var savedParam = Banana.document.getScriptSettings();
  if (savedParam.length > 0) {
    param = JSON.parse(savedParam);
    param = verifyParam(param);
  }
  printInvoice(jsonInvoice, repDocObj, repStyleObj, param);
}

Function settingsDialog

The function settingsDialog() is called from Banana when you select the button Params... from dialog Manage apps. You can write any code you need for your script.

/*Update script's parameters*/
function settingsDialog() {
   var param = initParam();
   var savedParam = Banana.document.getScriptSettings();
   if (savedParam.length > 0) {
      param = JSON.parse(savedParam);
   }   
   param = verifyParam(param);
   ...
   var paramToString = JSON.stringify(param);
   var value = Banana.document.scriptSaveSettings(paramToString);
}

 

Aiutaci a migliorare la documentazione

Sono benvenuti suggerimenti per come migliorare questa pagina.

Informaci quale tema necessita di una spiegazione migliore o come chiarire meglio un argomento.

Condividi questo articolo: Twitter | Facebook | LinkedIn | Email