refactor: pass dimension details to query
(cherry picked from commit 5dc22e1811)
# Conflicts:
# erpnext/accounts/utils.py
This commit is contained in:
@@ -29,6 +29,7 @@ class PaymentReconciliation(Document):
|
||||
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.
|
||||
@@ -115,8 +116,7 @@ class PaymentReconciliation(Document):
|
||||
|
||||
# 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)})
|
||||
@@ -472,7 +472,7 @@ class PaymentReconciliation(Document):
|
||||
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"),
|
||||
@@ -495,6 +495,14 @@ class PaymentReconciliation(Document):
|
||||
}
|
||||
)
|
||||
|
||||
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):
|
||||
@@ -604,8 +612,7 @@ class PaymentReconciliation(Document):
|
||||
|
||||
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))
|
||||
|
||||
@@ -630,6 +630,11 @@ def update_reference_in_payment_entry(
|
||||
if d.difference_amount is not None
|
||||
else payment_entry.get_exchange_rate(),
|
||||
"exchange_gain_loss": d.difference_amount,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"account": d.account,
|
||||
"dimensions": d.dimensions,
|
||||
>>>>>>> 5dc22e1811 (refactor: pass dimension details to query)
|
||||
}
|
||||
|
||||
if d.voucher_detail_no:
|
||||
@@ -1991,6 +1996,7 @@ def create_gain_loss_journal(
|
||||
ref2_dn,
|
||||
ref2_detail_no,
|
||||
cost_center,
|
||||
dimensions,
|
||||
) -> str:
|
||||
journal_entry = frappe.new_doc("Journal Entry")
|
||||
journal_entry.voucher_type = "Exchange Gain Or Loss"
|
||||
|
||||
@@ -1178,6 +1178,7 @@ class AccountsController(TransactionBase):
|
||||
self.name,
|
||||
arg.get("referenced_row"),
|
||||
arg.get("cost_center"),
|
||||
{},
|
||||
)
|
||||
frappe.msgprint(
|
||||
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
||||
@@ -1258,6 +1259,7 @@ class AccountsController(TransactionBase):
|
||||
self.name,
|
||||
d.idx,
|
||||
self.cost_center,
|
||||
{},
|
||||
)
|
||||
frappe.msgprint(
|
||||
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
||||
|
||||
Reference in New Issue
Block a user