Skip to content

Commit

Permalink
Merge pull request #35868 from ruthra-kumar/get_base_grand_total_whil…
Browse files Browse the repository at this point in the history
…e_pulling_reference_details

fix: incorrect outstanding and total amount in reference table of payment entry
  • Loading branch information
ruthra-kumar authored Jun 25, 2023
2 parents ebeb5e0 + 9655d78 commit a90fe25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre
if not total_amount:
if party_account_currency == company_currency:
# for handling cases that don't have multi-currency (base field)
total_amount = ref_doc.get("grand_total") or ref_doc.get("base_grand_total")
total_amount = ref_doc.get("base_grand_total") or ref_doc.get("grand_total")
exchange_rate = 1
else:
total_amount = ref_doc.get("grand_total")
Expand Down
24 changes: 24 additions & 0 deletions erpnext/accounts/doctype/payment_entry/test_payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from erpnext.accounts.doctype.payment_entry.payment_entry import (
InvalidPaymentEntry,
get_payment_entry,
get_reference_details,
)
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import (
make_purchase_invoice,
Expand Down Expand Up @@ -1037,6 +1038,29 @@ def test_duplicate_payment_entry_partial_allocate_amount(self):

self.assertRaises(frappe.ValidationError, pe_draft.submit)

def test_details_update_on_reference_table(self):
so = make_sales_order(
customer="_Test Customer USD", currency="USD", qty=1, rate=100, do_not_submit=True
)
so.conversion_rate = 50
so.submit()
pe = get_payment_entry("Sales Order", so.name)
pe.references.clear()
pe.paid_from = "Debtors - _TC"
pe.paid_from_account_currency = "INR"
pe.source_exchange_rate = 50
pe.save()

ref_details = get_reference_details(so.doctype, so.name, pe.paid_from_account_currency)
expected_response = {
"total_amount": 5000.0,
"outstanding_amount": 5000.0,
"exchange_rate": 1.0,
"due_date": None,
"bill_no": None,
}
self.assertDictEqual(ref_details, expected_response)


def create_payment_entry(**args):
payment_entry = frappe.new_doc("Payment Entry")
Expand Down

0 comments on commit a90fe25

Please sign in to comment.