|
|
@@ -371,12 +371,17 @@ def fmt_money(amount, precision=None, currency=None): |
|
|
|
# 40,000 -> 40,000.00 |
|
|
|
# 40,000.00000 -> 40,000.00 |
|
|
|
# 40,000.23000 -> 40,000.23 |
|
|
|
|
|
|
|
if decimal_str: |
|
|
|
parts = str(amount).split(decimal_str) |
|
|
|
decimals = parts[1] if len(parts) > 1 else '' |
|
|
|
if precision > 2: |
|
|
|
if len(decimals) < 3: |
|
|
|
precision = 2 |
|
|
|
if currency: |
|
|
|
fraction = frappe.db.get_value("Currency", currency, "fraction_units") or 100 |
|
|
|
precision = len(cstr(fraction)) - 1 |
|
|
|
else: |
|
|
|
precision = 2 |
|
|
|
elif len(decimals) < precision: |
|
|
|
precision = len(decimals) |
|
|
|
|
|
|
@@ -511,6 +516,13 @@ def is_html(text): |
|
|
|
break |
|
|
|
return out |
|
|
|
|
|
|
|
def is_image(filepath): |
|
|
|
from mimetypes import guess_type |
|
|
|
|
|
|
|
# filepath can be https://example.com/bed.jpg?v=129 |
|
|
|
filepath = filepath.split('?')[0] |
|
|
|
return (guess_type(filepath)[0] or "").startswith("image/") |
|
|
|
|
|
|
|
|
|
|
|
# from Jinja2 code |
|
|
|
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)') |
|
|
|