### Information about bug
**This issue has been tracked for 3 years now**
- On… the forum [here](https://discuss.frappe.io/t/total-debit-must-be-equal-to-total-credit-the-difference-is-0-009999999999990905/95779) and [here](https://discuss.frappe.io/t/multicurrency-journal-entry-debit-must-equal-credit/49301) in Version-15 AFAIK
- There's also this [related github issue which was closed without resolution](https://github.com/frappe/erpnext/issues/36698) in Version-14
### **Expected behaviour:**
Journal Entry should be able to ignore the debit credit difference if its under the standard or set currency precision.
### **Actual Behaviour**
Getting Exception Message: Total Debit must be equal to Total Credit. The difference is -0.000000XXXX
### **Workaround**
The only workaround is reducing **Currency Precision** to 1 decimal place in **System Settings**
### **Suggested Solution**
I believe we can resolve the issue by ignoring small discrepancies less than 0.01 by rounding-up one of the amounts so that there's no difference
We can change
```
def set_total_debit_credit(self):
self.total_debit, self.total_credit, self.difference = 0, 0, 0
for d in self.get("accounts"):
if d.debit and d.credit:
frappe.throw(_("You cannot credit and debit same account at the same time"))
self.total_debit = flt(self.total_debit) + flt(d.debit, d.precision("debit"))
self.total_credit = flt(self.total_credit) + flt(d.credit, d.precision("credit"))
self.difference = flt(self.total_debit, self.precision("total_debit")) - flt(
self.total_credit, self.precision("total_credit")
)
```
To
```
def set_total_debit_credit(self):
self.total_debit, self.total_credit, self.difference = 0, 0, 0
# Calculate total debit and credit
for d in self.get("accounts"):
if d.debit and d.credit:
frappe.throw(_("You cannot credit and debit the same account at the same time"))
self.total_debit += flt(d.debit, d.precision("debit"))
self.total_credit += flt(d.credit, d.precision("credit"))
# Compute the difference with rounding
self.difference = flt(
flt(self.total_debit, self.precision("total_debit")) -
flt(self.total_credit, self.precision("total_credit")),
self.precision("difference")
)
# Adjust for small discrepancies
if abs(self.difference) <= 0.01:
if self.total_debit > self.total_credit:
self.total_credit = flt(self.total_debit, self.precision("total_credit"))
else:
self.total_debit = flt(self.total_credit, self.precision("total_debit"))
self.difference = 0 # Ensure no discrepancy remains
```
### Module
accounts
### Version
ERPNext: v15.39.3 (version-15)
Frappe Framework: v15.45.1 (version-15)
### Installation method
None
### Relevant log output / Stack trace / Full Error Message.
```shell
File "apps/frappe/frappe/model/document.py", line 291, in insert
11:12:05 web.1 | self.run_before_save_methods()
11:12:05 web.1 | File "apps/frappe/frappe/model/document.py", line 1091, in run_before_save_methods
11:12:05 web.1 | self.run_method("validate")
11:12:05 web.1 | File "apps/frappe/frappe/model/document.py", line 962, in run_method
11:12:05 web.1 | out = Document.hook(fn)(self, *args, **kwargs)
11:12:05 web.1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11:12:05 web.1 | File "apps/frappe/frappe/model/document.py", line 1322, in composer
11:12:05 web.1 | return composed(self, method, *args, **kwargs)
11:12:05 web.1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11:12:05 web.1 | File "apps/frappe/frappe/model/document.py", line 1304, in runner
11:12:05 web.1 | add_to_return_value(self, fn(self, *args, **kwargs))
11:12:05 web.1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
11:12:05 web.1 | File "apps/frappe/frappe/model/document.py", line 959, in fn
11:12:05 web.1 | return method_object(*args, **kwargs)
11:12:05 web.1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11:12:05 web.1 | File "apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 132, in validate
11:12:05 web.1 | self.validate_total_debit_and_credit()
11:12:05 web.1 | File "apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 868, in validate_total_debit_and_credit
11:12:05 web.1 | frappe.throw(
11:12:05 web.1 | File "apps/frappe/frappe/__init__.py", line 655, in throw
11:12:05 web.1 | msgprint(
11:12:05 web.1 | File "apps/frappe/frappe/__init__.py", line 620, in msgprint
11:12:05 web.1 | _raise_exception()
11:12:05 web.1 | File "apps/frappe/frappe/__init__.py", line 571, in _raise_exception
11:12:05 web.1 | raise exc
11:12:05 web.1 | frappe.exceptions.ValidationError: Total Debit must be equal to Total Credit. The difference is -0.0000001
```