fix: Precision issues while allocating advance amoount
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 89a05b1..5a64e27 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -406,9 +406,10 @@
throw(_("""Payment Entry has been modified after you pulled it. Please pull it again."""))
def validate_allocated_amount(args):
+ precision = args.get('precision') or frappe.db.get_single_value("System Settings", "currency_precision")
if args.get("allocated_amount") < 0:
throw(_("Allocated amount cannot be negative"))
- elif args.get("allocated_amount") > args.get("unadjusted_amount"):
+ elif flt(args.get("allocated_amount"), precision) > flt(args.get("unadjusted_amount"), precision):
throw(_("Allocated amount cannot be greater than unadjusted amount"))
def update_reference_in_journal_entry(d, jv_obj):
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 12a81c7..5341fc0 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -656,6 +656,7 @@
'dr_or_cr': dr_or_cr,
'unadjusted_amount': flt(d.advance_amount),
'allocated_amount': flt(d.allocated_amount),
+ 'precision': d.precision('advance_amount'),
'exchange_rate': (self.conversion_rate
if self.party_account_currency != self.company_currency else 1),
'grand_total': (self.base_grand_total
@@ -1394,7 +1395,7 @@
)
def get_new_child_item(item_row):
- child_doctype = "Sales Order Item" if parent_doctype == "Sales Order" else "Purchase Order Item"
+ child_doctype = "Sales Order Item" if parent_doctype == "Sales Order" else "Purchase Order Item"
return set_order_defaults(parent_doctype, parent_doctype_name, child_doctype, child_docname, item_row)
def validate_quantity(child_item, d):