You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Information about bug
This issue has been tracked for 3 years now
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
To
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.
The text was updated successfully, but these errors were encountered: