refactor: pass dimension details to query
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index 83bccf4..f382434 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -71,6 +71,7 @@
self.common_filter_conditions = []
self.accounting_dimension_filter_conditions = []
self.ple_posting_date_filter = []
+ self.dimensions = get_dimensions()[0]
def load_from_db(self):
# 'modified' attribute is required for `run_doc_method` to work properly.
@@ -175,8 +176,7 @@
# pass dynamic dimension filter values to query builder
dimensions = {}
- dimensions_and_defaults = get_dimensions()
- for x in dimensions_and_defaults[0]:
+ for x in self.dimensions:
dimension = x.fieldname
if self.get(dimension):
dimensions.update({dimension: self.get(dimension)})
@@ -528,7 +528,7 @@
self.get_unreconciled_entries()
def get_payment_details(self, row, dr_or_cr):
- return frappe._dict(
+ payment_details = frappe._dict(
{
"voucher_type": row.get("reference_type"),
"voucher_no": row.get("reference_name"),
@@ -551,6 +551,14 @@
}
)
+ dimensions_dict = {}
+ for x in self.dimensions:
+ if row.get(x.fieldname):
+ dimensions_dict.update({x.fieldname: row.get(x.fieldname)})
+
+ payment_details.update({"dimensions": dimensions_dict})
+ return payment_details
+
def check_mandatory_to_fetch(self):
for fieldname in ["company", "party_type", "party", "receivable_payable_account"]:
if not self.get(fieldname):
@@ -660,8 +668,7 @@
def build_dimensions_filter_conditions(self):
ple = qb.DocType("Payment Ledger Entry")
- dimensions_and_defaults = get_dimensions()
- for x in dimensions_and_defaults[0]:
+ for x in self.dimensions:
dimension = x.fieldname
if self.get(dimension):
self.accounting_dimension_filter_conditions.append(ple[dimension] == self.get(dimension))
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index f933209..5fffa27 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -668,6 +668,7 @@
else payment_entry.get_exchange_rate(),
"exchange_gain_loss": d.difference_amount,
"account": d.account,
+ "dimensions": d.dimensions,
}
if d.voucher_detail_no:
@@ -2043,6 +2044,7 @@
ref2_dn,
ref2_detail_no,
cost_center,
+ dimensions,
) -> str:
journal_entry = frappe.new_doc("Journal Entry")
journal_entry.voucher_type = "Exchange Gain Or Loss"
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 31ff799..f8d53d8 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1275,6 +1275,7 @@
self.name,
arg.get("referenced_row"),
arg.get("cost_center"),
+ {},
)
frappe.msgprint(
_("Exchange Gain/Loss amount has been booked through {0}").format(
@@ -1355,6 +1356,7 @@
self.name,
d.idx,
self.cost_center,
+ {},
)
frappe.msgprint(
_("Exchange Gain/Loss amount has been booked through {0}").format(