This topic contains 3 replies, has 0 voices, and was last updated by cgieselman 8 years, 10 months ago.
-
AuthorPosts
-
January 21, 2016 at 8:45 am #2913
cgieselmanI’m working with the advanced pdf templates for an invoice and running into an annoying issue when I try to save.
My goal is to conditionally display a block of text dependent on the billing country and the amount remaining on the invoice.
Currently I have the line
Code:
followed by the code for the required text for that scenario. If I have only this condition in the code then the file will save fine and prints properly on a test invoice.I run into the problem when I attempt to write the condition for the alternative text. I am trying to use the line
Code:
then I get an error saying that the left and right sides of a comparison must be the same type.It seems to be that on save the code is verified but the “&&” conditions are only evaluated until a false result is found. If the second line is removed and the first switched to be amountremaining!=0 && billcountry==”US” then I get the same save error but given the nature of the && operator the order shouldn’t matter.
I’ve also tried the second line of code modified to
Code:
and this will save without an issue, again pointing to my thought that && and || operators are only evaluated as far as they need to be to determine the result, but when I try to print an invoice it fails to generate because of the mismatched left and right value types.I’m at my wits end with this, please help!
This is a cached copy. Click here to see the original post. -
January 21, 2016 at 12:04 pm #2914
cgieselmanAs a follow up I did get this to work but it is an ugly solution.
I ended up going with the line
Code:
I would still very much like to know why it behaved the way it did if anyone has any insight or if there is a better solution than what I’ve come to.
Thanks
-
January 22, 2016 at 2:24 am #2915
NelliottI wonder if this would work:
Code:
So long as your amount remaining is not a string value of “0”, !record.amountremaining would return true if it was 0;
Kinda daft anyway you look at it but advanced print / pdf coding is always a “challenge”.
-
January 22, 2016 at 6:26 am #2916
cgieselmanNelliot – I tried your suggestion and I got a slightly different error when I tried to save the template,
“Expecting a boolean (true/false) expression here Expression record.amountremaining does not evaluate to true/false it is an instance of com.netledger.templates.model.EmptyModel”
It seems to come from the same problem as all the others though, that on save the fields evaluate to null which in turn causes problems with the seemingly very strict freemarker language.
Thanks for the attempt though, “a challenge” is an understatement.
-
AuthorPosts
You must be logged in to reply to this topic.