Adding leading zeros to bpay field in Invoice template
Hi everyone,
This is a question for the template experts out there.
We make use of the excellent $F{[party:getBpayId(openvpms:get(.,'customer.entity'))]} function in our invoice template. It generates our Bpay reference numbers.
After a recent change in bank we have run into a new problem. In rare cases the generated reference number is too short. A work around is to add leading zeros to pad out the reference number length.
Despite every combination of functions, formatting, using the "Pattern" or "Pattern Expression" fields, I could think of, I run into problems with data types every time.
The bpay function returns a string. Options like String.format("%10s", field) require an integer. Just adding '000' to be Pattern field did not work either.
Any suggestions?
Matt
Re: Adding leading zeros to bpay field in Invoice template
Matt,
At a pure template level, ignoring any expressions and you need "000" only, without it ever changing; you could place a label adjacent to the left of the bpay field, containing nothing but "000", right aligned, with the same font, font size, box height and alignment in the box as the bpay field, which is then left aligned.
Simon Slater
Registered Linux User #463789 @ http://linuxcounter.net
Re: Adding leading zeros to bpay field in Invoice template
I thought that would work Simon.
What I neglected to mention was that the leading zero was only required for those derived bpay reference numbers had only 5 digits.
Almost all our owners have 6-7 digit references. References with lengths <6 or >7 digit are rejected.
This is a requirement we can change via the bank. Might be easier. :-)
Cheers,
Matt
Re: Adding leading zeros to bpay field in Invoice template
You should be able to do this by declaring a String variable containing the BPay identifier, and then left padding it as required with an expression e.g. (untested...):
This requires the use of JasperReports functions, which were first included in OpenVPMS 1.9.3. See https://openvpms.atlassian.net/browse/OVPMS-1934
Re: Adding leading zeros to bpay field in Invoice template
Thanks Tim,
We are on 1.9 only.
Will add this to steps after update.
Cheers,
matt