webERP Forum
[Solved] More Flexible Invoice Layout - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (/forumdisplay.php?fid=1)
+--- Forum: Feature Requests (/forumdisplay.php?fid=5)
+--- Thread: [Solved] More Flexible Invoice Layout (/showthread.php?tid=951)

Pages: 1 2


[Solved] More Flexible Invoice Layout - MacPhotoBiker - 06-27-2013 01:08 PM

Hi,

today I had a chat with a new webERP user who made some comments about the invoice layout of webERP. Based on this conversation I had some thoughts which I'd like to share here. Basically my question(s) will be if it would be possible to replace some of the fixed text components by variable values. I'm starting off my own situation, then trying to suggest a more flexible solution that would be beneficial for many.

1) "Tax Invoice"
In Canada, the term "Tax Invoice" is not common at all, usually simply "Invoice" is being used. I'm aware that the text could be probably modified in the corresponding php file. But in favour of user friendliness and in order to avoid that changes get modified with next update, I thought it would be nice if in the "Setup" area one could define which term to use (just like as it's done for "Tax Authority Reference Name".

2) "Tax"
In Canada, it is important to point out which Tax is being charged, as this depends on several parameters and it's not always obvious. There are different types of sales taxes (HST, PST, GST), and each province defines it's own rates.

It would be great if instead of the term "Tax" the actual name of the Tax Group to which a particular customer is assigned would be displayed.

3) "Bank Code" and "Account"
In Canada, bank details are barely needed since basically all payments are being done via cheque, not by wiring the money. It would be great if (similar to 1.) the terms for Bank Code and Account could be defined (and hence also left empty), or if they could be set to "on/ off". Since these settings may differ from customer to customer, it would be even better if these settings could be defined not only in general but as per customer.

As I mentioned, I'm aware that one could do this by some coding in the corresponding php file (not me yet though), but I believe that the above described concept could greatly contribute to flexibility and usability. Invoices are always going to customers, that's why I believe they should look "impeccable".

I'd appreciate we could share some thoughts on this topic.

Thanks a lot!


RE: More Flexible Invoice Layout - phil - 06-27-2013 03:35 PM

At some point there becomes a trade off between complexity of configuration and having things just so. The more complex the configuration the more it is possible to do as you describe above.

Ultimately, to have things "just so" there really is no substitute for just tweaking the odd bit of code. This sounds daunting BUT looking at the scripts should reveal that this perception is really not true - I have tried to make it so the code is readable. Look at the code in the file

includes/PDFTransPageHeader.inc

Code:
<?php

/* $Id: PDFTransPageHeader.inc 5809 2013-02-02 00:01:58Z daintree $ */

if (!$FirstPage){ /* only initiate a new page if its not the first */
    $pdf->newPage();
}

$YPos = $Page_Height - $Top_Margin;

$pdf->addJpegFromFile($_SESSION['LogoFile'],$Page_Width/2 -120,$YPos-40,0,60);
$FontSize =15;
if ($InvOrCredit=='Invoice') {

        $pdf->addText($Page_Width - 200, $YPos, $FontSize, _('TAX INVOICE') . ' ');
} else {
    $pdf->addText($Page_Width - 200, $YPos, $FontSize, _('CREDIT NOTE') . ' ');
}

Now tell me you cannot figure out how to change the words TAX INVOICE to just invoice?

I believe we are getting to the point where it is not desirable to make up new configuration parameters as this makes the configuration too daunting for newer users. When you think about the permutations of configuration there is actually no end to it and it is simpler just to modify the script. When you realise this the true beauty of webERP is revealed - you can have cake and eat it too :-)

When the code is written accessibly ....and great care has been taken to ensure that it is so, I don't believe such configuration is required or desirable.


RE: More Flexible Invoice Layout - MacPhotoBiker - 06-28-2013 10:17 AM

Hi Phil,

thanks a lot for your answer. I whole heartedly agree that with some simple PHP coding the invoice (like any document) can be perfectly customized. So far so good.

The reason why I'm a bit reluctant is basically the following.

Let's say I perfectly customize the invoice to my requirements. But then, sooner or later a new release will be published, and the changes will be overwritten. Sure, I could make a backup of that file, and after installing the update, I could restore it.

But what if the file in the release was modified, too? Then actually a "merged" version would be required, containing changes in both versions.

As for the wording, I would suggest a database table that contains all the different terms, this could be expanded even to different languages, like:

Parameter - English - Spanish
TermForInvoice - Invoice - Factura

There would be no trouble whatsoever with future updates, because the terms would be read from a database table, not being hard coded anywhere.

I think that in order to get more business customers, configuration should be possible without coding. From my customers, none would be able or even willing to do it. And it would be a lot of work for me to keep track of their individual changes.

But hey, that's just a conceptual comment, not a bug or even much of a problem.


RE: More Flexible Invoice Layout - phil - 06-28-2013 10:28 AM

So here is the dilemma:
a) Have more (and IMHO a mindless potential number of) configuration parameters - making implementation crazy complicated and time consuming - a la SAP et al - and inevitably there will something else - but now the code is so littered with ifs and variables it has become spaghetti it is very difficult to modify.
b) Manage the modified scripts in a separate directory and apply the odd patch as required.

Just another point on translations - you can make up your own words to replace the standards by adopting say en_US.utf8 and looking up these translated words and entering a translation you prefer - no modification - just select the language under the users settings. Languages can be maintained with webERP using

http://www.weberp.org/weberp/Z_poEditLangModule.php

and selecting the appropriate script PDFTransPageHeader.inc

in en_US I see this is translated to just plain ol INVOICE already :-)


RE: More Flexible Invoice Layout - MacPhotoBiker - 07-18-2013 05:32 AM

Hi Phil,

I just tried to do what (I believe) you suggested. I edited the file includes/PDFTransPageHeader.inc and changed line 15 from

$pdf->addText($Page_Width - 200, $YPos, $FontSize, _('TAX INVOICE') . ' ');

to

$pdf->addText($Page_Width - 200, $YPos, $FontSize, _('INVOICE') . ' ');

However, when I reprint an invoice, it still shows "TAX INVOICE" rather than "INVOICE".

Did I miss something, or will this only work for new invoices? (I even restarted the web server, but same result).

Merci!


RE: More Flexible Invoice Layout - phil - 07-18-2013 07:25 AM

That should work... I hesitate to even suggest it but I know I have done this myself :-)
Could it be that you are editing code that is not the code that is running on the live web-server?
Or are you running portrait invoices and edited PrintCustTrans.php when you really should be looking at PrintCustTrans_Portrait.php?
Don't you just hate it when the stupidest things leave you scratching your head :-)


RE: [Solved] More Flexible Invoice Layout - MacPhotoBiker - 07-18-2013 09:24 AM

Hi Phil,

thanks a lot! Your second guess was perfectly right, I was modifying the landscape file, not the portrait file. It works well now.

LOL, yes, I hate it when these little tiny things suddenly look like stumbling blocks, especially since I was so sure I'm on the right file Wink

I had a similiar experience before when I changed the logo. I replaced the correct file, but it wouldn't show, until I realized the old image was simply still cached...

Anyway, this was my first "source file editing", and indeed it does provide a fantastic flexibility.

Merci!


RE: [Solved] More Flexible Invoice Layout - phil - 07-18-2013 09:45 AM

The infinite possibilities and potential is now open to you to "configure" just any way you want :-)
Now how hard was it?


RE: [Solved] More Flexible Invoice Layout - MacPhotoBiker - 07-19-2013 12:19 AM

Apparently too hard Wink

Phil, I realized this particular file only generates the header part. Could you please point out for me which files generate the details/ line items, and the footer section?

What I'd like to change is this:

Line details: show long article description
Footer: Remove "Bank" information

Merci!


RE: [Solved] More Flexible Invoice Layout - phil - 07-19-2013 06:25 AM

PrintCustTrans_Portrait.php is where the guts are and the header is in the includes file