diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 958a74595a6..47ba17359f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,6 @@ repos: cypress/.*| .*node_modules.*| .*boilerplate.*| - erpnext/public/js/controllers/.*| erpnext/templates/pages/order.js| erpnext/templates/includes/.* )$ diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 97e40f490d6..f264639136b 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -23,15 +23,12 @@ erpnext.accounts.taxes = { onload: function (frm) { if (frm.get_field("taxes")) { frm.set_query("account_head", "taxes", function (doc) { + let account_type = ["Tax", "Chargeable"]; + if (frm.cscript.tax_table == "Sales Taxes and Charges") { - var account_type = ["Tax", "Chargeable", "Expense Account"]; + account_type.push("Expense Account"); } else { - var account_type = [ - "Tax", - "Chargeable", - "Income Account", - "Expenses Included In Valuation", - ]; + account_type.push("Income Account", "Expenses Included In Valuation"); } return { diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index acbffa95d7d..8a0719c6d3f 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -952,14 +952,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { 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 base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total; + let total_amount_to_pay; if (this.frm.doc.party_account_currency == this.frm.doc.currency) { - var total_amount_to_pay = flt( + total_amount_to_pay = flt( grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount, precision("grand_total") ); } else { - var total_amount_to_pay = flt( + total_amount_to_pay = flt( flt(base_grand_total, precision("base_grand_total")) - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount, @@ -1004,14 +1005,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { async set_total_amount_to_default_mop() { 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 total_amount_to_pay; if (this.frm.doc.party_account_currency == this.frm.doc.currency) { - var total_amount_to_pay = flt( + total_amount_to_pay = flt( grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount, precision("grand_total") ); } else { - var total_amount_to_pay = flt( + total_amount_to_pay = flt( flt(base_grand_total, precision("base_grand_total")) - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount, diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3fce8850d7a..d3832b4dd46 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1273,13 +1273,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe var set_party_account = function (set_pricing) { if (["Sales Invoice", "Purchase Invoice"].includes(me.frm.doc.doctype)) { - if (me.frm.doc.doctype == "Sales Invoice") { - var party_type = "Customer"; - var party_account_field = "debit_to"; - } else { - var party_type = "Supplier"; - var party_account_field = "credit_to"; - } + let party_type = me.frm.doc.doctype == "Sales Invoice" ? "Customer" : "Supplier"; + let party_account_field = me.frm.doc.doctype == "Sales Invoice" ? "debit_to" : "credit_to"; var party = me.frm.doc[frappe.model.scrub(party_type)]; if ( @@ -1986,7 +1981,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } if (this.frm.doc.operations && this.frm.doc.operations.length > 0) { - var item_grid = this.frm.fields_dict["operations"].grid; + let item_grid = this.frm.fields_dict["operations"].grid; $.each(["base_operating_cost", "base_hour_rate"], function (i, fname) { if (frappe.meta.get_docfield(item_grid.doctype, fname)) item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency); @@ -1994,7 +1989,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } if (this.frm.doc.secondary_items && this.frm.doc.secondary_items.length > 0) { - var item_grid = this.frm.fields_dict["secondary_items"].grid; + let item_grid = this.frm.fields_dict["secondary_items"].grid; $.each(["base_rate", "base_amount"], function (i, fname) { if (frappe.meta.get_docfield(item_grid.doctype, fname)) item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency); @@ -2391,7 +2386,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe row_to_modify[key] = pr_row[key]; } - if (this.frm.doc.hasOwnProperty("is_pos") && this.frm.doc.is_pos) { + if (Object.prototype.hasOwnProperty.call(this.frm.doc, "is_pos") && this.frm.doc.is_pos) { let r = await frappe.db.get_value("POS Profile", this.frm.doc.pos_profile, "cost_center"); if (r.message.cost_center) { row_to_modify["cost_center"] = r.message.cost_center; @@ -2658,7 +2653,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe $.each(me.frm.doc.items || [], function (i, item) { if ( item.name && - r.message.hasOwnProperty(item.name) && + Object.prototype.hasOwnProperty.call(r.message, item.name) && r.message[item.name].item_tax_template ) { item.item_tax_template = r.message[item.name].item_tax_template;