Has something changed with the liquid templates in a recent version? (I’m now using version 21.2.87.) I have a heavily customised theme for invoices, and column of numbers (inc GST) which are calculated using Liquid math filters (times: 1.1). Everything still works, except the founding filter (round: 2) no longer includes trailing zeros. (E.g. 170.50 now appears as 170.5.) In all previous versions of Manager that I used, this appeared as expected (170.50).
Thanks @Mark. format: 'n2' does indeed work. Like Ealfardan, I like to understand why something works too, but I can’t find any mention of this filter after Duck-Duck-Googling and looking here and here. Mark, can you enlighten us?
My hunch is that nothing has changed with Liquid and that this is a Manager issue. Why? On that Liquid cheat sheet, I noticed the money_without_currency filter and thought, perfect, that’s a filter custom-built for the task! But it too fails to add the trailing zeros in Manager. So, I can only assume that numerical formatting is being ignored for some reason, and that this mysterious format: 'n2' works because it turns the number into a string.
Possibly not the place to report other bugs, but some other things I’ve noticed with this version of Manager… The Theme editor window gives me a very thin text field for entering the ‘Template’ code, such that one has to scroll horizontally just to see beyond the first 30 characters or so. Manager also crashes for me after I print a PDF of my invoice.
You are correct, @Kal, it is not the place. Both issues have been reported previously as bugs. Depending on your operating system, they may have also been fixed. So look at the bugs list first. Make sure your software is up to date. Then, and only then, if your problem is not covered and/or resolved, start a new topic.
Yes Manager needs a Manager customisation forum to discuss the many ways of customising Manager which are beyond the capabilities of some users.
That way instead of a Moderator saying this is not the place to discuss Manger customisation, the moderator could just move it to the correct sub forum.
The result would be standard users would not be confused by Manager customisation discussions. And conversely support for Manger customisation would be available. I can see no other reasonable way of achieving community generated localisations and sharing of custom themes.
@Patch, my statement that this was not the place had nothing to do with discussions about customization. The point was that this topic is about rounding in a Liquid theme, and @Kal introduced two completely separate bugs that are the subject of other forum topics. The issue was topic diversion, not where customization should be discussed.
Duly noted. Yes, my last little comment was indeed off-topic (as I admitted), but it was related to the task of outputting invoices. I’ve been here before you may remember, where having gone to pains to set everything up nicely, a new version of Manager messes up my invoices again… so forgive me for expressing just a little hint of frustration. Sometimes the meta-chat derails a thread more than the original comment, and I think that’s where we are now.
I guessed that much. The question remains: Why are other valid number formatting filters (like round: 2 and money_without_currency no longer working? My guess is that format: 'n2' converts the value to a string type, whereas the others do not. But that’s only a guess, and it doesn’t explain what has changed in Manager.
I’m not sure, but I think it might be similar to a spreadsheet where cells could either be formatted as currency or numbers, in this case the ‘cells’ are numbers now.
Maybe?
Under the hood, it’s basically either a number (integer or float) or a string. The formatting (whether it has a dollar sign in front of it, trailing zeros, etc) is just how it’s printed to the screen (as a string). So yeah, when you lose those trailing zeros, it’s a pretty sure sign that it’s a number, and the formatting instructions have been lost. A pre-formatted string wouldn’t suffer the same fate, so I suspect that’s what the format filter does.