From 1fe891b287a1b3f225d29ee3d07e7b1824aba9e7 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 23 Apr 2021 08:04:00 +0530 Subject: [PATCH 1/7] refactor: Replace Class.extend with native class --- .../doctype/journal_entry/journal_entry.js | 36 +- .../payment_reconciliation.js | 38 +- .../doctype/pos_invoice/pos_invoice.js | 50 +-- .../purchase_invoice/purchase_invoice.js | 98 ++--- .../doctype/sales_invoice/sales_invoice.js | 127 ++++--- .../doctype/purchase_order/purchase_order.js | 90 ++--- .../request_for_quotation.js | 22 +- .../supplier_quotation/supplier_quotation.js | 22 +- erpnext/crm/doctype/lead/lead.js | 38 +- .../crm/doctype/opportunity/opportunity.js | 14 +- .../student_attendance_tool.js | 14 +- .../doctype/exercise_type/exercise_type.js | 26 +- erpnext/hr/doctype/employee/employee.js | 20 +- .../employee_attendance_tool.js | 20 +- .../upload_attendance/upload_attendance.js | 18 +- .../maintenance_schedule.js | 24 +- .../maintenance_visit/maintenance_visit.js | 10 +- erpnext/manufacturing/doctype/bom/bom.js | 24 +- erpnext/public/js/account_tree_grid.js | 81 ++-- erpnext/public/js/controllers/buying.js | 122 +++--- .../public/js/controllers/stock_controller.js | 22 +- .../public/js/controllers/taxes_and_totals.js | 146 +++---- erpnext/public/js/controllers/transaction.js | 358 +++++++++--------- erpnext/public/js/payment/payments.js | 92 ++--- erpnext/public/js/stock_analytics.js | 46 +-- erpnext/public/js/stock_grid_report.js | 24 +- erpnext/public/js/telephony.js | 10 +- .../public/js/utils/customer_quick_entry.js | 20 +- erpnext/public/js/utils/item_quick_entry.js | 90 ++--- erpnext/public/js/utils/item_selector.js | 22 +- .../js/utils/serial_no_batch_selector.js | 48 +-- .../installation_note/installation_note.js | 8 +- .../selling/doctype/quotation/quotation.js | 44 +-- .../doctype/sales_order/sales_order.js | 90 ++--- erpnext/selling/sales_common.js | 144 +++---- erpnext/stock/dashboard/item_dashboard.js | 26 +- .../doctype/delivery_note/delivery_note.js | 60 +-- .../landed_cost_voucher.js | 34 +- .../material_request/material_request.js | 42 +- .../purchase_receipt/purchase_receipt.js | 38 +- .../stock/doctype/stock_entry/stock_entry.js | 82 ++-- .../stock_reconciliation.js | 12 +- .../doctype/warranty_claim/warranty_claim.js | 10 +- erpnext/templates/includes/rfq.js | 34 +- 44 files changed, 1200 insertions(+), 1196 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 37b03f3f0e..2f8d3e31d9 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -194,19 +194,19 @@ var update_jv_details = function(doc, r) { refresh_field("accounts"); } -erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ - onload: function() { +erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Controller { + onload() { this.load_defaults(); this.setup_queries(); this.setup_balance_formatter(); erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); - }, + } - onload_post_render: function() { + onload_post_render() { cur_frm.get_field("accounts").grid.set_multiple_add("account"); - }, + } - load_defaults: function() { + load_defaults() { //this.frm.show_print_first = true; if(this.frm.doc.__islocal && this.frm.doc.company) { frappe.model.set_default_values(this.frm.doc); @@ -216,9 +216,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ var posting_date = this.frm.doc.posting_date; if(!this.frm.doc.amended_from) this.frm.set_value('posting_date', posting_date || frappe.datetime.get_today()); } - }, + } - setup_queries: function() { + setup_queries() { var me = this; me.frm.set_query("account", "accounts", function(doc, cdt, cdn) { @@ -324,9 +324,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ }); - }, + } - setup_balance_formatter: function() { + setup_balance_formatter() { var me = this; $.each(["balance", "party_balance"], function(i, field) { var df = frappe.meta.get_docfield("Journal Entry Account", field, me.frm.doc.name); @@ -339,9 +339,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ + ""; } }) - }, + } - reference_name: function(doc, cdt, cdn) { + reference_name(doc, cdt, cdn) { var d = frappe.get_doc(cdt, cdn); if(d.reference_name) { @@ -353,9 +353,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ this.get_outstanding('Journal Entry', d.reference_name, doc.company, d); } } - }, + } - get_outstanding: function(doctype, docname, company, child, due_date) { + get_outstanding(doctype, docname, company, child, due_date) { var me = this; var args = { "doctype": doctype, @@ -377,9 +377,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ } } }); - }, + } - accounts_add: function(doc, cdt, cdn) { + accounts_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); $.each(doc.accounts, function(i, d) { if(d.account && d.party && d.party_type) { @@ -402,9 +402,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ cur_frm.cscript.update_totals(doc); erpnext.accounts.dimensions.copy_dimension_from_first_row(this.frm, cdt, cdn, 'accounts'); - }, + } -}); +}; cur_frm.script_manager.make(erpnext.accounts.JournalEntry); diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 6b07197ec1..dd91fec3c1 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -34,8 +34,8 @@ frappe.ui.form.on("Payment Reconciliation Payment", { } }); -erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.extend({ - onload: function() { +erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationController extends frappe.ui.form.Controller { + onload() { var me = this; this.frm.set_query("party", function() { @@ -84,18 +84,18 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext frappe.throw({message: __("Please Select Both Company and Party Type First"), title: title}); } }; - }, + } - refresh: function() { + refresh() { this.frm.disable_save(); this.toggle_primary_action(); - }, + } - onload_post_render: function() { + onload_post_render() { this.toggle_primary_action(); - }, + } - party: function() { + party() { var me = this if (!me.frm.doc.receivable_payable_account && me.frm.doc.party_type && me.frm.doc.party) { return frappe.call({ @@ -112,9 +112,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext } }); } - }, + } - get_unreconciled_entries: function() { + get_unreconciled_entries() { var me = this; return this.frm.call({ doc: me.frm.doc, @@ -125,9 +125,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext } }); - }, + } - reconcile: function() { + reconcile() { var me = this; var show_dialog = me.frm.doc.payments.filter(d => d.difference_amount && !d.difference_account); @@ -209,9 +209,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext } else { this.reconcile_payment_entries(); } - }, + } - reconcile_payment_entries: function() { + reconcile_payment_entries() { var me = this; return this.frm.call({ @@ -222,9 +222,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext me.toggle_primary_action(); } }); - }, + } - set_invoice_options: function() { + set_invoice_options() { var me = this; var invoices = []; @@ -243,9 +243,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext } refresh_field("payments"); - }, + } - toggle_primary_action: function() { + toggle_primary_action() { if ((this.frm.doc.payments || []).length) { this.frm.fields_dict.reconcile.$input && this.frm.fields_dict.reconcile.$input.addClass("btn-primary"); @@ -259,6 +259,6 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext } } -}); +}; $.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js index 493bd44802..72d587afb5 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.js +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.js @@ -4,18 +4,18 @@ {% include 'erpnext/selling/sales_common.js' %}; frappe.provide("erpnext.accounts"); -erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend({ +erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnext.selling.SellingController { setup(doc) { this.setup_posting_date_time_check(); - this._super(doc); - }, + super.setup(doc); + } - company: function() { + company() { erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype); - }, + } onload(doc) { - this._super(); + super.onload(); this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice Merge Log']; if(doc.__islocal && doc.is_pos && frappe.get_route_str() !== 'point-of-sale') { this.frm.script_manager.trigger("is_pos"); @@ -23,10 +23,10 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( } erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); - }, + } refresh(doc) { - this._super(); + super.refresh(); if (doc.docstatus == 1 && !doc.is_return) { this.frm.add_custom_button(__('Return'), this.make_sales_return, __('Create')); this.frm.page.set_inner_btn_group_as_primary(__('Create')); @@ -36,13 +36,13 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( this.frm.return_print_format = "Sales Invoice Return"; this.frm.set_value('consolidated_invoice', ''); } - }, + } - is_pos: function() { + is_pos() { this.set_pos_data(); - }, + } - set_pos_data: async function() { + async set_pos_data() { if(this.frm.doc.is_pos) { this.frm.set_value("allocate_advances_automatically", 0); if(!this.frm.doc.company) { @@ -69,7 +69,7 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( } } } - }, + } customer() { if (!this.frm.doc.customer) return @@ -86,13 +86,13 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( }, () => { this.apply_pricing_rule(); }); - }, + } - amount: function(){ + amount(){ this.write_off_outstanding_amount_automatically() - }, + } - change_amount: function(){ + change_amount(){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){ this.calculate_write_off_amount(); }else { @@ -101,16 +101,16 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( } this.frm.refresh_fields(); - }, + } - loyalty_amount: function(){ + loyalty_amount(){ this.calculate_outstanding_amount(); this.frm.refresh_field("outstanding_amount"); this.frm.refresh_field("paid_amount"); this.frm.refresh_field("base_paid_amount"); - }, + } - write_off_outstanding_amount_automatically: function() { + write_off_outstanding_amount_automatically() { if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) { frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]); // this will make outstanding amount 0 @@ -125,15 +125,15 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend( this.calculate_outstanding_amount(false); this.frm.refresh_fields(); - }, + } - make_sales_return: function() { + make_sales_return() { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.pos_invoice.pos_invoice.make_sales_return", frm: cur_frm }) - }, -}) + } +} $.extend(cur_frm.cscript, new erpnext.selling.POSInvoiceController({ frm: cur_frm })) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 06aa20bfc5..b31cdce0b2 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -4,10 +4,10 @@ frappe.provide("erpnext.accounts"); {% include 'erpnext/public/js/controllers/buying.js' %}; -erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ - setup: function(doc) { +erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.BuyingController { + setup(doc) { this.setup_posting_date_time_check(); - this._super(doc); + super.setup(doc); // formatter for purchase invoice item if(this.frm.doc.update_stock) { @@ -25,14 +25,14 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } }; }); - }, + } - company: function() { + company() { erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype); - }, + } - onload: function() { - this._super(); + onload() { + super.onload(); if(!this.frm.doc.__islocal) { // show credit_to in print format @@ -48,11 +48,11 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); - }, + } - refresh: function(doc) { + refresh(doc) { const me = this; - this._super(); + super.refresh(); hide_fields(this.frm.doc); // Show / Hide button @@ -161,26 +161,26 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } this.frm.set_df_property("tax_withholding_category", "hidden", doc.apply_tds ? 0 : 1); - }, + } - unblock_invoice: function() { + unblock_invoice() { const me = this; frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.unblock_invoice', 'args': {'name': me.frm.doc.name}, 'callback': (r) => me.frm.reload_doc() }); - }, + } - block_invoice: function() { + block_invoice() { this.make_comment_dialog_and_block_invoice(); - }, + } - change_release_date: function() { + change_release_date() { this.make_dialog_and_set_release_date(); - }, + } - can_change_release_date: function(date) { + can_change_release_date(date) { const diff = frappe.datetime.get_diff(date, frappe.datetime.nowdate()); if (diff < 0) { frappe.throw(__('New release date should be in the future')); @@ -188,9 +188,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } else { return true; } - }, + } - make_comment_dialog_and_block_invoice: function(){ + make_comment_dialog_and_block_invoice(){ const me = this; const title = __('Block Invoice'); @@ -232,9 +232,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }); this.dialog.show(); - }, + } - make_dialog_and_set_release_date: function() { + make_dialog_and_set_release_date() { const me = this; const title = __('Set New Release Date'); @@ -263,17 +263,17 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }); this.dialog.show(); - }, + } - set_release_date: function(data) { + set_release_date(data) { return frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.change_release_date', 'args': data, 'callback': (r) => this.frm.reload_doc() }); - }, + } - supplier: function() { + supplier() { var me = this; // Do not update if inter company reference is there as the details will already be updated @@ -295,9 +295,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ me.frm.set_df_property("apply_tds", "read_only", me.frm.supplier_tds ? 0 : 1); me.frm.set_df_property("tax_withholding_category", "hidden", me.frm.supplier_tds ? 0 : 1); }) - }, + } - apply_tds: function(frm) { + apply_tds(frm) { var me = this; if (!me.frm.doc.apply_tds) { @@ -307,9 +307,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ me.frm.set_value("tax_withholding_category", me.frm.supplier_tds); me.frm.set_df_property("tax_withholding_category", "hidden", 0); } - }, + } - credit_to: function() { + credit_to() { var me = this; if(this.frm.doc.credit_to) { me.frm.call({ @@ -327,16 +327,16 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } }); } - }, + } - make_inter_company_invoice: function(frm) { + make_inter_company_invoice(frm) { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_inter_company_sales_invoice", frm: frm }); - }, + } - is_paid: function() { + is_paid() { hide_fields(this.frm.doc); if(cint(this.frm.doc.is_paid)) { this.frm.set_value("allocate_advances_automatically", 0); @@ -347,44 +347,44 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ } this.calculate_outstanding_amount(); this.frm.refresh_fields(); - }, + } - write_off_amount: function() { + write_off_amount() { this.set_in_company_currency(this.frm.doc, ["write_off_amount"]); this.calculate_outstanding_amount(); this.frm.refresh_fields(); - }, + } - paid_amount: function() { + paid_amount() { this.set_in_company_currency(this.frm.doc, ["paid_amount"]); this.write_off_amount(); this.frm.refresh_fields(); - }, + } - allocated_amount: function() { + allocated_amount() { this.calculate_total_advance(); this.frm.refresh_fields(); - }, + } - items_add: function(doc, cdt, cdn) { + items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("items", row, ["expense_account", "cost_center", "project"]); - }, + } - on_submit: function() { + on_submit() { $.each(this.frm.doc["items"] || [], function(i, row) { if(row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) }) - }, + } - make_debit_note: function() { + make_debit_note() { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_debit_note", frm: cur_frm }) - }, -}); + } +}; cur_frm.script_manager.make(erpnext.accounts.PurchaseInvoice); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index b361c0c345..8e8f85a3e4 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -2,23 +2,24 @@ // License: GNU General Public License v3. See license.txt // print heading +frappe.provide('cur_frm.pformat') cur_frm.pformat.print_heading = 'Invoice'; {% include 'erpnext/selling/sales_common.js' %}; frappe.provide("erpnext.accounts"); -erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ - setup: function(doc) { +erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends erpnext.selling.SellingController { + setup(doc) { this.setup_posting_date_time_check(); - this._super(doc); - }, - company: function() { + super.setup(doc); + } + company() { erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype); - }, - onload: function() { + } + onload() { var me = this; - this._super(); + super.onload(); this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice']; if(!this.frm.doc.__islocal && !this.frm.doc.customer && this.frm.doc.debit_to) { @@ -38,11 +39,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } erpnext.queries.setup_warehouse_query(this.frm); erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype); - }, + } - refresh: function(doc, dt, dn) { + refresh(doc, dt, dn) { const me = this; - this._super(); + super.refresh(); if(cur_frm.msgbox && cur_frm.msgbox.$wrapper.is(":visible")) { // hide new msgbox cur_frm.msgbox.hide(); @@ -141,16 +142,16 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, __('Create')); } } - }, + } - make_maintenance_schedule: function() { + make_maintenance_schedule() { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule", frm: cur_frm }) - }, + } - on_submit: function(doc, dt, dn) { + on_submit(doc, dt, dn) { var me = this; if (frappe.get_route()[0] != 'Form') { @@ -160,9 +161,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte $.each(doc["items"], function(i, row) { if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note) }) - }, + } - set_default_print_format: function() { + set_default_print_format() { // set default print format to POS type or Credit Note if(cur_frm.doc.is_pos) { if(cur_frm.pos_print_format) { @@ -183,9 +184,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.meta._default_print_format = null; } } - }, + } - sales_order_btn: function() { + sales_order_btn() { var me = this; this.$sales_order_btn = this.frm.add_custom_button(__('Sales Order'), function() { @@ -204,9 +205,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }) }, __("Get Items From")); - }, + } - quotation_btn: function() { + quotation_btn() { var me = this; this.$quotation_btn = this.frm.add_custom_button(__('Quotation'), function() { @@ -228,9 +229,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }) }, __("Get Items From")); - }, + } - delivery_note_btn: function() { + delivery_note_btn() { var me = this; this.$delivery_note_btn = this.frm.add_custom_button(__('Delivery Note'), function() { @@ -256,12 +257,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }); }, __("Get Items From")); - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, - customer: function() { + } + customer() { if (this.frm.doc.is_pos){ var pos_profile = this.frm.doc.pos_profile; } @@ -292,16 +293,16 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }); } - }, + } - make_inter_company_invoice: function() { + make_inter_company_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_inter_company_purchase_invoice", frm: me.frm }); - }, + } - debit_to: function() { + debit_to() { var me = this; if(this.frm.doc.debit_to) { me.frm.call({ @@ -319,14 +320,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }); } - }, + } - allocated_amount: function() { + allocated_amount() { this.calculate_total_advance(); this.frm.refresh_fields(); - }, + } - write_off_outstanding_amount_automatically: function() { + write_off_outstanding_amount_automatically() { if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) { frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]); // this will make outstanding amount 0 @@ -341,39 +342,39 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.calculate_outstanding_amount(false); this.frm.refresh_fields(); - }, + } - write_off_amount: function() { + write_off_amount() { this.set_in_company_currency(this.frm.doc, ["write_off_amount"]); this.write_off_outstanding_amount_automatically(); - }, + } - items_add: function(doc, cdt, cdn) { + items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("items", row, ["income_account", "cost_center"]); - }, + } - set_dynamic_labels: function() { - this._super(); + set_dynamic_labels() { + super.set_dynamic_labels(); this.frm.events.hide_fields(this.frm) - }, + } - items_on_form_rendered: function() { + items_on_form_rendered() { erpnext.setup_serial_no(); - }, + } - packed_items_on_form_rendered: function(doc, grid_row) { + packed_items_on_form_rendered(doc, grid_row) { erpnext.setup_serial_no(); - }, + } - make_sales_return: function() { + make_sales_return() { frappe.model.open_mapped_doc({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_sales_return", frm: cur_frm }) - }, + } - asset: function(frm, cdt, cdn) { + asset(frm, cdt, cdn) { var row = locals[cdt][cdn]; if(row.asset) { frappe.call({ @@ -387,18 +388,18 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }) } - }, + } - is_pos: function(frm){ + is_pos(frm){ this.set_pos_data(); - }, + } - pos_profile: function() { + pos_profile() { this.frm.doc.taxes = [] this.set_pos_data(); - }, + } - set_pos_data: function() { + set_pos_data() { if(this.frm.doc.is_pos) { this.frm.set_value("allocate_advances_automatically", 0); if(!this.frm.doc.company) { @@ -428,13 +429,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } } else this.frm.trigger("refresh"); - }, + } - amount: function(){ + amount(){ this.write_off_outstanding_amount_automatically() - }, + } - change_amount: function(){ + change_amount(){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){ this.calculate_write_off_amount(); }else { @@ -443,15 +444,15 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } this.frm.refresh_fields(); - }, + } - loyalty_amount: function(){ + loyalty_amount(){ this.calculate_outstanding_amount(); this.frm.refresh_field("outstanding_amount"); this.frm.refresh_field("paid_amount"); this.frm.refresh_field("base_paid_amount"); } -}); +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_frm})); diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index dd0f065848..c0e19e9c3d 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -61,8 +61,8 @@ frappe.ui.form.on("Purchase Order Item", { } }); -erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ - setup: function() { +erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends erpnext.buying.BuyingController { + setup() { this.frm.custom_make_buttons = { 'Purchase Receipt': 'Purchase Receipt', 'Purchase Invoice': 'Purchase Invoice', @@ -70,13 +70,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( 'Payment Entry': 'Payment', } - this._super(); + super.setup(); - }, + } - refresh: function(doc, cdt, cdn) { + refresh(doc, cdt, cdn) { var me = this; - this._super(); + super.refresh(); var allow_receipt = false; var is_drop_ship = false; @@ -182,9 +182,9 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( } else if(doc.docstatus===0) { cur_frm.cscript.add_from_mappers(); } - }, + } - get_items_from_open_material_requests: function() { + get_items_from_open_material_requests() { erpnext.utils.map_current_doc({ method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order_based_on_supplier", args: { @@ -202,17 +202,17 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( }, get_query_method: "erpnext.stock.doctype.material_request.material_request.get_material_requests_based_on_supplier" }); - }, + } - validate: function() { + validate() { set_schedule_date(this.frm); - }, + } - has_unsupplied_items: function() { + has_unsupplied_items() { return this.frm.doc['supplied_items'].some(item => item.required_qty != item.supplied_qty) - }, + } - make_stock_entry: function() { + make_stock_entry() { var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; }); var me = this; @@ -326,9 +326,9 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( me.dialog.hide(); }); - }, + } - _make_rm_stock_entry: function(rm_items) { + _make_rm_stock_entry(rm_items) { frappe.call({ method:"erpnext.buying.doctype.purchase_order.purchase_order.make_rm_stock_entry", args: { @@ -341,31 +341,31 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( frappe.set_route("Form", doclist[0].doctype, doclist[0].name); } }); - }, + } - make_inter_company_order: function(frm) { + make_inter_company_order(frm) { frappe.model.open_mapped_doc({ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order", frm: frm }); - }, + } - make_purchase_receipt: function() { + make_purchase_receipt() { frappe.model.open_mapped_doc({ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt", frm: cur_frm, freeze_message: __("Creating Purchase Receipt ...") }) - }, + } - make_purchase_invoice: function() { + make_purchase_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice", frm: cur_frm }) - }, + } - add_from_mappers: function() { + add_from_mappers() { var me = this; this.frm.add_custom_button(__('Material Request'), function() { @@ -471,13 +471,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( } }); }, __("Tools")); - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - items_add: function(doc, cdt, cdn) { + items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); if(doc.schedule_date) { row.schedule_date = doc.schedule_date; @@ -485,13 +485,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( } else { this.frm.script_manager.copy_from_first_row("items", row, ["schedule_date"]); } - }, + } - unhold_purchase_order: function(){ + unhold_purchase_order(){ cur_frm.cscript.update_status("Resume", "Draft") - }, + } - hold_purchase_order: function(){ + hold_purchase_order(){ var me = this; var d = new frappe.ui.Dialog({ title: __('Reason for Hold'), @@ -523,28 +523,28 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( } }); d.show(); - }, + } - unclose_purchase_order: function(){ + unclose_purchase_order(){ cur_frm.cscript.update_status('Re-open', 'Submitted') - }, + } - close_purchase_order: function(){ + close_purchase_order(){ cur_frm.cscript.update_status('Close', 'Closed') - }, + } - delivered_by_supplier: function(){ + delivered_by_supplier(){ cur_frm.cscript.update_status('Deliver', 'Delivered') - }, + } - items_on_form_rendered: function() { - set_schedule_date(this.frm); - }, - - schedule_date: function() { + items_on_form_rendered() { set_schedule_date(this.frm); } -}); + + schedule_date() { + set_schedule_date(this.frm); + } +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm})); diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js index b76c3784a4..ee0e1ef576 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -205,10 +205,10 @@ frappe.ui.form.on("Request for Quotation Supplier",{ }) -erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.extend({ - refresh: function() { +erpnext.buying.RequestforQuotationController = class RequestforQuotationController extends erpnext.buying.BuyingController { + refresh() { var me = this; - this._super(); + super.refresh(); if (this.frm.doc.docstatus===0) { this.frm.add_custom_button(__('Material Request'), function() { @@ -302,17 +302,17 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e me.get_suppliers_button(me.frm); }, __("Tools")); } - }, + } - calculate_taxes_and_totals: function() { + calculate_taxes_and_totals() { return; - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - get_suppliers_button: function (frm) { + get_suppliers_button (frm) { var doc = frm.doc; var dialog = new frappe.ui.Dialog({ title: __("Get Suppliers"), @@ -410,8 +410,8 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e }); dialog.show(); - }, -}); + } +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.RequestforQuotationController({frm: cur_frm})); diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index a0187b0a82..a3ba52e67b 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -4,19 +4,19 @@ // attach required files {% include 'erpnext/public/js/controllers/buying.js' %}; -erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ - setup: function() { +erpnext.buying.SupplierQuotationController = class SupplierQuotationController extends erpnext.buying.BuyingController { + setup() { this.frm.custom_make_buttons = { 'Purchase Order': 'Purchase Order', 'Quotation': 'Quotation' } - this._super(); - }, + super.setup(); + } - refresh: function() { + refresh() { var me = this; - this._super(); + super.refresh(); if (this.frm.doc.__islocal && !this.frm.doc.valid_till) { this.frm.set_value('valid_till', frappe.datetime.add_months(this.frm.doc.transaction_date, 1)); @@ -77,22 +77,22 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext }) }, __("Get Items From")); } - }, + } - make_purchase_order: function() { + make_purchase_order() { frappe.model.open_mapped_doc({ method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order", frm: cur_frm }) - }, - make_quotation: function() { + } + make_quotation() { frappe.model.open_mapped_doc({ method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_quotation", frm: cur_frm }) } -}); +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm})); diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js index 0c88d2826f..8dfee1d6c7 100644 --- a/erpnext/crm/doctype/lead/lead.js +++ b/erpnext/crm/doctype/lead/lead.js @@ -4,8 +4,8 @@ frappe.provide("erpnext"); cur_frm.email_field = "email_id"; -erpnext.LeadController = frappe.ui.form.Controller.extend({ - setup: function () { +erpnext.LeadController = class LeadController extends frappe.ui.form.Controller { + setup () { this.frm.make_methods = { 'Customer': this.make_customer, 'Quotation': this.make_quotation, @@ -13,9 +13,9 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ }; this.frm.toggle_reqd("lead_name", !this.frm.doc.organization_lead); - }, + } - onload: function () { + onload () { this.frm.set_query("customer", function (doc, cdt, cdn) { return { query: "erpnext.controllers.queries.customer_query" } }); @@ -27,9 +27,9 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ this.frm.set_query("contact_by", function (doc, cdt, cdn) { return { query: "frappe.core.doctype.user.user.user_query" } }); - }, + } - refresh: function () { + refresh () { let doc = this.frm.doc; erpnext.toggle_naming_series(); frappe.dynamic_link = { doc: doc, fieldname: 'name', doctype: 'Lead' } @@ -45,47 +45,47 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ } else { frappe.contacts.clear_address_and_contact(this.frm); } - }, + } - make_customer: function () { + make_customer () { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.lead.lead.make_customer", frm: cur_frm }) - }, + } - make_opportunity: function () { + make_opportunity () { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.lead.lead.make_opportunity", frm: cur_frm }) - }, + } - make_quotation: function () { + make_quotation () { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.lead.lead.make_quotation", frm: cur_frm }) - }, + } - organization_lead: function () { + organization_lead () { this.frm.toggle_reqd("lead_name", !this.frm.doc.organization_lead); this.frm.toggle_reqd("company_name", this.frm.doc.organization_lead); - }, + } - company_name: function () { + company_name () { if (this.frm.doc.organization_lead && !this.frm.doc.lead_name) { this.frm.set_value("lead_name", this.frm.doc.company_name); } - }, + } - contact_date: function () { + contact_date () { if (this.frm.doc.contact_date) { let d = moment(this.frm.doc.contact_date); d.add(1, "day"); this.frm.set_value("ends_on", d.format(frappe.defaultDatetimeFormat)); } } -}); +}; $.extend(cur_frm.cscript, new erpnext.LeadController({ frm: cur_frm })); diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index ac374a95f4..925c30b451 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -145,8 +145,8 @@ frappe.ui.form.on("Opportunity", { }) // TODO commonify this code -erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ - onload: function() { +erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller { + onload() { if(!this.frm.doc.status) { frm.set_value('status', 'Open'); @@ -159,9 +159,9 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ } this.setup_queries(); - }, + } - setup_queries: function() { + setup_queries() { var me = this; if(this.frm.fields_dict.contact_by.df.options.match(/^User/)) { @@ -185,15 +185,15 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ else if (me.frm.doc.opportunity_from == "Customer") { me.frm.set_query('party_name', erpnext.queries['customer']); } - }, + } - create_quotation: function() { + create_quotation() { frappe.model.open_mapped_doc({ method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation", frm: cur_frm }) } -}); +}; $.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm})); diff --git a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js index b59d848828..68e7780039 100644 --- a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js +++ b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js @@ -72,8 +72,8 @@ frappe.ui.form.on('Student Attendance Tool', { }); -education.StudentsEditor = Class.extend({ - init: function(frm, wrapper, students) { +education.StudentsEditor = class StudentsEditor { + constructor(frm, wrapper, students) { this.wrapper = wrapper; this.frm = frm; if(students.length > 0) { @@ -81,8 +81,8 @@ education.StudentsEditor = Class.extend({ } else { this.show_empty_state(); } - }, - make: function(frm, students) { + } + make(frm, students) { var me = this; $(this.wrapper).empty(); @@ -173,13 +173,13 @@ education.StudentsEditor = Class.extend({ }); $(htmls.join("")).appendTo(me.wrapper); - }, + } - show_empty_state: function() { + show_empty_state() { $(this.wrapper).html( `
${__("No Students in")} ${this.frm.doc.student_group}
` ); } -}); +}; diff --git a/erpnext/healthcare/doctype/exercise_type/exercise_type.js b/erpnext/healthcare/doctype/exercise_type/exercise_type.js index b49b00e219..06146047eb 100644 --- a/erpnext/healthcare/doctype/exercise_type/exercise_type.js +++ b/erpnext/healthcare/doctype/exercise_type/exercise_type.js @@ -9,14 +9,14 @@ frappe.ui.form.on('Exercise Type', { } }); -erpnext.ExerciseEditor = Class.extend({ - init: function(frm, wrapper) { +erpnext.ExerciseEditor = class ExerciseEditor { + constructor(frm, wrapper) { this.wrapper = wrapper; this.frm = frm; this.make(frm, wrapper); - }, + } - make: function(frm, wrapper) { + make(frm, wrapper) { $(this.wrapper).empty(); this.exercise_toolbar = $('

\ @@ -38,9 +38,9 @@ erpnext.ExerciseEditor = Class.extend({ this.make_cards(frm); this.make_buttons(frm); } - }, + } - make_cards: function(frm) { + make_cards(frm) { var me = this; $(me.exercise_cards).empty(); @@ -60,9 +60,9 @@ erpnext.ExerciseEditor = Class.extend({ `, {image_src: step.image, title: step.title, description: step.description, col_id: "col-"+i, card_id: "card-"+i, id: i})).appendTo(me.row); }); - }, + } - make_buttons: function(frm) { + make_buttons(frm) { let me = this; $('.btn-edit').on('click', function() { let id = $(this).attr('data-id'); @@ -82,9 +82,9 @@ erpnext.ExerciseEditor = Class.extend({ frm.dirty(); }, 300); }); - }, + } - show_add_card_dialog: function(frm) { + show_add_card_dialog(frm) { let me = this; let d = new frappe.ui.Dialog({ title: __('Add Exercise Step'), @@ -137,9 +137,9 @@ erpnext.ExerciseEditor = Class.extend({ primary_action_label: __('Add') }); d.show(); - }, + } - show_edit_card_dialog: function(frm, id) { + show_edit_card_dialog(frm, id) { let new_dialog = new frappe.ui.Dialog({ title: __("Edit Exercise Step"), fields: [ @@ -183,4 +183,4 @@ erpnext.ExerciseEditor = Class.extend({ }); new_dialog.show(); } -}); +}; diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index c21d4b893c..5639cc9ea4 100755 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -2,8 +2,8 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.hr"); -erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({ - setup: function() { +erpnext.hr.EmployeeController = class EmployeeController extends frappe.ui.form.Controller { + setup() { this.frm.fields_dict.user_id.get_query = function(doc, cdt, cdn) { return { query: "frappe.core.doctype.user.user.user_query", @@ -12,30 +12,30 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({ } this.frm.fields_dict.reports_to.get_query = function(doc, cdt, cdn) { return { query: "erpnext.controllers.queries.employee_query"} } - }, + } - refresh: function() { + refresh() { var me = this; erpnext.toggle_naming_series(); - }, + } - date_of_birth: function() { + date_of_birth() { return cur_frm.call({ method: "get_retirement_date", args: {date_of_birth: this.frm.doc.date_of_birth} }); - }, + } - salutation: function() { + salutation() { if(this.frm.doc.salutation) { this.frm.set_value("gender", { "Mr": "Male", "Ms": "Female" }[this.frm.doc.salutation]); } - }, + } -}); +}; frappe.ui.form.on('Employee',{ setup: function(frm) { frm.set_query("leave_policy", function() { diff --git a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js index 3205a92b1b..ab965d54e3 100644 --- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -68,13 +68,13 @@ erpnext.employee_attendance_tool = { } } -erpnext.MarkedEmployee = Class.extend({ - init: function(frm, wrapper, employee) { +erpnext.MarkedEmployee = class MarkedEmployee { + constructor(frm, wrapper, employee) { this.wrapper = wrapper; this.frm = frm; this.make(frm, employee); - }, - make: function(frm, employee) { + } + make(frm, employee) { var me = this; $(this.wrapper).empty(); @@ -104,16 +104,16 @@ erpnext.MarkedEmployee = Class.extend({ })).appendTo(row); }); } -}); +}; -erpnext.EmployeeSelector = Class.extend({ - init: function(frm, wrapper, employee) { +erpnext.EmployeeSelector = class EmployeeSelector { + constructor(frm, wrapper, employee) { this.wrapper = wrapper; this.frm = frm; this.make(frm, employee); - }, - make: function(frm, employee) { + } + make(frm, employee) { var me = this; $(this.wrapper).empty(); @@ -266,6 +266,6 @@ erpnext.EmployeeSelector = Class.extend({ mark_employee_toolbar.appendTo($(this.wrapper)); } -}); +}; diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.js b/erpnext/hr/doctype/upload_attendance/upload_attendance.js index 29aa85484a..bbafc82076 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.js +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.js @@ -5,19 +5,19 @@ frappe.provide("erpnext.hr"); -erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ - onload: function() { +erpnext.hr.AttendanceControlPanel = class AttendanceControlPanel extends frappe.ui.form.Controller { + onload() { this.frm.set_value("att_fr_date", frappe.datetime.get_today()); this.frm.set_value("att_to_date", frappe.datetime.get_today()); - }, + } - refresh: function() { + refresh() { this.frm.disable_save(); this.show_upload(); this.setup_import_progress(); - }, + } - get_template:function() { + get_template() { if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) { frappe.msgprint(__("Attendance From Date and Attendance To Date is mandatory")); return; @@ -28,7 +28,7 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ from_date: this.frm.doc.att_fr_date, to_date: this.frm.doc.att_to_date, }); - }, + } show_upload() { var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty(); @@ -36,7 +36,7 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ wrapper: $wrapper, method: 'erpnext.hr.doctype.upload_attendance.upload_attendance.upload' }); - }, + } setup_import_progress() { var $log_wrapper = $(this.frm.fields_dict.import_log.wrapper).empty(); @@ -64,6 +64,6 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ } }); } -}) +} cur_frm.cscript = new erpnext.hr.AttendanceControlPanel({frm: cur_frm}); diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js index ddbcdfde57..2adfaf45ef 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js @@ -45,8 +45,8 @@ frappe.ui.form.on('Maintenance Schedule', { }) // TODO commonify this code -erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({ - refresh: function() { +erpnext.maintenance.MaintenanceSchedule = class MaintenanceSchedule extends frappe.ui.form.Controller { + refresh() { frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'} var me = this; @@ -76,21 +76,21 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({ }); }, __('Create')); } - }, + } - start_date: function(doc, cdt, cdn) { + start_date(doc, cdt, cdn) { this.set_no_of_visits(doc, cdt, cdn); - }, + } - end_date: function(doc, cdt, cdn) { + end_date(doc, cdt, cdn) { this.set_no_of_visits(doc, cdt, cdn); - }, + } - periodicity: function(doc, cdt, cdn) { + periodicity(doc, cdt, cdn) { this.set_no_of_visits(doc, cdt, cdn); - }, + } - set_no_of_visits: function(doc, cdt, cdn) { + set_no_of_visits(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if (item.start_date && item.end_date && item.periodicity) { @@ -112,8 +112,8 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({ var no_of_visits = cint(date_diff / days_in_period[item.periodicity]); frappe.model.set_value(item.doctype, item.name, "no_of_visits", no_of_visits); } - }, -}); + } +}; $.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceSchedule({frm: cur_frm})); diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js index 4cbb02a5b3..12dc59ccfc 100644 --- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js @@ -41,8 +41,8 @@ frappe.ui.form.on('Maintenance Visit', { }) // TODO commonify this code -erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({ - refresh: function() { +erpnext.maintenance.MaintenanceVisit = class MaintenanceVisit extends frappe.ui.form.Controller { + refresh() { frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'} var me = this; @@ -96,7 +96,7 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({ }) }, __("Get Items From")); } - }, -}); + } +}; -$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm})); \ No newline at end of file +$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm})); diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index fbfd801a11..2b329448fb 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -357,16 +357,16 @@ frappe.ui.form.on("BOM", { } }); -erpnext.bom.BomController = erpnext.TransactionController.extend({ - conversion_rate: function(doc) { +erpnext.bom.BomController = class BomController extends erpnext.TransactionController { + conversion_rate(doc) { if(this.frm.doc.currency === this.get_company_currency()) { this.frm.set_value("conversion_rate", 1.0); } else { erpnext.bom.update_cost(doc); } - }, + } - item_code: function(doc, cdt, cdn){ + item_code(doc, cdt, cdn){ var scrap_items = false; var child = locals[cdt][cdn]; if (child.doctype == 'BOM Scrap Item') { @@ -378,19 +378,19 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({ } get_bom_material_detail(doc, cdt, cdn, scrap_items); - }, + } - buying_price_list: function(doc) { + buying_price_list(doc) { this.apply_price_list(); - }, + } - plc_conversion_rate: function(doc) { + plc_conversion_rate(doc) { if (!this.in_apply_price_list) { this.apply_price_list(null, true); } - }, + } - conversion_factor: function(doc, cdt, cdn) { + conversion_factor(doc, cdt, cdn) { if (frappe.meta.get_docfield(cdt, "stock_qty", cdn)) { var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "conversion_factor"]); @@ -399,8 +399,8 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({ this.toggle_conversion_factor(item); this.frm.events.update_cost(this.frm); } - }, -}); + } +}; $.extend(cur_frm.cscript, new erpnext.bom.BomController({frm: cur_frm})); diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 757f33eecc..413a5ee971 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ - init: function(wrapper, title) { - this._super({ +erpnext.AccountTreeGrid = class AccountTreeGrid extends frappe.views.TreeGridReport { + constructor(wrapper, title) { + super({ title: title, parent: $(wrapper).find('.layout-main'), page: wrapper.page, @@ -33,8 +33,24 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ } }, }); - }, - setup_columns: function() { + + this.filters = [ + {fieldtype: "Select", label: __("Company"), link:"Company", fieldname: "company", + default_value: __("Select Company..."), + filter: function(val, item, opts, me) { + if (item.company == val || val == opts.default_value) { + return me.apply_zero_filter(val, item, opts, me); + } + return false; + }}, + {fieldtype: "Select", label: "Fiscal Year", link:"Fiscal Year", fieldname: "fiscal_year", + default_value: __("Select Fiscal Year...")}, + {fieldtype: "Date", label: __("From Date"), fieldname: "from_date"}, + {fieldtype: "Label", label: __("To")}, + {fieldtype: "Date", label: __("To Date"), fieldname: "to_date"} + ] + } + setup_columns() { this.columns = [ {id: "name", name: __("Account"), field: "name", width: 300, cssClass: "cell-title"}, {id: "opening_dr", name: __("Opening (Dr)"), field: "opening_dr", width: 100, @@ -50,25 +66,10 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ {id: "closing_cr", name: __("Closing (Cr)"), field: "closing_cr", width: 100, formatter: this.currency_formatter} ]; + } - }, - filters: [ - {fieldtype: "Select", label: __("Company"), link:"Company", fieldname: "company", - default_value: __("Select Company..."), - filter: function(val, item, opts, me) { - if (item.company == val || val == opts.default_value) { - return me.apply_zero_filter(val, item, opts, me); - } - return false; - }}, - {fieldtype: "Select", label: "Fiscal Year", link:"Fiscal Year", fieldname: "fiscal_year", - default_value: __("Select Fiscal Year...")}, - {fieldtype: "Date", label: __("From Date"), fieldname: "from_date"}, - {fieldtype: "Label", label: __("To")}, - {fieldtype: "Date", label: __("To Date"), fieldname: "to_date"} - ], - setup_filters: function() { - this._super(); + setup_filters() { + super.setup_filters(); var me = this; // default filters this.filter_inputs.fiscal_year.change(function() { @@ -83,8 +84,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }); me.show_zero_check() if(me.ignore_closing_entry) me.ignore_closing_entry(); - }, - prepare_data: function() { + } + prepare_data() { var me = this; if(!this.primary_data) { // make accounts list @@ -113,12 +114,12 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ this.set_indent(); this.prepare_balances(); - }, - init_account: function(d) { + } + init_account(d) { this.reset_item_values(d); - }, + } - prepare_balances: function() { + prepare_balances() { var gl = frappe.report_dump.data['GL Entry']; var me = this; @@ -139,8 +140,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }); this.update_groups(); - }, - update_balances: function(account, posting_date, v) { + } + update_balances(account, posting_date, v) { // opening if (posting_date < this.opening_date || v.is_opening === "Yes") { if (account.report_type === "Profit and Loss" && @@ -161,8 +162,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ var closing_bal = flt(account.opening_dr) - flt(account.opening_cr) + flt(account.debit) - flt(account.credit); this.set_debit_or_credit(account, "closing", closing_bal); - }, - set_debit_or_credit: function(account, field, balance) { + } + set_debit_or_credit(account, field, balance) { if(balance > 0) { account[field+"_dr"] = balance; account[field+"_cr"] = 0; @@ -170,8 +171,8 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ account[field+"_cr"] = Math.abs(balance); account[field+"_dr"] = 0; } - }, - update_groups: function() { + } + update_groups() { // update groups var me= this; $.each(this.data, function(i, account) { @@ -202,9 +203,9 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ } } }); - }, + } - set_fiscal_year: function() { + set_fiscal_year() { if (this.opening_date > this.closing_date) { frappe.msgprint(__("Opening Date should be before Closing Date")); return; @@ -223,9 +224,9 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ frappe.msgprint(__("Opening Date and Closing Date should be within same Fiscal Year")); return; } - }, + } - show_general_ledger: function(account) { + show_general_ledger(account) { frappe.route_options = { account: account, company: this.company, @@ -234,4 +235,4 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ }; frappe.set_route("query-report", "General Ledger"); } -}); +}; diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 67b12fbca4..8ceae83620 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -9,14 +9,14 @@ cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; cur_frm.email_field = "contact_email"; -erpnext.buying.BuyingController = erpnext.TransactionController.extend({ - setup: function() { - this._super(); - }, +erpnext.buying.BuyingController = class BuyingController extends erpnext.TransactionController { + setup() { + super.setup(); + } - onload: function(doc, cdt, cdn) { + onload(doc, cdt, cdn) { this.setup_queries(doc, cdt, cdn); - this._super(); + super.onload(); this.frm.set_query('shipping_rule', function() { return { @@ -48,9 +48,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }); } /* eslint-enable */ - }, + } - setup_queries: function(doc, cdt, cdn) { + setup_queries(doc, cdt, cdn) { var me = this; if(this.frm.fields_dict.buying_price_list) { @@ -109,9 +109,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ return me.set_query_for_item_tax_template(doc, cdt, cdn) }); } - }, + } - refresh: function(doc) { + refresh(doc) { frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'supplier', doctype: 'Supplier'}; this.frm.toggle_display("supplier_name", @@ -122,38 +122,38 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this.set_from_product_bundle(); } - this._super(); - }, + super.refresh(); + } - supplier: function() { + supplier() { var me = this; erpnext.utils.get_party_details(this.frm, null, null, function(){ me.apply_price_list(); }); - }, + } - supplier_address: function() { + supplier_address() { erpnext.utils.get_address_display(this.frm); erpnext.utils.set_taxes_from_address(this.frm, "supplier_address", "supplier_address", "supplier_address"); - }, + } - buying_price_list: function() { + buying_price_list() { this.apply_price_list(); - }, + } - discount_percentage: function(doc, cdt, cdn) { + discount_percentage(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); item.discount_amount = 0.0; this.price_list_rate(doc, cdt, cdn); - }, + } - discount_amount: function(doc, cdt, cdn) { + discount_amount(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); item.discount_percentage = 0.0; this.price_list_rate(doc, cdt, cdn); - }, + } - qty: function(doc, cdt, cdn) { + qty(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if ((doc.doctype == "Purchase Receipt") || (doc.doctype == "Purchase Invoice" && (doc.update_stock || doc.is_return))) { frappe.model.round_floats_in(item, ["qty", "received_qty"]); @@ -168,22 +168,22 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item)); item.received_stock_qty = flt(item.conversion_factor, precision("conversion_factor", item)) * flt(item.received_qty); } - this._super(doc, cdt, cdn); - }, + super.qty(doc, cdt, cdn); + } - batch_no: function(doc, cdt, cdn) { - this._super(doc, cdt, cdn); - }, + batch_no(doc, cdt, cdn) { + super.batch_no(doc, cdt, cdn); + } - received_qty: function(doc, cdt, cdn) { + received_qty(doc, cdt, cdn) { this.calculate_accepted_qty(doc, cdt, cdn) - }, + } - rejected_qty: function(doc, cdt, cdn) { + rejected_qty(doc, cdt, cdn) { this.calculate_accepted_qty(doc, cdt, cdn) - }, + } - calculate_accepted_qty: function(doc, cdt, cdn){ + calculate_accepted_qty(doc, cdt, cdn){ var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]); @@ -191,9 +191,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item)); this.qty(doc, cdt, cdn); - }, + } - validate_negative_quantity: function(cdt, cdn, item, fieldnames){ + validate_negative_quantity(cdt, cdn, item, fieldnames){ if(!item || !fieldnames) { return } var is_negative_qty = false; @@ -206,9 +206,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } return is_negative_qty - }, + } - warehouse: function(doc, cdt, cdn) { + warehouse(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.warehouse) { return this.frm.call({ @@ -220,9 +220,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }); } - }, + } - project: function(doc, cdt, cdn) { + project(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if(item.project) { $.each(this.frm.doc["items"] || [], @@ -233,48 +233,48 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }); } - }, + } - rejected_warehouse: function(doc, cdt) { + rejected_warehouse(doc, cdt) { // trigger autofill_warehouse only if parent rejected_warehouse field is triggered if (["Purchase Invoice", "Purchase Receipt"].includes(cdt)) { this.autofill_warehouse(doc.items, "rejected_warehouse", doc.rejected_warehouse); } - }, + } - category: function(doc, cdt, cdn) { + category(doc, cdt, cdn) { // should be the category field of tax table if(cdt != doc.doctype) { this.calculate_taxes_and_totals(); } - }, - add_deduct_tax: function(doc, cdt, cdn) { + } + add_deduct_tax(doc, cdt, cdn) { this.calculate_taxes_and_totals(); - }, + } - set_from_product_bundle: function() { + set_from_product_bundle() { var me = this; this.frm.add_custom_button(__("Product Bundle"), function() { erpnext.buying.get_items_from_product_bundle(me.frm); }, __("Get Items From")); - }, + } - shipping_address: function(){ + shipping_address(){ var me = this; erpnext.utils.get_address_display(this.frm, "shipping_address", "shipping_address_display", true); - }, + } - billing_address: function() { + billing_address() { erpnext.utils.get_address_display(this.frm, "billing_address", "billing_address_display", true); - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - update_auto_repeat_reference: function(doc) { + update_auto_repeat_reference(doc) { if (doc.auto_repeat) { frappe.call({ method:"frappe.automation.doctype.auto_repeat.auto_repeat.update_reference", @@ -291,9 +291,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }) } - }, + } - manufacturer: function(doc, cdt, cdn) { + manufacturer(doc, cdt, cdn) { const row = locals[cdt][cdn]; if(row.manufacturer) { @@ -310,9 +310,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }); } - }, + } - manufacturer_part_no: function(doc, cdt, cdn) { + manufacturer_part_no(doc, cdt, cdn) { const row = locals[cdt][cdn]; if (row.manufacturer_part_no) { @@ -335,7 +335,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } } -}); +}; cur_frm.add_fetch('project', 'cost_center', 'cost_center'); @@ -496,4 +496,4 @@ erpnext.buying.get_items_from_product_bundle = function(frm) { }); dialog.show(); -} \ No newline at end of file +} diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js index 87b21b78de..d346357a8f 100644 --- a/erpnext/public/js/controllers/stock_controller.js +++ b/erpnext/public/js/controllers/stock_controller.js @@ -3,22 +3,22 @@ frappe.provide("erpnext.stock"); -erpnext.stock.StockController = frappe.ui.form.Controller.extend({ - onload: function() { +erpnext.stock.StockController = class StockController extends frappe.ui.form.Controller { + onload() { // warehouse query if company if (this.frm.fields_dict.company) { this.setup_warehouse_query(); } - }, + } - setup_warehouse_query: function() { + setup_warehouse_query() { var me = this; erpnext.queries.setup_queries(this.frm, "Warehouse", function() { return erpnext.queries.warehouse(me.frm.doc); }); - }, + } - setup_posting_date_time_check: function() { + setup_posting_date_time_check() { // make posting date default and read only unless explictly checked frappe.ui.form.on(this.frm.doctype, 'set_posting_date_and_time_read_only', function(frm) { if(frm.doc.docstatus == 0 && frm.doc.set_posting_time) { @@ -46,9 +46,9 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ frm.trigger('set_posting_date_and_time_read_only'); } }); - }, + } - show_stock_ledger: function() { + show_stock_ledger() { var me = this; if(this.frm.doc.docstatus > 0) { cur_frm.add_custom_button(__("Stock Ledger"), function() { @@ -63,9 +63,9 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ }, __("View")); } - }, + } - show_general_ledger: function() { + show_general_ledger() { var me = this; if(this.frm.doc.docstatus > 0) { cur_frm.add_custom_button(__('Accounting Ledger'), function() { @@ -81,4 +81,4 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ }, __("View")); } } -}); +}; diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 3a3ee3858b..448bb65364 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -1,12 +1,12 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -erpnext.taxes_and_totals = erpnext.payments.extend({ - setup: function() { +erpnext.taxes_and_totals = class taxes_and_totals extends erpnext.payments { + setup() { this.fetch_round_off_accounts(); - }, + } - apply_pricing_rule_on_item: function(item) { + apply_pricing_rule_on_item(item) { let effective_item_rate = item.price_list_rate; let item_rate = item.rate; if (in_list(["Sales Order", "Quotation"], item.parenttype) && item.blanket_order_rate) { @@ -32,9 +32,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } frappe.model.set_value(item.doctype, item.name, "rate", item_rate); - }, + } - calculate_taxes_and_totals: function(update_paid_amount) { + calculate_taxes_and_totals(update_paid_amount) { this.discount_amount_applied = false; this._calculate_taxes_and_totals(); this.calculate_discount_amount(); @@ -63,16 +63,16 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } this.frm.refresh_fields(); - }, + } - calculate_discount_amount: function(){ + calculate_discount_amount(){ if (frappe.meta.get_docfield(this.frm.doc.doctype, "discount_amount")) { this.set_discount_amount(); this.apply_discount_amount(); } - }, + } - _calculate_taxes_and_totals: function() { + _calculate_taxes_and_totals() { this.validate_conversion_rate(); this.calculate_item_values(); this.initialize_taxes(); @@ -82,9 +82,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.manipulate_grand_total_for_inclusive_tax(); this.calculate_totals(); this._cleanup(); - }, + } - validate_conversion_rate: function() { + validate_conversion_rate() { this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, (cur_frm) ? precision("conversion_rate") : 9); var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate", this.frm.doc.name); @@ -99,9 +99,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ frappe.throw(err_message); } } - }, + } - calculate_item_values: function() { + calculate_item_values() { var me = this; if (!this.discount_amount_applied) { $.each(this.frm.doc["items"] || [], function(i, item) { @@ -121,16 +121,16 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]); }); } - }, + } - set_in_company_currency: function(doc, fields) { + set_in_company_currency(doc, fields) { var me = this; $.each(fields, function(i, f) { doc["base_"+f] = flt(flt(doc[f], precision(f, doc)) * me.frm.doc.conversion_rate, precision("base_" + f, doc)); }); - }, + } - initialize_taxes: function() { + initialize_taxes() { var me = this; $.each(this.frm.doc["taxes"] || [], function(i, tax) { @@ -152,9 +152,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } frappe.model.round_floats_in(tax); }); - }, + } - fetch_round_off_accounts: function() { + fetch_round_off_accounts() { let me = this; frappe.flags.round_off_applicable_accounts = []; @@ -170,9 +170,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } }); } - }, + } - determine_exclusive_rate: function() { + determine_exclusive_rate() { var me = this; var has_inclusive_tax = false; @@ -210,9 +210,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ me.set_in_company_currency(item, ["net_rate", "net_amount"]); } }); - }, + } - get_current_tax_fraction: function(tax, item_tax_map) { + get_current_tax_fraction(tax, item_tax_map) { // Get tax fraction for calculating tax exclusive amount // from tax inclusive amount var current_tax_fraction = 0.0; @@ -241,14 +241,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ inclusive_tax_amount_per_qty *= -1; } return [current_tax_fraction, inclusive_tax_amount_per_qty]; - }, + } - _get_tax_rate: function(tax, item_tax_map) { + _get_tax_rate(tax, item_tax_map) { return (Object.keys(item_tax_map).indexOf(tax.account_head) != -1) ? flt(item_tax_map[tax.account_head], precision("rate", tax)) : tax.rate; - }, + } - calculate_net_total: function() { + calculate_net_total() { var me = this; this.frm.doc.total_qty = this.frm.doc.total = this.frm.doc.base_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0; @@ -261,9 +261,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ }); frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]); - }, + } - calculate_taxes: function() { + calculate_taxes() { var me = this; this.frm.doc.rounding_adjustment = 0; var actual_tax_dict = {}; @@ -339,9 +339,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } }); }); - }, + } - set_cumulative_total: function(row_idx, tax) { + set_cumulative_total(row_idx, tax) { var tax_amount = tax.tax_amount_after_discount_amount; if (tax.category == 'Valuation') { tax_amount = 0; @@ -354,13 +354,13 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } else { tax.total = flt(this.frm.doc["taxes"][row_idx-1].total + tax_amount, precision("total", tax)); } - }, + } - _load_item_tax_rate: function(item_tax_rate) { + _load_item_tax_rate(item_tax_rate) { return item_tax_rate ? JSON.parse(item_tax_rate) : {}; - }, + } - get_current_tax_amount: function(item, tax, item_tax_map) { + get_current_tax_amount(item, tax, item_tax_map) { var tax_rate = this._get_tax_rate(tax, item_tax_map); var current_tax_amount = 0.0; @@ -397,17 +397,17 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); return current_tax_amount; - }, + } - get_final_tax_amount: function(tax, current_tax_amount) { + get_final_tax_amount(tax, current_tax_amount) { if (frappe.flags.round_off_applicable_accounts.includes(tax.account_head)) { current_tax_amount = Math.round(current_tax_amount); } return current_tax_amount; - }, + } - set_item_wise_tax: function(item, tax, tax_rate, current_tax_amount) { + set_item_wise_tax(item, tax, tax_rate, current_tax_amount) { // store tax breakup for each item let tax_detail = tax.item_wise_tax_detail; let key = item.item_code || item.item_name; @@ -417,14 +417,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ item_wise_tax_amount += tax_detail[key][1]; tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax))]; - }, + } - round_off_totals: function(tax) { + round_off_totals(tax) { tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax)); tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax)); - }, + } - manipulate_grand_total_for_inclusive_tax: function() { + manipulate_grand_total_for_inclusive_tax() { var me = this; // if fully inclusive taxes and diff if (this.frm.doc["taxes"] && this.frm.doc["taxes"].length) { @@ -455,9 +455,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } } } - }, + } - calculate_totals: function() { + calculate_totals() { // Changing sequence can cause rounding_adjustmentng issue and on-screen discrepency var me = this; var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0; @@ -503,9 +503,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ // rounded totals this.set_rounded_total(); - }, + } - set_rounded_total: function() { + set_rounded_total() { var disable_rounded_total = 0; if(frappe.meta.get_docfield(this.frm.doc.doctype, "disable_rounded_total", this.frm.doc.name)) { disable_rounded_total = this.frm.doc.disable_rounded_total; @@ -527,9 +527,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.set_in_company_currency(this.frm.doc, ["rounding_adjustment", "rounded_total"]); } - }, + } - _cleanup: function() { + _cleanup() { this.frm.doc.base_in_words = this.frm.doc.in_words = ""; if(this.frm.doc["items"] && this.frm.doc["items"].length) { @@ -556,16 +556,16 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ tax.item_wise_tax_detail = JSON.stringify(tax.item_wise_tax_detail); }); } - }, + } - set_discount_amount: function() { + set_discount_amount() { if(this.frm.doc.additional_discount_percentage) { this.frm.doc.discount_amount = flt(flt(this.frm.doc[frappe.scrub(this.frm.doc.apply_discount_on)]) * this.frm.doc.additional_discount_percentage / 100, precision("discount_amount")); } - }, + } - apply_discount_amount: function() { + apply_discount_amount() { var me = this; var distributed_amount = 0.0; this.frm.doc.base_discount_amount = 0.0; @@ -603,9 +603,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this._calculate_taxes_and_totals(); } } - }, + } - get_total_for_discount_amount: function() { + get_total_for_discount_amount() { if(this.frm.doc.apply_discount_on == "Net Total") { return this.frm.doc.net_total; } else { @@ -629,27 +629,27 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ return flt(this.frm.doc.grand_total - total_actual_tax, precision("grand_total")); } - }, + } - calculate_total_advance: function(update_paid_amount) { + calculate_total_advance(update_paid_amount) { var total_allocated_amount = frappe.utils.sum($.map(this.frm.doc["advances"] || [], function(adv) { return flt(adv.allocated_amount, precision("allocated_amount", adv)); })); this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance")); this.calculate_outstanding_amount(update_paid_amount); - }, + } - is_internal_invoice: function() { + is_internal_invoice() { if (['Sales Invoice', 'Purchase Invoice'].includes(this.frm.doc.doctype)) { if (this.frm.doc.company === this.frm.doc.represents_company) { return true; } } return false; - }, + } - calculate_outstanding_amount: function(update_paid_amount) { + calculate_outstanding_amount(update_paid_amount) { // NOTE: // paid_amount and write_off_amount is only for POS/Loyalty Point Redemption Invoice // total_advance is only for non POS Invoice @@ -697,9 +697,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.frm.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount) + flt(this.frm.doc.change_amount * this.frm.doc.conversion_rate), precision("outstanding_amount")); } - }, + } - update_paid_amount_for_return: function() { + update_paid_amount_for_return() { var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total; if(this.frm.doc.party_account_currency == this.frm.doc.currency) { @@ -723,9 +723,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.frm.refresh_fields(); this.calculate_paid_amount(); - }, + } - set_default_payment: function(total_amount_to_pay, update_paid_amount) { + set_default_payment(total_amount_to_pay, update_paid_amount) { var me = this; var payment_status = true; if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)) { @@ -741,9 +741,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } }); } - }, + } - calculate_paid_amount: function() { + calculate_paid_amount() { var me = this; var paid_amount = 0.0; var base_paid_amount = 0.0; @@ -763,9 +763,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.frm.set_value('paid_amount', flt(paid_amount, precision("paid_amount"))); this.frm.set_value('base_paid_amount', flt(base_paid_amount, precision("base_paid_amount"))); - }, + } - calculate_change_amount: function(){ + calculate_change_amount(){ this.frm.doc.change_amount = 0.0; this.frm.doc.base_change_amount = 0.0; if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) @@ -784,9 +784,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ precision("base_change_amount")); } } - }, + } - calculate_write_off_amount: function(){ + calculate_write_off_amount(){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){ this.frm.doc.write_off_amount = flt(this.frm.doc.grand_total - this.frm.doc.paid_amount + this.frm.doc.change_amount, precision("write_off_amount")); @@ -798,4 +798,4 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ } this.calculate_outstanding_amount(false); } -}); +}; diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 1c0abdffcf..a4c165e9ee 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -3,9 +3,9 @@ frappe.provide('erpnext.accounts.dimensions'); -erpnext.TransactionController = erpnext.taxes_and_totals.extend({ - setup: function() { - this._super(); +erpnext.TransactionController = class TransactionController extends erpnext.taxes_and_totals { + setup() { + super.setup(); frappe.flags.hide_serial_batch_dialog = true; frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); @@ -222,8 +222,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } - }, - onload: function() { + } + onload() { var me = this; if(this.frm.doc.__islocal) { @@ -249,15 +249,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } ]); } - }, + } - is_return: function() { + is_return() { if(!this.frm.doc.is_return && this.frm.doc.return_against) { this.frm.set_value('return_against', ''); } - }, + } - setup_quality_inspection: function() { + setup_quality_inspection() { if(!in_list(["Delivery Note", "Sales Invoice", "Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)) { return; } @@ -290,9 +290,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } } }); - }, + } - make_payment_request: function() { + make_payment_request() { var me = this; const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], this.frm.doc.doctype)) ? "Inward" : "Outward"; @@ -314,9 +314,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } } }) - }, + } - onload_post_render: function() { + onload_post_render() { if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length && !(this.frm.doc.__onload ? this.frm.doc.__onload.load_after_mapping : false)) { frappe.after_ajax(() => this.apply_default_taxes()); @@ -328,9 +328,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.setup_item_selector(); this.frm.get_field("items").grid.set_multiple_add("item_code", "qty"); } - }, + } - refresh: function() { + refresh() { erpnext.toggle_naming_series(); erpnext.hide_company(); this.set_dynamic_labels(); @@ -360,9 +360,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ .appendTo($input_group); } } - }, + } - scan_barcode: function() { + scan_barcode() { let scan_barcode_field = this.frm.fields_dict["scan_barcode"]; let show_description = function(idx, exist = null) { @@ -434,9 +434,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } return false; - }, + } - apply_default_taxes: function() { + apply_default_taxes() { var me = this; var taxes_and_charges_field = frappe.meta.get_docfield(me.frm.doc.doctype, "taxes_and_charges", me.frm.doc.name); @@ -475,22 +475,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); } - }, + } - setup_sms: function() { + setup_sms() { var me = this; let blacklist = ['Purchase Invoice', 'BOM']; if(this.frm.doc.docstatus===1 && !in_list(["Lost", "Stopped", "Closed"], this.frm.doc.status) && !blacklist.includes(this.frm.doctype)) { this.frm.page.add_menu_item(__('Send SMS'), function() { me.send_sms(); }); } - }, + } - send_sms: function() { + send_sms() { var sms_man = new erpnext.SMSManager(this.frm.doc); - }, + } - barcode: function(doc, cdt, cdn) { + barcode(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(d.barcode=="" || d.barcode==null) { // barcode cleared, remove item @@ -499,9 +499,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.frm.from_barcode = this.frm.from_barcode ? this.frm.from_barcode + 1 : 1; this.item_code(doc, cdt, cdn); - }, + } - item_code: function(doc, cdt, cdn) { + item_code(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); var update_stock = 0, show_batch_dialog = 0; @@ -647,9 +647,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } } - }, + } - price_list_rate: function(doc, cdt, cdn) { + price_list_rate(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]); @@ -661,17 +661,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ precision("rate", item)); this.calculate_taxes_and_totals(); - }, + } - margin_rate_or_amount: function(doc, cdt, cdn) { + margin_rate_or_amount(doc, cdt, cdn) { // calculated the revised total margin and rate on margin rate changes let item = frappe.get_doc(cdt, cdn); this.apply_pricing_rule_on_item(item); this.calculate_taxes_and_totals(); cur_frm.refresh_fields(); - }, + } - margin_type: function(doc, cdt, cdn) { + margin_type(doc, cdt, cdn) { // calculate the revised total margin and rate on margin type changes let item = frappe.get_doc(cdt, cdn); if (!item.margin_type) { @@ -681,9 +681,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.calculate_taxes_and_totals(); cur_frm.refresh_fields(); } - }, + } - get_incoming_rate: function(item, posting_date, posting_time, voucher_type, company) { + get_incoming_rate(item, posting_date, posting_time, voucher_type, company) { let item_args = { 'item_code': item.item_code, @@ -706,9 +706,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ frappe.model.set_value(item.doctype, item.name, 'rate', r.message * item.conversion_factor); } }); - }, + } - add_taxes_from_item_tax_template: function(item_tax_map) { + add_taxes_from_item_tax_template(item_tax_map) { let me = this; if(item_tax_map && cint(frappe.defaults.get_default("add_taxes_from_item_tax_template"))) { @@ -726,9 +726,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); } - }, + } - serial_no: function(doc, cdt, cdn) { + serial_no(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); @@ -763,17 +763,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } } } - }, + } - validate: function() { + validate() { this.calculate_taxes_and_totals(false); - }, + } - update_stock: function() { + update_stock() { this.frm.trigger('set_default_internal_warehouse'); - }, + } - set_default_internal_warehouse: function() { + set_default_internal_warehouse() { let me = this; if ((this.frm.doc.doctype === 'Sales Invoice' && me.frm.doc.update_stock) || this.frm.doc.doctype == 'Delivery Note') { @@ -792,9 +792,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } } - }, + } - company: function() { + company() { var me = this; var set_pricing = function() { if(me.frm.doc.company && me.frm.fields_dict.currency) { @@ -901,16 +901,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if(this.frm.doc.company) { erpnext.last_selected_company = this.frm.doc.company; } - }, + } - transaction_date: function() { + transaction_date() { if (this.frm.doc.transaction_date) { this.frm.transaction_date = this.frm.doc.transaction_date; frappe.ui.form.trigger(this.frm.doc.doctype, "currency"); } - }, + } - posting_date: function() { + posting_date() { var me = this; if (this.frm.doc.posting_date) { this.frm.posting_date = this.frm.doc.posting_date; @@ -939,9 +939,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ frappe.ui.form.trigger(me.frm.doc.doctype, "currency"); } } - }, + } - due_date: function() { + due_date() { // due_date is to be changed, payment terms template and/or payment schedule must // be removed as due_date is automatically changed based on payment terms if (this.frm.doc.due_date && !this.frm.updating_party_details && !this.frm.doc.is_pos) { @@ -964,13 +964,13 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ frappe.msgprint(final_message); } } - }, + } - bill_date: function() { + bill_date() { this.posting_date(); - }, + } - recalculate_terms: function() { + recalculate_terms() { const doc = this.frm.doc; if (doc.payment_terms_template) { this.payment_terms_template(); @@ -989,17 +989,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } ); } - }, + } - get_company_currency: function() { + get_company_currency() { return erpnext.get_currency(this.frm.doc.company); - }, + } - contact_person: function() { + contact_person() { erpnext.utils.get_contact_details(this.frm); - }, + } - currency: function() { + currency() { /* manqala 19/09/2016: let the translation date be whichever of the transaction_date or posting_date is available */ var transaction_date = this.frm.doc.transaction_date || this.frm.doc.posting_date; /* end manqala */ @@ -1021,9 +1021,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } else { this.conversion_rate(); } - }, + } - conversion_rate: function() { + conversion_rate() { const me = this.frm; if(this.frm.doc.currency === this.get_company_currency()) { this.frm.set_value("conversion_rate", 1.0); @@ -1043,9 +1043,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } // Make read only if Accounts Settings doesn't allow stale rates this.frm.set_df_property("conversion_rate", "read_only", erpnext.stale_rate_allowed() ? 0 : 1); - }, + } - shipping_rule: function() { + shipping_rule() { var me = this; if(this.frm.doc.shipping_rule) { return this.frm.call({ @@ -1061,9 +1061,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ else { me.calculate_taxes_and_totals(); } - }, + } - set_margin_amount_based_on_currency: function(exchange_rate) { + set_margin_amount_based_on_currency(exchange_rate) { if (in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "Purchase Invoice", "Purchase Order", "Purchase Receipt"]), this.frm.doc.doctype) { var me = this; $.each(this.frm.doc.items || [], function(i, d) { @@ -1073,9 +1073,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); } - }, + } - set_actual_charges_based_on_currency: function(exchange_rate) { + set_actual_charges_based_on_currency(exchange_rate) { var me = this; $.each(this.frm.doc.taxes || [], function(i, d) { if(d.charge_type == "Actual") { @@ -1083,9 +1083,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ flt(d.tax_amount) / flt(exchange_rate)); } }); - }, + } - get_exchange_rate: function(transaction_date, from_currency, to_currency, callback) { + get_exchange_rate(transaction_date, from_currency, to_currency, callback) { var args; if (["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].includes(this.frm.doctype)) { args = "for_selling"; @@ -1107,9 +1107,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ callback(flt(r.message)); } }); - }, + } - price_list_currency: function() { + price_list_currency() { var me=this; this.set_dynamic_labels(); @@ -1123,9 +1123,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } else { this.plc_conversion_rate(); } - }, + } - plc_conversion_rate: function() { + plc_conversion_rate() { if(this.frm.doc.price_list_currency === this.get_company_currency()) { this.frm.set_value("plc_conversion_rate", 1.0); } else if(this.frm.doc.price_list_currency === this.frm.doc.currency @@ -1137,9 +1137,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if(!this.in_apply_price_list) { this.apply_price_list(null, true); } - }, + } - uom: function(doc, cdt, cdn) { + uom(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.uom) { @@ -1157,9 +1157,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } me.calculate_stock_uom_rate(doc, cdt, cdn); - }, + } - conversion_factor: function(doc, cdt, cdn, dont_fetch_price_list_rate) { + conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate) { if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) { var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "conversion_factor"]); @@ -1179,35 +1179,35 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } this.calculate_stock_uom_rate(doc, cdt, cdn); } - }, + } - batch_no: function(doc, cdt, cdn) { + batch_no(doc, cdt, cdn) { let item = frappe.get_doc(cdt, cdn); this.apply_price_list(item, true); - }, + } - toggle_conversion_factor: function(item) { + toggle_conversion_factor(item) { // toggle read only property for conversion factor field if the uom and stock uom are same if(this.frm.get_field('items').grid.fields_map.conversion_factor) { this.frm.fields_dict.items.grid.toggle_enable("conversion_factor", ((item.uom != item.stock_uom) && !frappe.meta.get_docfield(cur_frm.fields_dict.items.grid.doctype, "conversion_factor").read_only)? true: false); } - }, + } - qty: function(doc, cdt, cdn) { + qty(doc, cdt, cdn) { let item = frappe.get_doc(cdt, cdn); this.conversion_factor(doc, cdt, cdn, true); this.calculate_stock_uom_rate(doc, cdt, cdn); this.apply_pricing_rule(item, true); - }, + } - calculate_stock_uom_rate: function(doc, cdt, cdn) { + calculate_stock_uom_rate(doc, cdt, cdn) { let item = frappe.get_doc(cdt, cdn); - item.stock_uom_rate = flt(item.rate)/flt(item.conversion_factor); + item.stock_uom_rate = flt(item.rate)/flt(item.conversion_factor); refresh_field("stock_uom_rate", item.name, item.parentfield); - }, - service_stop_date: function(frm, cdt, cdn) { + } + service_stop_date(frm, cdt, cdn) { var child = locals[cdt][cdn]; if(child.service_stop_date) { @@ -1223,9 +1223,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ frappe.throw(__("Service Stop Date cannot be after Service End Date")); } } - }, + } - service_start_date: function(frm, cdt, cdn) { + service_start_date(frm, cdt, cdn) { var child = locals[cdt][cdn]; if(child.service_start_date) { @@ -1237,9 +1237,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }) } - }, + } - calculate_net_weight: function(){ + calculate_net_weight(){ /* Calculate Total Net Weight then further applied shipping rule to calculate shipping charges.*/ var me = this; this.frm.doc.total_net_weight= 0.0; @@ -1249,9 +1249,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); refresh_field("total_net_weight"); this.shipping_rule(); - }, + } - set_dynamic_labels: function() { + set_dynamic_labels() { // What TODO? should we make price list system non-mandatory? this.frm.toggle_reqd("plc_conversion_rate", !!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency)); @@ -1260,9 +1260,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.change_form_labels(company_currency); this.change_grid_labels(company_currency); this.frm.refresh_fields(); - }, + } - change_form_labels: function(company_currency) { + change_form_labels(company_currency) { var me = this; this.frm.set_currency_labels(["base_total", "base_net_total", "base_total_taxes_and_charges", @@ -1309,9 +1309,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if(frappe.meta.get_docfield(cur_frm.doctype, "base_net_total")) cur_frm.toggle_display("base_net_total", (show && (me.frm.doc.currency != company_currency))); - }, + } - change_grid_labels: function(company_currency) { + change_grid_labels(company_currency) { var me = this; this.frm.set_currency_labels(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount", "base_rate_with_margin"], @@ -1375,21 +1375,21 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ // set labels var $wrapper = $(this.frm.wrapper); - }, + } - recalculate: function() { + recalculate() { this.calculate_taxes_and_totals(); - }, + } - recalculate_values: function() { + recalculate_values() { this.calculate_taxes_and_totals(); - }, + } - calculate_charges: function() { + calculate_charges() { this.calculate_taxes_and_totals(); - }, + } - ignore_pricing_rule: function() { + ignore_pricing_rule() { if(this.frm.doc.ignore_pricing_rule) { var me = this; var item_list = []; @@ -1423,9 +1423,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } else { this.apply_pricing_rule(); } - }, + } - apply_pricing_rule: function(item, calculate_taxes_and_totals) { + apply_pricing_rule(item, calculate_taxes_and_totals) { var me = this; var args = this._get_args(item); if (!(args.items && args.items.length)) { @@ -1444,9 +1444,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } } }); - }, + } - _get_args: function(item) { + _get_args(item) { var me = this; return { "items": this._get_item_list(item), @@ -1474,9 +1474,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ "pos_profile": me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '', "coupon_code": me.frm.doc.coupon_code }; - }, + } - _get_item_list: function(item) { + _get_item_list(item) { var item_list = []; var append_item = function(d) { if (d.item_code) { @@ -1517,9 +1517,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } return item_list; - }, + } - _set_values_for_item_list: function(children) { + _set_values_for_item_list(children) { var me = this; var price_list_rate_changed = false; var items_rule_dict = {}; @@ -1556,9 +1556,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ me.apply_rule_on_other_items(items_rule_dict); if(!price_list_rate_changed) me.calculate_taxes_and_totals(); - }, + } - apply_rule_on_other_items: function(args) { + apply_rule_on_other_items(args) { const me = this; const fields = ["discount_percentage", "pricing_rules", "discount_amount", "rate"]; @@ -1577,9 +1577,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } } - }, + } - apply_product_discount: function(free_item_data) { + apply_product_discount(free_item_data) { const items = this.frm.doc.items.filter(d => (d.item_code == free_item_data.item_code && d.is_free_item)) || []; @@ -1593,9 +1593,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } if (items && items.length && free_item_data) { items[0].qty = free_item_data.qty } - }, + } - apply_price_list: function(item, reset_plc_conversion) { + apply_price_list(item, reset_plc_conversion) { // We need to reset plc_conversion_rate sometimes because the call to // `erpnext.stock.get_item_details.apply_price_list` is sensitive to its value if (!reset_plc_conversion) { @@ -1634,9 +1634,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }).always(() => { me.in_apply_price_list = false; }); - }, + } - remove_pricing_rule: function(item) { + remove_pricing_rule(item) { let me = this; const fields = ["discount_percentage", "discount_amount", "margin_rate_or_amount", "rate_with_margin"]; @@ -1670,18 +1670,18 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ me.trigger_price_list_rate(); } - }, + } - trigger_price_list_rate: function() { + trigger_price_list_rate() { var me = this; this.frm.doc.items.forEach(child_row => { me.frm.script_manager.trigger("price_list_rate", child_row.doctype, child_row.name); }) - }, + } - validate_company_and_party: function() { + validate_company_and_party() { var me = this; var valid = true; @@ -1696,9 +1696,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); return valid; - }, + } - get_terms: function() { + get_terms() { var me = this; erpnext.utils.get_terms(this.frm.doc.tc_name, this.frm.doc, function(r) { @@ -1706,9 +1706,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ me.frm.set_value("terms", r.message); } }); - }, + } - taxes_and_charges: function() { + taxes_and_charges() { var me = this; if(this.frm.doc.taxes_and_charges) { return this.frm.call({ @@ -1734,9 +1734,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); } - }, + } - tax_category: function() { + tax_category() { var me = this; if(me.frm.updating_party_details) return; @@ -1744,9 +1744,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => this.update_item_tax_map(), () => erpnext.utils.set_taxes(this.frm, "tax_category"), ]); - }, + } - item_tax_template: function(doc, cdt, cdn) { + item_tax_template(doc, cdt, cdn) { var me = this; if(me.frm.updating_party_details) return; @@ -1772,9 +1772,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ item.item_tax_rate = "{}"; me.calculate_taxes_and_totals(); } - }, + } - update_item_tax_map: function() { + update_item_tax_map() { var me = this; var item_codes = []; $.each(this.frm.doc.items || [], function(i, item) { @@ -1810,9 +1810,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }); } - }, + } - is_recurring: function() { + is_recurring() { // set default values for recurring documents if(this.frm.doc.is_recurring && this.frm.doc.__islocal) { frappe.msgprint(__("Please set recurring after saving")); @@ -1835,9 +1835,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } refresh_many(["notification_email_address", "repeat_on_day_of_month"]); - }, + } - from_date: function() { + from_date() { // set to_date if(this.frm.doc.from_date) { var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, @@ -1851,25 +1851,25 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ refresh_field('to_date'); } } - }, + } - set_gross_profit: function(item) { + set_gross_profit(item) { if (["Sales Order", "Quotation"].includes(this.frm.doc.doctype) && item.valuation_rate) { var rate = flt(item.rate) * flt(this.frm.doc.conversion_rate || 1); item.gross_profit = flt(((rate - item.valuation_rate) * item.stock_qty), precision("amount", item)); } - }, + } - setup_item_selector: function() { + setup_item_selector() { // TODO: remove item selector return; // if(!this.item_selector) { // this.item_selector = new erpnext.ItemSelector({frm: this.frm}); // } - }, + } - get_advances: function() { + get_advances() { if(!this.frm.is_return) { return this.frm.call({ method: "set_advances", @@ -1879,9 +1879,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }) } - }, + } - make_payment_entry: function() { + make_payment_entry() { return frappe.call({ method: cur_frm.cscript.get_method_for_payment(), args: { @@ -1894,9 +1894,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ // cur_frm.refresh_fields() } }); - }, + } - get_method_for_payment: function(){ + get_method_for_payment(){ 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(in_list(['Sales Invoice', 'Purchase Invoice'], cur_frm.doc.doctype)){ @@ -1907,9 +1907,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } return method - }, + } - set_query_for_batch: function(doc, cdt, cdn) { + set_query_for_batch(doc, cdt, cdn) { // Show item's batches in the dropdown of batch no var me = this; @@ -1939,9 +1939,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ filters: filters } } - }, + } - set_query_for_item_tax_template: function(doc, cdt, cdn) { + set_query_for_item_tax_template(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if(!item.item_code) { return doc.company ? {filters: {company: doc.company}} : {}; @@ -1961,9 +1961,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ filters: filters } } - }, + } - payment_terms_template: function() { + payment_terms_template() { var me = this; const doc = this.frm.doc; if(doc.payment_terms_template && doc.doctype !== 'Delivery Note') { @@ -1983,9 +1983,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }) } - }, + } - payment_term: function(doc, cdt, cdn) { + payment_term(doc, cdt, cdn) { var row = locals[cdt][cdn]; if(row.payment_term) { frappe.call({ @@ -2005,17 +2005,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }) } - }, + } - against_blanket_order: function(doc, cdt, cdn) { + against_blanket_order(doc, cdt, cdn) { var item = locals[cdt][cdn]; if(!item.against_blanket_order) { frappe.model.set_value(this.frm.doctype + " Item", item.name, "blanket_order", null); frappe.model.set_value(this.frm.doctype + " Item", item.name, "blanket_order_rate", 0.00); } - }, + } - blanket_order: function(doc, cdt, cdn) { + blanket_order(doc, cdt, cdn) { var me = this; var item = locals[cdt][cdn]; if (item.blanket_order && (item.parenttype=="Sales Order" || item.parenttype=="Purchase Order")) { @@ -2043,34 +2043,34 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }) } - }, + } - set_reserve_warehouse: function() { + set_reserve_warehouse() { this.autofill_warehouse(this.frm.doc.supplied_items, "reserve_warehouse", this.frm.doc.set_reserve_warehouse); - }, + } - set_warehouse: function() { + set_warehouse() { this.autofill_warehouse(this.frm.doc.items, "warehouse", this.frm.doc.set_warehouse); - }, + } - set_target_warehouse: function() { + set_target_warehouse() { this.autofill_warehouse(this.frm.doc.items, "target_warehouse", this.frm.doc.set_target_warehouse); - }, + } - set_from_warehouse: function() { + set_from_warehouse() { this.autofill_warehouse(this.frm.doc.items, "from_warehouse", this.frm.doc.set_from_warehouse); - }, + } - autofill_warehouse : function (child_table, warehouse_field, warehouse) { + autofill_warehouse(child_table, warehouse_field, warehouse) { if (warehouse && child_table && child_table.length) { let doctype = child_table[0].doctype; $.each(child_table || [], function(i, item) { frappe.model.set_value(doctype, item.name, warehouse_field, warehouse); }); } - }, + } - coupon_code: function() { + coupon_code() { var me = this; frappe.run_serially([ () => this.frm.doc.ignore_pricing_rule=1, @@ -2079,7 +2079,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => me.apply_pricing_rule() ]); } -}); +}; erpnext.show_serial_batch_selector = function (frm, d, callback, on_close, show_dialog) { let warehouse, receiving_stock, existing_stock; diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js index 0d656bc1fb..7df976c1be 100644 --- a/erpnext/public/js/payment/payments.js +++ b/erpnext/public/js/payment/payments.js @@ -1,31 +1,31 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -erpnext.payments = erpnext.stock.StockController.extend({ - make_payment: function() { +erpnext.payments = class payments extends erpnext.stock.StockController { + make_payment() { var me = this; this.dialog = new frappe.ui.Dialog({ title: 'Payment' }); - + this.dialog.show(); this.$body = this.dialog.body; this.set_payment_primary_action(); this.make_keyboard(); this.select_text() - }, + } - select_text: function(){ + select_text(){ var me = this; $(this.$body).find('.form-control').click(function(){ $(this).select(); }) - }, + } - set_payment_primary_action: function(){ + set_payment_primary_action(){ var me = this; - + this.dialog.set_primary_action(__("Submit"), function() { // Allow no ZERO payment $.each(me.frm.doc.payments, function (index, data) { @@ -36,18 +36,18 @@ erpnext.payments = erpnext.stock.StockController.extend({ } }); }) - }, + } - make_keyboard: function(){ + make_keyboard(){ var me = this; $(this.$body).empty(); $(this.$body).html(frappe.render_template('pos_payment', this.frm.doc)) this.show_payment_details(); this.bind_keyboard_event() this.clear_amount() - }, + } - make_multimode_payment: function(){ + make_multimode_payment(){ var me = this; if(this.frm.doc.change_amount > 0){ @@ -57,9 +57,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ this.payments = frappe.model.add_child(this.frm.doc, 'Multi Mode Payment', "payments"); this.payments.mode_of_payment = this.dialog.fields_dict.mode_of_payment.get_value(); this.payments.amount = flt(this.payment_val); - }, + } - show_payment_details: function(){ + show_payment_details(){ var me = this; var multimode_payments = $(this.$body).find('.multimode-payments').empty(); if(this.frm.doc.payments.length){ @@ -82,9 +82,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ }else{ $("

No payment mode selected in pos profile

").appendTo(multimode_payments) } - }, + } - set_outstanding_amount: function(){ + set_outstanding_amount(){ this.selected_mode = $(this.$body).find(repl("input[idx='%(idx)s']",{'idx': this.idx})); this.highlight_selected_row() this.payment_val = 0.0 @@ -99,47 +99,47 @@ erpnext.payments = erpnext.stock.StockController.extend({ } this.selected_mode.select() this.bind_amount_change_event(); - }, - - bind_keyboard_event: function(){ + } + + bind_keyboard_event(){ var me = this; this.payment_val = ''; this.bind_form_control_event(); this.bind_numeric_keys_event(); - }, + } - bind_form_control_event: function(){ + bind_form_control_event(){ var me = this; $(this.$body).find('.pos-payment-row').click(function(){ me.idx = $(this).attr("idx"); me.set_outstanding_amount() }) - + $(this.$body).find('.form-control').click(function(){ me.idx = $(this).attr("idx"); me.set_outstanding_amount(); me.update_paid_amount(true); }) - + $(this.$body).find('.write_off_amount').change(function(){ me.write_off_amount(flt($(this).val()), precision("write_off_amount")); }) - + $(this.$body).find('.change_amount').change(function(){ me.change_amount(flt($(this).val()), precision("change_amount")); }) - }, + } - highlight_selected_row: function(){ + highlight_selected_row(){ var me = this; var selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']",{'idx': this.idx})); $(this.$body).find('.pos-payment-row').removeClass('selected-payment-mode') selected_row.addClass('selected-payment-mode') $(this.$body).find('.amount').attr('disabled', true); this.selected_mode.attr('disabled', false); - }, - - bind_numeric_keys_event: function(){ + } + + bind_numeric_keys_event(){ var me = this; $(this.$body).find('.pos-keyboard-key').click(function(){ me.payment_val += $(this).text(); @@ -147,7 +147,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ me.idx = me.selected_mode.attr("idx") me.update_paid_amount() }) - + $(this.$body).find('.delete-btn').click(function(){ me.payment_val = cstr(flt(me.selected_mode.val())).slice(0, -1); me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency)); @@ -155,9 +155,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ me.update_paid_amount(); }) - }, - - bind_amount_change_event: function(){ + } + + bind_amount_change_event(){ var me = this; this.selected_mode.change(function(){ me.payment_val = flt($(this).val()) || 0.0; @@ -165,9 +165,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ me.idx = me.selected_mode.attr("idx") me.update_payment_amount() }) - }, + } - clear_amount: function() { + clear_amount() { var me = this; $(this.$body).find('.clr').click(function(e){ e.stopPropagation(); @@ -178,9 +178,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ me.highlight_selected_row(); me.update_payment_amount(); }) - }, + } - write_off_amount: function(write_off_amount) { + write_off_amount(write_off_amount) { var me = this; this.frm.doc.write_off_amount = flt(write_off_amount, precision("write_off_amount")); @@ -188,17 +188,17 @@ erpnext.payments = erpnext.stock.StockController.extend({ precision("base_write_off_amount")); this.calculate_outstanding_amount(false) this.show_amounts() - }, + } - change_amount: function(change_amount) { + change_amount(change_amount) { var me = this; this.frm.doc.change_amount = flt(change_amount, precision("change_amount")); this.calculate_write_off_amount() this.show_amounts() - }, + } - update_paid_amount: function(update_write_off) { + update_paid_amount(update_write_off) { var me = this; if(in_list(['change_amount', 'write_off_amount'], this.idx)){ var value = me.selected_mode.val(); @@ -213,9 +213,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ }else{ this.update_payment_amount() } - }, + } - update_payment_amount: function(){ + update_payment_amount(){ var me = this; $.each(this.frm.doc.payments, function(index, data){ @@ -226,9 +226,9 @@ erpnext.payments = erpnext.stock.StockController.extend({ this.calculate_outstanding_amount(false); this.show_amounts(); - }, + } - show_amounts: function(){ + show_amounts(){ var me = this; $(this.$body).find(".write_off_amount").val(format_currency(this.frm.doc.write_off_amount, this.frm.doc.currency)); $(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency)); @@ -236,4 +236,4 @@ erpnext.payments = erpnext.stock.StockController.extend({ $(this.$body).find('.outstanding_amount').text(format_currency(this.frm.doc.outstanding_amount, frappe.get_doc(":Company", this.frm.doc.company).default_currency)) this.update_invoice(); } -}) \ No newline at end of file +} diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index 140c9dc90b..c74b45e6db 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -2,8 +2,8 @@ // License: GNU General Public License v3. See license.txt -erpnext.StockAnalytics = erpnext.StockGridReport.extend({ - init: function(wrapper, opts) { +erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport { + constructor(wrapper, opts) { var args = { title: __("Stock Analytics"), parent: $(wrapper).find('.layout-main'), @@ -30,9 +30,9 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ if(opts) $.extend(args, opts); - this._super(args); - }, - setup_columns: function() { + super(args); + } + setup_columns() { var std_columns = [ {id: "name", name: __("Item"), field: "name", width: 300}, {id: "brand", name: __("Brand"), field: "brand", width: 100}, @@ -43,8 +43,9 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ this.make_date_range_columns(); this.columns = std_columns.concat(this.columns); - }, - filters: [ + } + + filters = [ {fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty", options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}], filter: function(val, item, opts, me) { @@ -66,20 +67,21 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ {label:__("Quarterly"), value:"Quarterly"}, {label:__("Yearly"), value:"Yearly"}, ]} - ], - setup_filters: function() { + ] + + setup_filters() { var me = this; - this._super(); + super.setup_filters(); this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]); this.show_zero_check(); - }, - init_filter_values: function() { - this._super(); + } + init_filter_values() { + super.init_filter_values(); this.filter_inputs.range && this.filter_inputs.range.val('Monthly'); - }, - prepare_data: function() { + } + prepare_data() { var me = this; if(!this.data) { @@ -112,8 +114,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ this.prepare_balances(); this.update_groups(); - }, - prepare_balances: function() { + } + prepare_balances() { var me = this; var from_date = frappe.datetime.str_to_obj(this.from_date); var to_date = frappe.datetime.str_to_obj(this.to_date); @@ -164,8 +166,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ item.closing_qty_value += diff; } } - }, - update_groups: function() { + } + update_groups() { var me = this; $.each(this.data, function(i, item) { // update groups @@ -192,8 +194,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ } } }); - }, - show_stock_ledger: function(item_code) { + } + show_stock_ledger(item_code) { frappe.route_options = { item_code: item_code, from_date: this.from_date, @@ -201,5 +203,5 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ }; frappe.set_route("query-report", "Stock Ledger"); } -}); +}; diff --git a/erpnext/public/js/stock_grid_report.js b/erpnext/public/js/stock_grid_report.js index 832fd3eccf..752fafdb97 100644 --- a/erpnext/public/js/stock_grid_report.js +++ b/erpnext/public/js/stock_grid_report.js @@ -1,16 +1,16 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -erpnext.StockGridReport = frappe.views.TreeGridReport.extend({ - get_item_warehouse: function(warehouse, item) { +erpnext.StockGridReport = class StockGridReport extends frappe.views.TreeGridReport { + get_item_warehouse(warehouse, item) { if(!this.item_warehouse[item]) this.item_warehouse[item] = {}; if(!this.item_warehouse[item][warehouse]) this.item_warehouse[item][warehouse] = { balance_qty: 0.0, balance_value: 0.0, fifo_stack: [] }; return this.item_warehouse[item][warehouse]; - }, + } - get_value_diff: function(wh, sl, is_fifo) { + get_value_diff(wh, sl, is_fifo) { // value if(sl.qty > 0) { // incoming - rate is given @@ -59,8 +59,8 @@ erpnext.StockGridReport = frappe.views.TreeGridReport.extend({ wh.balance_qty += sl.qty; wh.balance_value += value_diff; return value_diff; - }, - get_fifo_value_diff: function(wh, sl) { + } + get_fifo_value_diff(wh, sl) { // get exact rate from fifo stack var fifo_stack = (wh.fifo_stack || []).reverse(); var fifo_value_diff = 0.0; @@ -89,9 +89,9 @@ erpnext.StockGridReport = frappe.views.TreeGridReport.extend({ // reset the updated stack wh.fifo_stack = fifo_stack.reverse(); return -fifo_value_diff; - }, + } - get_serialized_value_diff: function(sl) { + get_serialized_value_diff(sl) { var me = this; var value_diff = 0.0; @@ -103,9 +103,9 @@ erpnext.StockGridReport = frappe.views.TreeGridReport.extend({ }); return value_diff; - }, + } - get_serialized_buying_rates: function() { + get_serialized_buying_rates() { var serialized_buying_rates = {}; if (frappe.report_dump.data["Serial No"]) { @@ -115,5 +115,5 @@ erpnext.StockGridReport = frappe.views.TreeGridReport.extend({ } return serialized_buying_rates; - }, -}); + } +}; diff --git a/erpnext/public/js/telephony.js b/erpnext/public/js/telephony.js index 9548d6c5f3..1c3e314797 100644 --- a/erpnext/public/js/telephony.js +++ b/erpnext/public/js/telephony.js @@ -1,19 +1,19 @@ -frappe.ui.form.ControlData = frappe.ui.form.ControlData.extend( { +frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlData { make_input() { - this._super(); + super.make_input(); if (this.df.options == 'Phone') { this.setup_phone(); } if (this.frm && this.frm.fields_dict) { Object.values(this.frm.fields_dict).forEach(function(field) { - if (field.df.read_only === 1 && field.df.options === 'Phone' + if (field.df.read_only === 1 && field.df.options === 'Phone' && field.disp_area.style[0] != 'display' && !field.has_icon) { field.setup_phone(); field.has_icon = true; } }); } - }, + } setup_phone() { if (frappe.phone_call.handler) { let control = this.df.read_only ? '.control-value' : '.control-input'; @@ -30,4 +30,4 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlData.extend( { }); } } -}); +}; diff --git a/erpnext/public/js/utils/customer_quick_entry.js b/erpnext/public/js/utils/customer_quick_entry.js index ebe6cd98f8..efb8dd9d5c 100644 --- a/erpnext/public/js/utils/customer_quick_entry.js +++ b/erpnext/public/js/utils/customer_quick_entry.js @@ -1,17 +1,17 @@ frappe.provide('frappe.ui.form'); -frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ - init: function(doctype, after_insert) { +frappe.ui.form.CustomerQuickEntryForm = class CustomerQuickEntryForm extends frappe.ui.form.QuickEntryForm { + constructor(doctype, after_insert) { + super(doctype, after_insert); this.skip_redirect_on_error = true; - this._super(doctype, after_insert); - }, + } - render_dialog: function() { + render_dialog() { this.mandatory = this.mandatory.concat(this.get_variant_fields()); - this._super(); - }, + super.render_dialog(); + } - get_variant_fields: function() { + get_variant_fields() { var variant_fields = [{ fieldtype: "Section Break", label: __("Primary Contact Details"), @@ -77,5 +77,5 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ }]; return variant_fields; - }, -}) \ No newline at end of file + } +} diff --git a/erpnext/public/js/utils/item_quick_entry.js b/erpnext/public/js/utils/item_quick_entry.js index 27ef107ace..7e0198d33b 100644 --- a/erpnext/public/js/utils/item_quick_entry.js +++ b/erpnext/public/js/utils/item_quick_entry.js @@ -1,27 +1,27 @@ frappe.provide('frappe.ui.form'); -frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ - init: function(doctype, after_insert) { - this._super(doctype, after_insert); - }, +frappe.ui.form.ItemQuickEntryForm = class ItemQuickEntryForm extends frappe.ui.form.QuickEntryForm { + constructor(doctype, after_insert) { + super(doctype, after_insert); + } - render_dialog: function() { + render_dialog() { this.mandatory = this.get_variant_fields().concat(this.mandatory); this.mandatory = this.mandatory.concat(this.get_attributes_fields()); this.check_naming_series_based_on(); - this._super(); + super.render_dialog(); this.init_post_render_dialog_operations(); this.preset_fields_for_template(); this.dialog.$wrapper.find('.edit-full').text(__('Edit in full page for more options like assets, serial nos, batches etc.')) - }, + } - check_naming_series_based_on: function() { + check_naming_series_based_on() { if (frappe.defaults.get_default("item_naming_by") === "Naming Series") { this.mandatory = this.mandatory.filter(d => d.fieldname !== "item_code"); } - }, + } - init_post_render_dialog_operations: function() { + init_post_render_dialog_operations() { this.dialog.fields_dict.attribute_html.$wrapper.append(frappe.render_template("item_quick_entry")); this.init_for_create_variant_trigger(); this.init_for_item_template_trigger(); @@ -29,9 +29,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ this.toggle_manufacturer_fields(); this.dialog.get_field("item_template").df.hidden = 1; this.dialog.get_field("item_template").refresh(); - }, + } - register_primary_action: function() { + register_primary_action() { var me = this; this.dialog.set_primary_action(__('Save'), function() { if (me.dialog.working) return; @@ -59,9 +59,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ me.insert(variant_values); } }); - }, + } - insert: function(variant_values) { + insert(variant_values) { let me = this; return new Promise(resolve => { frappe.call({ @@ -94,9 +94,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ freeze: true }); }); - }, + } - open_doc: function() { + open_doc() { this.dialog.hide(); this.update_doc(); if (this.dialog.fields_dict.create_variant.$input.prop("checked")) { @@ -106,9 +106,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ } else { frappe.set_route('Form', this.doctype, this.doc.name); } - }, + } - get_variant_fields: function() { + get_variant_fields() { var variant_fields = [{ fieldname: "create_variant", fieldtype: "Check", @@ -130,9 +130,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ }]; return variant_fields; - }, + } - get_manufacturing_fields: function() { + get_manufacturing_fields() { this.manufacturer_fields = [{ fieldtype: 'Link', options: 'Manufacturer', @@ -148,9 +148,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ reqd: 0 }]; return this.manufacturer_fields; - }, + } - get_attributes_fields: function() { + get_attributes_fields() { var attribute_fields = [{ fieldname: 'attribute_html', fieldtype: 'HTML' @@ -158,18 +158,18 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ attribute_fields = attribute_fields.concat(this.get_manufacturing_fields()); return attribute_fields; - }, + } - init_for_create_variant_trigger: function() { + init_for_create_variant_trigger() { var me = this; this.dialog.fields_dict.create_variant.$input.on("click", function() { me.preset_fields_for_template(); me.init_post_template_trigger_operations(false, [], true); }); - }, + } - preset_fields_for_template: function() { + preset_fields_for_template() { var for_variant = this.dialog.get_value('create_variant'); // setup template field, seen and mandatory if variant @@ -195,9 +195,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ f.refresh(); }); - }, + } - init_for_item_template_trigger: function() { + init_for_item_template_trigger() { var me = this; me.dialog.fields_dict["item_template"].df.onchange = () => { @@ -228,9 +228,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ me.init_post_template_trigger_operations(false, [], true); } } - }, + } - init_post_template_trigger_operations: function(is_manufacturer, attributes, attributes_flag) { + init_post_template_trigger_operations(is_manufacturer, attributes, attributes_flag) { this.attributes = attributes; this.attribute_values = {}; this.attributes_count = attributes.length; @@ -240,23 +240,23 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ this.toggle_manufacturer_fields(); this.dialog.fields_dict.attribute_html.$wrapper.find(".attributes").toggleClass("hide-control", attributes_flag); this.dialog.fields_dict.attribute_html.$wrapper.find(".attributes-header").toggleClass("hide-control", attributes_flag); - }, + } - toggle_manufacturer_fields: function() { + toggle_manufacturer_fields() { var me = this; $.each(this.manufacturer_fields, function(i, dialog_field) { me.dialog.get_field(dialog_field.fieldname).df.hidden = !me.is_manufacturer; me.dialog.get_field(dialog_field.fieldname).df.reqd = dialog_field.fieldname == 'manufacturer' ? me.is_manufacturer : false; me.dialog.get_field(dialog_field.fieldname).refresh(); }); - }, + } - initiate_render_attributes: function() { + initiate_render_attributes() { this.dialog.fields_dict.attribute_html.$wrapper.find(".attributes").empty(); this.render_attributes(this.attributes); - }, + } - render_attributes: function(attributes) { + render_attributes(attributes) { var me = this; this.dialog.get_field('attribute_html').toggle(true); @@ -291,9 +291,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ }); } }); - }, + } - init_make_control: function(fieldtype, row) { + init_make_control(fieldtype, row) { this[row.attribute] = frappe.ui.form.make_control({ df: { "fieldtype": fieldtype, @@ -305,9 +305,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ only_input: false }); this[row.attribute].make_input(); - }, + } - init_awesomplete_for_attribute: function(row) { + init_awesomplete_for_attribute(row) { var me = this; this[row.attribute].input.awesomplete = new Awesomplete(this[row.attribute].input, { @@ -343,9 +343,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ me.attribute_values[$(e.target).attr("data-fieldname")] = e.target.value; $(e.target).closest(".frappe-control").toggleClass("has-error", e.target.value ? false : true); }); - }, + } - get_variant_doc: function() { + get_variant_doc() { var me = this; var variant_doc = {}; var attribute = this.validate_mandatory_attributes(); @@ -381,9 +381,9 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ }) } return variant_doc; - }, + } - validate_mandatory_attributes: function() { + validate_mandatory_attributes() { var me = this; var attribute = {}; var mandatory = []; @@ -404,4 +404,4 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ } return attribute; } -}); \ No newline at end of file +}; diff --git a/erpnext/public/js/utils/item_selector.js b/erpnext/public/js/utils/item_selector.js index d04c488a59..9fc264086a 100644 --- a/erpnext/public/js/utils/item_selector.js +++ b/erpnext/public/js/utils/item_selector.js @@ -1,5 +1,5 @@ -erpnext.ItemSelector = Class.extend({ - init: function(opts) { +erpnext.ItemSelector = class ItemSelector { + constructor(opts) { $.extend(this, opts); if (!this.item_field) { @@ -12,9 +12,9 @@ erpnext.ItemSelector = Class.extend({ this.grid = this.frm.get_field("items").grid; this.setup(); - }, + } - setup: function() { + setup() { var me = this; if(!this.grid.add_items_button) { this.grid.add_items_button = this.grid.add_custom_button(__('Add Items'), function() { @@ -26,9 +26,9 @@ erpnext.ItemSelector = Class.extend({ setTimeout(function() { me.dialog.input.focus(); }, 1000); }); } - }, + } - make_dialog: function() { + make_dialog() { this.dialog = new frappe.ui.Dialog({ title: __('Add Items') }); @@ -53,9 +53,9 @@ erpnext.ItemSelector = Class.extend({ me.timeout_id = undefined; }, 500); }); - }, + } - add_item: function(item_code) { + add_item(item_code) { // add row or update qty var added = false; @@ -82,9 +82,9 @@ erpnext.ItemSelector = Class.extend({ ]); } - }, + } - render_items: function() { + render_items() { let args = { query: this.item_query, filters: {} @@ -107,4 +107,4 @@ erpnext.ItemSelector = Class.extend({ me.dialog.results.html(frappe.render_template('item_selector', {'data':r.values})); }); } -}); \ No newline at end of file +}; diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index d49a8138fb..d44c708356 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -1,6 +1,6 @@ -erpnext.SerialNoBatchSelector = Class.extend({ - init: function(opts, show_dialog) { +erpnext.SerialNoBatchSelector = class SerialNoBatchSelector { + constructor(opts, show_dialog) { $.extend(this, opts); this.show_dialog = show_dialog; // frm, item, warehouse_details, has_batch, oldest @@ -12,16 +12,16 @@ erpnext.SerialNoBatchSelector = Class.extend({ if(d && d.has_serial_no && !(this.show_dialog == false)) this.has_serial_no = 1; this.setup(); - }, + } - setup: function() { + setup() { this.item_code = this.item.item_code; this.qty = this.item.qty; this.make_dialog(); this.on_close_dialog(); - }, + } - make_dialog: function() { + make_dialog() { var me = this; this.data = this.oldest ? this.oldest : []; @@ -176,15 +176,15 @@ erpnext.SerialNoBatchSelector = Class.extend({ } this.dialog.show(); - }, + } - on_close_dialog: function() { + on_close_dialog() { this.dialog.get_close_btn().on('click', () => { this.on_close && this.on_close(this.item); }); - }, + } - validate: function() { + validate() { let values = this.values; if(!values.warehouse) { frappe.throw(__("Please select a warehouse")); @@ -210,7 +210,7 @@ erpnext.SerialNoBatchSelector = Class.extend({ } return true; } - }, + } update_batch_items() { // clones an items if muliple batches are selected. @@ -233,14 +233,14 @@ erpnext.SerialNoBatchSelector = Class.extend({ 'selected_qty', this.values.warehouse); }); } - }, + } update_serial_no_item() { // just updates serial no for the item if(this.has_serial_no && !this.has_batch) { this.map_row_values(this.item, this.values, 'serial_no', 'qty'); } - }, + } update_batch_serial_no_items() { // if serial no selected is from different batches, adds new rows for each batch. @@ -281,14 +281,14 @@ erpnext.SerialNoBatchSelector = Class.extend({ }); }) } - }, + } - batch_exists: function(batch) { + batch_exists(batch) { const batches = this.frm.doc.items.map(data => data.batch_no); return (batches && in_list(batches, batch)) ? true : false; - }, + } - map_row_values: function(row, values, number, qty_field, warehouse) { + map_row_values(row, values, number, qty_field, warehouse) { row.qty = values[qty_field]; row.transfer_qty = flt(values[qty_field]) * flt(row.conversion_factor); row[number] = values[number]; @@ -301,9 +301,9 @@ erpnext.SerialNoBatchSelector = Class.extend({ } this.frm.dirty(); - }, + } - update_total_qty: function() { + update_total_qty() { let qty_field = this.dialog.fields_dict.qty; let total_qty = 0; @@ -312,9 +312,9 @@ erpnext.SerialNoBatchSelector = Class.extend({ }); qty_field.set_input(total_qty); - }, + } - get_batch_fields: function() { + get_batch_fields() { var me = this; return [ @@ -425,9 +425,9 @@ erpnext.SerialNoBatchSelector = Class.extend({ }, } ]; - }, + } - get_serial_no_fields: function() { + get_serial_no_fields() { var me = this; this.serial_list = []; @@ -510,4 +510,4 @@ erpnext.SerialNoBatchSelector = Class.extend({ } ]; } -}); +}; diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index 7fd0877d11..ffa185baf6 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -30,8 +30,8 @@ frappe.ui.form.on('Installation Note', { frappe.provide("erpnext.selling"); // TODO commonify this code -erpnext.selling.InstallationNote = frappe.ui.form.Controller.extend({ - refresh: function() { +erpnext.selling.InstallationNote = class InstallationNote extends frappe.ui.form.Controller { + refresh() { var me = this; if (this.frm.doc.docstatus===0) { this.frm.add_custom_button(__('From Delivery Note'), @@ -54,7 +54,7 @@ erpnext.selling.InstallationNote = frappe.ui.form.Controller.extend({ }, "fa fa-download", "btn-default" ); } - }, -}); + } +}; $.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 5a0d9c9065..10606bf81e 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -36,13 +36,13 @@ frappe.ui.form.on('Quotation', { } }); -erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ - onload: function(doc, dt, dn) { +erpnext.selling.QuotationController = class QuotationController extends erpnext.selling.SellingController { + onload(doc, dt, dn) { var me = this; - this._super(doc, dt, dn); + super.(doc, dt, dn); - }, - party_name: function() { + } + party_name() { var me = this; erpnext.utils.get_party_details(this.frm, null, null, function() { me.apply_price_list(); @@ -51,9 +51,9 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ if(me.frm.doc.quotation_to=="Lead" && me.frm.doc.party_name) { me.frm.trigger("get_lead_details"); } - }, - refresh: function(doc, dt, dn) { - this._super(doc, dt, dn); + } + refresh(doc, dt, dn) { + super.refresh(doc, dt, dn); doctype = doc.quotation_to == 'Customer' ? 'Customer':'Lead'; frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'party_name', doctype: doctype} @@ -121,9 +121,9 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ this.toggle_reqd_lead_customer(); - }, + } - set_dynamic_field_label: function(){ + set_dynamic_field_label(){ if (this.frm.doc.quotation_to == "Customer") { this.frm.set_df_property("party_name", "label", "Customer"); @@ -138,22 +138,22 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ return{ query: "erpnext.controllers.queries.lead_query" } } } - }, + } - toggle_reqd_lead_customer: function() { + toggle_reqd_lead_customer() { var me = this; // to overwrite the customer_filter trigger from queries.js this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to); this.frm.set_query('customer_address', this.address_query); this.frm.set_query('shipping_address_name', this.address_query); - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - address_query: function(doc) { + address_query(doc) { return { query: 'frappe.contacts.doctype.address.address.address_query', filters: { @@ -161,20 +161,20 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ link_name: doc.party_name } }; - }, + } - validate_company_and_party: function(party_field) { + validate_company_and_party(party_field) { if(!this.frm.doc.quotation_to) { frappe.msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name])); return false; } else if (this.frm.doc.quotation_to == "Lead") { return true; } else { - return this._super(party_field); + return super.validate_company_and_party(party_field); } - }, + } - get_lead_details: function() { + get_lead_details() { var me = this; if(!this.frm.doc.quotation_to === "Lead") { return; @@ -198,7 +198,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ } }) } -}); +}; cur_frm.script_manager.make(erpnext.selling.QuotationController); diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index e3b41e66fb..d5ceca8ec8 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -102,14 +102,14 @@ frappe.ui.form.on("Sales Order Item", { } }); -erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ - onload: function(doc, dt, dn) { - this._super(); - }, +erpnext.selling.SalesOrderController = class SalesOrderController extends erpnext.selling.SellingController { + onload(doc, dt, dn) { + super.onload(); + } - refresh: function(doc, dt, dn) { + refresh(doc, dt, dn) { var me = this; - this._super(); + super.refresh(); let allow_delivery = false; if (doc.docstatus==1) { @@ -241,14 +241,14 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } this.order_type(doc); - }, + } create_pick_list() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.create_pick_list", frm: this.frm }) - }, + } make_work_order() { var me = this; @@ -343,33 +343,33 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } } }); - }, + } - order_type: function() { + order_type() { this.toggle_delivery_date(); - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - make_material_request: function() { + make_material_request() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request", frm: this.frm }) - }, + } - skip_delivery_note: function() { + skip_delivery_note() { this.toggle_delivery_date(); - }, + } - toggle_delivery_date: function() { + toggle_delivery_date() { this.frm.fields_dict.items.grid.toggle_reqd("delivery_date", (this.frm.doc.order_type == "Sales" && !this.frm.doc.skip_delivery_note)); - }, + } - make_raw_material_request: function() { + make_raw_material_request() { var me = this; this.frm.call({ doc: this.frm.doc, @@ -390,9 +390,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } } }); - }, + } - make_raw_material_request_dialog: function(r) { + make_raw_material_request_dialog(r) { var fields = [ {fieldtype:'Check', fieldname:'include_exploded_items', label: __('Include Exploded Items')}, @@ -447,9 +447,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( primary_action_label: __('Create') }); d.show(); - }, + } - make_delivery_note_based_on_delivery_date: function() { + make_delivery_note_based_on_delivery_date() { var me = this; var delivery_dates = []; @@ -509,51 +509,51 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } else { this.make_delivery_note(); } - }, + } - make_delivery_note: function() { + make_delivery_note() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note", frm: this.frm }) - }, + } - make_sales_invoice: function() { + make_sales_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice", frm: this.frm }) - }, + } - make_maintenance_schedule: function() { + make_maintenance_schedule() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_schedule", frm: this.frm }) - }, + } - make_project: function() { + make_project() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_project", frm: this.frm }) - }, + } - make_inter_company_order: function() { + make_inter_company_order() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_inter_company_purchase_order", frm: this.frm }); - }, + } - make_maintenance_visit: function() { + make_maintenance_visit() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit", frm: this.frm }) - }, + } - make_purchase_order: function(){ + make_purchase_order(){ let pending_items = this.frm.doc.items.some((item) =>{ let pending_qty = flt(item.stock_qty) - flt(item.ordered_qty); return pending_qty > 0; @@ -690,9 +690,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( dialog.get_field("items_for_po").refresh(); dialog.wrapper.find('.grid-heading-row .grid-row-check').click(); dialog.show(); - }, + } - hold_sales_order: function(){ + hold_sales_order(){ var me = this; var d = new frappe.ui.Dialog({ title: __('Reason for Hold'), @@ -724,11 +724,11 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } }); d.show(); - }, - close_sales_order: function(){ + } + close_sales_order(){ this.frm.cscript.update_status("Close", "Closed") - }, - update_status: function(label, status){ + } + update_status(label, status){ var doc = this.frm.doc; var me = this; frappe.ui.form.is_saving = true; @@ -743,5 +743,5 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } }); } -}); +}; $.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm})); diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 04285735ab..eb02867720 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -9,15 +9,15 @@ cur_frm.cscript.tax_table = "Sales Taxes and Charges"; cur_frm.email_field = "contact_email"; frappe.provide("erpnext.selling"); -erpnext.selling.SellingController = erpnext.TransactionController.extend({ - setup: function() { - this._super(); +erpnext.selling.SellingController = class SellingController extends erpnext.TransactionController { + setup() { + super.setup(); this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate"); this.frm.add_fetch("sales_person", "commission_rate", "commission_rate"); - }, + } - onload: function() { - this._super(); + onload() { + super.onload(); this.setup_queries(); this.frm.set_query('shipping_rule', function() { return { @@ -26,9 +26,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }; }); - }, + } - setup_queries: function() { + setup_queries() { var me = this; $.each([["customer", "customer"], @@ -81,10 +81,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } - }, + } - refresh: function() { - this._super(); + refresh() { + super.refresh(); frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'} @@ -95,45 +95,45 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.toggle_display("packing_list", packing_list_exists ? true : false); } this.toggle_editable_price_list_rate(); - }, + } - customer: function() { + customer() { var me = this; erpnext.utils.get_party_details(this.frm, null, null, function() { me.apply_price_list(); }); - }, + } - customer_address: function() { + customer_address() { erpnext.utils.get_address_display(this.frm, "customer_address"); erpnext.utils.set_taxes_from_address(this.frm, "customer_address", "customer_address", "shipping_address_name"); - }, + } - shipping_address_name: function() { + shipping_address_name() { erpnext.utils.get_address_display(this.frm, "shipping_address_name", "shipping_address"); erpnext.utils.set_taxes_from_address(this.frm, "shipping_address_name", "customer_address", "shipping_address_name"); - }, + } - sales_partner: function() { + sales_partner() { this.apply_pricing_rule(); - }, + } - campaign: function() { + campaign() { this.apply_pricing_rule(); - }, + } - selling_price_list: function() { + selling_price_list() { this.apply_price_list(); this.set_dynamic_labels(); - }, + } - discount_percentage: function(doc, cdt, cdn) { + discount_percentage(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); item.discount_amount = 0.0; this.apply_discount_on_item(doc, cdt, cdn, 'discount_percentage'); - }, + } - discount_amount: function(doc, cdt, cdn) { + discount_amount(doc, cdt, cdn) { if(doc.name === cdn) { return; @@ -142,9 +142,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var item = frappe.get_doc(cdt, cdn); item.discount_percentage = 0.0; this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount'); - }, + } - apply_discount_on_item: function(doc, cdt, cdn, field) { + apply_discount_on_item(doc, cdt, cdn, field) { var item = frappe.get_doc(cdt, cdn); if(!item.price_list_rate) { item[field] = 0.0; @@ -152,14 +152,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.price_list_rate(doc, cdt, cdn); } this.set_gross_profit(item); - }, + } - commission_rate: function() { + commission_rate() { this.calculate_commission(); refresh_field("total_commission"); - }, + } - total_commission: function() { + total_commission() { if(this.frm.doc.base_net_total) { frappe.model.round_floats_in(this.frm.doc, ["base_net_total", "total_commission"]); @@ -175,9 +175,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.set_value("commission_rate", flt(this.frm.doc.total_commission * 100.0 / this.frm.doc.base_net_total)); } - }, + } - allocated_percentage: function(doc, cdt, cdn) { + allocated_percentage(doc, cdt, cdn) { var sales_person = frappe.get_doc(cdt, cdn); if(sales_person.allocated_percentage) { @@ -193,15 +193,15 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ refresh_field(["allocated_percentage", "allocated_amount", "commission_rate","incentives"], sales_person.name, sales_person.parentfield); } - }, + } - sales_person: function(doc, cdt, cdn) { + sales_person(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); this.calculate_incentive(row); refresh_field("incentives",row.name,row.parentfield); - }, + } - warehouse: function(doc, cdt, cdn) { + warehouse(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); @@ -239,18 +239,18 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } }) - }, + } - toggle_editable_price_list_rate: function() { + toggle_editable_price_list_rate() { var df = frappe.meta.get_docfield(this.frm.doc.doctype + " Item", "price_list_rate", this.frm.doc.name); var editable_price_list_rate = cint(frappe.defaults.get_default("editable_price_list_rate")); if(df && editable_price_list_rate) { df.read_only = 0; } - }, + } - calculate_commission: function() { + calculate_commission() { if(this.frm.fields_dict.commission_rate) { if(this.frm.doc.commission_rate > 100) { var msg = __(frappe.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name)) + @@ -262,9 +262,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.doc.total_commission = flt(this.frm.doc.base_net_total * this.frm.doc.commission_rate / 100.0, precision("total_commission")); } - }, + } - calculate_contribution: function() { + calculate_contribution() { var me = this; $.each(this.frm.doc.doctype.sales_team || [], function(i, sales_person) { frappe.model.round_floats_in(sales_person); @@ -274,18 +274,18 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ precision("allocated_amount", sales_person)); } }); - }, + } - calculate_incentive: function(row) { + calculate_incentive(row) { if(row.allocated_amount) { row.incentives = flt( row.allocated_amount * row.commission_rate / 100.0, precision("incentives", row)); } - }, + } - batch_no: function(doc, cdt, cdn) { + batch_no(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); @@ -312,14 +312,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } }) - }, + } - set_dynamic_labels: function() { - this._super(); + set_dynamic_labels() { + super.set_dynamic_labels(); this.set_product_bundle_help(this.frm.doc); - }, + } - set_product_bundle_help: function(doc) { + set_product_bundle_help(doc) { if(!cur_frm.fields_dict.packing_list) return; if ((doc.packed_items || []).length) { $(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true); @@ -337,9 +337,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } } refresh_field('product_bundle_help'); - }, + } - company_address: function() { + company_address() { var me = this; if(this.frm.doc.company_address) { frappe.call({ @@ -354,42 +354,42 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } else { this.frm.set_value("company_address_display", ""); } - }, + } - conversion_factor: function(doc, cdt, cdn, dont_fetch_price_list_rate) { - this._super(doc, cdt, cdn, dont_fetch_price_list_rate); + conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate) { + super.conversion_factor(doc, cdt, cdn, dont_fetch_price_list_rate); if(frappe.meta.get_docfield(cdt, "stock_qty", cdn) && in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return; this.set_batch_number(cdt, cdn); } - }, + } - batch_no: function(doc, cdt, cdn) { - this._super(doc, cdt, cdn); - }, + batch_no(doc, cdt, cdn) { + super.batch_no(doc, cdt, cdn); + } - qty: function(doc, cdt, cdn) { - this._super(doc, cdt, cdn); + qty(doc, cdt, cdn) { + super.qty(doc, cdt, cdn); if(in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return; this.set_batch_number(cdt, cdn); } - }, + } /* Determine appropriate batch number and set it in the form. * @param {string} cdt - Document Doctype * @param {string} cdn - Document name */ - set_batch_number: function(cdt, cdn) { + set_batch_number(cdt, cdn) { const doc = frappe.get_doc(cdt, cdn); if (doc && doc.has_batch_no && doc.warehouse) { this._set_batch_number(doc); } - }, + } - _set_batch_number: function(doc) { + _set_batch_number(doc) { let args = {'item_code': doc.item_code, 'warehouse': doc.warehouse, 'qty': flt(doc.qty) * flt(doc.conversion_factor)}; if (doc.has_serial_no && doc.serial_no) { args['serial_no'] = doc.serial_no @@ -406,9 +406,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } } }); - }, + } - update_auto_repeat_reference: function(doc) { + update_auto_repeat_reference(doc) { if (doc.auto_repeat) { frappe.call({ method:"frappe.automation.doctype.auto_repeat.auto_repeat.update_reference", @@ -426,7 +426,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }) } } -}); +}; frappe.ui.form.on(cur_frm.doctype,"project", function(frm) { if(in_list(["Delivery Note", "Sales Invoice"], frm.doc.doctype)) { diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index 95cb92b1b3..30e0b762bd 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -1,11 +1,11 @@ frappe.provide('erpnext.stock'); -erpnext.stock.ItemDashboard = Class.extend({ - init: function(opts) { +erpnext.stock.ItemDashboard = class ItemDashboard { + constructor(opts) { $.extend(this, opts); this.make(); - }, - make: function() { + } + make() { var me = this; this.start = 0; if(!this.sort_by) { @@ -73,8 +73,8 @@ erpnext.stock.ItemDashboard = Class.extend({ me.refresh(); }); - }, - refresh: function() { + } + refresh() { if(this.before_refresh) { this.before_refresh(); } @@ -98,8 +98,8 @@ erpnext.stock.ItemDashboard = Class.extend({ me.render(r.message); } }); - }, - render: function(data) { + } + render(data) { if (this.start===0) { this.max_count = 0; this.result.empty(); @@ -135,9 +135,9 @@ erpnext.stock.ItemDashboard = Class.extend({ $(`
${message}
`).appendTo(this.result); } - }, + } - get_item_dashboard_data: function(data, max_count, show_item) { + get_item_dashboard_data(data, max_count, show_item) { if(!max_count) max_count = 0; if(!data) data = []; @@ -164,9 +164,9 @@ erpnext.stock.ItemDashboard = Class.extend({ can_write:can_write, show_item: show_item || false }; - }, + } - get_capacity_dashboard_data: function(data) { + get_capacity_dashboard_data(data) { if (!data) data = []; data.forEach(function(d) { @@ -183,7 +183,7 @@ erpnext.stock.ItemDashboard = Class.extend({ can_write: can_write, }; } -}); +}; erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callback) { var dialog = new frappe.ui.Dialog({ diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 334bdeac9d..63ea198c59 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -123,17 +123,17 @@ frappe.ui.form.on("Delivery Note Item", { } }); -erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({ - setup: function(doc) { +erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpnext.selling.SellingController { + setup(doc) { this.setup_posting_date_time_check(); - this._super(doc); + super.setup(doc); this.frm.make_methods = { 'Delivery Trip': this.make_delivery_trip, }; - }, - refresh: function(doc, dt, dn) { + } + refresh(doc, dt, dn) { var me = this; - this._super(); + super.refresh(); if ((!doc.is_return) && (doc.status!="Closed" || this.frm.is_new())) { if (this.frm.doc.docstatus===0) { this.frm.add_custom_button(__('Sales Order'), @@ -231,64 +231,64 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( erpnext.utils.make_subscription(doc.doctype, doc.name) }, __('Create')) } - }, + } - make_shipment: function() { + make_shipment() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_shipment", frm: this.frm }) - }, + } - make_sales_invoice: function() { + make_sales_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", frm: this.frm }) - }, + } - make_installation_note: function() { + make_installation_note() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note", frm: this.frm }); - }, + } - make_sales_return: function() { + make_sales_return() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_return", frm: this.frm }) - }, + } - make_delivery_trip: function() { + make_delivery_trip() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", frm: cur_frm }) - }, + } - tc_name: function() { + tc_name() { this.get_terms(); - }, + } - items_on_form_rendered: function(doc, grid_row) { + items_on_form_rendered(doc, grid_row) { erpnext.setup_serial_no(); - }, + } - packed_items_on_form_rendered: function(doc, grid_row) { + packed_items_on_form_rendered(doc, grid_row) { erpnext.setup_serial_no(); - }, + } - close_delivery_note: function(doc){ + close_delivery_note(doc){ this.update_status("Closed") - }, + } - reopen_delivery_note : function() { + reopen_delivery_note() { this.update_status("Submitted") - }, + } - update_status: function(status) { + update_status(status) { var me = this; frappe.ui.form.is_saving = true; frappe.call({ @@ -302,8 +302,8 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( frappe.ui.form.is_saving = false; } }) - }, -}); + } +}; $.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm})); diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js index 1abbc35334..433f78adc9 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js +++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js @@ -5,8 +5,8 @@ frappe.provide("erpnext.stock"); -erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ - setup: function() { +erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock.StockController { + setup() { var me = this; this.frm.fields_dict.purchase_receipts.grid.get_field('receipt_document').get_query = function (doc, cdt, cdn) { @@ -30,9 +30,9 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ this.frm.add_fetch("receipt_document", "supplier", "supplier"); this.frm.add_fetch("receipt_document", "posting_date", "posting_date"); this.frm.add_fetch("receipt_document", "base_grand_total", "grand_total"); - }, + } - refresh: function() { + refresh() { var help_content = `

@@ -67,9 +67,9 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ let company_currency = frappe.get_doc(":Company", this.frm.doc.company).default_currency; this.frm.set_currency_labels(["total_taxes_and_charges"], company_currency); } - }, + } - get_items_from_purchase_receipts: function() { + get_items_from_purchase_receipts() { var me = this; if(!this.frm.doc.purchase_receipts.length) { frappe.msgprint(__("Please enter Purchase Receipt first")); @@ -82,22 +82,22 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ } }); } - }, + } - amount: function(frm) { + amount(frm) { this.set_total_taxes_and_charges(); this.set_applicable_charges_for_item(); - }, + } - set_total_taxes_and_charges: function() { + set_total_taxes_and_charges() { var total_taxes_and_charges = 0.0; $.each(this.frm.doc.taxes || [], function(i, d) { total_taxes_and_charges += flt(d.base_amount); }); this.frm.set_value("total_taxes_and_charges", total_taxes_and_charges); - }, + } - set_applicable_charges_for_item: function() { + set_applicable_charges_for_item() { var me = this; if(this.frm.doc.taxes.length) { @@ -123,15 +123,15 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ refresh_field("items"); } } - }, - distribute_charges_based_on: function (frm) { + } + distribute_charges_based_on (frm) { this.set_applicable_charges_for_item(); - }, + } - items_remove: () => { + items_remove() { this.trigger('set_applicable_charges_for_item'); } -}); +}; cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher); diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 527b0d3ea9..86936b4db3 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -403,28 +403,28 @@ frappe.ui.form.on("Material Request Item", { } }); -erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({ - tc_name: function() { +erpnext.buying.MaterialRequestController = class MaterialRequestController extends erpnext.buying.BuyingController { + tc_name() { this.get_terms(); - }, + } - item_code: function() { + item_code() { // to override item code trigger from transaction.js - }, + } - validate_company_and_party: function() { + validate_company_and_party() { return true; - }, + } - calculate_taxes_and_totals: function() { + calculate_taxes_and_totals() { return; - }, + } - validate: function() { + validate() { set_schedule_date(this.frm); - }, + } - onload: function(doc, cdt, cdn) { + onload(doc, cdt, cdn) { this.frm.set_query("item_code", "items", function() { if (doc.material_request_type == "Customer Provided") { return{ @@ -438,9 +438,9 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten } } }); - }, + } - items_add: function(doc, cdt, cdn) { + items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); if(doc.schedule_date) { row.schedule_date = doc.schedule_date; @@ -448,16 +448,16 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten } else { this.frm.script_manager.copy_from_first_row("items", row, ["schedule_date"]); } - }, + } - items_on_form_rendered: function() { - set_schedule_date(this.frm); - }, - - schedule_date: function() { + items_on_form_rendered() { set_schedule_date(this.frm); } -}); + + schedule_date() { + set_schedule_date(this.frm); + } +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm})); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 57cc3504a9..f87b273d64 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -86,15 +86,15 @@ frappe.ui.form.on("Purchase Receipt", { } }); -erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ - setup: function(doc) { +erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extends erpnext.buying.BuyingController { + setup(doc) { this.setup_posting_date_time_check(); - this._super(doc); - }, + super.setup(doc); + } - refresh: function() { + refresh() { var me = this; - this._super(); + super.refresh(); if(this.frm.doc.docstatus > 0) { this.show_stock_ledger(); //removed for temporary @@ -173,31 +173,31 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend } this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes"); - }, + } - make_purchase_invoice: function() { + make_purchase_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", frm: cur_frm }) - }, + } - make_purchase_return: function() { + make_purchase_return() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_return", frm: cur_frm }) - }, + } - close_purchase_receipt: function() { + close_purchase_receipt() { cur_frm.cscript.update_status("Closed"); - }, + } - reopen_purchase_receipt: function() { + reopen_purchase_receipt() { cur_frm.cscript.update_status("Submitted"); - }, + } - make_retention_stock_entry: function() { + make_retention_stock_entry() { frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.move_sample_to_retention_warehouse", args:{ @@ -214,13 +214,13 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend } } }); - }, + } - apply_putaway_rule: function() { + apply_putaway_rule() { if (this.frm.doc.apply_putaway_rule) erpnext.apply_putaway_rule(this.frm); } -}); +}; // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 64dcbed1d8..16e74636ce 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -777,8 +777,8 @@ frappe.ui.form.on('Landed Cost Taxes and Charges', { } }); -erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ - setup: function() { +erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockController { + setup() { var me = this; this.setup_posting_date_time_check(); @@ -825,9 +825,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ frappe.dynamic_link = { doc: this.frm.doc, fieldname: 'supplier', doctype: 'Supplier' } this.frm.set_query("supplier_address", erpnext.queries.address_query) - }, + } - onload_post_render: function() { + onload_post_render() { var me = this; this.set_default_account(function() { if(me.frm.doc.__islocal && me.frm.doc.company && !me.frm.doc.amended_from) { @@ -836,9 +836,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }); this.frm.get_field("items").grid.set_multiple_add("item_code", "qty"); - }, + } - refresh: function() { + refresh() { var me = this; erpnext.toggle_naming_series(); this.toggle_related_fields(this.frm.doc); @@ -850,22 +850,22 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ erpnext.hide_company(); erpnext.utils.add_item(this.frm); this.frm.trigger('add_to_transit'); - }, + } - scan_barcode: function() { + scan_barcode() { let transaction_controller= new erpnext.TransactionController({frm:this.frm}); transaction_controller.scan_barcode(); - }, + } - on_submit: function() { + on_submit() { this.clean_up(); - }, + } - after_cancel: function() { + after_cancel() { this.clean_up(); - }, + } - set_default_account: function(callback) { + set_default_account(callback) { var me = this; if(this.frm.doc.company && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { @@ -885,9 +885,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }); } - }, + } - clean_up: function() { + clean_up() { // Clear Work Order record from locals, because it is updated via Stock Entry if(this.frm.doc.work_order && in_list(["Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture"], @@ -895,13 +895,13 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ frappe.model.remove_from_locals("Work Order", this.frm.doc.work_order); } - }, + } - fg_completed_qty: function() { + fg_completed_qty() { this.get_items(); - }, + } - get_items: function() { + get_items() { var me = this; if(!this.frm.doc.fg_completed_qty || !this.frm.doc.bom_no) frappe.throw(__("BOM and Manufacturing Quantity are required")); @@ -917,9 +917,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }); } - }, + } - work_order: function() { + work_order() { var me = this; this.toggle_enable_bom(); if(!me.frm.doc.work_order || me.frm.doc.job_card) { @@ -952,13 +952,13 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } } }); - }, + } - toggle_enable_bom: function() { + toggle_enable_bom() { this.frm.toggle_enable("bom_no", !!!this.frm.doc.work_order); - }, + } - add_excise_button: function() { + add_excise_button() { if(frappe.boot.sysdefaults.country === "India") this.frm.add_custom_button(__("Excise Invoice"), function() { var excise = frappe.model.make_new_doc_and_get_name('Journal Entry'); @@ -966,35 +966,35 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ excise.voucher_type = 'Excise Entry'; frappe.set_route('Form', 'Journal Entry', excise.name); }, __('Create')); - }, + } - items_add: function(doc, cdt, cdn) { + items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("items", row, ["expense_account", "cost_center"]); if(!row.s_warehouse) row.s_warehouse = this.frm.doc.from_warehouse; if(!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse; - }, + } - from_warehouse: function(doc) { + from_warehouse(doc) { this.frm.trigger('set_tansit_warehouse'); this.set_warehouse_in_children(doc.items, "s_warehouse", doc.from_warehouse); - }, + } - to_warehouse: function(doc) { + to_warehouse(doc) { this.set_warehouse_in_children(doc.items, "t_warehouse", doc.to_warehouse); - }, + } - set_warehouse_in_children: function(child_table, warehouse_field, warehouse) { + set_warehouse_in_children(child_table, warehouse_field, warehouse) { let transaction_controller = new erpnext.TransactionController(); transaction_controller.autofill_warehouse(child_table, warehouse_field, warehouse); - }, + } - items_on_form_rendered: function(doc, grid_row) { + items_on_form_rendered(doc, grid_row) { erpnext.setup_serial_no(); - }, + } - toggle_related_fields: function(doc) { + toggle_related_fields(doc) { this.frm.toggle_enable("from_warehouse", doc.purpose!='Material Receipt'); this.frm.toggle_enable("to_warehouse", doc.purpose!='Material Issue'); @@ -1021,12 +1021,12 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ doc.purpose!='Material Issue'); this.frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue'); - }, + } - supplier: function(doc) { + supplier(doc) { erpnext.utils.get_party_details(this.frm, null, null, null); } -}); +}; erpnext.stock.select_batch_and_serial_no = (frm, item) => { let get_warehouse_type_and_name = (item) => { diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index ac4ed5e75d..3badc7ee60 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -220,8 +220,8 @@ frappe.ui.form.on("Stock Reconciliation Item", { }); -erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ - setup: function() { +erpnext.stock.StockReconciliation = class StockReconciliation extends erpnext.stock.StockController { + setup() { var me = this; this.setup_posting_date_time_check(); @@ -249,17 +249,17 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ } } } - }, + } - refresh: function() { + refresh() { if(this.frm.doc.docstatus > 0) { this.show_stock_ledger(); if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { this.show_general_ledger(); } } - }, + } -}); +}; cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm}); diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js index 79f46758d1..c9aa41fdae 100644 --- a/erpnext/support/doctype/warranty_claim/warranty_claim.js +++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js @@ -36,8 +36,8 @@ frappe.ui.form.on("Warranty Claim", { } }); -erpnext.support.WarrantyClaim = frappe.ui.form.Controller.extend({ - refresh: function() { +erpnext.support.WarrantyClaim = class WarrantyClaim extends frappe.ui.form.Controller { + refresh() { frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'} if(!cur_frm.doc.__islocal && @@ -45,15 +45,15 @@ erpnext.support.WarrantyClaim = frappe.ui.form.Controller.extend({ cur_frm.add_custom_button(__('Maintenance Visit'), this.make_maintenance_visit); } - }, + } - make_maintenance_visit: function() { + make_maintenance_visit() { frappe.model.open_mapped_doc({ method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit", frm: cur_frm }) } -}); +}; $.extend(cur_frm.cscript, new erpnext.support.WarrantyClaim({frm: cur_frm})); diff --git a/erpnext/templates/includes/rfq.js b/erpnext/templates/includes/rfq.js index b56c416dbd..37beb5a584 100644 --- a/erpnext/templates/includes/rfq.js +++ b/erpnext/templates/includes/rfq.js @@ -11,23 +11,23 @@ $(document).ready(function() { doc.buying_price_list = "{{ doc.buying_price_list }}" }); -rfq = Class.extend({ - init: function(){ +rfq = class rfq { + constructor(){ this.onfocus_select_all(); this.change_qty(); this.change_rate(); this.terms(); this.submit_rfq(); this.navigate_quotations(); - }, + } - onfocus_select_all: function(){ + onfocus_select_all(){ $("input").click(function(){ $(this).select(); }) - }, + } - change_qty: function(){ + change_qty(){ var me = this; $('.rfq-items').on("change", ".rfq-qty", function(){ me.idx = parseFloat($(this).attr('data-idx')); @@ -36,9 +36,9 @@ rfq = Class.extend({ me.update_qty_rate(); $(this).val(format_number(me.qty, doc.number_format, 2)); }) - }, + } - change_rate: function(){ + change_rate(){ var me = this; $(".rfq-items").on("change", ".rfq-rate", function(){ me.idx = parseFloat($(this).attr('data-idx')); @@ -47,15 +47,15 @@ rfq = Class.extend({ me.update_qty_rate(); $(this).val(format_number(me.rate, doc.number_format, 2)); }) - }, + } - terms: function(){ + terms(){ $(".terms").on("change", ".terms-feedback", function(){ doc.terms = $(this).val(); }) - }, + } - update_qty_rate: function(){ + update_qty_rate(){ var me = this; doc.grand_total = 0.0; $.each(doc.items, function(idx, data){ @@ -69,9 +69,9 @@ rfq = Class.extend({ doc.grand_total += flt(data.amount); $('.tax-grand-total').text(format_number(doc.grand_total, doc.number_format, 2)); }) - }, + } - submit_rfq: function(){ + submit_rfq(){ $('.btn-sm').click(function(){ frappe.freeze(); frappe.call({ @@ -90,12 +90,12 @@ rfq = Class.extend({ } }) }) - }, + } - navigate_quotations: function() { + navigate_quotations() { $('.quotations').click(function(){ name = $(this).attr('idx') window.location.href = "/quotations/" + encodeURIComponent(name); }) } -}) +} From f75173826707e10815cfd91bc167c00434a0a6c8 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 14:51:05 +0530 Subject: [PATCH 2/7] fix: Make js bundles --- .../js/bank-reconciliation-tool.bundle.js | 3 +++ erpnext/public/js/erpnext-web.bundle.js | 2 ++ erpnext/public/js/erpnext.bundle.js | 27 +++++++++++++++++++ .../{marketplace.js => marketplace.bundle.js} | 0 erpnext/public/js/item-dashboard.bundle.js | 5 ++++ erpnext/public/js/point-of-sale.bundle.js | 8 ++++++ 6 files changed, 45 insertions(+) create mode 100644 erpnext/public/js/bank-reconciliation-tool.bundle.js create mode 100644 erpnext/public/js/erpnext-web.bundle.js create mode 100644 erpnext/public/js/erpnext.bundle.js rename erpnext/public/js/hub/{marketplace.js => marketplace.bundle.js} (100%) create mode 100644 erpnext/public/js/item-dashboard.bundle.js create mode 100644 erpnext/public/js/point-of-sale.bundle.js diff --git a/erpnext/public/js/bank-reconciliation-tool.bundle.js b/erpnext/public/js/bank-reconciliation-tool.bundle.js new file mode 100644 index 0000000000..636ef18a51 --- /dev/null +++ b/erpnext/public/js/bank-reconciliation-tool.bundle.js @@ -0,0 +1,3 @@ +import "./bank_reconciliation_tool/data_table_manager"; +import "./bank_reconciliation_tool/number_card"; +import "./bank_reconciliation_tool/dialog_manager"; diff --git a/erpnext/public/js/erpnext-web.bundle.js b/erpnext/public/js/erpnext-web.bundle.js new file mode 100644 index 0000000000..7db6967923 --- /dev/null +++ b/erpnext/public/js/erpnext-web.bundle.js @@ -0,0 +1,2 @@ +import "./website_utils"; +import "./shopping_cart"; diff --git a/erpnext/public/js/erpnext.bundle.js b/erpnext/public/js/erpnext.bundle.js new file mode 100644 index 0000000000..519cfcac72 --- /dev/null +++ b/erpnext/public/js/erpnext.bundle.js @@ -0,0 +1,27 @@ +import "./conf"; +import "./utils"; +import "./queries"; +import "./sms_manager"; +import "./utils/party"; +import "./controllers/stock_controller"; +import "./payment/payments"; +import "./controllers/taxes_and_totals"; +import "./controllers/transaction"; +import "./templates/item_selector.html"; +import "./templates/employees_to_mark_attendance.html"; +import "./utils/item_selector"; +import "./help_links"; +import "./agriculture/ternary_plot"; +import "./templates/item_quick_entry.html"; +import "./utils/item_quick_entry"; +import "./utils/customer_quick_entry"; +import "./education/student_button.html"; +import "./education/assessment_result_tool.html"; +import "./hub/hub_factory"; +import "./call_popup/call_popup"; +import "./utils/dimension_tree_filter"; +import "./telephony"; +import "./templates/call_link.html"; + +// import { sum } from 'frappe/public/utils/util.js' + diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.bundle.js similarity index 100% rename from erpnext/public/js/hub/marketplace.js rename to erpnext/public/js/hub/marketplace.bundle.js diff --git a/erpnext/public/js/item-dashboard.bundle.js b/erpnext/public/js/item-dashboard.bundle.js new file mode 100644 index 0000000000..2d329e26aa --- /dev/null +++ b/erpnext/public/js/item-dashboard.bundle.js @@ -0,0 +1,5 @@ +import "../../stock/dashboard/item_dashboard.html"; +import "../../stock/dashboard/item_dashboard_list.html"; +import "../../stock/dashboard/item_dashboard.js"; +import "../../stock/page/warehouse_capacity_summary/warehouse_capacity_summary.html"; +import "../../stock/page/warehouse_capacity_summary/warehouse_capacity_summary_header.html"; diff --git a/erpnext/public/js/point-of-sale.bundle.js b/erpnext/public/js/point-of-sale.bundle.js new file mode 100644 index 0000000000..fbc4bbbbb3 --- /dev/null +++ b/erpnext/public/js/point-of-sale.bundle.js @@ -0,0 +1,8 @@ +import "../../selling/page/point_of_sale/pos_item_selector.js"; +import "../../selling/page/point_of_sale/pos_item_cart.js"; +import "../../selling/page/point_of_sale/pos_item_details.js"; +import "../../selling/page/point_of_sale/pos_number_pad.js"; +import "../../selling/page/point_of_sale/pos_payment.js"; +import "../../selling/page/point_of_sale/pos_past_order_list.js"; +import "../../selling/page/point_of_sale/pos_past_order_summary.js"; +import "../../selling/page/point_of_sale/pos_controller.js"; From ff3b71d2e7ad0897ca1a641febf88cba7c212fbb Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 14:52:13 +0530 Subject: [PATCH 3/7] fix: Make css bundles --- erpnext/public/css/email.css | 29 - erpnext/public/css/erpnext.css | 408 ------------ erpnext/public/css/leaflet/leaflet.css | 611 ------------------ erpnext/public/css/leaflet/leaflet.draw.css | 316 --------- erpnext/public/less/hub.less | 375 ----------- erpnext/public/less/pos.less | 229 ------- erpnext/public/less/products.less | 71 -- erpnext/public/less/website.less | 388 ----------- .../email.less => scss/email.bundle.scss} | 16 +- erpnext/public/scss/erpnext-web.bundle.scss | 2 + erpnext/public/scss/erpnext.bundle.scss | 3 + .../{less/erpnext.less => scss/erpnext.scss} | 62 +- 12 files changed, 44 insertions(+), 2466 deletions(-) delete mode 100644 erpnext/public/css/email.css delete mode 100644 erpnext/public/css/erpnext.css delete mode 100755 erpnext/public/css/leaflet/leaflet.css delete mode 100755 erpnext/public/css/leaflet/leaflet.draw.css delete mode 100644 erpnext/public/less/hub.less delete mode 100644 erpnext/public/less/pos.less delete mode 100644 erpnext/public/less/products.less delete mode 100644 erpnext/public/less/website.less rename erpnext/public/{less/email.less => scss/email.bundle.scss} (60%) create mode 100644 erpnext/public/scss/erpnext-web.bundle.scss create mode 100644 erpnext/public/scss/erpnext.bundle.scss rename erpnext/public/{less/erpnext.less => scss/erpnext.scss} (82%) diff --git a/erpnext/public/css/email.css b/erpnext/public/css/email.css deleted file mode 100644 index 8cf1a31ad6..0000000000 --- a/erpnext/public/css/email.css +++ /dev/null @@ -1,29 +0,0 @@ -.panel-header { - background-color: #fafbfc; - border: 1px solid #d1d8dd; - border-radius: 3px 3px 0 0; -} -.panel-body { - background-color: #fff; - border: 1px solid #d1d8dd; - border-top: none; - border-radius: 0 0 3px 3px; - overflow-wrap: break-word; -} -.sender-avatar { - width: 24px; - height: 24px; - border-radius: 3px; - vertical-align: middle; -} -.sender-avatar-placeholder { - width: 24px; - height: 24px; - border-radius: 3px; - vertical-align: middle; - line-height: 24px; - text-align: center; - color: #d1d8dd; - border: 1px solid #d1d8dd; - background-color: #fff; -} diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css deleted file mode 100644 index 6e4efcb668..0000000000 --- a/erpnext/public/css/erpnext.css +++ /dev/null @@ -1,408 +0,0 @@ -.erpnext-footer { - margin: 11px auto; - text-align: center; -} -.show-all-reports { - margin-top: 5px; - font-size: 11px; -} -/* toolbar */ -.toolbar-splash { - width: 32px; - height: 32px; - margin: -10px auto; -} -.erpnext-icon { - width: 24px; - margin-right: 0px; - margin-top: -3px; -} -.dashboard-list-item { - background-color: inherit; - padding: 5px 0px; - border-bottom: 1px solid #d1d8dd; -} -#page-stock-balance .dashboard-list-item { - padding: 5px 15px; -} -.dashboard-list-item:last-child { - border-bottom: none; -} -.frappe-control[data-fieldname='result_html'] { - overflow: scroll; -} -.assessment-result-tool { - table-layout: fixed; -} -.assessment-result-tool input { - width: 100%; - border: 0; - outline: none; - text-align: right; -} -.assessment-result-tool th { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} -.assessment-result-tool .total-score, -.assessment-result-tool .grade, -.assessment-result-tool .score { - text-align: right; -} -/* pos */ -body[data-route="pos"] .pos-bill-toolbar { - padding: 10px 0px; - height: 51px; -} -body[data-route="pos"] .pos-bill-item:hover, -body[data-route="pos"] .list-customers-table > .pos-list-row:hover { - background-color: #f5f7fa; - cursor: pointer; -} -body[data-route="pos"] .pos-item-qty { - display: inline-block; -} -body[data-route="pos"] .pos-qty-row > div { - padding: 5px 0px; -} -body[data-route="pos"] .pos-qty-btn { - margin-top: 3px; - cursor: pointer; - font-size: 120%; -} -body[data-route="pos"] .search-area .form-group { - max-width: 100% !important; -} -body[data-route="pos"] .tax-table { - margin-bottom: 10px; -} -body[data-route="pos"] .discount-field-col { - padding-left: 24px; -} -body[data-route="pos"] .discount-amount-area .input-group:first-child { - margin-bottom: 2px; -} -body[data-route="pos"] .payment-toolbar .row { - width: 323px; - margin: 0 auto; -} -body[data-route="pos"] .payment-mode { - cursor: pointer; - font-family: sans-serif; - font-size: 15px; -} -body[data-route="pos"] .pos-payment-row .col-xs-6 { - padding: 15px; -} -body[data-route="pos"] .pos-payment-row { - border-bottom: 1px solid #d1d8dd; - margin: 2px 0px 5px 0px; - height: 60px; - margin-top: 0px; - margin-bottom: 0px; -} -body[data-route="pos"] .pos-payment-row:hover, -body[data-route="pos"] .pos-keyboard-key:hover { - background-color: #fafbfc; - cursor: pointer; -} -body[data-route="pos"] .pos-keyboard-key, -body[data-route="pos"] .delete-btn { - border: 1px solid #d1d8dd; - height: 85px; - width: 85px; - margin: 10px 10px; - font-size: 24px; - font-weight: 200; - background-color: #FDFDFD; - border-color: #e8e8e8; -} -body[data-route="pos"] .numeric-keypad { - border: 1px solid #d1d8dd; - height: 69px; - width: 69px; - font-size: 20px; - font-weight: 200; - background-color: #FDFDFD; - border-color: #e8e8e8; - margin-left: -4px; -} -body[data-route="pos"] .pos-pay { - height: 69px; - width: 69px; - font-size: 17px; - font-weight: 200; - margin-left: -4px; -} -body[data-route="pos"] .numeric-keypad { - height: 60px; - width: 60px; - font-size: 20px; - font-weight: 200; - border-radius: 0; - background-color: #fff; - margin-left: -4px; -} -@media (max-width: 1199px) { - body[data-route="pos"] .numeric-keypad { - height: 45px; - width: 45px; - font-size: 14px; - } -} -@media (max-width: 991px) { - body[data-route="pos"] .numeric-keypad { - height: 40px; - width: 40px; - } -} -body[data-route="pos"] .numeric_keypad { - margin-left: -15px; -} -body[data-route="pos"] .numeric_keypad > .row > button { - border: none; - border-right: 1px solid #d1d8dd; - border-bottom: 1px solid #d1d8dd; -} -body[data-route="pos"] .numeric_keypad > .row > button:first-child { - border-left: 1px solid #d1d8dd; -} -body[data-route="pos"] .numeric_keypad > .row:first-child > button { - border-top: 1px solid #d1d8dd; -} -body[data-route="pos"] .pos-pay { - background-color: #5E64FF; - border: none; -} -body[data-route="pos"] .multimode-payments { - padding-left: 30px; -} -body[data-route="pos"] .payment-toolbar { - padding-right: 30px; -} -body[data-route="pos"] .list-row-head.pos-invoice-list { - border-top: 1px solid #d1d8dd; -} -body[data-route="pos"] .modal-dialog { - width: 750px; -} -@media (max-width: 767px) { - body[data-route="pos"] .modal-dialog { - width: auto; - } - body[data-route="pos"] .modal-dialog .modal-content { - height: auto; - } -} -@media (max-width: 767px) { - body[data-route="pos"] .amount-row h3 { - font-size: 15px; - } - body[data-route="pos"] .pos-keyboard-key, - body[data-route="pos"] .delete-btn { - height: 50px; - } - body[data-route="pos"] .multimode-payments { - padding-left: 15px; - } - body[data-route="pos"] .payment-toolbar { - padding-right: 15px; - } -} -body[data-route="pos"] .amount-label { - font-size: 16px; -} -body[data-route="pos"] .selected-payment-mode { - background-color: #fafbfc; - cursor: pointer; -} -body[data-route="pos"] .pos-invoice-list { - padding: 15px 10px; -} -body[data-route="pos"] .write_off_amount, -body[data-route="pos"] .change_amount { - margin: 15px; - width: 130px; -} -body[data-route="pos"] .pos-list-row { - display: table; - table-layout: fixed; - width: 100%; - padding: 9px 15px; - font-size: 12px; - margin: 0px; - border-bottom: 1px solid #d1d8dd; -} -body[data-route="pos"] .pos-list-row .cell { - display: table-cell; - vertical-align: middle; -} -body[data-route="pos"] .pos-list-row .cell.price-cell { - width: 50%; -} -body[data-route="pos"] .pos-list-row .subject { - width: 40%; -} -body[data-route="pos"] .pos-list-row .list-row-checkbox, -body[data-route="pos"] .pos-list-row .list-select-all { - margin-right: 7px; -} -body[data-route="pos"] .pos-bill-header { - background-color: #f5f7fa; - border: 1px solid #d1d8dd; - padding: 13px 15px; -} -body[data-route="pos"] .pos-list-row.active { - background-color: #fffce7; -} -body[data-route="pos"] .totals-area { - border-right: 1px solid #d1d8dd; - border-left: 1px solid #d1d8dd; - margin-bottom: 15px; -} -body[data-route="pos"] .tax-area .pos-list-row { - border: none; -} -body[data-route="pos"] .item-cart-items { - height: calc(100vh - 526px); - overflow: auto; - border: 1px solid #d1d8dd; - border-top: none; -} -@media (max-width: 767px) { - body[data-route="pos"] .item-cart-items { - height: 30vh; - } -} -body[data-route="pos"] .no-items-message { - min-height: 200px; - display: flex; - align-items: center; - justify-content: center; - height: 100%; -} -body[data-route="pos"] .pos-list-row:last-child { - border-bottom: none; -} -body[data-route="pos"] .form-section-heading { - padding: 0; -} -body[data-route="pos"] .item-list { - border: 1px solid #d1d8dd; - border-top: none; - max-height: calc(100vh - 190px); - overflow: auto; -} -@media (max-width: 767px) { - body[data-route="pos"] .item-list { - max-height: initial; - } -} -body[data-route="pos"] .item-list .image-field { - height: 140px; -} -body[data-route="pos"] .item-list .image-field .placeholder-text { - font-size: 50px; -} -body[data-route="pos"] .item-list .pos-item-wrapper { - position: relative; -} -body[data-route="pos"] .pos-bill-toolbar { - margin-top: 10px; -} -body[data-route="pos"] .search-item .form-group { - margin: 0; -} -body[data-route="pos"] .item-list-area .pos-bill-header { - padding: 5px; - padding-left: 15px; -} -body[data-route="pos"] .pos-selected-item-action .pos-list-row:first-child { - padding-top: 0; -} -body[data-route="pos"] .pos-selected-item-action > .pos-list-row { - border: none; -} -@media (max-width: 1199px) { - body[data-route="pos"] .pos-selected-item-action > .pos-list-row { - padding: 5px 15px; - } -} -body[data-route="pos"] .edit-customer-btn { - position: absolute; - right: 57px; - top: 15px; - z-index: 100; -} -body[data-route="pos"] .btn-more { - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; - background-color: #fafbfc; - min-height: 200px; -} -body[data-route="pos"] .collapse-btn { - cursor: pointer; -} -@media (max-width: 767px) { - body[data-route="pos"] .page-actions { - max-width: 110px; - } -} -.price-info { - position: absolute; - left: 0; - bottom: 0; - margin: 0 0 15px 15px; - background-color: rgba(141, 153, 166, 0.6); - padding: 5px 9px; - border-radius: 3px; - color: #fff; -} -.leaderboard .result { - border-top: 1px solid #d1d8dd; -} -.leaderboard .list-item { - padding-left: 45px; -} -.leaderboard .list-item_content { - padding-right: 45px; -} -.exercise-card { - box-shadow: 0 1px 3px rgba(0,0,0,0.30); - border-radius: 2px; - padding: 6px 6px 6px 8px; - margin-top: 10px; - height: 100% !important; -} -.exercise-card .card-img-top { - width: 100%; - height: 15vw; - object-fit: cover; -} -.exercise-card .btn-edit { - position: absolute; - bottom: 10px; - left: 20px; -} -.exercise-card .btn-del { - position: absolute; - bottom: 10px; - left: 50px; -} -.exercise-card .card-body { - margin-bottom: 10px; -} -.exercise-card .card-footer { - padding: 10px; -} -.exercise-row { - height: 100% !important; - display: flex; - flex-wrap: wrap; -} -.exercise-col { - padding: 10px; -} diff --git a/erpnext/public/css/leaflet/leaflet.css b/erpnext/public/css/leaflet/leaflet.css deleted file mode 100755 index 979a8bd712..0000000000 --- a/erpnext/public/css/leaflet/leaflet.css +++ /dev/null @@ -1,611 +0,0 @@ -/* required styles */ - -.leaflet-pane, -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow, -.leaflet-tile-container, -.leaflet-map-pane svg, -.leaflet-map-pane canvas, -.leaflet-zoom-box, -.leaflet-image-layer, -.leaflet-layer { - position: absolute; - left: 0; - top: 0; -} - -.leaflet-container { - overflow: hidden; - -ms-touch-action: none; - touch-action: none; -} - -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow { - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; - -webkit-user-drag: none; -} - - -/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ - -.leaflet-safari .leaflet-tile { - image-rendering: -webkit-optimize-contrast; -} - - -/* hack that prevents hw layers "stretching" when loading new tiles */ - -.leaflet-safari .leaflet-tile-container { - width: 1600px; - height: 1600px; - -webkit-transform-origin: 0 0; -} - -.leaflet-marker-icon, -.leaflet-marker-shadow { - display: block; -} - - -/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ - - -/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ - -.leaflet-container .leaflet-overlay-pane svg, -.leaflet-container .leaflet-marker-pane img, -.leaflet-container .leaflet-tile-pane img, -.leaflet-container img.leaflet-image-layer { - max-width: none !important; -} - -.leaflet-tile { - filter: inherit; - visibility: hidden; -} - -.leaflet-tile-loaded { - visibility: inherit; -} - -.leaflet-zoom-box { - width: 0; - height: 0; - -moz-box-sizing: border-box; - box-sizing: border-box; - z-index: 800; -} - - -/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ - -.leaflet-overlay-pane svg { - -moz-user-select: none; -} - -.leaflet-pane { - z-index: 400; -} - -.leaflet-tile-pane { - z-index: 200; -} - -.leaflet-overlay-pane { - z-index: 400; -} - -.leaflet-shadow-pane { - z-index: 500; -} - -.leaflet-marker-pane { - z-index: 600; -} - -.leaflet-popup-pane { - z-index: 700; -} - -.leaflet-map-pane canvas { - z-index: 100; -} - -.leaflet-map-pane svg { - z-index: 200; -} - -.leaflet-vml-shape { - width: 1px; - height: 1px; -} - -.lvml { - behavior: url(#default#VML); - display: inline-block; - position: absolute; -} - - -/* control positioning */ - -.leaflet-control { - position: relative; - z-index: 800; - pointer-events: auto; -} - -.leaflet-top, -.leaflet-bottom { - position: absolute; - z-index: 1000; - pointer-events: none; -} - -.leaflet-top { - top: 0; -} - -.leaflet-right { - right: 0; -} - -.leaflet-bottom { - bottom: 0; -} - -.leaflet-left { - left: 0; -} - -.leaflet-control { - float: left; - clear: both; -} - -.leaflet-right .leaflet-control { - float: right; -} - -.leaflet-top .leaflet-control { - margin-top: 10px; -} - -.leaflet-bottom .leaflet-control { - margin-bottom: 10px; -} - -.leaflet-left .leaflet-control { - margin-left: 10px; -} - -.leaflet-right .leaflet-control { - margin-right: 10px; -} - - -/* zoom and fade animations */ - -.leaflet-fade-anim .leaflet-tile { - will-change: opacity; -} - -.leaflet-fade-anim .leaflet-popup { - opacity: 0; - -webkit-transition: opacity 0.2s linear; - -moz-transition: opacity 0.2s linear; - -o-transition: opacity 0.2s linear; - transition: opacity 0.2s linear; -} - -.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { - opacity: 1; -} - -.leaflet-zoom-animated { - -webkit-transform-origin: 0 0; - -ms-transform-origin: 0 0; - transform-origin: 0 0; -} - -.leaflet-zoom-anim .leaflet-zoom-animated { - will-change: transform; -} - -.leaflet-zoom-anim .leaflet-zoom-animated { - -webkit-transition: -webkit-transform 0.25s cubic-bezier(0, 0, 0.25, 1); - -moz-transition: -moz-transform 0.25s cubic-bezier(0, 0, 0.25, 1); - -o-transition: -o-transform 0.25s cubic-bezier(0, 0, 0.25, 1); - transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1); -} - -.leaflet-zoom-anim .leaflet-tile, -.leaflet-pan-anim .leaflet-tile { - -webkit-transition: none; - -moz-transition: none; - -o-transition: none; - transition: none; -} - -.leaflet-zoom-anim .leaflet-zoom-hide { - visibility: hidden; -} - - -/* cursors */ - -.leaflet-interactive { - cursor: pointer; -} - -.leaflet-grab { - cursor: -webkit-grab; - cursor: -moz-grab; -} - -.leaflet-crosshair, -.leaflet-crosshair .leaflet-interactive { - cursor: crosshair; -} - -.leaflet-popup-pane, -.leaflet-control { - cursor: auto; -} - -.leaflet-dragging .leaflet-grab, -.leaflet-dragging .leaflet-grab .leaflet-interactive, -.leaflet-dragging .leaflet-marker-draggable { - cursor: move; - cursor: -webkit-grabbing; - cursor: -moz-grabbing; -} - - -/* visual tweaks */ - -.leaflet-container { - background: #ddd; - outline: 0; -} - -.leaflet-container a { - color: #0078A8; -} - -.leaflet-container a.leaflet-active { - outline: 2px solid orange; -} - -.leaflet-zoom-box { - border: 2px dotted #38f; - background: rgba(255, 255, 255, 0.5); -} - - -/* general typography */ - -.leaflet-container { - font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; -} - - -/* general toolbar styles */ - -.leaflet-bar { - box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65); - border-radius: 4px; -} - -.leaflet-bar a, -.leaflet-bar a:hover { - background-color: #fff; - border-bottom: 1px solid #ccc; - width: 26px; - height: 26px; - line-height: 26px; - display: block; - text-align: center; - text-decoration: none; - color: black; -} - -.leaflet-bar a, -.leaflet-control-layers-toggle { - background-position: 50% 50%; - background-repeat: no-repeat; - display: block; -} - -.leaflet-bar a:hover { - background-color: #f4f4f4; -} - -.leaflet-bar a:first-child { - border-top-left-radius: 4px; - border-top-right-radius: 4px; -} - -.leaflet-bar a:last-child { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-bottom: none; -} - -.leaflet-bar a.leaflet-disabled { - cursor: default; - background-color: #f4f4f4; - color: #bbb; -} - -.leaflet-touch .leaflet-bar a { - width: 30px; - height: 30px; - line-height: 30px; -} - - -/* zoom control */ - -.leaflet-control-zoom-in, -.leaflet-control-zoom-out { - font: bold 18px 'Lucida Console', Monaco, monospace; - text-indent: 1px; -} - -.leaflet-control-zoom-out { - font-size: 20px; -} - -.leaflet-touch .leaflet-control-zoom-in { - font-size: 22px; -} - -.leaflet-touch .leaflet-control-zoom-out { - font-size: 24px; -} - - -/* layers control */ - -.leaflet-control-layers { - box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4); - background: #fff; - border-radius: 5px; -} - -.leaflet-control-layers-toggle { - background-image: url('assets/erpnext/images/leaflet/layers.png'); - width: 36px; - height: 36px; -} - -.leaflet-retina .leaflet-control-layers-toggle { - background-image: url('assets/erpnext/images/leaflet/layers-2x.png'); - background-size: 26px 26px; -} - -.leaflet-touch .leaflet-control-layers-toggle { - width: 44px; - height: 44px; -} - -.leaflet-control-layers .leaflet-control-layers-list, -.leaflet-control-layers-expanded .leaflet-control-layers-toggle { - display: none; -} - -.leaflet-control-layers-expanded .leaflet-control-layers-list { - display: block; - position: relative; -} - -.leaflet-control-layers-expanded { - padding: 6px 10px 6px 6px; - color: #333; - background: #fff; -} - -.leaflet-control-layers-scrollbar { - overflow-y: scroll; - padding-right: 5px; -} - -.leaflet-control-layers-selector { - margin-top: 2px; - position: relative; - top: 1px; -} - -.leaflet-control-layers label { - display: block; -} - -.leaflet-control-layers-separator { - height: 0; - border-top: 1px solid #ddd; - margin: 5px -10px 5px -6px; -} - - -/* attribution and scale controls */ - -.leaflet-container .leaflet-control-attribution { - background: #fff; - background: rgba(255, 255, 255, 0.7); - margin: 0; -} - -.leaflet-control-attribution, -.leaflet-control-scale-line { - padding: 0 5px; - color: #333; -} - -.leaflet-control-attribution a { - text-decoration: none; -} - -.leaflet-control-attribution a:hover { - text-decoration: underline; -} - -.leaflet-container .leaflet-control-attribution, -.leaflet-container .leaflet-control-scale { - font-size: 11px; -} - -.leaflet-left .leaflet-control-scale { - margin-left: 5px; -} - -.leaflet-bottom .leaflet-control-scale { - margin-bottom: 5px; -} - -.leaflet-control-scale-line { - border: 2px solid #777; - border-top: none; - line-height: 1.1; - padding: 2px 5px 1px; - font-size: 11px; - white-space: nowrap; - overflow: hidden; - -moz-box-sizing: border-box; - box-sizing: border-box; - background: #fff; - background: rgba(255, 255, 255, 0.5); -} - -.leaflet-control-scale-line:not(:first-child) { - border-top: 2px solid #777; - border-bottom: none; - margin-top: -2px; -} - -.leaflet-control-scale-line:not(:first-child):not(:last-child) { - border-bottom: 2px solid #777; -} - -.leaflet-touch .leaflet-control-attribution, -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - box-shadow: none; -} - -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - border: 2px solid rgba(0, 0, 0, 0.2); - background-clip: padding-box; -} - - -/* popup */ - -.leaflet-popup { - position: absolute; - text-align: center; -} - -.leaflet-popup-content-wrapper { - padding: 1px; - text-align: left; - border-radius: 12px; -} - -.leaflet-popup-content { - margin: 13px 19px; - line-height: 1.4; -} - -.leaflet-popup-content p { - margin: 18px 0; -} - -.leaflet-popup-tip-container { - margin: 0 auto; - width: 40px; - height: 20px; - position: relative; - overflow: hidden; -} - -.leaflet-popup-tip { - width: 17px; - height: 17px; - padding: 1px; - margin: -10px auto 0; - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); -} - -.leaflet-popup-content-wrapper, -.leaflet-popup-tip { - background: white; - color: #333; - box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4); -} - -.leaflet-container a.leaflet-popup-close-button { - position: absolute; - top: 0; - right: 0; - padding: 4px 4px 0 0; - border: none; - text-align: center; - width: 18px; - height: 14px; - font: 16px/14px Tahoma, Verdana, sans-serif; - color: #c3c3c3; - text-decoration: none; - font-weight: bold; - background: transparent; -} - -.leaflet-container a.leaflet-popup-close-button:hover { - color: #999; -} - -.leaflet-popup-scrolled { - overflow: auto; - border-bottom: 1px solid #ddd; - border-top: 1px solid #ddd; -} - -.leaflet-oldie .leaflet-popup-content-wrapper { - zoom: 1; -} - -.leaflet-oldie .leaflet-popup-tip { - width: 24px; - margin: 0 auto; - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; - filter: progid: DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); -} - -.leaflet-oldie .leaflet-popup-tip-container { - margin-top: -1px; -} - -.leaflet-oldie .leaflet-control-zoom, -.leaflet-oldie .leaflet-control-layers, -.leaflet-oldie .leaflet-popup-content-wrapper, -.leaflet-oldie .leaflet-popup-tip { - border: 1px solid #999; -} - - -/* div icon */ - -.leaflet-div-icon { - background: #fff; - border: 1px solid #666; -} \ No newline at end of file diff --git a/erpnext/public/css/leaflet/leaflet.draw.css b/erpnext/public/css/leaflet/leaflet.draw.css deleted file mode 100755 index 6fb7db0e64..0000000000 --- a/erpnext/public/css/leaflet/leaflet.draw.css +++ /dev/null @@ -1,316 +0,0 @@ -/* ================================================================== */ - - -/* Toolbars -/* ================================================================== */ - -.leaflet-draw-section { - position: relative; -} - -.leaflet-draw-toolbar { - margin-top: 12px; -} - -.leaflet-draw-toolbar-top { - margin-top: 0; -} - -.leaflet-draw-toolbar-notop a:first-child { - border-top-right-radius: 0; -} - -.leaflet-draw-toolbar-nobottom a:last-child { - border-bottom-right-radius: 0; -} - -.leaflet-draw-toolbar a { - background-image: url('assets/erpnext/images/leaflet/spritesheet.png'); - background-repeat: no-repeat; -} - -.leaflet-retina .leaflet-draw-toolbar a { - background-image: url('assets/erpnext/images/leaflet/spritesheet-2x.png'); - background-size: 270px 30px; -} - -.leaflet-draw a { - display: block; - text-align: center; - text-decoration: none; -} - - -/* ================================================================== */ - - -/* Toolbar actions menu -/* ================================================================== */ - -.leaflet-draw-actions { - display: none; - list-style: none; - margin: 0; - padding: 0; - position: absolute; - left: 26px; - /* leaflet-draw-toolbar.left + leaflet-draw-toolbar.width */ - top: 0; - white-space: nowrap; -} - -.leaflet-right .leaflet-draw-actions { - right: 26px; - left: auto; -} - -.leaflet-draw-actions li { - display: inline-block; -} - -.leaflet-draw-actions li:first-child a { - border-left: none; -} - -.leaflet-draw-actions li:last-child a { - -webkit-border-radius: 0 4px 4px 0; - border-radius: 0 4px 4px 0; -} - -.leaflet-right .leaflet-draw-actions li:last-child a { - -webkit-border-radius: 0; - border-radius: 0; -} - -.leaflet-right .leaflet-draw-actions li:first-child a { - -webkit-border-radius: 4px 0 0 4px; - border-radius: 4px 0 0 4px; -} - -.leaflet-draw-actions a { - background-color: #919187; - border-left: 1px solid #AAA; - color: #FFF; - font: 11px/19px "Helvetica Neue", Arial, Helvetica, sans-serif; - line-height: 28px; - text-decoration: none; - padding-left: 10px; - padding-right: 10px; - height: 28px; -} - -.leaflet-draw-actions-bottom { - margin-top: 0; -} - -.leaflet-draw-actions-top { - margin-top: 1px; -} - -.leaflet-draw-actions-top a, -.leaflet-draw-actions-bottom a { - height: 27px; - line-height: 27px; -} - -.leaflet-draw-actions a:hover { - background-color: #A0A098; -} - -.leaflet-draw-actions-top.leaflet-draw-actions-bottom a { - height: 26px; - line-height: 26px; -} - - -/* ================================================================== */ - - -/* Draw toolbar -/* ================================================================== */ - -.leaflet-draw-toolbar .leaflet-draw-draw-polyline { - background-position: -2px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-draw-polygon { - background-position: -31px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-draw-rectangle { - background-position: -62px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-draw-circle { - background-position: -92px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-draw-marker { - background-position: -122px -2px; -} - - -/* ================================================================== */ - - -/* Edit toolbar -/* ================================================================== */ - -.leaflet-draw-toolbar .leaflet-draw-edit-edit { - background-position: -152px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-edit-remove { - background-position: -182px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled { - background-position: -212px -2px; -} - -.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled { - background-position: -242px -2px; -} - - -/* ================================================================== */ - - -/* Drawing styles -/* ================================================================== */ - -.leaflet-mouse-marker { - background-color: #fff; - cursor: crosshair; -} - -.leaflet-draw-tooltip { - background: rgb(54, 54, 54); - background: rgba(0, 0, 0, 0.5); - border: 1px solid transparent; - -webkit-border-radius: 4px; - border-radius: 4px; - color: #fff; - font: 12px/18px "Helvetica Neue", Arial, Helvetica, sans-serif; - margin-left: 20px; - margin-top: -21px; - padding: 4px 8px; - position: absolute; - visibility: hidden; - white-space: nowrap; - z-index: 6; -} - -.leaflet-draw-tooltip:before { - border-right: 6px solid black; - border-right-color: rgba(0, 0, 0, 0.5); - border-top: 6px solid transparent; - border-bottom: 6px solid transparent; - content: ""; - position: absolute; - top: 7px; - left: -7px; -} - -.leaflet-error-draw-tooltip { - background-color: #F2DEDE; - border: 1px solid #E6B6BD; - color: #B94A48; -} - -.leaflet-error-draw-tooltip:before { - border-right-color: #E6B6BD; -} - -.leaflet-draw-tooltip-single { - margin-top: -12px -} - -.leaflet-draw-tooltip-subtext { - color: #f8d5e4; -} - -.leaflet-draw-guide-dash { - font-size: 1%; - opacity: 0.6; - position: absolute; - width: 5px; - height: 5px; -} - - -/* ================================================================== */ - - -/* Edit styles -/* ================================================================== */ - -.leaflet-edit-marker-selected { - background: rgba(254, 87, 161, 0.1); - border: 4px dashed rgba(254, 87, 161, 0.6); - -webkit-border-radius: 4px; - border-radius: 4px; -} - -.leaflet-edit-move { - cursor: move; -} - -.leaflet-edit-resize { - cursor: pointer; -} - - -/* ================================================================== */ - - -/* Old IE styles -/* ================================================================== */ - -.leaflet-oldie .leaflet-draw-toolbar { - border: 3px solid #999; -} - -.leaflet-oldie .leaflet-draw-toolbar a { - background-color: #eee; -} - -.leaflet-oldie .leaflet-draw-toolbar a:hover { - background-color: #fff; -} - -.leaflet-oldie .leaflet-draw-actions { - left: 32px; - margin-top: 3px; -} - -.leaflet-oldie .leaflet-draw-actions li { - display: inline; - zoom: 1; -} - -.leaflet-oldie .leaflet-edit-marker-selected { - border: 4px dashed #fe93c2; -} - -.leaflet-oldie .leaflet-draw-actions a { - background-color: #999; -} - -.leaflet-oldie .leaflet-draw-actions a:hover { - background-color: #a5a5a5; -} - -.leaflet-oldie .leaflet-draw-actions-top a { - margin-top: 1px; -} - -.leaflet-oldie .leaflet-draw-actions-bottom a { - height: 28px; - line-height: 28px; -} - -.leaflet-oldie .leaflet-draw-actions-top.leaflet-draw-actions-bottom a { - height: 27px; - line-height: 27px; -} \ No newline at end of file diff --git a/erpnext/public/less/hub.less b/erpnext/public/less/hub.less deleted file mode 100644 index 29deada8a4..0000000000 --- a/erpnext/public/less/hub.less +++ /dev/null @@ -1,375 +0,0 @@ -@import "variables.less"; -@import (reference) "desk.less"; - -body[data-route*="marketplace"] { - .layout-side-section { - padding-top: 25px; - padding-left: 5px; - padding-right: 25px; - } - - [data-route], [data-action] { - cursor: pointer; - } - - .layout-main-section { - border: none; - font-size: @text-medium; - padding-top: 25px; - - @media (max-width: @screen-xs) { - padding-left: 20px; - padding-right: 20px; - } - } - - input, textarea { - font-size: @text-medium; - } - - .hub-image { - height: 200px; - } - - .hub-image-loading, .hub-image-broken { - content: " "; - position: absolute; - left: 0; - height: 100%; - width: 100%; - background-color: var(--bg-light-gray); - display: flex; - align-items: center; - justify-content: center; - - span { - font-size: 32px; - color: @text-extra-muted; - } - } - - .progress-bar { - background-color: #89da28; - } - - .subpage-title.flex { - align-items: flex-start; - justify-content: space-between; - } - - .hub-card { - margin-bottom: 25px; - position: relative; - border: 1px solid @border-color; - border-radius: 4px; - overflow: hidden; - - &:hover .hub-card-overlay { - display: block; - } - } - - .hub-card.is-local { - &.active { - .hub-card-header { - background-color: #f4ffe5; - } - - .octicon-check { - display: inline; - } - } - - .octicon-check { - display: none; - position: absolute; - font-size: 20px; - right: 15px; - top: 50%; - transform: translateY(-50%); - } - } - - .hub-card-header { - position: relative; - padding: 12px 15px; - height: 60px; - border-bottom: 1px solid @border-color; - } - - .hub-card-body { - position: relative; - height: 200px; - } - - .hub-card-overlay { - display: none; - position: absolute; - top: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.05); - } - - .hub-card-overlay-body { - position: relative; - height: 100%; - } - - .hub-card-overlay-button { - position: absolute; - right: 15px; - bottom: 15px; - } - - .hub-card-image { - position: relative; - width: 100%; - height: 100%; - object-fit: contain; - } - - .hub-search-container { - margin-bottom: 20px; - - input { - height: 32px; - } - } - - .hub-sidebar { - padding-top: 25px; - padding-right: 15px; - } - - .hub-sidebar-group { - margin-bottom: 10px; - } - - .hub-sidebar-item { - padding: 5px 8px; - margin-bottom: 3px; - border-radius: 4px; - border: 1px solid transparent; - - &.active, &:hover:not(.is-title) { - border-color: @border-color; - } - } - - .hub-item-image { - position: relative; - border: 1px solid @border-color; - border-radius: 4px; - overflow: hidden; - height: 200px; - width: 200px; - display: flex; - align-items: center; - } - - .hub-item-skeleton-image { - border-radius: 4px; - background-color: @light-bg; - overflow: hidden; - height: 200px; - width: 200px; - } - - .hub-skeleton { - background-color: @light-bg; - color: @light-bg; - max-width: 500px; - } - - .hub-item-seller img { - width: 50px; - height: 50px; - border-radius: 4px; - border: 1px solid @border-color; - } - - .register-title { - font-size: @text-regular; - } - - .register-form { - border: 1px solid @border-color; - border-radius: 4px; - padding: 15px 25px; - } - - .publish-area.filled { - .empty-items-container { - display: none; - } - } - - .publish-area.empty { - .hub-items-container { - display: none; - } - } - - .publish-area-head { - display: flex; - justify-content: space-between; - margin-bottom: 20px; - } - - .hub-list-item { - display: flex; - justify-content: space-between; - align-items: center; - border: 1px solid @border-color; - margin-bottom: -1px; - overflow: hidden; - } - - .hub-list-item:first-child { - border-top-left-radius: 4px; - border-top-right-radius: 4px; - } - .hub-list-item:last-child { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - } - - .hub-list-left { - display: flex; - align-items: center; - max-width: 90%; - } - - .hub-list-right { - padding-right: 15px; - } - - .hub-list-image { - position: relative; - width: 58px; - height: 58px; - border-right: 1px solid @border-color; - - &::after { - font-size: 12px; - } - } - - .hub-list-body { - padding: 12px 15px; - } - - .hub-list-title { - font-weight: bold; - } - - .hub-list-subtitle { - color: @text-muted; - } - - .selling-item-message-card { - max-width: 500px; - margin-bottom: 15px; - border-radius: 3px; - border: 1px solid @border-color; - .selling-item-detail { - overflow: auto; - .item-image { - float: left; - height: 80px; - width: 80px; - object-fit: contain; - margin: 5px; - } - .item-name { - margin-left: 10px; - } - } - .received-message-container { - clear: left; - background-color: @light-bg; - .received-message { - border-top: 1px solid @border-color; - padding: 10px; - } - .frappe-timestamp { - float: right; - } - } - } - - .form-container { - .frappe-control { - max-width: 100% !important; - } - } - - .form-message { - padding-top: 0; - padding-bottom: 0; - border-bottom: none; - } - - .hub-items-container { - .hub-items-header { - justify-content: space-between; - align-items: baseline; - } - } - - .hub-item-container { - overflow: hidden; - } - - .hub-item-review-container { - margin-top: calc(30vh); - } - - .hub-item-dropdown { - margin-top: 20px; - } - - /* messages page */ - - .message-list-item { - display: flex; - align-items: center; - padding: 8px 12px; - - &:not(.active) { - filter: grayscale(1); - color: @text-muted; - } - - &:hover { - background-color: @light-bg; - } - - .list-item-left { - width: 30px; - border-radius: 4px; - overflow: hidden; - margin-right: 15px; - } - - .list-item-body { - font-weight: bold; - padding-bottom: 1px; - } - } - - .message-container { - display: flex; - flex-direction: column; - border: 1px solid @border-color; - border-radius: 3px; - height: calc(100vh - 300px); - justify-content: space-between; - padding: 15px; - } - - .message-list { - overflow: scroll; - } -} diff --git a/erpnext/public/less/pos.less b/erpnext/public/less/pos.less deleted file mode 100644 index b081ed4414..0000000000 --- a/erpnext/public/less/pos.less +++ /dev/null @@ -1,229 +0,0 @@ -@import "../../../../frappe/frappe/public/less/variables.less"; - -[data-route="point-of-sale"] { - .layout-main-section-wrapper { - margin-bottom: 0; - } - - .pos-items-wrapper { - max-height: ~"calc(100vh - 210px)"; - } -} - -.pos { - // display: flex; - padding: 15px; -} - -.list-item { - min-height: 40px; - height: auto; -} - -.cart-container { - padding: 0 15px; - // flex: 2; - display: inline-block; - width: 39%; - vertical-align: top; -} - -.item-container { - padding: 0 15px; - // flex: 3; - display: inline-block; - width: 60%; - vertical-align: top; -} - -.search-field { - width: 60%; - - input::placeholder { - font-size: @text-medium; - } -} - -.item-group-field { - width: 40%; - margin-left: 15px; -} - -.cart-wrapper { - margin-bottom: 12px; - .list-item__content:not(:first-child) { - justify-content: flex-end; - } - - .list-item--head .list-item__content:nth-child(2) { - flex: 1.5; - } -} - -.cart-items { - height: 150px; - overflow: auto; - - .list-item.current-item { - background-color: @light-yellow; - } - - .list-item.current-item.qty input { - border: 1px solid @brand-primary; - font-weight: bold; - } - - .list-item.current-item.disc .discount { - font-weight: bold; - } - - .list-item.current-item.rate .rate { - font-weight: bold; - } - - .list-item .quantity { - flex: 1.5; - } - - input { - text-align: right; - height: 22px; - font-size: @text-medium; - } -} - -.fields { - display: flex; -} - -.pos-items-wrapper { - max-height: 480px; - overflow-y: auto; -} - -.pos-items { - overflow: hidden; -} - -.pos-item-wrapper { - display: flex; - flex-direction: column; - position: relative; - width: 25%; -} - -.image-view-container { - display: block; -} - -.image-view-container .image-field { - height: auto; -} - -.empty-state { - height: 100%; - position: relative; - - span { - position: absolute; - color: @text-muted; - font-size: @text-medium; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - } -} - -@keyframes yellow-fade { - 0% {background-color: @light-yellow;} - 100% {background-color: transparent;} -} - -.highlight { - animation: yellow-fade 1s ease-in 1; -} - -input[type=number]::-webkit-inner-spin-button, -input[type=number]::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; -} - -// number pad - -.number-pad { - border-collapse: collapse; - cursor: pointer; - display: table; -} -.num-row { - display: table-row; -} -.num-col { - display: table-cell; - border: 1px solid @border-color; - - & > div { - width: 50px; - height: 50px; - text-align: center; - line-height: 50px; - } - - &.active { - background-color: @light-yellow; - } - - &.brand-primary { - background-color: @brand-primary; - color: #ffffff; - } -} - -// taxes, totals and discount area -.discount-amount { - .discount-inputs { - display: flex; - flex-direction: column; - padding: 15px 0; - } - - input:first-child { - margin-bottom: 10px; - } -} - -.taxes-and-totals { - border-top: 1px solid @border-color; - - .taxes { - display: flex; - flex-direction: column; - padding: 15px 0; - align-items: flex-end; - - & > div:first-child { - margin-bottom: 10px; - } - } -} - -.grand-total { - border-top: 1px solid @border-color; - - .list-item { - height: 60px; - } - - .grand-total-value { - font-size: 18px; - } -} - -.rounded-total-value { - font-size: 18px; -} - -.quantity-total { - font-size: 18px; -} \ No newline at end of file diff --git a/erpnext/public/less/products.less b/erpnext/public/less/products.less deleted file mode 100644 index 5e744ceac5..0000000000 --- a/erpnext/public/less/products.less +++ /dev/null @@ -1,71 +0,0 @@ -@import "variables.less"; - -.products-list .product-image { - display: inline-block; - width: 160px; - height: 160px; - object-fit: contain; - margin-right: 1rem; -} - -.product-image.no-image { - display: flex; - justify-content: center; - align-items: center; - font-size: 3rem; - color: var(--gray); - background: var(--light); -} - -.product-image a { - text-decoration: none; -} - -.filter-options { - margin-left: -5px; - padding-left: 5px; - max-height: 300px; - overflow: auto; -} - -.item-slideshow-image { - height: 3rem; - width: 3rem; - object-fit: contain; - padding: 0.5rem; - border: 1px solid @border-color; - border-radius: 4px; - cursor: pointer; - - &:hover, &.active { - border-color: var(--primary); - } -} - -.address-card { - cursor: pointer; - position: relative; - - .check { - display: none; - } - - &.active { - border-color: var(--primary); - - .check { - display: inline-flex; - } - } -} - -.check { - display: inline-flex; - padding: 0.25rem; - background: var(--primary); - color: white; - border-radius: 50%; - font-size: 12px; - width: 24px; - height: 24px; -} \ No newline at end of file diff --git a/erpnext/public/less/website.less b/erpnext/public/less/website.less deleted file mode 100644 index ac878de105..0000000000 --- a/erpnext/public/less/website.less +++ /dev/null @@ -1,388 +0,0 @@ -@import "variables.less"; - -.web-long-description { - font-size: 18px; - line-height: 200%; -} - -.web-page-content { - margin-bottom: 30px; -} - -.item-stock { - margin-bottom: 10px !important; -} - -.product-link { - display: block; - text-align: center; -} - - -.product-image img { - max-height: 500px; - margin: 0 auto; -} - -@media (max-width: 767px) { - .product-image { - height: 0px; - padding: 0px 0px 100%; - overflow: hidden; - } -} - -.product-image-square { - width: 100%; - height: 0; - padding: 50% 0px; - background-size: cover; - background-repeat: no-repeat; - background-position: center top; -} - -.product-image.missing-image { - .product-image-square; - position: relative; - background-color: @light-border-color; -} - -.product-image.missing-image .octicon { - font-size: 32px; - color: @border-color; -} - -.product-search { - margin-bottom: 15px; -} - - -@media (max-width: 767px) { - .product-search { - width: 100%; - } -} - -.borderless td, .borderless th { - border-bottom: 1px solid @light-border-color; - padding-left:0px !important; - line-height: 1.8em !important; -} - -.item-desc { - border-top: 2px solid @light-border-color; - padding-top:10px; -} - -.featured-products { - border-top: 1px solid @light-border-color; -} - -.transaction-list-item { - .indicator { - font-weight: inherit; - color: @text-muted; - } - - .transaction-time { - margin-top: 5px; - } - -} - -// order.html -.transaction-subheading { - .indicator { - font-weight: inherit; - color: @text-muted; - } -} - -.order-container { - margin: 50px 0px; - - .order-item-header .h6 { - padding: 7px 15px; - } - - .order-items { - margin: 30px 0px 0px; - } - - .order-item-table { - margin: 0px -15px; - } - - .order-item-header { - border-bottom: 1px solid #d1d8dd; - } - - .order-image-col { - padding-right: 0px; - } - - .order-image { - max-width: 55px; - max-height: 55px; - margin-top: -5px; - } - - .order-taxes { - margin-top: 30px; - - .row { - margin-top: 15px; - } - } - - .tax-grand-total-row { - padding-top: 15px; - padding-bottom: 30px; - } - - .tax-grand-total { - display: inline-block; - font-size: 16px; - font-weight: bold; - margin-top: 5px; - } -} - -.cart-container { - margin: 50px 0px; - - .checkout { - margin-bottom:15px; - } - - .cart-item-header .h6 { - padding: 7px 15px; - } - - .cart-items { - margin: 30px 0px 0px; - } - - .cart-item-table { - margin: 0px -15px; - } - - .cart-item-header { - border-bottom: 1px solid #d1d8dd; - } - - .cart-image-col { - padding-right: 0px; - } - - .cart-image { - max-width: 55px; - max-height: 55px; - margin-top: -5px; - } - - .cart-taxes { - margin-top: 30px; - - .row { - margin-top: 15px; - } - } - - .tax-grand-total-row { - border-top: 1px solid @border-color; - padding-top: 15px; - } - - .cart-addresses { - margin-top: 50px; - } -} - -.cart-items-dropdown .cart-dropdown, -.item_name_dropdown { - display: none; - -} - -.cart-dropdown-container { - width: 400px; - padding: 15px; - - .item-price { - display: block !important; - padding-bottom: 10px; - } - - .cart-item-header { - border-bottom: 1px solid #d1d8dd; - } - - .cart-items-dropdown { - max-height: 350px; - } - - .cart-items-dropdown .cart-dropdown { - display:block; - margin-top:15px; - } - - .item_name_dropdown { - display:block; - } - - .item-description, - .cart-items .checkout, - .item_name_and_description { - display: none; - } - - .checkout-btn { - padding-bottom:25px; - } - .col-name-description { - margin-bottom:8px; - } -} - -// .number-spinner { -// width:100px; -// margin-top:5px; -// } - -.cart-btn { - border-color: #ccc; -} -.cart-qty { - text-align:center; -} - -.product-list-link { - .row { - border-bottom: 1px solid @light-border-color; - } - - .row:hover { - background-color: @light-bg; - } - - .row > div { - padding-top: 15px; - padding-bottom: 15px; - } -} - -.product-list-link:first-child .row { - border-top: 1px solid @light-border-color; -} - -.item-group-nav-buttons { - margin-top: 15px; -} - -.footer-subscribe { - .btn-default { - background-color: transparent; - border: 1px solid @border-color; - } -} - -@media (min-width: 992px) { - .footer-subscribe { - max-width: 350px; - } -} - -.item-group-content { - margin-top: 30px; -} - -.item-group-slideshow { - margin-bottom: 1rem; -} - -.product-image-img { - border: 1px solid @light-border-color; - border-radius: 3px; -} - -.product-text { - word-wrap: break-word; - height: 75px; - display: block; /* Fallback for non-webkit */ - display: -webkit-box; - max-width: 100%; - margin: 0 auto; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; - overflow: hidden; - text-overflow: ellipsis; -} - -.product-image-wrapper { - padding-bottom: 40px; -} - -.duration-bar { - display: inline-block; - color: white; - background: #8FD288; - padding: 3px; -} - -.duration-invisible { - visibility: hidden; -} - -.duration-value { - float: right; -} - -.bar-outer-text { - color: #8FD288; - background: none; - float: none; - border: none; -} - -.bom-spec { - margin-bottom: 20px; -} - -.modal-title { - margin-top: 5px; -} - -.modal-header { - padding: 10px 15px; -} -// For Item Alternate Image -.item-alternative-image { - padding: 5px; - margin-bottom: 5px; - - &:hover { - border-color: @brand-primary; - } -} - -.item-slideshow-image { - height: 3rem; - width: 3rem; - object-fit: contain; - padding: 0.5rem; - border: 1px solid @border-color; - border-radius: 4px; - cursor: pointer; - - &:hover, &.active { - border-color: @brand-primary; - } -} - -.section-products { - .card-img-top { - max-height: 300px; - object-fit: contain; - } -} \ No newline at end of file diff --git a/erpnext/public/less/email.less b/erpnext/public/scss/email.bundle.scss similarity index 60% rename from erpnext/public/less/email.less rename to erpnext/public/scss/email.bundle.scss index 4077c4940d..3c0b918dae 100644 --- a/erpnext/public/less/email.less +++ b/erpnext/public/scss/email.bundle.scss @@ -1,14 +1,14 @@ -@import "../../../../frappe/frappe/public/less/variables.less"; +@import "frappe/public/scss/desk/variables"; .panel-header { - background-color: @light-bg; - border: 1px solid @border-color; + background-color: var(--bg-color); + border: 1px solid $border-color; border-radius: 3px 3px 0 0; } .panel-body { background-color: #fff; - border: 1px solid @border-color; + border: 1px solid $border-color; border-top: none; border-radius: 0 0 3px 3px; overflow-wrap: break-word; @@ -22,11 +22,11 @@ } .sender-avatar-placeholder { - .sender-avatar; + @extend .sender-avatar; line-height: 24px; text-align: center; - color: @border-color; - border: 1px solid @border-color; + color: $border-color; + border: 1px solid $border-color; background-color: #fff; -} \ No newline at end of file +} diff --git a/erpnext/public/scss/erpnext-web.bundle.scss b/erpnext/public/scss/erpnext-web.bundle.scss new file mode 100644 index 0000000000..6ef1892a3d --- /dev/null +++ b/erpnext/public/scss/erpnext-web.bundle.scss @@ -0,0 +1,2 @@ +@import "./shopping_cart"; +@import "./website"; diff --git a/erpnext/public/scss/erpnext.bundle.scss b/erpnext/public/scss/erpnext.bundle.scss new file mode 100644 index 0000000000..d3313c7cee --- /dev/null +++ b/erpnext/public/scss/erpnext.bundle.scss @@ -0,0 +1,3 @@ +@import "./erpnext"; +@import "./call_popup"; +@import "./point-of-sale"; diff --git a/erpnext/public/less/erpnext.less b/erpnext/public/scss/erpnext.scss similarity index 82% rename from erpnext/public/less/erpnext.less rename to erpnext/public/scss/erpnext.scss index 4076ebec1f..0e6186138f 100644 --- a/erpnext/public/less/erpnext.less +++ b/erpnext/public/scss/erpnext.scss @@ -1,4 +1,4 @@ -@import "variables.less"; +@import "frappe/public/scss/desk/variables"; .erpnext-footer { margin: 11px auto; @@ -141,7 +141,7 @@ body[data-route="pos"] { } .pos-payment-row { - border-bottom:1px solid @border-color; + border-bottom:1px solid $border-color; margin: 2px 0px 5px 0px; height: 60px; margin-top: 0px; @@ -149,12 +149,12 @@ body[data-route="pos"] { } .pos-payment-row:hover, .pos-keyboard-key:hover{ - background-color: @light-bg; + background-color: var(--bg-color); cursor: pointer; } .pos-keyboard-key, .delete-btn { - border: 1px solid @border-color; + border: 1px solid $border-color; height:85px; width:85px; margin:10px 10px; @@ -165,7 +165,7 @@ body[data-route="pos"] { } .numeric-keypad { - border: 1px solid @border-color; + border: 1px solid $border-color; height:69px; width:69px; font-size:20px; @@ -192,13 +192,13 @@ body[data-route="pos"] { background-color: #fff; margin-left:-4px; - @media (max-width: @screen-md) { + @media (max-width: map-get($grid-breakpoints, "xl")) { height: 45px; width: 45px; font-size: 14px; } - @media (max-width: @screen-sm) { + @media (max-width: map-get($grid-breakpoints, "lg")) { height: 40px; width: 40px; } @@ -209,21 +209,21 @@ body[data-route="pos"] { & > .row > button { border: none; - border-right: 1px solid @border-color; - border-bottom: 1px solid @border-color; + border-right: 1px solid $border-color; + border-bottom: 1px solid $border-color; &:first-child { - border-left: 1px solid @border-color; + border-left: 1px solid $border-color; } } & > .row:first-child > button { - border-top: 1px solid @border-color; + border-top: 1px solid $border-color; } } .pos-pay { - background-color: @brand-primary; + background-color: var(--primary); border: none; } @@ -236,13 +236,13 @@ body[data-route="pos"] { } .list-row-head.pos-invoice-list { - border-top: 1px solid @border-color; + border-top: 1px solid $border-color; } .modal-dialog { width: 750px; - @media (max-width: @screen-xs) { + @media (max-width: map-get($grid-breakpoints, 'md')) { width: auto; .modal-content { @@ -251,7 +251,7 @@ body[data-route="pos"] { } } - @media (max-width: @screen-xs) { + @media (max-width: map-get($grid-breakpoints, 'md')) { .amount-row h3 { font-size: 15px; } @@ -271,7 +271,7 @@ body[data-route="pos"] { } .selected-payment-mode { - background-color: @light-bg; + background-color: var(--bg-color); cursor: pointer; } @@ -291,7 +291,7 @@ body[data-route="pos"] { padding: 9px 15px; font-size: 12px; margin: 0px; - border-bottom: 1px solid @border-color; + border-bottom: 1px solid $border-color; .cell { display: table-cell; @@ -313,17 +313,17 @@ body[data-route="pos"] { .pos-bill-header { background-color: #f5f7fa; - border: 1px solid @border-color; + border: 1px solid $border-color; padding: 13px 15px; } .pos-list-row.active { - background-color: @light-yellow; + background-color: var(--fg-hover-color); } .totals-area { - border-right: 1px solid @border-color; - border-left: 1px solid @border-color; + border-right: 1px solid $border-color; + border-left: 1px solid $border-color; margin-bottom: 15px; } @@ -332,12 +332,12 @@ body[data-route="pos"] { } .item-cart-items { - height: ~"calc(100vh - 526px)"; + height: calc(100vh - 526px); overflow: auto; - border: 1px solid @border-color; + border: 1px solid $border-color; border-top: none; - @media (max-width: @screen-xs) { + @media (max-width: map-get($grid-breakpoints, 'md')) { height: 30vh; } } @@ -359,12 +359,12 @@ body[data-route="pos"] { } .item-list { - border: 1px solid @border-color; + border: 1px solid $border-color; border-top: none; - max-height: ~"calc(100vh - 190px)"; + max-height: calc(100vh - 190px); overflow: auto; - @media (max-width: @screen-xs) { + @media (max-width: map-get($grid-breakpoints, 'md')) { max-height: initial; } @@ -402,7 +402,7 @@ body[data-route="pos"] { &> .pos-list-row { border: none; - @media (max-width: @screen-md) { + @media (max-width: map-get($grid-breakpoints, 'xl')) { padding: 5px 15px; } } @@ -420,7 +420,7 @@ body[data-route="pos"] { justify-content: center; align-items: center; cursor: pointer; - background-color: @light-bg; + background-color: var(--bg-color); min-height: 200px; } @@ -428,7 +428,7 @@ body[data-route="pos"] { cursor: pointer; } - @media (max-width: @screen-xs) { + @media (max-width: map-get($grid-breakpoints, 'md')) { .page-actions { max-width: 110px; } @@ -491,4 +491,4 @@ body[data-route="pos"] { .exercise-col { padding: 10px; -} \ No newline at end of file +} From 464d838447fe4876df25d2ee328fa6d655ce4d6b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 14:53:42 +0530 Subject: [PATCH 4/7] fix: Update bundle paths --- .../bank_reconciliation_tool.js | 2 +- .../bank_statement_import/bank_statement_import.js | 2 +- erpnext/hooks.py | 9 +++++---- erpnext/public/js/hub/hub_factory.js | 6 +----- erpnext/selling/page/point_of_sale/point_of_sale.js | 4 ++-- erpnext/stock/doctype/item/item.js | 2 +- erpnext/stock/page/stock_balance/stock_balance.js | 2 +- .../warehouse_capacity_summary.js | 4 ++-- erpnext/templates/generators/item/item.html | 10 ++++------ erpnext/templates/pages/cart.html | 8 +++----- 10 files changed, 21 insertions(+), 28 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js index 10f660a140..f2c3dea116 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js @@ -15,7 +15,7 @@ frappe.ui.form.on("Bank Reconciliation Tool", { }, refresh: function (frm) { - frappe.require("assets/js/bank-reconciliation-tool.min.js", () => + frappe.require("bank-reconciliation-tool.bundle.js", () => frm.trigger("make_reconciliation_tool") ); frm.upload_statement_button = frm.page.set_secondary_action( diff --git a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.js b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.js index ad4ff9ee60..2b6aeee1bc 100644 --- a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.js +++ b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.js @@ -319,7 +319,7 @@ frappe.ui.form.on("Bank Statement Import", { return; } - frappe.require("/assets/js/data_import_tools.min.js", () => { + frappe.require("data_import_tools.bundle.js", () => { frm.import_preview = new frappe.data_import.ImportPreview({ wrapper: frm.get_field("import_preview").$wrapper, doctype: frm.doc.reference_doctype, diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 4b3597afd7..3f145dc958 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -15,10 +15,11 @@ app_logo_url = "/assets/erpnext/images/erpnext-logo.svg" develop_version = '13.x.x-develop' -app_include_js = "/assets/js/erpnext.min.js" -app_include_css = "/assets/css/erpnext.css" -web_include_js = "/assets/js/erpnext-web.min.js" -web_include_css = "/assets/css/erpnext-web.css" +app_include_js = "erpnext.bundle.js" +app_include_css = "erpnext.bundle.css" +web_include_js = "erpnext-web.bundle.js" +web_include_css = "erpnext-web.bundle.css" +email_css = "email.bundle.css" doctype_js = { "Address": "public/js/address.js", diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 8dab2d6251..9c67c1cf9f 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -19,11 +19,7 @@ frappe.views.MarketplaceFactory = class MarketplaceFactory extends frappe.views. } make(page_name) { - const assets = [ - '/assets/js/marketplace.min.js' - ]; - - frappe.require(assets, () => { + frappe.require('marketplace.bundle.js', () => { erpnext.hub.marketplace = new erpnext.hub.Marketplace({ parent: this.make_page(true, page_name) }); diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index e3405e0ce8..6db4150be9 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -7,7 +7,7 @@ frappe.pages['point-of-sale'].on_page_load = function(wrapper) { single_column: true }); - frappe.require('assets/js/point-of-sale.min.js', function() { + frappe.require('point-of-sale.bundle.js', function() { wrapper.pos = new erpnext.PointOfSale.Controller(wrapper); window.cur_pos = wrapper.pos; }); @@ -19,4 +19,4 @@ frappe.pages['point-of-sale'].refresh = function(wrapper) { wrapper.pos.wrapper.html(""); wrapper.pos.check_opening_entry(); } -}; \ No newline at end of file +}; diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 2079cf88dd..2aa42e66f8 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -379,7 +379,7 @@ $.extend(erpnext.item, { // Show Stock Levels only if is_stock_item if (frm.doc.is_stock_item) { - frappe.require('assets/js/item-dashboard.min.js', function() { + frappe.require('item-dashboard.bundle.js', function() { const section = frm.dashboard.add_section('', __("Stock Levels")); erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({ parent: section, diff --git a/erpnext/stock/page/stock_balance/stock_balance.js b/erpnext/stock/page/stock_balance/stock_balance.js index bddffd465e..f00dd3e791 100644 --- a/erpnext/stock/page/stock_balance/stock_balance.js +++ b/erpnext/stock/page/stock_balance/stock_balance.js @@ -62,7 +62,7 @@ frappe.pages['stock-balance'].on_page_load = function(wrapper) { // page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'}); - frappe.require('assets/js/item-dashboard.min.js', function() { + frappe.require('item-dashboard.bundle.js', function() { page.item_dashboard = new erpnext.stock.ItemDashboard({ parent: page.main, page_length: 20, diff --git a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js index b610e7dd58..c0ffdc9d51 100644 --- a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js +++ b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js @@ -79,7 +79,7 @@ frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) { } }); - frappe.require('assets/js/item-dashboard.min.js', function() { + frappe.require('item-dashboard.bundle.js', function() { $(frappe.render_template('warehouse_capacity_summary_header')).appendTo(page.main); page.capacity_dashboard = new erpnext.stock.ItemDashboard({ @@ -117,4 +117,4 @@ frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) { setup_click('Item'); setup_click('Warehouse'); }); -}; \ No newline at end of file +}; diff --git a/erpnext/templates/generators/item/item.html b/erpnext/templates/generators/item/item.html index 135982d709..17f6880293 100644 --- a/erpnext/templates/generators/item/item.html +++ b/erpnext/templates/generators/item/item.html @@ -28,9 +28,7 @@ {% block base_scripts %} - - - - - -{% endblock %} \ No newline at end of file +{{ include_script("frappe-web.bundle.js") }} +{{ include_script("controls.bundle.js") }} +{{ include_script("dialog.bundle.js") }} +{% endblock %} diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html index ea343713a1..c64c6343cc 100644 --- a/erpnext/templates/pages/cart.html +++ b/erpnext/templates/pages/cart.html @@ -139,9 +139,7 @@ {% block base_scripts %} - - - - - +{{ include_script("frappe-web.bundle.js") }} +{{ include_script("controls.bundle.js") }} +{{ include_script("dialog.bundle.js") }} {% endblock %} From 0c8294c963782767829228c95191ec87e0f5afd0 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 14:53:55 +0530 Subject: [PATCH 5/7] fix: gitignore dist directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 652fbdc317..63c51c4976 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ latest_updates.json .wnf-lang-status *.egg-info dist/ +erpnext/public/dist erpnext/docs/current *.swp *.swo From a0ac5e3b13b230c309c4069a7a5b9aa63e9c2bb9 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 14:57:32 +0530 Subject: [PATCH 6/7] chore: Add git blame ignore revs file Ignore the commit which replaces use of Class.extend with native class in git blames --- .git-blame-ignore-revs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..c820d233a5 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,12 @@ +# Since version 2.23 (released in August 2019), git-blame has a feature +# to ignore or bypass certain commits. +# +# This file contains a list of commits that are not likely what you +# are looking for in a blame, such as mass reformatting or renaming. +# You can set this file as a default ignore file for blame by running +# the following command. +# +# $ git config blame.ignoreRevsFile .git-blame-ignore-revs + +# Replace use of Class.extend with native JS class +1fe891b287a1b3f225d29ee3d07e7b1824aba9e7 From f97cc0367b699cb8342bd753c7e54d8a3b1d0cf9 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 7 May 2021 15:32:06 +0530 Subject: [PATCH 7/7] fix: initialize filters in constructor --- erpnext/public/js/stock_analytics.js | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index c74b45e6db..dfe2c88ea8 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -31,6 +31,30 @@ erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport { if(opts) $.extend(args, opts); super(args); + + this.filters = [ + {fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty", + options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}], + filter: function(val, item, opts, me) { + return me.apply_zero_filter(val, item, opts, me); + }}, + {fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand", + default_value: __("Select Brand..."), filter: function(val, item, opts) { + return val == opts.default_value || item.brand == val || item._show; + }, link_formatter: {filter_input: "brand"}}, + {fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse", + default_value: __("Select Warehouse...")}, + {fieldtype:"Date", label: __("From Date"), fieldname: "from_date"}, + {fieldtype:"Date", label: __("To Date"), fieldname: "to_date"}, + {fieldtype:"Select", label: __("Range"), fieldname: "range", + options:[ + {label:__("Daily"), value:"Daily"}, + {label:__("Weekly"), value:"Weekly"}, + {label:__("Monthly"), value:"Monthly"}, + {label:__("Quarterly"), value:"Quarterly"}, + {label:__("Yearly"), value:"Yearly"}, + ]} + ]; } setup_columns() { var std_columns = [ @@ -45,30 +69,6 @@ erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport { this.columns = std_columns.concat(this.columns); } - filters = [ - {fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty", - options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}], - filter: function(val, item, opts, me) { - return me.apply_zero_filter(val, item, opts, me); - }}, - {fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand", - default_value: __("Select Brand..."), filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val || item._show; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse", - default_value: __("Select Warehouse...")}, - {fieldtype:"Date", label: __("From Date"), fieldname: "from_date"}, - {fieldtype:"Date", label: __("To Date"), fieldname: "to_date"}, - {fieldtype:"Select", label: __("Range"), fieldname: "range", - options:[ - {label:__("Daily"), value:"Daily"}, - {label:__("Weekly"), value:"Weekly"}, - {label:__("Monthly"), value:"Monthly"}, - {label:__("Quarterly"), value:"Quarterly"}, - {label:__("Yearly"), value:"Yearly"}, - ]} - ] - setup_filters() { var me = this; super.setup_filters();