refactor(test): assert Exc journal when reconciling Journa to invoic
diff --git a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
index 2ac7df0..1d843ab 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py
@@ -686,14 +686,24 @@
# Check if difference journal entry gets generated for difference amount after reconciliation
pr.reconcile()
- total_debit_amount = frappe.db.get_all(
+ total_credit_amount = frappe.db.get_all(
"Journal Entry Account",
{"account": self.debtors_eur, "docstatus": 1, "reference_name": si.name},
- "sum(debit) as amount",
+ "sum(credit) as amount",
group_by="reference_name",
)[0].amount
- self.assertEqual(flt(total_debit_amount, 2), -500)
+ # total credit includes the exchange gain/loss amount
+ self.assertEqual(flt(total_credit_amount, 2), 8500)
+
+ jea_parent = frappe.db.get_all(
+ "Journal Entry Account",
+ filters={"account": self.debtors_eur, "docstatus": 1, "reference_name": si.name, "credit": 500},
+ fields=["parent"],
+ )[0]
+ self.assertEqual(
+ frappe.db.get_value("Journal Entry", jea_parent.parent, "voucher_type"), "Exchange Gain Or Loss"
+ )
def test_difference_amount_via_payment_entry(self):
# Make Sale Invoice
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 2548bdc..5abff41 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1038,8 +1038,8 @@
# "reference_type": self.doctype,
# "reference_name": self.name,
# "reference_detail_no": arg.idx,
- reverse_dr_or_cr + "_in_account_currency": abs(arg.get("difference_amount")),
reverse_dr_or_cr: abs(arg.get("difference_amount")),
+ reverse_dr_or_cr + "_in_account_currency": 0,
}
)