fix: No handlefor Cost centers in Accounts Receivable
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
index c999eb9..29c4f7d 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
@@ -34,7 +34,7 @@
filters: {
'company': company
}
- }
+ };
}
},
{
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 59117c8..044fc1d 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -617,9 +617,19 @@
elif party_type_field=="supplier":
self.add_supplier_filters(conditions, values)
+ if self.filters.cost_center:
+ self.get_cost_center_conditions(conditions)
+
self.add_accounting_dimensions_filters(conditions, values)
return " and ".join(conditions), values
+ def get_cost_center_conditions(self, conditions):
+ lft, rgt = frappe.db.get_value("Cost Center", self.filters.cost_center, ["lft", "rgt"])
+ cost_center_list = [center.name for center in frappe.get_list("Cost Center", filters = {'lft': (">=", lft), 'rgt': ("<=", rgt)})]
+
+ cost_center_string = '", "'.join(cost_center_list)
+ conditions.append('cost_center in ("{0}")'.format(cost_center_string))
+
def get_order_by_condition(self):
if self.filters.get('group_by_party'):
return "order by party, posting_date"