Feature request: custom template engine
Posted: 05 October 2014, 15:03
Hello,
first of all thanks a lot for the very good app! I used earlier versions of iCompta for my personal accounts and recently I decided to use it also for my business. I was very happy to hear about the possibility to print invoices. Unfortunately, the Italian legislation is quite complex and just writing the amount (with and without taxes) is not enough. I understand that I can't expect iCompta to support all the Italian subtleties, but I believe it actually doesn't need to, because the necessary computations could easily be computed externally by the template engine. The point is that the MGTemplateEngine is not powerful enough for that, being simply a framework for string substitutions and little more. I initially thought the problem could be approached by extending MGTemplateEngine with just a couple custom "filters" (implementing addition and multiplication), but the fact that you can't neither concatenate filters nor assign the result of an expression to a variable is very limiting.
What I would like to request, is to allow the user to provide its own custom template engine. In practice, when asked to print an invoice, iCompta could invoke a user-provided command line, passing it the invoice data (for example passing the data in json or some other notation on stdin) and then interpret the script output as the html to be printed. With such a feature, anyone could write a script (for example in python) to accommodate for any complex computation or layout, with no additional effort on iCompta. What do you think? Would that be possible? I understand that this feature would be used only by script-savvy pro users, but it seems very easy to implement, so it might still be worth the effort.
first of all thanks a lot for the very good app! I used earlier versions of iCompta for my personal accounts and recently I decided to use it also for my business. I was very happy to hear about the possibility to print invoices. Unfortunately, the Italian legislation is quite complex and just writing the amount (with and without taxes) is not enough. I understand that I can't expect iCompta to support all the Italian subtleties, but I believe it actually doesn't need to, because the necessary computations could easily be computed externally by the template engine. The point is that the MGTemplateEngine is not powerful enough for that, being simply a framework for string substitutions and little more. I initially thought the problem could be approached by extending MGTemplateEngine with just a couple custom "filters" (implementing addition and multiplication), but the fact that you can't neither concatenate filters nor assign the result of an expression to a variable is very limiting.
What I would like to request, is to allow the user to provide its own custom template engine. In practice, when asked to print an invoice, iCompta could invoke a user-provided command line, passing it the invoice data (for example passing the data in json or some other notation on stdin) and then interpret the script output as the html to be printed. With such a feature, anyone could write a script (for example in python) to accommodate for any complex computation or layout, with no additional effort on iCompta. What do you think? Would that be possible? I understand that this feature would be used only by script-savvy pro users, but it seems very easy to implement, so it might still be worth the effort.