From 43061f4416f4c04cbd4442cd128ff504d3ecfc04 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 11 Sep 2023 19:16:25 +0530 Subject: [PATCH] fix: correct set_query filters --- .../doctype/payment_reconciliation/payment_reconciliation.js | 3 ++- erpnext/buying/doctype/supplier/supplier.js | 1 + erpnext/selling/doctype/customer/customer.js | 1 + erpnext/setup/doctype/company/company.js | 4 ++-- erpnext/setup/doctype/customer_group/customer_group.js | 1 + erpnext/setup/doctype/supplier_group/supplier_group.js | 1 + 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 2adc1238b7..9072ce4561 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -24,7 +24,8 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo filters: { "company": this.frm.doc.company, "is_group": 0, - "account_type": frappe.boot.party_account_types[this.frm.doc.party_type] + "account_type": frappe.boot.party_account_types[this.frm.doc.party_type], + "root_type": this.frm.doc.party_type == 'Customer' ? "Asset" : "Liability" } }; }); diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 372ca56b86..08dc44c71b 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -12,6 +12,7 @@ frappe.ui.form.on("Supplier", { return { filters: { 'account_type': 'Payable', + 'root_type': 'Liability', 'company': d.company, "is_group": 0 } diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 60f0941559..e274a52690 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -23,6 +23,7 @@ frappe.ui.form.on("Customer", { let d = locals[cdt][cdn]; let filters = { 'account_type': 'Receivable', + 'root_type': 'Asset', 'company': d.company, "is_group": 0 }; diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index fa207ecdd1..4973dab505 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -200,8 +200,8 @@ erpnext.company.setup_queries = function(frm) { $.each([ ["default_bank_account", {"account_type": "Bank"}], ["default_cash_account", {"account_type": "Cash"}], - ["default_receivable_account", {"account_type": "Receivable"}], - ["default_payable_account", {"account_type": "Payable"}], + ["default_receivable_account", { "root_type": "Asset", "account_type": "Receivable" }], + ["default_payable_account", { "root_type": "Liability", "account_type": "Payable" }], ["default_expense_account", {"root_type": "Expense"}], ["default_income_account", {"root_type": "Income"}], ["round_off_account", {"root_type": "Expense"}], diff --git a/erpnext/setup/doctype/customer_group/customer_group.js b/erpnext/setup/doctype/customer_group/customer_group.js index 49a90f959d..3c81b0283c 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.js +++ b/erpnext/setup/doctype/customer_group/customer_group.js @@ -30,6 +30,7 @@ frappe.ui.form.on("Customer Group", { frm.set_query('account', 'accounts', function (doc, cdt, cdn) { return { filters: { + 'root_type': 'Asset', "account_type": 'Receivable', "company": locals[cdt][cdn].company, "is_group": 0 diff --git a/erpnext/setup/doctype/supplier_group/supplier_group.js b/erpnext/setup/doctype/supplier_group/supplier_group.js index b2acfd7355..33629297ff 100644 --- a/erpnext/setup/doctype/supplier_group/supplier_group.js +++ b/erpnext/setup/doctype/supplier_group/supplier_group.js @@ -30,6 +30,7 @@ frappe.ui.form.on("Supplier Group", { frm.set_query('account', 'accounts', function (doc, cdt, cdn) { return { filters: { + 'root_type': 'Liability', 'account_type': 'Payable', 'company': locals[cdt][cdn].company, "is_group": 0