mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-28 14:18:24 +00:00
fix: respect zero currency precision (#58395)
(cherry picked from commit ce23fcc055)
This commit is contained in:
@@ -7,6 +7,7 @@ from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_ent
|
|||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
from erpnext.accounts.party import get_party_shipping_address
|
from erpnext.accounts.party import get_party_shipping_address
|
||||||
from erpnext.accounts.utils import (
|
from erpnext.accounts.utils import (
|
||||||
|
get_currency_precision,
|
||||||
get_future_stock_vouchers,
|
get_future_stock_vouchers,
|
||||||
get_voucherwise_gl_entries,
|
get_voucherwise_gl_entries,
|
||||||
get_zero_cutoff,
|
get_zero_cutoff,
|
||||||
@@ -155,3 +156,18 @@ class TestUtils(ERPNextTestSuite):
|
|||||||
self.assertEqual(get_zero_cutoff(None), 0.005)
|
self.assertEqual(get_zero_cutoff(None), 0.005)
|
||||||
self.assertEqual(get_zero_cutoff("EUR"), 0.005)
|
self.assertEqual(get_zero_cutoff("EUR"), 0.005)
|
||||||
self.assertEqual(get_zero_cutoff("BHD"), 0.0005)
|
self.assertEqual(get_zero_cutoff("BHD"), 0.0005)
|
||||||
|
|
||||||
|
def test_get_currency_precision_respects_zero_and_fallback(self):
|
||||||
|
currency_precision = frappe.db.get_default("currency_precision")
|
||||||
|
number_format = frappe.db.get_default("number_format")
|
||||||
|
|
||||||
|
try:
|
||||||
|
frappe.db.set_default("number_format", "#,###.##")
|
||||||
|
frappe.db.set_default("currency_precision", "0")
|
||||||
|
self.assertEqual(get_currency_precision(), 0)
|
||||||
|
|
||||||
|
frappe.db.set_default("currency_precision", "")
|
||||||
|
self.assertEqual(get_currency_precision(), 2)
|
||||||
|
finally:
|
||||||
|
frappe.db.set_default("currency_precision", currency_precision or "")
|
||||||
|
frappe.db.set_default("number_format", number_format or "#,###.##")
|
||||||
|
|||||||
@@ -1189,12 +1189,12 @@ def fix_total_debit_credit():
|
|||||||
|
|
||||||
|
|
||||||
def get_currency_precision():
|
def get_currency_precision():
|
||||||
precision = cint(frappe.db.get_default("currency_precision"))
|
currency_precision = frappe.db.get_default("currency_precision")
|
||||||
if not precision:
|
if currency_precision not in (None, ""):
|
||||||
number_format = frappe.db.get_default("number_format") or "#,###.##"
|
return cint(currency_precision)
|
||||||
precision = get_number_format_info(number_format)[2]
|
|
||||||
|
|
||||||
return precision
|
number_format = frappe.db.get_default("number_format") or "#,###.##"
|
||||||
|
return get_number_format_info(number_format)[2]
|
||||||
|
|
||||||
|
|
||||||
def get_fraction_units(currency: str) -> int:
|
def get_fraction_units(currency: str) -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user