From 701d59b5ae0b5edde292d43bbdef73cc80e7fea2 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Sun, 1 Apr 2018 00:44:31 +0530 Subject: [PATCH] fix decimal split --- frappe/utils/data.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/utils/data.py b/frappe/utils/data.py index acbe86f030..d3ae851ad0 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -373,8 +373,11 @@ def fmt_money(amount, precision=None, currency=None): # 40,000.23000 -> 40,000.23 if decimal_str: - parts = str(amount).split(decimal_str) - decimals = parts[1] if len(parts) > 1 else '' + decimals_after = str(amount % 1) + parts = decimals_after.split(decimal_str) + parts = parts[1] if len(parts) > 1 else '' + decimals = parts + print("Decimals: {}".format(decimals)) if precision > 2: if len(decimals) < 3: if currency: @@ -414,7 +417,8 @@ def fmt_money(amount, precision=None, currency=None): parts.reverse() amount = comma_str.join(parts) + ((precision and decimal_str) and (decimal_str + decimals) or "") - amount = minus + amount + if amount != '0': + amount = minus + amount if currency and frappe.defaults.get_global_default("hide_currency_symbol") != "Yes": symbol = frappe.db.get_value("Currency", currency, "symbol") or currency