Statement Layout Extension

文件资料 •
在此文中

Create personalized statement report extension

We have published our templates on github.com/BananaAccounting. In this section you will find different basic examples.

You can save a copy of one template in your computer and make the changes you wish. In order to use your custom template in Banana you have to:

  • select the command Reports - Customers - Print statements...
  • In the Print statements dialog select Manage apps...
  • In the Manage apps dialog select Add from file... and choose your statement report file you just created

Extension attributes

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

Report code

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);
}

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);
}

 

 

Tell us how we can help you better
If the information on this page is not what you're looking for, is not clear enough, or is not up-to-date, let us know.

分享这篇文章: Twitter | Facebook | LinkedIn | Email