Merge pull request #23355 from Anurag810/accounts_recievable

fix: Cost Center filter in accounts receivable and payable report
This commit is contained in:
Deepesh Garg 2020-09-20 19:36:30 +05:30 committed by GitHub
commit 5c8dd6a0ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -34,7 +34,7 @@ frappe.query_reports["Accounts Receivable"] = {
filters: {
'company': company
}
}
};
}
},
{

View File

@ -617,9 +617,19 @@ class ReceivablePayableReport(object):
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"