Skip to content

Commit

Permalink
fix: reset dr_or_cr for every reference
Browse files Browse the repository at this point in the history
  • Loading branch information
GursheenK committed Nov 13, 2023
1 parent 5b446d4 commit a59c942
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,9 @@ def add_party_gl_entries(self, gl_entries):
item=self,
)

dr_or_cr = "credit" if self.payment_type == "Receive" else "debit"

for d in self.get("references"):
# re-defining dr_or_cr for every reference in order to avoid the last value affecting calculation of reverse
dr_or_cr = "credit" if self.payment_type == "Receive" else "debit"
cost_center = self.cost_center
if d.reference_doctype == "Sales Invoice" and not cost_center:
cost_center = frappe.db.get_value(d.reference_doctype, d.reference_name, "cost_center")
Expand All @@ -1072,7 +1072,7 @@ def add_party_gl_entries(self, gl_entries):
against_voucher_type = d.reference_doctype
against_voucher = d.reference_name

reverse_dr_or_cr, standalone_note = 0, 0
reverse_dr_or_cr = 0
if d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]:
is_return = frappe.db.get_value(d.reference_doctype, d.reference_name, "is_return")
payable_party_types = get_party_types_from_account_type("Payable")
Expand All @@ -1098,6 +1098,7 @@ def add_party_gl_entries(self, gl_entries):
)
gl_entries.append(gle)

dr_or_cr = "credit" if self.payment_type == "Receive" else "debit"
if self.unallocated_amount:
exchange_rate = self.get_exchange_rate()
base_unallocated_amount = self.unallocated_amount * exchange_rate
Expand Down

0 comments on commit a59c942

Please sign in to comment.