Merge pull request #37268 from GursheenK/ar-summary-party-filter
fix: AP AR filters from Party link
This commit is contained in:
commit
f160e49483
@ -146,7 +146,7 @@ def get_ar_filters(doc, entry):
|
|||||||
return {
|
return {
|
||||||
"report_date": doc.posting_date if doc.posting_date else None,
|
"report_date": doc.posting_date if doc.posting_date else None,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
"party": entry.customer,
|
"party": [entry.customer],
|
||||||
"customer_name": entry.customer_name if entry.customer_name else None,
|
"customer_name": entry.customer_name if entry.customer_name else None,
|
||||||
"payment_terms_template": doc.payment_terms_template if doc.payment_terms_template else None,
|
"payment_terms_template": doc.payment_terms_template if doc.payment_terms_template else None,
|
||||||
"sales_partner": doc.sales_partner if doc.sales_partner else None,
|
"sales_partner": doc.sales_partner if doc.sales_partner else None,
|
||||||
|
@ -95,18 +95,11 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
"options": "Payment Terms Template"
|
"options": "Payment Terms Template"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_type",
|
"fieldname":"party_type",
|
||||||
"label": __("Party Type"),
|
"label": __("Party Type"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Autocomplete",
|
||||||
"options": "Party Type",
|
options: get_party_type_options(),
|
||||||
get_query: () => {
|
on_change: function() {
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'account_type': 'Payable'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
on_change: () => {
|
|
||||||
frappe.query_report.set_filter_value('party', "");
|
frappe.query_report.set_filter_value('party', "");
|
||||||
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') !== "Supplier");
|
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') !== "Supplier");
|
||||||
}
|
}
|
||||||
@ -114,8 +107,15 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"party",
|
"fieldname":"party",
|
||||||
"label": __("Party"),
|
"label": __("Party"),
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "MultiSelectList",
|
||||||
"options": "party_type",
|
get_data: function(txt) {
|
||||||
|
if (!frappe.query_report.filters) return;
|
||||||
|
|
||||||
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
|
if (!party_type) return;
|
||||||
|
|
||||||
|
return frappe.db.get_link_options(party_type, txt);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "supplier_group",
|
"fieldname": "supplier_group",
|
||||||
@ -164,3 +164,15 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Payable', 9);
|
erpnext.utils.add_dimensions('Accounts Payable', 9);
|
||||||
|
|
||||||
|
function get_party_type_options() {
|
||||||
|
let options = [];
|
||||||
|
frappe.db.get_list(
|
||||||
|
"Party Type", {filters:{"account_type": "Payable"}, fields:['name']}
|
||||||
|
).then((res) => {
|
||||||
|
res.forEach((party_type) => {
|
||||||
|
options.push(party_type.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return options;
|
||||||
|
}
|
@ -34,7 +34,7 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
|||||||
filters = {
|
filters = {
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
"party_type": "Supplier",
|
"party_type": "Supplier",
|
||||||
"party": self.supplier,
|
"party": [self.supplier],
|
||||||
"report_date": today(),
|
"report_date": today(),
|
||||||
"range1": 30,
|
"range1": 30,
|
||||||
"range2": 60,
|
"range2": 60,
|
||||||
|
@ -72,18 +72,11 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_type",
|
"fieldname":"party_type",
|
||||||
"label": __("Party Type"),
|
"label": __("Party Type"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Autocomplete",
|
||||||
"options": "Party Type",
|
options: get_party_type_options(),
|
||||||
get_query: () => {
|
on_change: function() {
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'account_type': 'Payable'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
on_change: () => {
|
|
||||||
frappe.query_report.set_filter_value('party', "");
|
frappe.query_report.set_filter_value('party', "");
|
||||||
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') !== "Supplier");
|
frappe.query_report.toggle_filter_display('supplier_group', frappe.query_report.get_filter_value('party_type') !== "Supplier");
|
||||||
}
|
}
|
||||||
@ -91,8 +84,15 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"party",
|
"fieldname":"party",
|
||||||
"label": __("Party"),
|
"label": __("Party"),
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "MultiSelectList",
|
||||||
"options": "party_type",
|
get_data: function(txt) {
|
||||||
|
if (!frappe.query_report.filters) return;
|
||||||
|
|
||||||
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
|
if (!party_type) return;
|
||||||
|
|
||||||
|
return frappe.db.get_link_options(party_type, txt);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"payment_terms_template",
|
"fieldname":"payment_terms_template",
|
||||||
@ -122,3 +122,15 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Payable Summary', 9);
|
erpnext.utils.add_dimensions('Accounts Payable Summary', 9);
|
||||||
|
|
||||||
|
function get_party_type_options() {
|
||||||
|
let options = [];
|
||||||
|
frappe.db.get_list(
|
||||||
|
"Party Type", {filters:{"account_type": "Payable"}, fields:['name']}
|
||||||
|
).then((res) => {
|
||||||
|
res.forEach((party_type) => {
|
||||||
|
options.push(party_type.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return options;
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
frappe.provide("erpnext.utils");
|
||||||
|
|
||||||
frappe.query_reports["Accounts Receivable"] = {
|
frappe.query_reports["Accounts Receivable"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
@ -38,19 +40,11 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_type",
|
"fieldname":"party_type",
|
||||||
"label": __("Party Type"),
|
"label": __("Party Type"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Autocomplete",
|
||||||
"options": "Party Type",
|
options: get_party_type_options(),
|
||||||
"Default": "Customer",
|
on_change: function() {
|
||||||
get_query: () => {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'account_type': 'Receivable'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
on_change: () => {
|
|
||||||
frappe.query_report.set_filter_value('party', "");
|
frappe.query_report.set_filter_value('party', "");
|
||||||
frappe.query_report.toggle_filter_display('customer_group', frappe.query_report.get_filter_value('party_type') !== "Customer");
|
frappe.query_report.toggle_filter_display('customer_group', frappe.query_report.get_filter_value('party_type') !== "Customer");
|
||||||
}
|
}
|
||||||
@ -58,8 +52,15 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"party",
|
"fieldname":"party",
|
||||||
"label": __("Party"),
|
"label": __("Party"),
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "MultiSelectList",
|
||||||
"options": "party_type",
|
get_data: function(txt) {
|
||||||
|
if (!frappe.query_report.filters) return;
|
||||||
|
|
||||||
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
|
if (!party_type) return;
|
||||||
|
|
||||||
|
return frappe.db.get_link_options(party_type, txt);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_account",
|
"fieldname": "party_account",
|
||||||
@ -192,3 +193,16 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Receivable', 9);
|
erpnext.utils.add_dimensions('Accounts Receivable', 9);
|
||||||
|
|
||||||
|
|
||||||
|
function get_party_type_options() {
|
||||||
|
let options = [];
|
||||||
|
frappe.db.get_list(
|
||||||
|
"Party Type", {filters:{"account_type": "Receivable"}, fields:['name']}
|
||||||
|
).then((res) => {
|
||||||
|
res.forEach((party_type) => {
|
||||||
|
options.push(party_type.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return options;
|
||||||
|
}
|
@ -801,7 +801,7 @@ class ReceivablePayableReport(object):
|
|||||||
self.qb_selection_filter.append(self.filters.party_type == self.ple.party_type)
|
self.qb_selection_filter.append(self.filters.party_type == self.ple.party_type)
|
||||||
|
|
||||||
if self.filters.get("party"):
|
if self.filters.get("party"):
|
||||||
self.qb_selection_filter.append(self.filters.party == self.ple.party)
|
self.qb_selection_filter.append(self.ple.party.isin(self.filters.party))
|
||||||
|
|
||||||
if self.filters.party_account:
|
if self.filters.party_account:
|
||||||
self.qb_selection_filter.append(self.ple.account == self.filters.party_account)
|
self.qb_selection_filter.append(self.ple.account == self.filters.party_account)
|
||||||
|
@ -573,7 +573,7 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
|||||||
filters = {
|
filters = {
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
"party": self.customer,
|
"party": [self.customer],
|
||||||
"report_date": today(),
|
"report_date": today(),
|
||||||
"range1": 30,
|
"range1": 30,
|
||||||
"range2": 60,
|
"range2": 60,
|
||||||
@ -605,3 +605,41 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
|||||||
for field in expected:
|
for field in expected:
|
||||||
with self.subTest(field=field):
|
with self.subTest(field=field):
|
||||||
self.assertEqual(report_output.get(field), expected.get(field))
|
self.assertEqual(report_output.get(field), expected.get(field))
|
||||||
|
|
||||||
|
def test_multi_select_party_filter(self):
|
||||||
|
self.customer1 = self.customer
|
||||||
|
self.create_customer("_Test Customer 2")
|
||||||
|
self.customer2 = self.customer
|
||||||
|
self.create_customer("_Test Customer 3")
|
||||||
|
self.customer3 = self.customer
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"party_type": "Customer",
|
||||||
|
"party": [self.customer1, self.customer3],
|
||||||
|
"report_date": today(),
|
||||||
|
"range1": 30,
|
||||||
|
"range2": 60,
|
||||||
|
"range3": 90,
|
||||||
|
"range4": 120,
|
||||||
|
}
|
||||||
|
|
||||||
|
si1 = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
|
||||||
|
si1.customer = self.customer1
|
||||||
|
si1.save().submit()
|
||||||
|
|
||||||
|
si2 = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
|
||||||
|
si2.customer = self.customer2
|
||||||
|
si2.save().submit()
|
||||||
|
|
||||||
|
si3 = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
|
||||||
|
si3.customer = self.customer3
|
||||||
|
si3.save().submit()
|
||||||
|
|
||||||
|
# check invoice grand total and invoiced column's value for 3 payment terms
|
||||||
|
report = execute(filters)
|
||||||
|
|
||||||
|
expected_output = {self.customer1, self.customer3}
|
||||||
|
self.assertEqual(len(report[1]), 2)
|
||||||
|
output_for = set([x.party for x in report[1]])
|
||||||
|
self.assertEqual(output_for, expected_output)
|
||||||
|
@ -72,19 +72,11 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_type",
|
"fieldname":"party_type",
|
||||||
"label": __("Party Type"),
|
"label": __("Party Type"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Autocomplete",
|
||||||
"options": "Party Type",
|
options: get_party_type_options(),
|
||||||
"Default": "Customer",
|
on_change: function() {
|
||||||
get_query: () => {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'account_type': 'Receivable'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
on_change: () => {
|
|
||||||
frappe.query_report.set_filter_value('party', "");
|
frappe.query_report.set_filter_value('party', "");
|
||||||
frappe.query_report.toggle_filter_display('customer_group', frappe.query_report.get_filter_value('party_type') !== "Customer");
|
frappe.query_report.toggle_filter_display('customer_group', frappe.query_report.get_filter_value('party_type') !== "Customer");
|
||||||
}
|
}
|
||||||
@ -92,8 +84,15 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"party",
|
"fieldname":"party",
|
||||||
"label": __("Party"),
|
"label": __("Party"),
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "MultiSelectList",
|
||||||
"options": "party_type",
|
get_data: function(txt) {
|
||||||
|
if (!frappe.query_report.filters) return;
|
||||||
|
|
||||||
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
|
if (!party_type) return;
|
||||||
|
|
||||||
|
return frappe.db.get_link_options(party_type, txt);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"customer_group",
|
"fieldname":"customer_group",
|
||||||
@ -151,3 +150,15 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Receivable Summary', 9);
|
erpnext.utils.add_dimensions('Accounts Receivable Summary', 9);
|
||||||
|
|
||||||
|
function get_party_type_options() {
|
||||||
|
let options = [];
|
||||||
|
frappe.db.get_list(
|
||||||
|
"Party Type", {filters:{"account_type": "Receivable"}, fields:['name']}
|
||||||
|
).then((res) => {
|
||||||
|
res.forEach((party_type) => {
|
||||||
|
options.push(party_type.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return options;
|
||||||
|
}
|
@ -88,7 +88,7 @@ frappe.ui.form.on("Supplier", {
|
|||||||
}, __("View"));
|
}, __("View"));
|
||||||
|
|
||||||
frm.add_custom_button(__('Accounts Payable'), function () {
|
frm.add_custom_button(__('Accounts Payable'), function () {
|
||||||
frappe.set_route('query-report', 'Accounts Payable', { supplier: frm.doc.name });
|
frappe.set_route('query-report', 'Accounts Payable', { party_type: "Supplier", party: frm.doc.name });
|
||||||
}, __("View"));
|
}, __("View"));
|
||||||
|
|
||||||
frm.add_custom_button(__('Bank Account'), function () {
|
frm.add_custom_button(__('Bank Account'), function () {
|
||||||
|
@ -138,7 +138,7 @@ frappe.ui.form.on("Customer", {
|
|||||||
// custom buttons
|
// custom buttons
|
||||||
|
|
||||||
frm.add_custom_button(__('Accounts Receivable'), function () {
|
frm.add_custom_button(__('Accounts Receivable'), function () {
|
||||||
frappe.set_route('query-report', 'Accounts Receivable', {customer:frm.doc.name});
|
frappe.set_route('query-report', 'Accounts Receivable', { party_type: "Customer", party: frm.doc.name });
|
||||||
}, __('View'));
|
}, __('View'));
|
||||||
|
|
||||||
frm.add_custom_button(__('Accounting Ledger'), function () {
|
frm.add_custom_button(__('Accounting Ledger'), function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user