refactor: usage of in_list

(cherry picked from commit d238751e6b)

# Conflicts:
#	erpnext/accounts/doctype/payment_entry/payment_entry.js
#	erpnext/buying/doctype/purchase_order/purchase_order.js
#	erpnext/public/js/controllers/accounts.js
#	erpnext/public/js/controllers/buying.js
#	erpnext/public/js/controllers/transaction.js
#	erpnext/public/js/utils/sales_common.js
#	erpnext/templates/form_grid/item_grid.html
This commit is contained in:
barredterra
2024-03-19 12:03:36 +01:00
committed by Mergify
parent 93fe136386
commit 7f2a54d95b
22 changed files with 1120 additions and 39 deletions

View File

@@ -5,6 +5,7 @@
frappe.provide("erpnext.taxes");
frappe.provide("erpnext.taxes.flags");
<<<<<<< HEAD
frappe.ui.form.on(cur_frm.doctype, {
setup: function(frm) {
// set conditional display for rate column in taxes
@@ -12,6 +13,58 @@ frappe.ui.form.on(cur_frm.doctype, {
if(in_list(['Sales Taxes and Charges', 'Purchase Taxes and Charges'], grid_row.doc.doctype)) {
erpnext.taxes.set_conditional_mandatory_rate_or_amount(grid_row);
}
=======
erpnext.accounts.taxes = {
setup_tax_validations: function(doctype) {
let me = this;
frappe.ui.form.on(doctype, {
setup: function(frm) {
// set conditional display for rate column in taxes
$(frm.wrapper).on('grid-row-render', function(e, grid_row) {
if(['Sales Taxes and Charges', 'Purchase Taxes and Charges'].includes(grid_row.doc.doctype)) {
me.set_conditional_mandatory_rate_or_amount(grid_row);
}
});
},
onload: function(frm) {
if(frm.get_field("taxes")) {
frm.set_query("account_head", "taxes", function(doc) {
if(frm.cscript.tax_table == "Sales Taxes and Charges") {
var account_type = ["Tax", "Chargeable", "Expense Account"];
} else {
var account_type = ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation"];
}
return {
query: "erpnext.controllers.queries.tax_account_query",
filters: {
"account_type": account_type,
"company": doc.company,
}
}
});
frm.set_query("cost_center", "taxes", function(doc) {
return {
filters: {
"company": doc.company,
"is_group": 0
}
};
});
}
},
validate: function(frm) {
// neither is absolutely mandatory
if(frm.get_docfield("taxes")) {
frm.get_docfield("taxes", "rate").reqd = 0;
frm.get_docfield("taxes", "tax_amount").reqd = 0;
}
},
taxes_on_form_rendered: function(frm) {
me.set_conditional_mandatory_rate_or_amount(frm.open_grid_row());
},
>>>>>>> d238751e6b (refactor: usage of in_list)
});
},
onload: function(frm) {