Link to Github Issue: Payment greater than Outstanding · Issue #34704 · frappe/erpnext · GitHub
Information about bug
Getting a an error “Payment against Sales Invoice ACC-SINV-2023-xxxx cannot be greater than Outstanding Amount 14.1”
even though the payment being made (Debit to a Bank Account) is 14.1
On investigating further (logging the total
from JV and invoice_outstanding_amount
) I found that the total value is 14.100000000000001
where as the outstanding amount is 14.1
It seems that this issue is due to the way “floating-point numbers are represented in computer memory, the actual sum calculated by the computer might be slightly different. This can result in a total of 14.100000000000001 instead of 14.1” [According to ChatGPT]
Has anyone from the community faced this issue before?
Below is the JV JSON
{"docstatus":0,"doctype":"Journal Entry","name":"new-journal-entry-1","__islocal":1,"__unsaved":1,"owner":"Administrator","voucher_type":"Journal Entry","naming_series":"ACC-JV-.YYYY.-","company":"ABC","apply_tds":0,"multi_currency":0,"total_amount_currency":"USD","write_off_based_on":"Accounts Receivable","is_opening":"No","accounts":[{"docstatus":0,"doctype":"Journal Entry Account","name":"new-journal-entry-account-1","__islocal":1,"__unsaved":1,"owner":"Administrator","cost_center":"Main - S","account_currency":"USD","reference_type":"Sales Invoice","is_advance":"No","parent":"new-journal-entry-1","parentfield":"accounts","parenttype":"Journal Entry","idx":1,"account":"Debtors - S","balance":266003.64,"party_type":"Customer","account_type":"Receivable","exchange_rate":1,"debit":0,"credit":3.14,"party":"ABC Store","reference_name":"ACC-SINV-2023-44225","credit_in_account_currency":3.14},{"docstatus":0,"doctype":"Journal Entry Account","name":"new-journal-entry-account-2","__islocal":1,"__unsaved":1,"owner":"Administrator","cost_center":"Main - S","account_currency":"USD","reference_type":"Sales Invoice","is_advance":"No","parent":"new-journal-entry-1","parentfield":"accounts","parenttype":"Journal Entry","idx":2,"account":"Debtors - S","balance":266003.64,"party_type":"Customer","account_type":"Receivable","exchange_rate":1,"debit":0,"credit":10.96,"party":"ABC Store","__unedited":false,"credit_in_account_currency":10.96,"reference_name":"ACC-SINV-2023-44225"},{"docstatus":0,"doctype":"Journal Entry Account","name":"new-journal-entry-account-3","__islocal":1,"__unsaved":1,"owner":"Administrator","cost_center":"Main - S","account_currency":"USD","reference_type":"","is_advance":"No","parent":"new-journal-entry-1","parentfield":"accounts","parenttype":"Journal Entry","idx":3,"__unedited":false,"account":"Clearing Account USD - S","party":"","party_type":"","debit_in_account_currency":14.1,"debit":14.1,"balance":503766.04,"account_type":"","exchange_rate":1,"credit":0}],"posting_date":"2023-04-01","total_debit":14.1,"total_credit":14.100000000000001,"difference":0}
Module
accounts
Version
ERPNext: v13.39.1 (version-13)
Frappe Framework: v13.41.2 (version-13)
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 69, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 38, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1457, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 24, in savedocs
doc.save()
File "apps/frappe/frappe/model/document.py", line 310, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 332, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 261, in insert
self.run_before_save_methods()
File "apps/frappe/frappe/model/document.py", line 1052, in run_before_save_methods
self.run_method("validate")
File "apps/frappe/frappe/model/document.py", line 941, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1261, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1243, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 938, in fn
return method_object(*args, **kwargs)
File "apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 68, in validate
self.validate_reference_doc()
File "apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 531, in validate_reference_doc
self.validate_invoices()
File "apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 591, in validate_invoices
reference_type, reference_name, invoice.outstanding_amount
File "apps/frappe/frappe/__init__.py", line 511, in throw
as_list=as_list,
File "apps/frappe/frappe/__init__.py", line 479, in msgprint
_raise_exception()
File "apps/frappe/frappe/__init__.py", line 434, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Payment against Sales Invoice ACC-SINV-2023-44225 cannot be greater than Outstanding Amount 14.1 ```