/
Support price formatting with cents [5.2.2-B2]
Support price formatting with cents [5.2.2-B2]
In-Portal has developer-friendly code when dealing with number display. For example, while declaring a database column on PHP side developer can:
- specify the "format" parameter for desired number precision during rounding, e.g. "5.127" will be shown as "5.13" with the "format" field option set to "%01.2f";
- specify the "cut_zeros" parameter to remove trailing zeros from a number, e.g. "5.10000" will be shown as "5.1" and "5.00000" will be shown as "5".
There uncovered case would be money columns, where a fixed number of decimals places always need to be present (e.g. "5.00" instead of "5") and no rounding should occur on larger precisions, e.g. "5.1230" is shown as "5.123" instead of "5.12".
Solution
Change the "kFormatter::Format" method to support the "keep_cents" field option, which will cut zeros in that number to that (specified in the "keep_cents" field option) number.