refactor: usage of in_list

(cherry picked from commit d238751e6b)
This commit is contained in:
barredterra
2024-03-19 12:03:36 +01:00
committed by Mergify
parent 0bdda1226f
commit f0e00daa1c
22 changed files with 59 additions and 59 deletions

View File

@@ -196,7 +196,7 @@ frappe.ui.form.on("Journal Entry", {
!(frm.doc.accounts || []).length || !(frm.doc.accounts || []).length ||
((frm.doc.accounts || []).length === 1 && !frm.doc.accounts[0].account) ((frm.doc.accounts || []).length === 1 && !frm.doc.accounts[0].account)
) { ) {
if (in_list(["Bank Entry", "Cash Entry"], frm.doc.voucher_type)) { if (["Bank Entry", "Cash Entry"].includes(frm.doc.voucher_type)) {
return frappe.call({ return frappe.call({
type: "GET", type: "GET",
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account", method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account",
@@ -308,7 +308,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
filters: [[jvd.reference_type, "docstatus", "=", 1]], filters: [[jvd.reference_type, "docstatus", "=", 1]],
}; };
if (in_list(["Sales Invoice", "Purchase Invoice"], jvd.reference_type)) { if (["Sales Invoice", "Purchase Invoice"].includes(jvd.reference_type)) {
out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]); out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]);
// Filter by cost center // Filter by cost center
if (jvd.cost_center) { if (jvd.cost_center) {
@@ -320,7 +320,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]); out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]);
} }
if (in_list(["Sales Order", "Purchase Order"], jvd.reference_type)) { if (["Sales Order", "Purchase Order"].includes(jvd.reference_type)) {
// party_type and party mandatory // party_type and party mandatory
frappe.model.validate_missing(jvd, "party_type"); frappe.model.validate_missing(jvd, "party_type");
frappe.model.validate_missing(jvd, "party"); frappe.model.validate_missing(jvd, "party");

View File

@@ -32,7 +32,7 @@ frappe.ui.form.on("Payment Entry", {
frm.set_query("paid_from", function () { frm.set_query("paid_from", function () {
frm.events.validate_company(frm); frm.events.validate_company(frm);
var account_types = in_list(["Pay", "Internal Transfer"], frm.doc.payment_type) var account_types = ["Pay", "Internal Transfer"].includes(frm.doc.payment_type)
? ["Bank", "Cash"] ? ["Bank", "Cash"]
: [frappe.boot.party_account_types[frm.doc.party_type]]; : [frappe.boot.party_account_types[frm.doc.party_type]];
return { return {
@@ -87,7 +87,7 @@ frappe.ui.form.on("Payment Entry", {
frm.set_query("paid_to", function () { frm.set_query("paid_to", function () {
frm.events.validate_company(frm); frm.events.validate_company(frm);
var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) var account_types = ["Receive", "Internal Transfer"].includes(frm.doc.payment_type)
? ["Bank", "Cash"] ? ["Bank", "Cash"]
: [frappe.boot.party_account_types[frm.doc.party_type]]; : [frappe.boot.party_account_types[frm.doc.party_type]];
return { return {
@@ -134,7 +134,7 @@ frappe.ui.form.on("Payment Entry", {
frm.set_query("payment_term", "references", function (frm, cdt, cdn) { frm.set_query("payment_term", "references", function (frm, cdt, cdn) {
const child = locals[cdt][cdn]; const child = locals[cdt][cdn];
if ( if (
in_list(["Purchase Invoice", "Sales Invoice"], child.reference_doctype) && ["Purchase Invoice", "Sales Invoice"].includes(child.reference_doctype) &&
child.reference_name child.reference_name
) { ) {
return { return {
@@ -623,7 +623,7 @@ frappe.ui.form.on("Payment Entry", {
if (frm.doc.paid_from_account_currency == company_currency) { if (frm.doc.paid_from_account_currency == company_currency) {
frm.set_value("source_exchange_rate", 1); frm.set_value("source_exchange_rate", 1);
} else if (frm.doc.paid_from) { } else if (frm.doc.paid_from) {
if (in_list(["Internal Transfer", "Pay"], frm.doc.payment_type)) { if (["Internal Transfer", "Pay"].includes(frm.doc.payment_type)) {
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency; let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
frappe.call({ frappe.call({
method: "erpnext.setup.utils.get_exchange_rate", method: "erpnext.setup.utils.get_exchange_rate",
@@ -1042,7 +1042,7 @@ frappe.ui.form.on("Payment Entry", {
} }
var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding; var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding;
} else if (in_list(["Customer", "Supplier"], frm.doc.party_type)) { } else if (["Customer", "Supplier"].includes(frm.doc.party_type)) {
total_negative_outstanding = flt(total_negative_outstanding, precision("outstanding_amount")); total_negative_outstanding = flt(total_negative_outstanding, precision("outstanding_amount"));
if (paid_amount > total_negative_outstanding) { if (paid_amount > total_negative_outstanding) {
if (total_negative_outstanding == 0) { if (total_negative_outstanding == 0) {
@@ -1213,7 +1213,7 @@ frappe.ui.form.on("Payment Entry", {
if ( if (
frm.doc.party_type == "Customer" && frm.doc.party_type == "Customer" &&
!in_list(["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"], row.reference_doctype) !["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"].includes(row.reference_doctype)
) { ) {
frappe.model.set_value(row.doctype, row.name, "reference_doctype", null); frappe.model.set_value(row.doctype, row.name, "reference_doctype", null);
frappe.msgprint( frappe.msgprint(
@@ -1227,7 +1227,7 @@ frappe.ui.form.on("Payment Entry", {
if ( if (
frm.doc.party_type == "Supplier" && frm.doc.party_type == "Supplier" &&
!in_list(["Purchase Order", "Purchase Invoice", "Journal Entry"], row.reference_doctype) !["Purchase Order", "Purchase Invoice", "Journal Entry"].includes(row.reference_doctype)
) { ) {
frappe.model.set_value(row.doctype, row.name, "against_voucher_type", null); frappe.model.set_value(row.doctype, row.name, "against_voucher_type", null);
frappe.msgprint( frappe.msgprint(
@@ -1323,7 +1323,7 @@ frappe.ui.form.on("Payment Entry", {
bank_account: function (frm) { bank_account: function (frm) {
const field = frm.doc.payment_type == "Pay" ? "paid_from" : "paid_to"; const field = frm.doc.payment_type == "Pay" ? "paid_from" : "paid_to";
if (frm.doc.bank_account && in_list(["Pay", "Receive"], frm.doc.payment_type)) { if (frm.doc.bank_account && ["Pay", "Receive"].includes(frm.doc.payment_type)) {
frappe.call({ frappe.call({
method: "erpnext.accounts.doctype.bank_account.bank_account.get_bank_account_details", method: "erpnext.accounts.doctype.bank_account.bank_account.get_bank_account_details",
args: { args: {

View File

@@ -28,7 +28,7 @@ frappe.ui.form.on("Payment Request", "refresh", function (frm) {
if ( if (
frm.doc.payment_request_type == "Inward" && frm.doc.payment_request_type == "Inward" &&
frm.doc.payment_channel !== "Phone" && frm.doc.payment_channel !== "Phone" &&
!in_list(["Initiated", "Paid"], frm.doc.status) && !["Initiated", "Paid"].includes(frm.doc.status) &&
!frm.doc.__islocal && !frm.doc.__islocal &&
frm.doc.docstatus == 1 frm.doc.docstatus == 1
) { ) {

View File

@@ -79,7 +79,7 @@ frappe.ui.form.on("Asset", {
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1); frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
if (frm.doc.docstatus == 1) { if (frm.doc.docstatus == 1) {
if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) { if (["Submitted", "Partially Depreciated", "Fully Depreciated"].includes(frm.doc.status)) {
frm.add_custom_button( frm.add_custom_button(
__("Transfer Asset"), __("Transfer Asset"),
function () { function () {
@@ -365,7 +365,7 @@ frappe.ui.form.on("Asset", {
if (v.journal_entry) { if (v.journal_entry) {
asset_values.push(asset_value); asset_values.push(asset_value);
} else { } else {
if (in_list(["Scrapped", "Sold"], frm.doc.status)) { if (["Scrapped", "Sold"].includes(frm.doc.status)) {
asset_values.push(null); asset_values.push(null);
} else { } else {
asset_values.push(asset_value); asset_values.push(asset_value);
@@ -400,7 +400,7 @@ frappe.ui.form.on("Asset", {
}); });
} }
if (in_list(["Scrapped", "Sold"], frm.doc.status)) { if (["Scrapped", "Sold"].includes(frm.doc.status)) {
x_intervals.push(frappe.format(frm.doc.disposal_date, { fieldtype: "Date" })); x_intervals.push(frappe.format(frm.doc.disposal_date, { fieldtype: "Date" }));
asset_values.push(0); asset_values.push(0);
} }

View File

@@ -291,7 +291,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
this.frm.fields_dict.items_section.wrapper.removeClass("hide-border"); this.frm.fields_dict.items_section.wrapper.removeClass("hide-border");
} }
if (!in_list(["Closed", "Delivered"], doc.status)) { if (!["Closed", "Delivered"].includes(doc.status)) {
if ( if (
this.frm.doc.status !== "Closed" && this.frm.doc.status !== "Closed" &&
flt(this.frm.doc.per_received, 2) < 100 && flt(this.frm.doc.per_received, 2) < 100 &&
@@ -336,7 +336,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
this.frm.page.set_inner_btn_group_as_primary(__("Status")); this.frm.page.set_inner_btn_group_as_primary(__("Status"));
} }
} else if (in_list(["Closed", "Delivered"], doc.status)) { } else if (["Closed", "Delivered"].includes(doc.status)) {
if (this.frm.has_perm("submit")) { if (this.frm.has_perm("submit")) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Re-open"), __("Re-open"),

View File

@@ -400,7 +400,7 @@ frappe.ui.form.on("BOM", {
}, },
rm_cost_as_per(frm) { rm_cost_as_per(frm) {
if (in_list(["Valuation Rate", "Last Purchase Rate"], frm.doc.rm_cost_as_per)) { if (["Valuation Rate", "Last Purchase Rate"].includes(frm.doc.rm_cost_as_per)) {
frm.set_value("plc_conversion_rate", 1.0); frm.set_value("plc_conversion_rate", 1.0);
} }
}, },

View File

@@ -129,7 +129,7 @@ frappe.ui.form.on("Production Plan", {
if ( if (
frm.doc.mr_items && frm.doc.mr_items &&
frm.doc.mr_items.length && frm.doc.mr_items.length &&
!in_list(["Material Requested", "Closed"], frm.doc.status) !["Material Requested", "Closed"].includes(frm.doc.status)
) { ) {
frm.add_custom_button( frm.add_custom_button(
__("Material Request"), __("Material Request"),

View File

@@ -196,7 +196,7 @@ frappe.ui.form.on("Work Order", {
}, },
add_custom_button_to_return_components: function (frm) { add_custom_button_to_return_components: function (frm) {
if (frm.doc.docstatus === 1 && in_list(["Closed", "Completed"], frm.doc.status)) { if (frm.doc.docstatus === 1 && ["Closed", "Completed"].includes(frm.doc.status)) {
let non_consumed_items = frm.doc.required_items.filter((d) => { let non_consumed_items = frm.doc.required_items.filter((d) => {
return flt(d.consumed_qty) < flt(d.transferred_qty - d.returned_qty); return flt(d.consumed_qty) < flt(d.transferred_qty - d.returned_qty);
}); });
@@ -596,7 +596,7 @@ erpnext.work_order = {
); );
} }
if (doc.docstatus === 1 && !in_list(["Closed", "Completed"], doc.status)) { if (doc.docstatus === 1 && !["Closed", "Completed"].includes(doc.status)) {
if (doc.status != "Stopped" && doc.status != "Completed") { if (doc.status != "Stopped" && doc.status != "Completed") {
frm.add_custom_button( frm.add_custom_button(
__("Stop"), __("Stop"),

View File

@@ -20,7 +20,7 @@ frappe.ui.form.on("Communication", {
); );
} }
if (!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) { if (!["Lead", "Opportunity"].includes(frm.doc.reference_doctype)) {
frm.add_custom_button( frm.add_custom_button(
__("Lead"), __("Lead"),
() => { () => {

View File

@@ -11,7 +11,7 @@ erpnext.accounts.taxes = {
setup: function(frm) { setup: function(frm) {
// set conditional display for rate column in taxes // set conditional display for rate column in taxes
$(frm.wrapper).on('grid-row-render', function(e, grid_row) { $(frm.wrapper).on('grid-row-render', function(e, grid_row) {
if(in_list(['Sales Taxes and Charges', 'Purchase Taxes and Charges'], grid_row.doc.doctype)) { if(['Sales Taxes and Charges', 'Purchase Taxes and Charges'].includes(grid_row.doc.doctype)) {
me.set_conditional_mandatory_rate_or_amount(grid_row); me.set_conditional_mandatory_rate_or_amount(grid_row);
} }
}); });

View File

@@ -129,7 +129,7 @@ erpnext.buying = {
} }
toggle_subcontracting_fields() { toggle_subcontracting_fields() {
if (in_list(['Purchase Receipt', 'Purchase Invoice'], this.frm.doc.doctype)) { if (['Purchase Receipt', 'Purchase Invoice'].includes(this.frm.doc.doctype)) {
this.frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty', this.frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty',
'read_only', this.frm.doc.__onload && this.frm.doc.__onload.backflush_based_on === 'BOM'); 'read_only', this.frm.doc.__onload && this.frm.doc.__onload.backflush_based_on === 'BOM');

View File

@@ -9,7 +9,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
apply_pricing_rule_on_item(item) { apply_pricing_rule_on_item(item) {
let effective_item_rate = item.price_list_rate; let effective_item_rate = item.price_list_rate;
let item_rate = item.rate; let item_rate = item.rate;
if (in_list(["Sales Order", "Quotation"], item.parenttype) && item.blanket_order_rate) { if (["Sales Order", "Quotation"].includes(item.parenttype) && item.blanket_order_rate) {
effective_item_rate = item.blanket_order_rate; effective_item_rate = item.blanket_order_rate;
} }
if (item.margin_type == "Percentage") { if (item.margin_type == "Percentage") {
@@ -52,7 +52,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
// Advance calculation applicable to Sales/Purchase Invoice // Advance calculation applicable to Sales/Purchase Invoice
if ( if (
in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype) ["Sales Invoice", "POS Invoice", "Purchase Invoice"].includes(this.frm.doc.doctype)
&& this.frm.doc.docstatus < 2 && this.frm.doc.docstatus < 2
&& !this.frm.doc.is_return && !this.frm.doc.is_return
) { ) {
@@ -60,7 +60,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
} }
if ( if (
in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) ["Sales Invoice", "POS Invoice"].includes(this.frm.doc.doctype)
&& this.frm.doc.is_pos && this.frm.doc.is_pos
&& this.frm.doc.is_return && this.frm.doc.is_return
) { ) {
@@ -69,7 +69,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
} }
// Sales person's commission // Sales person's commission
if (in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) { if (["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].includes(this.frm.doc.doctype)) {
this.calculate_commission(); this.calculate_commission();
this.calculate_contribution(); this.calculate_contribution();
} }
@@ -562,7 +562,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
? this.frm.doc["taxes"][tax_count - 1].total + flt(this.frm.doc.rounding_adjustment) ? this.frm.doc["taxes"][tax_count - 1].total + flt(this.frm.doc.rounding_adjustment)
: this.frm.doc.net_total); : this.frm.doc.net_total);
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "POS Invoice"], this.frm.doc.doctype)) { if(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "POS Invoice"].includes(this.frm.doc.doctype)) {
this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ? this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ?
flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total; flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total;
} else { } else {
@@ -570,7 +570,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0; this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0;
if(tax_count) { if(tax_count) {
$.each(this.frm.doc["taxes"] || [], function(i, tax) { $.each(this.frm.doc["taxes"] || [], function(i, tax) {
if (in_list(["Valuation and Total", "Total"], tax.category)) { if (["Valuation and Total", "Total"].includes(tax.category)) {
if(tax.add_deduct_tax == "Add") { if(tax.add_deduct_tax == "Add") {
me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount_after_discount_amount); me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount_after_discount_amount);
} else { } else {
@@ -717,7 +717,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
var actual_taxes_dict = {}; var actual_taxes_dict = {};
$.each(this.frm.doc["taxes"] || [], function(i, tax) { $.each(this.frm.doc["taxes"] || [], function(i, tax) {
if (in_list(["Actual", "On Item Quantity"], tax.charge_type)) { if (["Actual", "On Item Quantity"].includes(tax.charge_type)) {
var tax_amount = (tax.category == "Valuation") ? 0.0 : tax.tax_amount; var tax_amount = (tax.category == "Valuation") ? 0.0 : tax.tax_amount;
tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0; tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0;
actual_taxes_dict[tax.idx] = tax_amount; actual_taxes_dict[tax.idx] = tax_amount;
@@ -762,7 +762,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
// NOTE: // NOTE:
// paid_amount and write_off_amount is only for POS/Loyalty Point Redemption Invoice // paid_amount and write_off_amount is only for POS/Loyalty Point Redemption Invoice
// total_advance is only for non POS Invoice // total_advance is only for non POS Invoice
if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) && this.frm.doc.is_return){ if(["Sales Invoice", "POS Invoice"].includes(this.frm.doc.doctype) && this.frm.doc.is_return){
this.calculate_paid_amount(); this.calculate_paid_amount();
} }
@@ -770,7 +770,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]); frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)) { if(["Sales Invoice", "POS Invoice", "Purchase Invoice"].includes(this.frm.doc.doctype)) {
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total; let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total; let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
@@ -793,7 +793,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
this.frm.refresh_field("base_paid_amount"); this.frm.refresh_field("base_paid_amount");
} }
if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype)) { if(["Sales Invoice", "POS Invoice"].includes(this.frm.doc.doctype)) {
let total_amount_for_payment = (this.frm.doc.redeem_loyalty_points && this.frm.doc.loyalty_amount) let total_amount_for_payment = (this.frm.doc.redeem_loyalty_points && this.frm.doc.loyalty_amount)
? flt(total_amount_to_pay - this.frm.doc.loyalty_amount, precision("base_grand_total")) ? flt(total_amount_to_pay - this.frm.doc.loyalty_amount, precision("base_grand_total"))
: total_amount_to_pay; : total_amount_to_pay;
@@ -897,7 +897,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
calculate_change_amount(){ calculate_change_amount(){
this.frm.doc.change_amount = 0.0; this.frm.doc.change_amount = 0.0;
this.frm.doc.base_change_amount = 0.0; this.frm.doc.base_change_amount = 0.0;
if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) if(["Sales Invoice", "POS Invoice"].includes(this.frm.doc.doctype)
&& this.frm.doc.paid_amount > this.frm.doc.grand_total && !this.frm.doc.is_return) { && this.frm.doc.paid_amount > this.frm.doc.grand_total && !this.frm.doc.is_return) {
var payment_types = $.map(this.frm.doc.payments, function(d) { return d.type; }); var payment_types = $.map(this.frm.doc.payments, function(d) { return d.type; });

View File

@@ -315,7 +315,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
setup_quality_inspection() { setup_quality_inspection() {
if(!in_list(["Delivery Note", "Sales Invoice", "Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"], this.frm.doc.doctype)) { if(!["Delivery Note", "Sales Invoice", "Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"].includes(this.frm.doc.doctype)) {
return; return;
} }
@@ -327,7 +327,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.frm.page.set_inner_btn_group_as_primary(__('Create')); this.frm.page.set_inner_btn_group_as_primary(__('Create'));
} }
const inspection_type = in_list(["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"], this.frm.doc.doctype) const inspection_type = ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"].includes(this.frm.doc.doctype)
? "Incoming" : "Outgoing"; ? "Incoming" : "Outgoing";
let quality_inspection_field = this.frm.get_docfield("items", "quality_inspection"); let quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
@@ -359,7 +359,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
make_payment_request() { make_payment_request() {
let me = this; let me = this;
const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], this.frm.doc.doctype)) const payment_request_type = (['Sales Order', 'Sales Invoice'].includes(this.frm.doc.doctype))
? "Inward" : "Outward"; ? "Inward" : "Outward";
frappe.call({ frappe.call({
@@ -474,7 +474,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
setup_sms() { setup_sms() {
var me = this; var me = this;
let blacklist = ['Purchase Invoice', 'BOM']; let blacklist = ['Purchase Invoice', 'BOM'];
if(this.frm.doc.docstatus===1 && !in_list(["Lost", "Stopped", "Closed"], this.frm.doc.status) if(this.frm.doc.docstatus===1 && !["Lost", "Stopped", "Closed"].includes(this.frm.doc.status)
&& !blacklist.includes(this.frm.doctype)) { && !blacklist.includes(this.frm.doctype)) {
this.frm.page.add_menu_item(__('Send SMS'), function() { me.send_sms(); }); this.frm.page.add_menu_item(__('Send SMS'), function() { me.send_sms(); });
} }
@@ -760,7 +760,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
on_submit() { on_submit() {
if (in_list(["Purchase Invoice", "Sales Invoice"], this.frm.doc.doctype) if (["Purchase Invoice", "Sales Invoice"].includes(this.frm.doc.doctype)
&& !this.frm.doc.update_stock) { && !this.frm.doc.update_stock) {
return; return;
} }
@@ -864,7 +864,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
var set_party_account = function(set_pricing) { var set_party_account = function(set_pricing) {
if (in_list(["Sales Invoice", "Purchase Invoice"], me.frm.doc.doctype)) { if (["Sales Invoice", "Purchase Invoice"].includes(me.frm.doc.doctype)) {
if(me.frm.doc.doctype=="Sales Invoice") { if(me.frm.doc.doctype=="Sales Invoice") {
var party_type = "Customer"; var party_type = "Customer";
var party_account_field = 'debit_to'; var party_account_field = 'debit_to';
@@ -899,7 +899,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") && if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") &&
in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)) { ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'].includes(this.frm.doctype)) {
erpnext.utils.get_shipping_address(this.frm, function() { erpnext.utils.get_shipping_address(this.frm, function() {
set_party_account(set_pricing); set_party_account(set_pricing);
}); });
@@ -1610,7 +1610,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
"doctype": me.frm.doc.doctype, "doctype": me.frm.doc.doctype,
"name": me.frm.doc.name, "name": me.frm.doc.name,
"is_return": cint(me.frm.doc.is_return), "is_return": cint(me.frm.doc.is_return),
"update_stock": in_list(['Sales Invoice', 'Purchase Invoice'], me.frm.doc.doctype) ? cint(me.frm.doc.update_stock) : 0, "update_stock": ['Sales Invoice', 'Purchase Invoice'].includes(me.frm.doc.doctype) ? cint(me.frm.doc.update_stock) : 0,
"conversion_factor": me.frm.doc.conversion_factor, "conversion_factor": me.frm.doc.conversion_factor,
"pos_profile": me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '', "pos_profile": me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '',
"coupon_code": me.frm.doc.coupon_code "coupon_code": me.frm.doc.coupon_code
@@ -2256,7 +2256,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
get_method_for_payment() { get_method_for_payment() {
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry"; var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
if(cur_frm.doc.__onload && cur_frm.doc.__onload.make_payment_via_journal_entry){ if(cur_frm.doc.__onload && cur_frm.doc.__onload.make_payment_via_journal_entry){
if(in_list(['Sales Invoice', 'Purchase Invoice'], cur_frm.doc.doctype)){ if(['Sales Invoice', 'Purchase Invoice'].includes( cur_frm.doc.doctype)){
method = "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_invoice"; method = "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_invoice";
}else { }else {
method= "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_order"; method= "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_order";
@@ -2496,7 +2496,7 @@ erpnext.show_serial_batch_selector = function (frm, item_row, callback, on_close
} }
frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() { frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() {
if (in_list(["Sales Invoice", "Delivery Note"], frm.doc.doctype)) { if (["Sales Invoice", "Delivery Note"].includes(frm.doc.doctype)) {
item_row.type_of_transaction = frm.doc.is_return ? "Inward" : "Outward"; item_row.type_of_transaction = frm.doc.is_return ? "Inward" : "Outward";
} else { } else {
item_row.type_of_transaction = frm.doc.is_return ? "Outward" : "Inward"; item_row.type_of_transaction = frm.doc.is_return ? "Outward" : "Inward";

View File

@@ -218,7 +218,7 @@ erpnext.payments = class payments extends erpnext.stock.StockController {
update_paid_amount(update_write_off) { update_paid_amount(update_write_off) {
var me = this; var me = this;
if (in_list(["change_amount", "write_off_amount"], this.idx)) { if (["change_amount", "write_off_amount"].includes(this.idx)) {
var value = me.selected_mode.val(); var value = me.selected_mode.val();
if (me.idx == "change_amount") { if (me.idx == "change_amount") {
me.change_amount(value); me.change_amount(value);

View File

@@ -28,11 +28,11 @@ erpnext.SMSManager = function SMSManager(doc) {
"Purchase Receipt": "Items has been received against purchase receipt: " + doc.name, "Purchase Receipt": "Items has been received against purchase receipt: " + doc.name,
}; };
if (in_list(["Sales Order", "Delivery Note", "Sales Invoice"], doc.doctype)) if (["Sales Order", "Delivery Note", "Sales Invoice"].includes(doc.doctype))
this.show(doc.contact_person, "Customer", doc.customer, "", default_msg[doc.doctype]); this.show(doc.contact_person, "Customer", doc.customer, "", default_msg[doc.doctype]);
else if (doc.doctype === "Quotation") else if (doc.doctype === "Quotation")
this.show(doc.contact_person, "Customer", doc.party_name, "", default_msg[doc.doctype]); this.show(doc.contact_person, "Customer", doc.party_name, "", default_msg[doc.doctype]);
else if (in_list(["Purchase Order", "Purchase Receipt"], doc.doctype)) else if (["Purchase Order", "Purchase Receipt"].includes(doc.doctype))
this.show(doc.contact_person, "Supplier", doc.supplier, "", default_msg[doc.doctype]); this.show(doc.contact_person, "Supplier", doc.supplier, "", default_msg[doc.doctype]);
else if (doc.doctype == "Lead") this.show("", "", "", doc.mobile_no, default_msg[doc.doctype]); else if (doc.doctype == "Lead") this.show("", "", "", doc.mobile_no, default_msg[doc.doctype]);
else if (doc.doctype == "Opportunity") else if (doc.doctype == "Opportunity")

View File

@@ -14,10 +14,10 @@ erpnext.utils.get_party_details = function (frm, method, args, callback) {
if (!args) { if (!args) {
if ( if (
(frm.doctype != "Purchase Order" && frm.doc.customer) || (frm.doctype != "Purchase Order" && frm.doc.customer) ||
(frm.doc.party_name && in_list(["Quotation", "Opportunity"], frm.doc.doctype)) (frm.doc.party_name && ["Quotation", "Opportunity"].includes(frm.doc.doctype))
) { ) {
let party_type = "Customer"; let party_type = "Customer";
if (frm.doc.quotation_to && in_list(["Lead", "Prospect"], frm.doc.quotation_to)) { if (frm.doc.quotation_to && ["Lead", "Prospect"].includes(frm.doc.quotation_to)) {
party_type = frm.doc.quotation_to; party_type = frm.doc.quotation_to;
} }

View File

@@ -303,7 +303,7 @@ erpnext.sales_common = {
if ((doc.packed_items || []).length) { if ((doc.packed_items || []).length) {
$(this.frm.fields_dict.packing_list.row.wrapper).toggle(true); $(this.frm.fields_dict.packing_list.row.wrapper).toggle(true);
if (in_list(["Delivery Note", "Sales Invoice"], doc.doctype)) { if (["Delivery Note", "Sales Invoice"].includes(doc.doctype)) {
var help_msg = var help_msg =
"<div class='alert alert-warning'>" + "<div class='alert alert-warning'>" +
__( __(
@@ -315,7 +315,7 @@ erpnext.sales_common = {
} }
} else { } else {
$(this.frm.fields_dict.packing_list.row.wrapper).toggle(false); $(this.frm.fields_dict.packing_list.row.wrapper).toggle(false);
if (in_list(["Delivery Note", "Sales Invoice"], doc.doctype)) { if (["Delivery Note", "Sales Invoice"].includes(doc.doctype)) {
frappe.meta.get_docfield(doc.doctype, "product_bundle_help", doc.name).options = ""; frappe.meta.get_docfield(doc.doctype, "product_bundle_help", doc.name).options = "";
} }
} }
@@ -416,7 +416,7 @@ erpnext.sales_common = {
project() { project() {
let me = this; let me = this;
if (in_list(["Delivery Note", "Sales Invoice", "Sales Order"], this.frm.doc.doctype)) { if (["Delivery Note", "Sales Invoice", "Sales Order"].includes(this.frm.doc.doctype)) {
if (this.frm.doc.project) { if (this.frm.doc.project) {
frappe.call({ frappe.call({
method: "erpnext.projects.doctype.project.project.get_cost_center_name", method: "erpnext.projects.doctype.project.project.get_cost_center_name",

View File

@@ -34,7 +34,7 @@ frappe.ui.form.on("Import Supplier Invoice", {
}, },
toggle_read_only_fields: function (frm) { toggle_read_only_fields: function (frm) {
if (in_list(["File Import Completed", "Processing File Data"], frm.doc.status)) { if (["File Import Completed", "Processing File Data"].includes(frm.doc.status)) {
cur_frm.set_read_only(); cur_frm.set_read_only();
cur_frm.refresh_fields(); cur_frm.refresh_fields();
frm.set_df_property("import_invoices", "hidden", 1); frm.set_df_property("import_invoices", "hidden", 1);

View File

@@ -73,7 +73,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const { status } = doc; const { status } = doc;
let indicator_color = ""; let indicator_color = "";
in_list(["Paid", "Consolidated"], status) && (indicator_color = "green"); ["Paid", "Consolidated"].includes(status) && (indicator_color = "green");
status === "Draft" && (indicator_color = "red"); status === "Draft" && (indicator_color = "red");
status === "Return" && (indicator_color = "grey"); status === "Return" && (indicator_color = "grey");

View File

@@ -8,7 +8,7 @@ frappe.ui.form.on("Closing Stock Balance", {
}, },
generate_closing_balance(frm) { generate_closing_balance(frm) {
if (in_list(["Queued", "Failed"], frm.doc.status)) { if (["Queued", "Failed"].includes(frm.doc.status)) {
frm.add_custom_button(__("Generate Closing Stock Balance"), () => { frm.add_custom_button(__("Generate Closing Stock Balance"), () => {
frm.call({ frm.call({
method: "enqueue_job", method: "enqueue_job",

View File

@@ -1,9 +1,9 @@
frappe.listview_settings["Delivery Trip"] = { frappe.listview_settings["Delivery Trip"] = {
add_fields: ["status"], add_fields: ["status"],
get_indicator: function (doc) { get_indicator: function (doc) {
if (in_list(["Cancelled", "Draft"], doc.status)) { if (["Cancelled", "Draft"].includes(doc.status)) {
return [__(doc.status), "red", "status,=," + doc.status]; return [__(doc.status), "red", "status,=," + doc.status];
} else if (in_list(["In Transit", "Scheduled"], doc.status)) { } else if (["In Transit", "Scheduled"].includes(doc.status)) {
return [__(doc.status), "orange", "status,=," + doc.status]; return [__(doc.status), "orange", "status,=," + doc.status];
} else if (doc.status === "Completed") { } else if (doc.status === "Completed") {
return [__(doc.status), "green", "status,=," + doc.status]; return [__(doc.status), "green", "status,=," + doc.status];

View File

@@ -18,7 +18,7 @@
actual_qty = (frm.doc.doctype==="Sales Order" actual_qty = (frm.doc.doctype==="Sales Order"
? doc.projected_qty : doc.actual_qty); ? doc.projected_qty : doc.actual_qty);
if(flt(frm.doc.per_delivered, 2) < 100 if(flt(frm.doc.per_delivered, 2) < 100
&& in_list(["Sales Order Item", "Delivery Note Item"], doc.doctype)) { && ["Sales Order Item", "Delivery Note Item"].includes(doc.doctype)) {
if(actual_qty != undefined) { if(actual_qty != undefined) {
if(actual_qty >= doc.qty) { if(actual_qty >= doc.qty) {
var color = "green"; var color = "green";