From ab74ca7fff18222f8e89818c433d9c05d9e273bc Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 30 May 2017 12:54:42 +0530 Subject: [PATCH] Lint and fix JS files --- erpnext/accounts/doctype/account/account.js | 58 ++++----- .../accounts/doctype/account/account_tree.js | 4 +- erpnext/accounts/doctype/asset/asset.js | 74 +++++------ erpnext/accounts/doctype/asset/asset_list.js | 2 +- .../doctype/asset_movement/asset_movement.js | 2 +- .../doctype/bank_guarantee/bank_guarantee.js | 4 +- .../doctype/cost_center/cost_center.js | 2 +- .../doctype/fiscal_year/fiscal_year.js | 4 +- .../doctype/journal_entry/journal_entry.js | 11 +- .../monthly_distribution.js | 12 +- .../doctype/payment_entry/payment_entry.js | 66 ++++++---- .../payment_reconciliation.js | 9 +- .../period_closing_voucher.js | 2 +- .../doctype/pos_profile/pos_profile.js | 30 ++--- .../doctype/pricing_rule/pricing_rule.js | 116 ++++++++--------- .../purchase_invoice/purchase_invoice.js | 12 +- .../purchase_taxes_and_charges_template.js | 6 +- .../doctype/sales_invoice/sales_invoice.js | 25 ++-- erpnext/accounts/page/pos/pos.js | 70 +++++----- .../accounts_payable/accounts_payable.js | 4 +- .../accounts_payable_summary.js | 4 +- .../accounts_receivable.js | 6 +- .../accounts_receivable_summary.js | 8 +- .../bank_clearance_summary.js | 2 +- .../bank_reconciliation_statement.js | 2 +- .../budget_variance_report.js | 2 +- .../item_wise_purchase_register.js | 2 +- .../item_wise_sales_register.js | 2 +- .../payment_period_based_on_invoice_date.js | 2 +- .../purchase_invoice_trends.js | 2 +- .../purchase_register/purchase_register.js | 2 +- .../sales_invoice_trends.js | 2 +- .../report/sales_register/sales_register.js | 2 +- .../doctype/purchase_order/purchase_order.js | 2 +- .../purchase_order/purchase_order_list.js | 24 ++-- .../request_for_quotation.js | 86 ++++++------- erpnext/buying/doctype/supplier/supplier.js | 28 ++-- .../supplier_quotation/supplier_quotation.js | 2 +- .../purchase_analytics/purchase_analytics.js | 8 +- .../purchase_order_trends.js | 2 +- .../quoted_item_comparison.js | 105 +++++++-------- erpnext/crm/doctype/lead/lead.js | 13 +- .../crm/doctype/opportunity/opportunity.js | 9 +- .../campaign_efficiency.js | 30 ++--- ...nutes_to_first_response_for_opportunity.js | 50 ++++---- erpnext/hr/doctype/appraisal/appraisal.js | 4 +- erpnext/hr/doctype/attendance/attendance.js | 2 +- .../employee_attendance_tool.js | 2 +- .../hr/doctype/employee_loan/employee_loan.js | 48 +++---- .../hr/doctype/expense_claim/expense_claim.js | 17 ++- .../leave_allocation/leave_allocation.js | 2 +- .../leave_application/leave_application.js | 8 +- .../leave_control_panel.js | 22 ++-- .../hr/doctype/offer_letter/offer_letter.js | 16 +-- .../process_payroll/process_payroll.js | 104 +++++++-------- erpnext/hr/doctype/salary_slip/salary_slip.js | 2 +- .../salary_structure/salary_structure.js | 35 ++--- .../upload_attendance/upload_attendance.js | 6 +- erpnext/hr/doctype/vehicle_log/vehicle_log.js | 22 ++-- erpnext/hr/page/team_updates/team_updates.js | 9 +- .../report/salary_register/salary_register.js | 2 +- .../maintenance_schedule.js | 8 +- .../maintenance_visit/maintenance_visit.js | 4 +- erpnext/manufacturing/doctype/bom/bom.js | 34 ++--- .../production_order/production_order.js | 26 ++-- .../production_planning_tool.js | 11 +- .../production_analytics.js | 22 ++-- .../bom_stock_report/bom_stock_report.js | 26 ++-- .../production_order_stock_report.js | 13 +- erpnext/projects/doctype/project/project.js | 12 +- .../projects/doctype/timesheet/timesheet.js | 19 +-- erpnext/public/js/account_tree_grid.js | 25 ++-- erpnext/public/js/communication.js | 2 +- erpnext/public/js/controllers/accounts.js | 13 +- erpnext/public/js/controllers/buying.js | 121 +++++++++--------- .../public/js/controllers/taxes_and_totals.js | 27 ++-- erpnext/public/js/controllers/transaction.js | 37 +++--- erpnext/public/js/payment/payments.js | 6 +- erpnext/public/js/purchase_trends_filters.js | 4 +- erpnext/public/js/sales_trends_filters.js | 6 +- erpnext/public/js/setup_wizard.js | 20 +-- erpnext/public/js/shopping_cart.js | 19 +-- erpnext/public/js/sms_manager.js | 6 +- erpnext/public/js/stock_analytics.js | 11 +- erpnext/public/js/utils.js | 2 +- erpnext/public/js/utils/item_selector.js | 4 +- erpnext/public/js/utils/party.js | 6 +- .../assessment_plan/assessment_plan.js | 70 +++++----- .../assessment_result/assessment_result.js | 78 +++++------ .../course_schedule/course_schedule.js | 22 ++-- .../course_scheduling_tool.js | 18 +-- .../doctype/fee_structure/fee_structure.js | 2 +- erpnext/schools/doctype/fees/fees.js | 12 +- erpnext/schools/doctype/fees/fees_list.js | 3 +- .../program_enrollment/program_enrollment.js | 8 +- .../program_enrollment_tool.js | 6 +- .../student_applicant/student_applicant.js | 2 +- .../student_attendance_tool.js | 11 -- .../student_group_creation_tool.js | 8 +- .../absent_student_report.js | 2 +- .../student_batch_wise_attendance.js | 14 +- .../student_monthly_attendance_sheet.js | 70 +++++----- .../installation_note/installation_note.js | 10 +- .../selling/doctype/quotation/quotation.js | 6 +- .../doctype/sales_order/sales_order.js | 14 +- .../doctype/sales_order/sales_order_list.js | 6 +- .../page/sales_analytics/sales_analytics.js | 9 +- .../quotation_trends/quotation_trends.js | 2 +- .../sales_order_trends/sales_order_trends.js | 2 +- ..._person_target_variance_item_group_wise.js | 2 +- .../sales_person_wise_transaction_summary.js | 2 +- ...rritory_target_variance_item_group_wise.js | 2 +- erpnext/selling/sales_common.js | 54 ++++---- erpnext/setup/doctype/company/company.js | 57 +++++---- .../doctype/email_digest/email_digest.js | 10 +- .../global_defaults/global_defaults.js | 2 +- erpnext/stock/dashboard/item_dashboard.js | 2 +- erpnext/stock/doctype/batch/batch.js | 106 +++++++-------- .../doctype/delivery_note/delivery_note.js | 4 +- erpnext/stock/doctype/item/item.js | 14 +- .../landed_cost_voucher.js | 67 +++++----- .../material_request/material_request.js | 13 +- .../doctype/packing_slip/packing_slip.js | 28 ++-- .../purchase_receipt/purchase_receipt.js | 8 +- .../stock/doctype/stock_entry/stock_entry.js | 24 ++-- .../doctype/stock_entry/stock_entry_list.js | 2 +- .../stock_reconciliation.js | 4 +- .../batch_item_expiry_status.js | 2 +- .../batch_wise_balance_history.js | 2 +- .../delivery_note_trends.js | 2 +- .../itemwise_recommended_reorder_level.js | 4 +- .../purchase_receipt_trends.js | 2 +- .../report/stock_balance/stock_balance.js | 2 +- .../support_analytics/support_analytics.js | 9 +- erpnext/templates/includes/cart.js | 23 ++-- erpnext/templates/includes/product_list.js | 1 - erpnext/templates/includes/product_page.js | 23 ++-- erpnext/templates/pages/projects.js | 7 +- 138 files changed, 1280 insertions(+), 1268 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 4c04fc6f70a..8a9a4398a4f 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -2,26 +2,26 @@ // License: GNU General Public License v3. See license.txt -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - if(doc.__islocal) { - msgprint(__("Please create new account from Chart of Accounts.")); +cur_frm.cscript.refresh = function (doc, cdt, cdn) { + if (doc.__islocal) { + frappe.msgprint(__("Please create new account from Chart of Accounts.")); throw "cannot create"; } cur_frm.toggle_display('account_name', doc.__islocal); // hide fields if group - cur_frm.toggle_display(['account_type', 'tax_rate'], cint(doc.is_group)==0) + cur_frm.toggle_display(['account_type', 'tax_rate'], cint(doc.is_group) == 0) // disable fields cur_frm.toggle_enable(['account_name', 'is_group', 'company'], false); - if(cint(doc.is_group)==0) { + if (cint(doc.is_group) == 0) { cur_frm.toggle_display('freeze_account', doc.__onload && doc.__onload.can_freeze_account); } // read-only for root accounts - if(!doc.parent_account) { + if (!doc.parent_account) { cur_frm.set_read_only(); cur_frm.set_intro(__("This is a root account and cannot be edited.")); } else { @@ -38,53 +38,53 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.add_fetch('parent_account', 'report_type', 'report_type'); cur_frm.add_fetch('parent_account', 'root_type', 'root_type'); -cur_frm.cscript.account_type = function(doc, cdt, cdn) { - if(doc.is_group==0) { +cur_frm.cscript.account_type = function (doc, cdt, cdn) { + if (doc.is_group == 0) { cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax'); - cur_frm.toggle_display('warehouse', doc.account_type=='Stock'); + cur_frm.toggle_display('warehouse', doc.account_type == 'Stock'); } } -cur_frm.cscript.add_toolbar_buttons = function(doc) { +cur_frm.cscript.add_toolbar_buttons = function (doc) { cur_frm.add_custom_button(__('Chart of Accounts'), - function() { frappe.set_route("Tree", "Account"); }); + function () { frappe.set_route("Tree", "Account"); }); if (doc.is_group == 1) { cur_frm.add_custom_button(__('Group to Non-Group'), - function() { cur_frm.cscript.convert_to_ledger(); }, 'fa fa-retweet', 'btn-default'); + function () { cur_frm.cscript.convert_to_ledger(); }, 'fa fa-retweet', 'btn-default'); } else if (cint(doc.is_group) == 0) { - cur_frm.add_custom_button(__('Ledger'), function() { + cur_frm.add_custom_button(__('Ledger'), function () { frappe.route_options = { "account": doc.name, - "from_date": sys_defaults.year_start_date, - "to_date": sys_defaults.year_end_date, + "from_date": frappe.sys_defaults.year_start_date, + "to_date": frappe.sys_defaults.year_end_date, "company": doc.company }; frappe.set_route("query-report", "General Ledger"); }); cur_frm.add_custom_button(__('Non-Group to Group'), - function() { cur_frm.cscript.convert_to_group(); }, 'fa fa-retweet', 'btn-default') + function () { cur_frm.cscript.convert_to_group(); }, 'fa fa-retweet', 'btn-default') } } -cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { - if(r.message == 1) { - cur_frm.refresh(); - } - }); +cur_frm.cscript.convert_to_ledger = function (doc, cdt, cdn) { + return $c_obj(cur_frm.doc, 'convert_group_to_ledger', '', function (r, rt) { + if (r.message == 1) { + cur_frm.refresh(); + } + }); } -cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { - if(r.message == 1) { - cur_frm.refresh(); - } - }); +cur_frm.cscript.convert_to_group = function (doc, cdt, cdn) { + return $c_obj(cur_frm.doc, 'convert_ledger_to_group', '', function (r, rt) { + if (r.message == 1) { + cur_frm.refresh(); + } + }); } -cur_frm.fields_dict['parent_account'].get_query = function(doc) { +cur_frm.fields_dict['parent_account'].get_query = function (doc) { return { filters: { "is_group": 1, diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index 1fbbf4fa91c..2cfafd1eefb 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -72,8 +72,8 @@ frappe.treeview_settings["Account"] = { click: function(node, btn) { frappe.route_options = { "account": node.label, - "from_date": sys_defaults.year_start_date, - "to_date": sys_defaults.year_end_date, + "from_date": frappe.sys_defaults.year_start_date, + "to_date": frappe.sys_defaults.year_end_date, "company": frappe.defaults.get_default('company') ? frappe.defaults.get_default('company'): "" }; frappe.set_route("query-report", "General Ledger"); diff --git a/erpnext/accounts/doctype/asset/asset.js b/erpnext/accounts/doctype/asset/asset.js index a1b3dd3bbf4..7c4eeae93a4 100644 --- a/erpnext/accounts/doctype/asset/asset.js +++ b/erpnext/accounts/doctype/asset/asset.js @@ -14,7 +14,7 @@ frappe.ui.form.on('Asset', { } }; }); - + frm.set_query("warehouse", function() { return { "filters": { @@ -24,12 +24,12 @@ frappe.ui.form.on('Asset', { }; }); }, - + refresh: function(frm) { frappe.ui.form.trigger("Asset", "is_existing_asset"); frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1); frm.events.make_schedules_editable(frm); - + if (frm.doc.docstatus==1) { if (frm.doc.status=='Submitted' && !frm.doc.is_existing_asset && !frm.doc.purchase_invoice) { frm.add_custom_button("Make Purchase Invoice", function() { @@ -40,60 +40,60 @@ frappe.ui.form.on('Asset', { frm.add_custom_button("Transfer Asset", function() { erpnext.asset.transfer_asset(frm); }); - + frm.add_custom_button("Scrap Asset", function() { erpnext.asset.scrap_asset(frm); }); - + frm.add_custom_button("Sell Asset", function() { erpnext.asset.make_sales_invoice(frm); }); - + } else if (frm.doc.status=='Scrapped') { frm.add_custom_button("Restore Asset", function() { erpnext.asset.restore_asset(frm); }); } - + frm.trigger("show_graph"); } }, - - show_graph: function(frm) { + + show_graph: function(frm) { var x_intervals = ["x", frm.doc.purchase_date]; var asset_values = ["Asset Value", frm.doc.gross_purchase_amount]; var last_depreciation_date = frm.doc.purchase_date; - + if(frm.doc.opening_accumulated_depreciation) { - last_depreciation_date = frappe.datetime.add_months(frm.doc.next_depreciation_date, + last_depreciation_date = frappe.datetime.add_months(frm.doc.next_depreciation_date, -1*frm.doc.frequency_of_depreciation); - + x_intervals.push(last_depreciation_date); - asset_values.push(flt(frm.doc.gross_purchase_amount) - + asset_values.push(flt(frm.doc.gross_purchase_amount) - flt(frm.doc.opening_accumulated_depreciation)); } - + $.each(frm.doc.schedules || [], function(i, v) { x_intervals.push(v.schedule_date); - asset_value = flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount); - if(v.journal_entry) { + var asset_value = flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount); + if(v.journal_entry) { last_depreciation_date = v.schedule_date; asset_values.push(asset_value) } else { if (in_list(["Scrapped", "Sold"], frm.doc.status)) { - asset_values.push(null) + asset_values.push(null) } else { asset_values.push(asset_value) } } }) - + if(in_list(["Scrapped", "Sold"], frm.doc.status)) { x_intervals.push(frm.doc.disposal_date); asset_values.push(0); last_depreciation_date = frm.doc.disposal_date; } - + frm.dashboard.setup_chart({ data: { x: 'x', @@ -117,9 +117,9 @@ frappe.ui.form.on('Asset', { padding: {bottom: 10} } } - }); + }); }, - + item_code: function(frm) { if(frm.doc.item_code) { frappe.call({ @@ -137,27 +137,27 @@ frappe.ui.form.on('Asset', { }) } }, - + is_existing_asset: function(frm) { frm.toggle_enable("supplier", frm.doc.is_existing_asset); frm.toggle_reqd("next_depreciation_date", !frm.doc.is_existing_asset); }, - + opening_accumulated_depreciation: function(frm) { erpnext.asset.set_accululated_depreciation(frm); }, - + depreciation_method: function(frm) { frm.events.make_schedules_editable(frm); }, - + make_schedules_editable: function(frm) { var is_editable = frm.doc.depreciation_method==="Manual" ? true : false; frm.toggle_enable("schedules", is_editable); frm.fields_dict["schedules"].grid.toggle_enable("schedule_date", is_editable); frm.fields_dict["schedules"].grid.toggle_enable("depreciation_amount", is_editable); } - + }); frappe.ui.form.on('Depreciation Schedule', { @@ -177,7 +177,7 @@ frappe.ui.form.on('Depreciation Schedule', { }) } }, - + depreciation_amount: function(frm, cdt, cdn) { erpnext.asset.set_accululated_depreciation(frm); } @@ -186,11 +186,11 @@ frappe.ui.form.on('Depreciation Schedule', { erpnext.asset.set_accululated_depreciation = function(frm) { if(frm.doc.depreciation_method != "Manual") return; - - accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation); + + var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation); $.each(frm.doc.schedules || [], function(i, row) { accumulated_depreciation += flt(row.depreciation_amount); - frappe.model.set_value(row.doctype, row.name, + frappe.model.set_value(row.doctype, row.name, "accumulated_depreciation_amount", accumulated_depreciation); }) } @@ -260,9 +260,9 @@ erpnext.asset.transfer_asset = function(frm) { title: __("Transfer Asset"), fields: [ { - "label": __("Target Warehouse"), + "label": __("Target Warehouse"), "fieldname": "target_warehouse", - "fieldtype": "Link", + "fieldtype": "Link", "options": "Warehouse", "get_query": function () { return { @@ -271,13 +271,13 @@ erpnext.asset.transfer_asset = function(frm) { ["Warehouse", "is_group", "=", 0] ] } - }, - "reqd": 1 + }, + "reqd": 1 }, { - "label": __("Date"), + "label": __("Date"), "fieldname": "transfer_date", - "fieldtype": "Datetime", + "fieldtype": "Datetime", "reqd": 1, "default": frappe.datetime.now_datetime() } @@ -285,7 +285,7 @@ erpnext.asset.transfer_asset = function(frm) { }); dialog.set_primary_action(__("Transfer"), function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; dialog.hide(); return frappe.call({ diff --git a/erpnext/accounts/doctype/asset/asset_list.js b/erpnext/accounts/doctype/asset/asset_list.js index 961ab3ffd90..8e262f13786 100644 --- a/erpnext/accounts/doctype/asset/asset_list.js +++ b/erpnext/accounts/doctype/asset/asset_list.js @@ -1,3 +1,3 @@ frappe.listview_settings['Asset'] = { - add_fields: ['image'] + add_fields: ['image'] } \ No newline at end of file diff --git a/erpnext/accounts/doctype/asset_movement/asset_movement.js b/erpnext/accounts/doctype/asset_movement/asset_movement.js index 808f01a40ce..70c4080d1c8 100644 --- a/erpnext/accounts/doctype/asset_movement/asset_movement.js +++ b/erpnext/accounts/doctype/asset_movement/asset_movement.js @@ -4,7 +4,7 @@ frappe.ui.form.on('Asset Movement', { onload: function(frm) { frm.add_fetch("asset", "warehouse", "source_warehouse"); - + frm.set_query("target_warehouse", function() { return { filters: [ diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js index 499320223a7..0439b73818b 100644 --- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js +++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js @@ -20,11 +20,11 @@ frappe.ui.form.on('Bank Guarantee', { }); }, start_date: function(frm) { - end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1); + var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1); cur_frm.set_value("end_date", end_date); }, validity: function(frm) { - end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1); + var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1); cur_frm.set_value("end_date", end_date); } }); \ No newline at end of file diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index 5d11005c314..cbc37fff8d3 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -43,7 +43,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) { if(!doc.company){ - msgprint(__('Please enter company name first')); + frappe.msgprint(__('Please enter company name first')); } } diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js index a516557824f..4dc64338ae4 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js @@ -13,7 +13,7 @@ $.extend(cur_frm.cscript, { this.frm.toggle_enable('year_start_date', doc.__islocal) this.frm.toggle_enable('year_end_date', doc.__islocal) - if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) { + if (!doc.__islocal && (doc.name != frappe.sys_defaults.fiscal_year)) { this.frm.add_custom_button(__("Default"), this.frm.cscript.set_as_default, "fa fa-star"); this.frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'")); @@ -30,7 +30,7 @@ $.extend(cur_frm.cscript, { year_start_date: function(doc, dt, dn) { var me = this; - year_end_date = + var year_end_date = frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1); this.frm.set_value("year_end_date", year_end_date); }, diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index bb01103624d..4880224c24e 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -62,11 +62,10 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ if(this.frm.doc.__islocal && this.frm.doc.company) { frappe.model.set_default_values(this.frm.doc); $.each(this.frm.doc.accounts || [], function(i, jvd) { - frappe.model.set_default_values(jvd); - } - ); + frappe.model.set_default_values(jvd); + }); - if(!this.frm.doc.amended_from) this.frm.doc.posting_date = this.frm.posting_date || get_today(); + if(!this.frm.doc.amended_from) this.frm.doc.posting_date = this.frm.posting_date || frappe.datetime.get_today(); } }, @@ -124,7 +123,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ // account filter frappe.model.validate_missing(jvd, "account"); - party_account_field = jvd.reference_type==="Sales Invoice" ? "debit_to": "credit_to"; + var party_account_field = jvd.reference_type==="Sales Invoice" ? "debit_to": "credit_to"; out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]); } else { // party_type and party mandatory @@ -243,7 +242,7 @@ cur_frm.cscript.update_totals = function(doc) { cur_frm.cscript.get_balance = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){ - cur_frm.refresh(); + cur_frm.refresh(); }); } diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js index 6f3c1c4bbca..7b489de0a35 100644 --- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js +++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js @@ -2,13 +2,13 @@ // License: GNU General Public License v3. See license.txt cur_frm.cscript.onload = function(doc,cdt,cdn){ - if(doc.__islocal){ - var callback1 = function(r,rt){ - refresh_field('percentages'); - } + if(doc.__islocal){ + var callback1 = function(r,rt){ + refresh_field('percentages'); + } - return $c('runserverobj',args={'method':'get_months', 'docs':doc}, callback1); - } + return $c('runserverobj', {'method':'get_months', 'docs':doc}, callback1); + } } cur_frm.cscript.refresh = function(doc,cdt,cdn){ diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 2eef79cd761..f54193ba893 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -36,7 +36,7 @@ frappe.ui.form.on('Payment Entry', { frm.set_query("paid_to", function() { var party_account_type = frm.doc.party_type=="Customer" ? "Receivable" : "Payable"; var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) ? - ["Bank", "Cash"] : party_account_type; + ["Bank", "Cash"] : party_account_type; return { filters: { @@ -182,8 +182,8 @@ frappe.ui.form.on('Payment Entry', { if(frm.doc.payment_type == "Internal Transfer") { $.each(["party", "party_balance", "paid_from", "paid_to", "references", "total_allocated_amount"], function(i, field) { - frm.set_value(field, null); - }) + frm.set_value(field, null); + }); } else { if(!frm.doc.party) frm.set_value("party_type", frm.doc.payment_type=="Receive" ? "Customer" : "Supplier"); @@ -200,9 +200,10 @@ frappe.ui.form.on('Payment Entry', { $.each(["party", "party_balance", "paid_from", "paid_to", "paid_from_account_currency", "paid_from_account_balance", "paid_to_account_currency", "paid_to_account_balance", - "references", "total_allocated_amount"], function(i, field) { + "references", "total_allocated_amount"], + function(i, field) { frm.set_value(field, null); - }) + }) } }, @@ -487,13 +488,17 @@ frappe.ui.form.on('Payment Entry', { } }); - if((frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") || - (frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier")) { - if(total_positive_outstanding > total_negative_outstanding) - frm.set_value("paid_amount", - total_positive_outstanding - total_negative_outstanding); - } else if (total_negative_outstanding && - (total_positive_outstanding < total_negative_outstanding)) { + if( + (frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") || + (frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") + ) { + if(total_positive_outstanding > total_negative_outstanding) + frm.set_value("paid_amount", + total_positive_outstanding - total_negative_outstanding); + } else if ( + total_negative_outstanding && + total_positive_outstanding < total_negative_outstanding + ) { frm.set_value("received_amount", total_negative_outstanding - total_positive_outstanding); } @@ -561,9 +566,11 @@ frappe.ui.form.on('Payment Entry', { row.allocated_amount = 0 //If allocate payment amount checkbox is unchecked, set zero to allocate amount if(frm.doc.allocate_payment_amount){ if(row.outstanding_amount > 0 && allocated_positive_outstanding > 0) { - if(row.outstanding_amount >= allocated_positive_outstanding) - row.allocated_amount = allocated_positive_outstanding; - else row.allocated_amount = row.outstanding_amount; + if(row.outstanding_amount >= allocated_positive_outstanding) { + row.allocated_amount = allocated_positive_outstanding; + } else { + row.allocated_amount = row.outstanding_amount; + } allocated_positive_outstanding -= flt(row.allocated_amount); } else if (row.outstanding_amount < 0 && allocated_negative_outstanding) { @@ -581,7 +588,8 @@ frappe.ui.form.on('Payment Entry', { }, set_total_allocated_amount: function(frm) { - var total_allocated_amount = base_total_allocated_amount = 0.0; + var total_allocated_amount = 0.0; + var base_total_allocated_amount = 0.0; $.each(frm.doc.references || [], function(i, row) { if (row.allocated_amount) { total_allocated_amount += flt(row.allocated_amount); @@ -653,19 +661,21 @@ frappe.ui.form.on('Payment Entry', { return; } - if(frm.doc.party_type=="Customer" - && !in_list(["Sales Order", "Sales Invoice", "Journal Entry"], row.reference_doctype)) { - frappe.model.set_value(row.doctype, row.name, "reference_doctype", null); - frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Sales Order, Sales Invoice or Journal Entry", [row.idx])); - return false; - } + if(frm.doc.party_type=="Customer" && + !in_list(["Sales Order", "Sales Invoice", "Journal Entry"], row.reference_doctype) + ) { + frappe.model.set_value(row.doctype, row.name, "reference_doctype", null); + frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Sales Order, Sales Invoice or Journal Entry", [row.idx])); + return false; + } - if(frm.doc.party_type=="Supplier" && !in_list(["Purchase Order", - "Purchase Invoice", "Journal Entry"], row.reference_doctype)) { - frappe.model.set_value(row.doctype, row.name, "against_voucher_type", null); - frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Purchase Order, Purchase Invoice or Journal Entry", [row.idx])); - return false; - } + if(frm.doc.party_type=="Supplier" && + !in_list(["Purchase Order", "Purchase Invoice", "Journal Entry"], row.reference_doctype) + ) { + frappe.model.set_value(row.doctype, row.name, "against_voucher_type", null); + frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Purchase Order, Purchase Invoice or Journal Entry", [row.idx])); + return false; + } } if (row) { diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 272e47448ef..ebd9439d0e1 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -14,7 +14,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext this.frm.set_query('receivable_payable_account', function() { if(!me.frm.doc.company || !me.frm.doc.party_type) { - msgprint(__("Please select Company and Party Type first")); + frappe.msgprint(__("Please select Company and Party Type first")); } else { return{ filters: { @@ -29,7 +29,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext this.frm.set_query('bank_cash_account', function() { if(!me.frm.doc.company) { - msgprint(__("Please select Company first")); + frappe.msgprint(__("Please select Company first")); } else { return{ filters:[ @@ -96,10 +96,11 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext }, set_invoice_options: function() { + var me = this; var invoices = []; $.each(me.frm.doc.invoices || [], function(i, row) { - if (row.invoice_number && !inList(invoices, row.invoice_number)) + if (row.invoice_number && !in_list(invoices, row.invoice_number)) invoices.push(row.invoice_type + " | " + row.invoice_number); }); @@ -108,7 +109,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext me.frm.doc.name).options = "\n" + invoices.join("\n"); $.each(me.frm.doc.payments || [], function(i, p) { - if(!inList(invoices, cstr(p.invoice_number))) p.invoice_number = null; + if(!in_list(invoices, cstr(p.invoice_number))) p.invoice_number = null; }); } diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js index c5ded6dde0d..03b8f932a9e 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js @@ -3,7 +3,7 @@ frappe.ui.form.on('Period Closing Voucher', { onload: function(frm) { - if (!frm.doc.transaction_date) frm.doc.transaction_date = dateutil.obj_to_str(new Date()); + if (!frm.doc.transaction_date) frm.doc.transaction_date = frappe.datetime.obj_to_str(new Date()); }, setup: function(frm) { diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.js b/erpnext/accounts/doctype/pos_profile/pos_profile.js index c1aa0c3cb52..83016a903de 100755 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.js +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.js @@ -35,8 +35,8 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { 'company': doc.company, 'account_type': "Income Account" } - } -} + }; +}; // Cost Center @@ -47,8 +47,8 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { 'company': doc.company, 'is_group': 0 } - } -} + }; +}; // Expense Account @@ -60,8 +60,8 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) { "company": doc.company, "is_group": 0 } - } -} + }; +}; // ------------------ Get Print Heading ------------------------------------ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { @@ -69,13 +69,13 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) filters:[ ['Print Heading', 'docstatus', '!=', 2] ] - } -} + }; +}; cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) { - return{ query:"frappe.core.doctype.user.user.user_query"} -} + return{ query:"frappe.core.doctype.user.user.user_query"}; +}; cur_frm.fields_dict.write_off_account.get_query = function(doc) { return{ @@ -84,16 +84,16 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { 'is_group': 0, 'company': doc.company } - } -} + }; +}; // Write off cost center -//----------------------- +// ----------------------- cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) { return{ filters:{ 'is_group': 0, 'company': doc.company } - } -} + }; +}; diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js index 03bb7aef5ad..120329b30fb 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js @@ -2,63 +2,65 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Pricing Rule", "refresh", function(frm) { - var help_content = ['', - '', - '', - '
', - '

', - __('Notes'), - ':

', - '
    ', - '
  • ', - __("Pricing Rule is made to overwrite Price List / define discount percentage, based on some criteria."), - '
  • ', - '
  • ', - __("If selected Pricing Rule is made for 'Price', it will overwrite Price List. Pricing Rule price is the final price, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field."), - '
  • ', - '
  • ', - __('Discount Percentage can be applied either against a Price List or for all Price List.'), - '
  • ', - '
  • ', - __('To not apply Pricing Rule in a particular transaction, all applicable Pricing Rules should be disabled.'), - '
  • ', - '
', - '
', - '

', - __('How Pricing Rule is applied?'), - '

', - '
    ', - '
  1. ', - __("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand."), - '
  2. ', - '
  3. ', - __("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Type, Campaign, Sales Partner etc."), - '
  4. ', - '
  5. ', - __('Pricing Rules are further filtered based on quantity.'), - '
  6. ', - '
  7. ', - __('If two or more Pricing Rules are found based on the above conditions, Priority is applied. Priority is a number between 0 to 20 while default value is zero (blank). Higher number means it will take precedence if there are multiple Pricing Rules with same conditions.'), - '
  8. ', - '
  9. ', - __('Even if there are multiple Pricing Rules with highest priority, then following internal priorities are applied:'), - '
      ', - '
    • ', - __('Item Code > Item Group > Brand'), - '
    • ', - '
    • ', - __('Customer > Customer Group > Territory'), - '
    • ', - '
    • ', - __('Supplier > Supplier Type'), - '
    • ', - '
    ', - '
  10. ', - '
  11. ', - __('If multiple Pricing Rules continue to prevail, users are asked to set Priority manually to resolve conflict.'), - '
  12. ', - '
', - '
'].join("\n"); + var help_content = + ` + + +
+

+ + ${__('Notes')} +

+
    +
  • + ${__("Pricing Rule is made to overwrite Price List / define discount percentage, based on some criteria.")} +
  • +
  • + ${__("If selected Pricing Rule is made for 'Price', it will overwrite Price List. Pricing Rule price is the final price, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field.")} +
  • +
  • + ${__('Discount Percentage can be applied either against a Price List or for all Price List.')} +
  • +
  • + ${__('To not apply Pricing Rule in a particular transaction, all applicable Pricing Rules should be disabled.')} +
  • +
+
+

+ ${__('How Pricing Rule is applied?')} +

+
    +
  1. + ${__("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand.")} +
  2. +
  3. + ${__("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Type, Campaign, Sales Partner etc.")} +
  4. +
  5. + ${__('Pricing Rules are further filtered based on quantity.')} +
  6. +
  7. + ${__('If two or more Pricing Rules are found based on the above conditions, Priority is applied. Priority is a number between 0 to 20 while default value is zero (blank). Higher number means it will take precedence if there are multiple Pricing Rules with same conditions.')} +
  8. +
  9. + ${__('Even if there are multiple Pricing Rules with highest priority, then following internal priorities are applied:')} +
      +
    • + ${__('Item Code > Item Group > Brand')} +
    • +
    • + ${__('Customer > Customer Group > Territory')} +
    • +
    • + ${__('Supplier > Supplier Type')} +
    • +
    +
  10. +
  11. + ${__('If multiple Pricing Rules continue to prevail, users are asked to set Priority manually to resolve conflict.')} +
  12. +
+
`; set_field_options("pricing_rule_help", help_content); diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index b48fb20d6f6..94621513f3d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -101,8 +101,8 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list, }, function() { - me.apply_pricing_rule(); - }) + me.apply_pricing_rule(); + }) }, credit_to: function() { @@ -130,7 +130,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ if(cint(this.frm.doc.is_paid)) { if(!this.frm.doc.company) { this.frm.set_value("is_paid", 0) - msgprint(__("Please specify Company to proceed")); + frappe.msgprint(__("Please specify Company to proceed")); } } this.calculate_outstanding_amount(); @@ -195,19 +195,19 @@ cur_frm.script_manager.make(erpnext.accounts.PurchaseInvoice); // Hide Fields // ------------ function hide_fields(doc) { - parent_fields = ['due_date', 'is_opening', 'advances_section', 'from_date', 'to_date']; + var parent_fields = ['due_date', 'is_opening', 'advances_section', 'from_date', 'to_date']; if(cint(doc.is_paid) == 1) { hide_field(parent_fields); } else { - for (i in parent_fields) { + for (var i in parent_fields) { var docfield = frappe.meta.docfield_map[doc.doctype][parent_fields[i]]; if(!docfield.hidden) unhide_field(parent_fields[i]); } } - item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty']; + var item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty']; cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock, (cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false)); diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js index a1d8bf85d27..eb0ea7fef81 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js @@ -9,11 +9,11 @@ frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, var d = locals[cdt][cdn]; if(!d.category && d.add_deduct_tax) { - msgprint(__("Please select Category first")); + frappe.msgprint(__("Please select Category first")); d.add_deduct_tax = ''; } else if(d.category != 'Total' && d.add_deduct_tax == 'Deduct') { - msgprint(__("Cannot deduct when category is for 'Valuation' or 'Valuation and Total'")); + frappe.msgprint(__("Cannot deduct when category is for 'Valuation' or 'Valuation and Total'")); d.add_deduct_tax = ''; } refresh_field('add_deduct_tax', d.name, 'taxes'); @@ -23,7 +23,7 @@ frappe.ui.form.on("Purchase Taxes and Charges", "category", function(doc, cdt, c var d = locals[cdt][cdn]; if (d.category != 'Total' && d.add_deduct_tax == 'Deduct') { - msgprint(__("Cannot deduct when category is for 'Valuation' or 'Vaulation and Total'")); + frappe.msgprint(__("Cannot deduct when category is for 'Valuation' or 'Vaulation and Total'")); d.add_deduct_tax = ''; } refresh_field('add_deduct_tax', d.name, 'taxes'); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 3fbde29bbff..e03d4d4efe2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -175,8 +175,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte account: this.frm.doc.debit_to, price_list: this.frm.doc.selling_price_list, }, function() { - me.apply_pricing_rule(); - }) + me.apply_pricing_rule(); + }) }, debit_to: function() { @@ -267,7 +267,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if(this.frm.doc.is_pos) { if(!this.frm.doc.company) { this.frm.set_value("is_pos", 0); - msgprint(__("Please specify Company to proceed")); + frappe.msgprint(__("Please specify Company to proceed")); } else { var me = this; return this.frm.call({ @@ -311,19 +311,19 @@ $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_ // Hide Fields // ------------ cur_frm.cscript.hide_fields = function(doc) { - parent_fields = ['project', 'due_date', 'is_opening', 'source', 'total_advance', 'get_advances', + var parent_fields = ['project', 'due_date', 'is_opening', 'source', 'total_advance', 'get_advances', 'advances', 'sales_partner', 'commission_rate', 'total_commission', 'advances', 'from_date', 'to_date']; if(cint(doc.is_pos) == 1) { hide_field(parent_fields); } else { - for (i in parent_fields) { + for (var i in parent_fields) { var docfield = frappe.meta.docfield_map[doc.doctype][parent_fields[i]]; if(!docfield.hidden) unhide_field(parent_fields[i]); } } - item_fields_stock = ['batch_no', 'actual_batch_qty', 'actual_qty', 'expense_account', + var item_fields_stock = ['batch_no', 'actual_batch_qty', 'actual_qty', 'expense_account', 'warehouse', 'expense_account', 'quality_inspection'] cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock, (cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false)); @@ -400,7 +400,7 @@ cur_frm.set_query("income_account", "items", function(doc) { }); // expense account -if (sys_defaults.auto_accounting_for_stock) { +if (frappe.sys_defaults.auto_accounting_for_stock) { cur_frm.fields_dict['items'].grid.get_field('expense_account').get_query = function(doc) { return { filters: { @@ -442,11 +442,12 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { }) if(cur_frm.doc.is_pos) { - cur_frm.msgbox = frappe.msgprint(format('{0}\ - {1}', [ - __('Print'), __('New') - ])); + cur_frm.msgbox = frappe.msgprint( + ` + ${__('Print')} + + ${__('New')}` + ); } else if(cint(frappe.boot.notification_settings.sales_invoice)) { cur_frm.email_doc(frappe.boot.notification_settings.sales_invoice_message); diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index dc524e109d3..b80bf464cad 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -113,7 +113,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ email_prompt: function() { var me = this; - fields = [{label:__("To"), fieldtype:"Data", reqd: 0, fieldname:"recipients",length:524288}, + var fields = [{label:__("To"), fieldtype:"Data", reqd: 0, fieldname:"recipients",length:524288}, {fieldtype: "Section Break", collapsible: 1, label: "CC & Standard Reply"}, {fieldtype: "Section Break"}, {label:__("Subject"), fieldtype:"Data", reqd: 1, @@ -602,7 +602,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var html = ""; if(this.si_docs.length) { this.si_docs.forEach(function (data, i) { - for (key in data) { + for (var key in data) { html += frappe.render_template("pos_invoice_list", { sr: i + 1, name: key, @@ -965,7 +965,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ make_item_list: function () { var me = this; if (!this.price_list) { - msgprint(__("Price List not found or disabled")); + frappe.msgprint(__("Price List not found or disabled")); return; } @@ -1232,7 +1232,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ remove_zero_qty_item: function () { var me = this; - idx = 0 + var idx = 0; this.items = [] $.each(this.frm.doc["items"] || [], function (i, d) { if (!in_list(me.remove_item, d.idx)) { @@ -1250,7 +1250,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.wrapper.find('input.discount-percentage').on("change", function () { me.frm.doc.additional_discount_percentage = flt($(this).val(), precision("additional_discount_percentage")); - total = me.frm.doc.grand_total + var total = me.frm.doc.grand_total if (me.frm.doc.apply_discount_on == 'Net Total') { total = me.frm.doc.net_total @@ -1442,7 +1442,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if (this.frm.doc.docstatus == 1) { this.page.set_secondary_action(__("Print"), function () { - html = frappe.render(me.print_template_data, me.frm.doc) + var html = frappe.render(me.print_template_data, me.frm.doc) me.print_document(html) }) this.page.add_menu_item(__("Email"), function () { @@ -1465,19 +1465,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ print_dialog: function () { var me = this; - this.msgprint = frappe.msgprint(format('{0}\ - {1}', [ - __('Print'), __('New') - ])); + this.frappe.msgprint = frappe.msgprint( + `${__('Print')} + ${__('New')}`); $('.print_doc').click(function () { - html = frappe.render(me.print_template_data, me.frm.doc) + var html = frappe.render(me.print_template_data, me.frm.doc) me.print_document(html) }) $('.new_doc').click(function () { - me.msgprint.hide() + me.frappe.msgprint.hide() me.make_new_cart() }) }, @@ -1506,9 +1505,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ //Remove the sold serial no from the cache $.each(this.frm.doc.items, function(index, data) { - sn = data.serial_no.split('\n') + var sn = data.serial_no.split('\n') if(sn.length) { - serial_no_list = me.serial_no_data[data.item_code] + var serial_no_list = me.serial_no_data[data.item_code] if(serial_no_list) { $.each(sn, function(i, serial_no) { if(in_list(Object.keys(serial_no_list), serial_no)) { @@ -1531,7 +1530,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ toggle_input_field: function () { var pointer_events = 'inherit' - disabled = this.frm.doc.docstatus == 1 ? true: false; + var disabled = this.frm.doc.docstatus == 1 ? true: false; $(this.wrapper).find('input').attr("disabled", disabled); $(this.wrapper).find('select').attr("disabled", disabled); $(this.wrapper).find('input').attr("disabled", disabled); @@ -1571,7 +1570,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var me = this; this.si_docs = this.get_doc_from_localstorage(); $.each(this.si_docs, function (index, data) { - for (key in data) { + for (var key in data) { if (key == me.name) { me.si_docs[index][key] = me.frm.doc; me.update_localstorage(); @@ -1634,10 +1633,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ get_submitted_invoice: function () { var invoices = []; var index = 1; - docs = this.get_doc_from_localstorage(); + var docs = this.get_doc_from_localstorage(); if (docs) { invoices = $.map(docs, function (data) { - for (key in data) { + for (var key in data) { if (data[key].docstatus == 1 && index < 50) { index++ data[key].docstatus = 0; @@ -1656,7 +1655,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.new_si_docs = []; if (this.removed_items) { $.each(this.si_docs, function (index, data) { - for (key in data) { + for (var key in data) { if (!in_list(me.removed_items, key)) { me.new_si_docs.push(data); } @@ -1715,8 +1714,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ validate_serial_no: function () { var me = this; - var item_code = serial_no = ''; - for (key in this.item_serial_no) { + var item_code = '' + var serial_no = ''; + for (var key in this.item_serial_no) { item_code = key; serial_no = me.item_serial_no[key][0]; } @@ -1763,20 +1763,24 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ mandatory_batch_no: function () { var me = this; if (this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]) { - frappe.prompt([ - {'fieldname': 'batch', 'fieldtype': 'Select', 'label': __('Batch No'), 'reqd': 1, 'options':this.batch_no_data[this.items[0].item_code]} - ], - function(values){ - me.item_batch_no[me.items[0].item_code] = values.batch; - }, - __('Select Batch No')) - } + frappe.prompt([{ + 'fieldname': 'batch', + 'fieldtype': 'Select', + 'label': __('Batch No'), + 'reqd': 1, + 'options': this.batch_no_data[this.items[0].item_code] + }], + function(values){ + me.item_batch_no[me.items[0].item_code] = values.batch; + }, + __('Select Batch No')) + } }, apply_pricing_rule: function () { var me = this; $.each(this.frm.doc["items"], function (n, item) { - pricing_rule = me.get_pricing_rule(item) + var pricing_rule = me.get_pricing_rule(item) me.validate_pricing_rule(pricing_rule) if (pricing_rule.length) { item.pricing_rule = pricing_rule[0].name; @@ -1836,7 +1840,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ validate_condition: function (data) { //This method check condition based on applicable for - condition = this.get_mapper_for_pricing_rule(data)[data.applicable_for] + var condition = this.get_mapper_for_pricing_rule(data)[data.applicable_for] if (in_list(condition[1], condition[0])) { return true } @@ -1869,7 +1873,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ } }) - count = 0 + var count = 0 $.each(priority_list, function (index, value) { if (value == priority) { count++ diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js index 3ab522e4982..0c24feb96d5 100644 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.js +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js @@ -20,13 +20,13 @@ frappe.query_reports["Accounts Payable"] = { "fieldname":"report_date", "label": __("As on Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"ageing_based_on", "label": __("Ageing Based On"), "fieldtype": "Select", - "options": 'Posting Date' + NEWLINE + 'Due Date', + "options": 'Posting Date\nDue Date', "default": "Posting Date" }, { diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js index 0a1734ae22c..6277cc764da 100644 --- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js +++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js @@ -20,13 +20,13 @@ frappe.query_reports["Accounts Payable Summary"] = { "fieldname":"report_date", "label": __("Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"ageing_based_on", "label": __("Ageing Based On"), "fieldtype": "Select", - "options": 'Posting Date' + NEWLINE + 'Due Date', + "options": 'Posting Date\nDue Date', "default": "Posting Date" }, { diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js index f98d0378ed2..55d863928f5 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js @@ -26,7 +26,7 @@ frappe.query_reports["Accounts Receivable"] = { "fieldname":"credit_days_based_on", "label": __("Credit Days Based On"), "fieldtype": "Select", - "options": "" + NEWLINE + "Fixed Days" + NEWLINE + "Last Day of the Next Month" + "options": "\nFixed Days\nLast Day of the Next Month" }, { "fieldtype": "Break", @@ -35,13 +35,13 @@ frappe.query_reports["Accounts Receivable"] = { "fieldname":"report_date", "label": __("As on Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"ageing_based_on", "label": __("Ageing Based On"), "fieldtype": "Select", - "options": 'Posting Date' + NEWLINE + 'Due Date', + "options": 'Posting Date\nDue Date', "default": "Posting Date" }, { diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js index a18c1a7e79a..ceed5e595ba 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js @@ -26,7 +26,7 @@ frappe.query_reports["Accounts Receivable Summary"] = { "fieldname":"credit_days_based_on", "label": __("Credit Days Based On"), "fieldtype": "Select", - "options": "" + NEWLINE + "Fixed Days" + NEWLINE + "Last Day of the Next Month" + "options": "\nFixed Days\nLast Day of the Next Month" }, { "fieldtype": "Break", @@ -35,13 +35,13 @@ frappe.query_reports["Accounts Receivable Summary"] = { "fieldname":"report_date", "label": __("Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"ageing_based_on", "label": __("Ageing Based On"), "fieldtype": "Select", - "options": 'Posting Date' + NEWLINE + 'Due Date', + "options": 'Posting Date\nDue Date', "default": "Posting Date" }, { @@ -70,7 +70,7 @@ frappe.query_reports["Accounts Receivable Summary"] = { onload: function(report) { report.page.add_inner_button(__("Accounts Receivable"), function() { var filters = report.get_values(); - frappe.set_route('query-report', 'Accounts Receivable', {company: filters.company}); + frappe.set_route('query-report', 'Accounts Receivable', { company: filters.company }); }); } } diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js index e4f0384dcd2..dbee0229737 100644 --- a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js +++ b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js @@ -14,7 +14,7 @@ frappe.query_reports["Bank Clearance Summary"] = { "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"account", diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js index e420fb9dd10..0f9fdd7c023 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js @@ -25,7 +25,7 @@ frappe.query_reports["Bank Reconciliation Statement"] = { "fieldname":"report_date", "label": __("Date"), "fieldtype": "Date", - "default": get_today(), + "default": frappe.datetime.get_today(), "reqd": 1 }, ] diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.js b/erpnext/accounts/report/budget_variance_report/budget_variance_report.js index 2b7f1f3809f..1315b25d75c 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.js +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.js @@ -8,7 +8,7 @@ frappe.query_reports["Budget Variance Report"] = { label: __("Fiscal Year"), fieldtype: "Link", options: "Fiscal Year", - default: sys_defaults.fiscal_year, + default: frappe.sys_defaults.fiscal_year, reqd: 1 }, { diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js index bad826ed148..8d33524abb2 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js @@ -14,7 +14,7 @@ frappe.query_reports["Item-wise Purchase Register"] = { "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname": "item_code", diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js index 142a55f3c5b..65cec518fe8 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js @@ -14,7 +14,7 @@ frappe.query_reports["Item-wise Sales Register"] = frappe.query_reports["Sales R "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"customer", diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.js b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.js index 5c20510fc4c..9d4a3527a96 100644 --- a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.js +++ b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.js @@ -21,7 +21,7 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: get_today() + default: frappe.datetime.get_today() }, { fieldname:"payment_type", diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js index cc00b2af301..a95cfacaeef 100644 --- a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js +++ b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js @@ -3,6 +3,6 @@ frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { frappe.query_reports["Purchase Invoice Trends"] = { - filters: get_filters() + filters: erpnext.get_purchase_trends_filters() } }); \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_register/purchase_register.js b/erpnext/accounts/report/purchase_register/purchase_register.js index d32f7b64c08..cd795310da7 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.js +++ b/erpnext/accounts/report/purchase_register/purchase_register.js @@ -14,7 +14,7 @@ frappe.query_reports["Purchase Register"] = { "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"supplier", diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js index 0f92223d386..2d320f52cfa 100644 --- a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js +++ b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js @@ -3,6 +3,6 @@ frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { frappe.query_reports["Sales Invoice Trends"] = { - filters: get_filters() + filters: erpnext.get_sales_trends_filters() } }); \ No newline at end of file diff --git a/erpnext/accounts/report/sales_register/sales_register.js b/erpnext/accounts/report/sales_register/sales_register.js index d7aac5a83d7..2ac4ae8b2ab 100644 --- a/erpnext/accounts/report/sales_register/sales_register.js +++ b/erpnext/accounts/report/sales_register/sales_register.js @@ -14,7 +14,7 @@ frappe.query_reports["Sales Register"] = { "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() }, { "fieldname":"customer", diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index cfd333670a3..c533e6bbcdd 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -55,7 +55,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( if(is_drop_ship && doc.status!="Delivered"){ cur_frm.add_custom_button(__('Delivered'), - this.delivered_by_supplier, __("Status")); + this.delivered_by_supplier, __("Status")); cur_frm.page.set_inner_btn_group_as_primary(__("Status")); } diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_list.js b/erpnext/buying/doctype/purchase_order/purchase_order_list.js index f6e7eeba270..99f372b8ff5 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order_list.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order_list.js @@ -1,34 +1,34 @@ frappe.listview_settings['Purchase Order'] = { add_fields: ["base_grand_total", "company", "currency", "supplier", "supplier_name", "per_received", "per_billed", "status"], - get_indicator: function(doc) { - if(doc.status==="Closed"){ + get_indicator: function (doc) { + if (doc.status === "Closed") { return [__("Closed"), "green", "status,=,Closed"]; - } else if (doc.status==="Delivered") { + } else if (doc.status === "Delivered") { return [__("Delivered"), "green", "status,=,Closed"]; - }else if(flt(doc.per_received, 2) < 100 && doc.status!=="Closed") { - if(flt(doc.per_billed, 2) < 100) { + } else if (flt(doc.per_received, 2) < 100 && doc.status !== "Closed") { + if (flt(doc.per_billed, 2) < 100) { return [__("To Receive and Bill"), "orange", "per_received,<,100|per_billed,<,100|status,!=,Closed"]; } else { return [__("To Receive"), "orange", "per_received,<,100|per_billed,=,100|status,!=,Closed"]; } - } else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) < 100 && doc.status!=="Closed") { + } else if (flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) < 100 && doc.status !== "Closed") { return [__("To Bill"), "orange", "per_received,=,100|per_billed,<,100|status,!=,Closed"]; - } else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) == 100 && doc.status!=="Closed") { + } else if (flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) == 100 && doc.status !== "Closed") { return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Closed"]; } }, - onload: function(listview) { + onload: function (listview) { var method = "erpnext.buying.doctype.purchase_order.purchase_order.close_or_unclose_purchase_orders"; - listview.page.add_menu_item(__("Close"), function() { - listview.call_for_selected_items(method, {"status": "Closed"}); + listview.page.add_menu_item(__("Close"), function () { + listview.call_for_selected_items(method, { "status": "Closed" }); }); - listview.page.add_menu_item(__("Re-open"), function() { - listview.call_for_selected_items(method, {"status": "Submitted"}); + listview.page.add_menu_item(__("Re-open"), function () { + listview.call_for_selected_items(method, { "status": "Submitted" }); }); } }; 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 593f6679944..ce759aaae86 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -56,17 +56,17 @@ frappe.ui.form.on("Request for Quotation",{ var dialog = new frappe.ui.Dialog({ title: __("For Supplier"), fields: [ - {"fieldtype": "Select", "label": __("Supplier"), - "fieldname": "supplier", "options":"Supplier", - "options": $.map(doc.suppliers, - function(d) { return d.supplier }), "reqd": 1 }, - {"fieldtype": "Button", "label": __("Make Supplier Quotation"), - "fieldname": "make_supplier_quotation", "cssClass": "btn-primary"}, + { "fieldtype": "Select", "label": __("Supplier"), + "fieldname": "supplier", + "options": doc.suppliers.map(d => d.supplier), + "reqd": 1 }, + { "fieldtype": "Button", "label": __("Make Supplier Quotation"), + "fieldname": "make_supplier_quotation", "cssClass": "btn-primary" }, ] }); dialog.fields_dict.make_supplier_quotation.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; dialog.hide(); return frappe.call({ @@ -117,7 +117,7 @@ frappe.ui.form.on("Request for Quotation Supplier",{ +"&supplier_idx="+encodeURIComponent(child.idx) +"&no_letterhead=0")); if(!w) { - msgprint(__("Please enable pop-ups")); return; + frappe.msgprint(__("Please enable pop-ups")); return; } } }) @@ -144,44 +144,44 @@ erpnext.buying.RequestforQuotationController = erpnext.buying.BuyingController.e } }) }, __("Get items from")); - // Get items from open Material Requests based on supplier - this.frm.add_custom_button(__('Possible Supplier'), function() { - // Create a dialog window for the user to pick their supplier - var d = new frappe.ui.Dialog({ - title: __('Select Possible Supplier'), - fields: [ - {fieldname: 'supplier', fieldtype:'Link', options:'Supplier', label:'Supplier', reqd:1}, - {fieldname: 'ok_button', fieldtype:'Button', label:'Get Items from Material Requests'}, - ] - }); + // Get items from open Material Requests based on supplier + this.frm.add_custom_button(__('Possible Supplier'), function() { + // Create a dialog window for the user to pick their supplier + var d = new frappe.ui.Dialog({ + title: __('Select Possible Supplier'), + fields: [ + {fieldname: 'supplier', fieldtype:'Link', options:'Supplier', label:'Supplier', reqd:1}, + {fieldname: 'ok_button', fieldtype:'Button', label:'Get Items from Material Requests'}, + ] + }); - // On the user clicking the ok button - d.fields_dict.ok_button.input.onclick = function() { - var btn = d.fields_dict.ok_button.input; - var v = d.get_values(); - if(v) { - $(btn).set_working(); + // On the user clicking the ok button + d.fields_dict.ok_button.input.onclick = function() { + var btn = d.fields_dict.ok_button.input; + var v = d.get_values(); + if(v) { + $(btn).set_working(); - erpnext.utils.map_current_doc({ - method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_item_from_material_requests_based_on_supplier", - source_name: v.supplier, - target: me.frm, - setters: { - company: me.frm.doc.company - }, - get_query_filters: { - material_request_type: "Purchase", - docstatus: 1, - status: ["!=", "Stopped"], - per_ordered: ["<", 99.99] - } - }); - $(btn).done_working(); - d.hide(); - } + erpnext.utils.map_current_doc({ + method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_item_from_material_requests_based_on_supplier", + source_name: v.supplier, + target: me.frm, + setters: { + company: me.frm.doc.company + }, + get_query_filters: { + material_request_type: "Purchase", + docstatus: 1, + status: ["!=", "Stopped"], + per_ordered: ["<", 99.99] + } + }); + $(btn).done_working(); + d.hide(); } - d.show(); - }, __("Get items from")); + } + d.show(); + }, __("Get items from")); } }, diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 7e5e0458129..c7df33d9f19 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -2,10 +2,10 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Supplier", { - setup: function(frm) { - frm.set_query('default_price_list', { 'buying': 1}); - frm.set_query('account', 'accounts', function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; + setup: function (frm) { + frm.set_query('default_price_list', { 'buying': 1 }); + frm.set_query('account', 'accounts', function (doc, cdt, cdn) { + var d = locals[cdt][cdn]; return { filters: { 'account_type': 'Payable', @@ -15,30 +15,30 @@ frappe.ui.form.on("Supplier", { } }); }, - refresh: function(frm) { - frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Supplier'} + refresh: function (frm) { + frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Supplier' } - if(frappe.defaults.get_default("supp_master_name")!="Naming Series") { + if (frappe.defaults.get_default("supp_master_name") != "Naming Series") { frm.toggle_display("naming_series", false); } else { erpnext.toggle_naming_series(); } - if(frm.doc.__islocal){ - hide_field(['address_html','contact_html']); + if (frm.doc.__islocal) { + hide_field(['address_html', 'contact_html']); frappe.geo.clear_address_and_contact(frm); } else { - unhide_field(['address_html','contact_html']); + unhide_field(['address_html', 'contact_html']); frappe.geo.render_address_and_contact(frm); // custom buttons - frm.add_custom_button(__('Accounting Ledger'), function() { + frm.add_custom_button(__('Accounting Ledger'), function () { frappe.set_route('query-report', 'General Ledger', - {party_type:'Supplier', party:frm.doc.name}); + { party_type: 'Supplier', party: frm.doc.name }); }); - frm.add_custom_button(__('Accounts Payable'), function() { - frappe.set_route('query-report', 'Accounts Payable', {supplier:frm.doc.name}); + frm.add_custom_button(__('Accounts Payable'), function () { + frappe.set_route('query-report', 'Accounts Payable', { supplier: frm.doc.name }); }); // indicators diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 6bcbdbacac8..3767248e369 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -5,7 +5,7 @@ {% include 'erpnext/public/js/controllers/buying.js' %}; frappe.ui.form.on('Suppier Quotation', { - setup: function() { + setup: function(frm) { frm.custom_make_buttons = { 'Purchase Order': 'Purchase Order' } diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index 10d13213986..de3d337c344 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -10,7 +10,6 @@ frappe.pages['purchase-analytics'].on_page_load = function(wrapper) { new erpnext.PurchaseAnalytics(wrapper); - frappe.breadcrumbs.add("Buying"); } @@ -18,7 +17,6 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ init: function(wrapper) { this._super({ title: __("Purchase Analytics"), - page: wrapper, parent: $(wrapper).find('.layout-main'), page: wrapper.page, doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", "Fiscal Year", @@ -193,13 +191,13 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ }, prepare_balances: function() { var me = this; - var from_date = dateutil.str_to_obj(this.from_date); - var to_date = dateutil.str_to_obj(this.to_date); + var from_date = frappe.datetime.str_to_obj(this.from_date); + var to_date = frappe.datetime.str_to_obj(this.to_date); var is_val = this.value_or_qty == 'Value'; $.each(this.tl[this.based_on], function(i, tl) { if (me.is_default('company') ? true : tl.company === me.company) { - var posting_date = dateutil.str_to_obj(tl.posting_date); + var posting_date = frappe.datetime.str_to_obj(tl.posting_date); if (posting_date >= from_date && posting_date <= to_date) { var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js index f7fe90fe461..83d25d80ba2 100644 --- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js +++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js @@ -3,6 +3,6 @@ frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { frappe.query_reports["Purchase Order Trends"] = { - filters: get_filters() + filters: erpnext.get_purchase_trends_filters() } }); \ No newline at end of file diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js index 9b0b2437185..ad6ea7d7f89 100644 --- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js +++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js @@ -3,30 +3,26 @@ frappe.query_reports["Quoted Item Comparison"] = { "filters": [ - { - "fieldname":"supplier_quotation", - "label": __("Supplier Quotation"), - "fieldtype": "Link", - "options": "Supplier Quotation", - "default": "", - "get_query": function() { - return { - filters: {"docstatus": ["<",2]} - } + { + "fieldname": "supplier_quotation", + "label": __("Supplier Quotation"), + "fieldtype": "Link", + "options": "Supplier Quotation", + "default": "", + "get_query": function () { + return { filters: { "docstatus": ["<", 2] } } } - - - },{ - "fieldname":"item", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item", - "default": "", - "reqd": 1, - "get_query": function() { + }, + { + "fieldname": "item", + "label": __("Item"), + "fieldtype": "Link", + "options": "Item", + "default": "", + "reqd": 1, + "get_query": function () { var quote = frappe.query_report_filters_by_name.supplier_quotation.get_value(); - if (quote != "") - { + if (quote != "") { return { query: "erpnext.buying.doctype.quality_inspection.quality_inspection.item_query", filters: { @@ -35,79 +31,74 @@ frappe.query_reports["Quoted Item Comparison"] = { } } } - else{ - return{ - filters: {"disabled":0} + else { + return { + filters: { "disabled": 0 } } } } - } + } ], - onload: function(report) { - //Create a button for setting the default supplier - report.page.add_inner_button(__("Select Default Supplier"), function() { + onload: function (report) { + // Create a button for setting the default supplier + report.page.add_inner_button(__("Select Default Supplier"), function () { var reporter = frappe.query_reports["Quoted Item Comparison"]; - + //Always make a new one so that the latest values get updated reporter.make_default_supplier_dialog(report); report.dialog.show(); - setTimeout(function() { report.dialog.input.focus(); }, 1000); - + setTimeout(function () { report.dialog.input.focus(); }, 1000); + }, 'Tools'); - + }, "make_default_supplier_dialog": function (report) { - //Get the name of the item to change + // Get the name of the item to change var filters = report.get_values(); var item_code = filters.item; - - //Get a list of the suppliers (with a blank as well) for the user to select + + // Get a list of the suppliers (with a blank as well) for the user to select var select_options = ""; - for (let supplier of report.data) - { - select_options += supplier.supplier_name+ '\n' + for (let supplier of report.data) { + select_options += supplier.supplier_name + '\n' } - - //Create a dialog window for the user to pick their supplier + + // Create a dialog window for the user to pick their supplier var d = new frappe.ui.Dialog({ title: __('Select Default Supplier'), fields: [ - {fieldname: 'supplier', fieldtype:'Select', label:'Supplier', reqd:1,options:select_options}, - {fieldname: 'ok_button', fieldtype:'Button', label:'Set Default Supplier'}, + { fieldname: 'supplier', fieldtype: 'Select', label: 'Supplier', reqd: 1, options: select_options }, + { fieldname: 'ok_button', fieldtype: 'Button', label: 'Set Default Supplier' }, ] }); - - //On the user clicking the ok button - d.fields_dict.ok_button.input.onclick = function() { + + // On the user clicking the ok button + d.fields_dict.ok_button.input.onclick = function () { var btn = d.fields_dict.ok_button.input; var v = report.dialog.get_values(); - if(v) { + if (v) { $(btn).set_working(); - - //Set the default_supplier field of the appropriate Item to the selected supplier + + // Set the default_supplier field of the appropriate Item to the selected supplier frappe.call({ method: "frappe.client.set_value", args: { - doctype: "Item", + doctype: "Item", name: item_code, fieldname: "default_supplier", - value: v.supplier, + value: v.supplier, }, - callback: function (r){ + callback: function (r) { $(btn).done_working(); - msgprint("Successfully Set Supplier"); + frappe.msgprint("Successfully Set Supplier"); report.dialog.hide(); - } }); } } report.dialog = d; - - } - } diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js index 7e221254ff5..36aa18677f3 100644 --- a/erpnext/crm/doctype/lead/lead.js +++ b/erpnext/crm/doctype/lead/lead.js @@ -7,34 +7,35 @@ cur_frm.email_field = "email_id"; erpnext.LeadController = frappe.ui.form.Controller.extend({ setup: function() { this.frm.fields_dict.customer.get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.customer_query" } } + return { query: "erpnext.controllers.queries.customer_query" } } }, onload: function() { if(cur_frm.fields_dict.lead_owner.df.options.match(/^User/)) { cur_frm.fields_dict.lead_owner.get_query = function(doc, cdt, cdn) { - return { query:"frappe.core.doctype.user.user.user_query" } } + return { query: "frappe.core.doctype.user.user.user_query" } + } } if(cur_frm.fields_dict.contact_by.df.options.match(/^User/)) { cur_frm.fields_dict.contact_by.get_query = function(doc, cdt, cdn) { - return { query:"frappe.core.doctype.user.user.user_query" } } + return { query: "frappe.core.doctype.user.user.user_query" } } } }, refresh: function() { var doc = this.frm.doc; erpnext.toggle_naming_series(); - frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'name', doctype: 'Lead'} + frappe.dynamic_link = {doc: doc, fieldname: 'name', doctype: 'Lead'} - if(!this.frm.doc.__islocal && this.frm.doc.__onload && !this.frm.doc.__onload.is_customer) { + if(!doc.__islocal && doc.__onload && !doc.__onload.is_customer) { this.frm.add_custom_button(__("Customer"), this.create_customer, __("Make")); this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __("Make")); this.frm.add_custom_button(__("Quotation"), this.make_quotation, __("Make")); cur_frm.page.set_inner_btn_group_as_primary(__("Make")); } - if(!this.frm.doc.__islocal) { + if(!doc.__islocal) { frappe.geo.render_address_and_contact(cur_frm); } else { frappe.geo.clear_address_and_contact(cur_frm); diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 974b23e69ad..d25c87b50d4 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -107,7 +107,8 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ $.each([["lead", "lead"], ["customer", "customer"], - ["contact_person", "contact_query"]], function(i, opts) { + ["contact_person", "contact_query"]], + function(i, opts) { me.frm.set_query(opts[0], erpnext.queries[opts[1]]); }); }, @@ -157,7 +158,7 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) { $.each(r.message, function(k, v) { frappe.model.set_value(cdt, cdn, k, v); }); - refresh_field('image_view', d.name, 'items'); + refresh_field('image_view', d.name, 'items'); } } }) @@ -184,7 +185,7 @@ cur_frm.cscript['Declare Opportunity Lost'] = function() { }); dialog.fields_dict.update.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; return cur_frm.call({ doc: cur_frm.doc, @@ -192,7 +193,7 @@ cur_frm.cscript['Declare Opportunity Lost'] = function() { args: args.reason, callback: function(r) { if(r.exc) { - msgprint(__("There were errors.")); + frappe.msgprint(__("There were errors.")); } else { dialog.hide(); cur_frm.refresh(); diff --git a/erpnext/crm/report/campaign_efficiency/campaign_efficiency.js b/erpnext/crm/report/campaign_efficiency/campaign_efficiency.js index 2b25f1dfba2..0bc77a3f2a8 100644 --- a/erpnext/crm/report/campaign_efficiency/campaign_efficiency.js +++ b/erpnext/crm/report/campaign_efficiency/campaign_efficiency.js @@ -1,19 +1,19 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt frappe.query_reports["Campaign Efficiency"] = { - "filters": [ - { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.defaults.get_user_default("year_start_date"), - }, - { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.defaults.get_user_default("year_end_date"), - } - ] - }; + "filters": [ + { + "fieldname": "from_date", + "label": __("From Date"), + "fieldtype": "Date", + "default": frappe.defaults.get_user_default("year_start_date"), + }, + { + "fieldname": "to_date", + "label": __("To Date"), + "fieldtype": "Date", + "default": frappe.defaults.get_user_default("year_end_date"), + } + ] +}; diff --git a/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js b/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js index b1e4917129f..d9c4c8b7fc8 100644 --- a/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js +++ b/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js @@ -2,40 +2,40 @@ // For license information, please see license.txt frappe.query_reports["Minutes to First Response for Opportunity"] = { - "filters": [ - { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", + "filters": [ + { + "fieldname": "from_date", + "label": __("From Date"), + "fieldtype": "Date", 'reqd': 1, - "default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30) - }, - { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", + "default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30) + }, + { + "fieldname": "to_date", + "label": __("To Date"), + "fieldtype": "Date", 'reqd': 1, - "default":frappe.datetime.nowdate() - }, - ], - get_chart_data: function(columns, result) { + "default": frappe.datetime.nowdate() + }, + ], + get_chart_data: function (columns, result) { return { data: { x: 'Date', columns: [ - ['Date'].concat($.map(result, function(d) { return d[0]; })), - ['Mins to first response'].concat($.map(result, function(d) { return d[1]; })) + ['Date'].concat($.map(result, function (d) { return d[0]; })), + ['Mins to first response'].concat($.map(result, function (d) { return d[1]; })) ] // rows: [['Date', 'Mins to first response']].concat(result) }, - axis: { - x: { - type: 'timeseries', - tick: { - format: frappe.ui.py_date_format - } - } - }, + axis: { + x: { + type: 'timeseries', + tick: { + format: frappe.ui.py_date_format + } + } + }, chart_type: 'line', } diff --git a/erpnext/hr/doctype/appraisal/appraisal.js b/erpnext/hr/doctype/appraisal/appraisal.js index 728e5c2f2c0..64d6f40e0e8 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.js +++ b/erpnext/hr/doctype/appraisal/appraisal.js @@ -46,11 +46,11 @@ cur_frm.cscript.score = function(doc,cdt,cdn){ var d = locals[cdt][cdn]; if (d.score){ if (flt(d.score) > 5) { - msgprint(__("Score must be less than or equal to 5")); + frappe.msgprint(__("Score must be less than or equal to 5")); d.score = 0; refresh_field('score', d.name, 'goals'); } - total = flt(d.per_weightage*d.score)/100; + var total = flt(d.per_weightage*d.score)/100; d.score_earned = total.toPrecision(2); refresh_field('score_earned', d.name, 'goals'); } diff --git a/erpnext/hr/doctype/attendance/attendance.js b/erpnext/hr/doctype/attendance/attendance.js index 7f2b18f0e4c..c3c3cb82f94 100644 --- a/erpnext/hr/doctype/attendance/attendance.js +++ b/erpnext/hr/doctype/attendance/attendance.js @@ -5,7 +5,7 @@ cur_frm.add_fetch('employee', 'company', 'company'); cur_frm.add_fetch('employee', 'employee_name', 'employee_name'); cur_frm.cscript.onload = function(doc, cdt, cdn) { - if(doc.__islocal) cur_frm.set_value("attendance_date", get_today()); + if(doc.__islocal) cur_frm.set_value("attendance_date", frappe.datetime.get_today()); } cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) { 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 c0c0ef0fe04..376d0c0a5a5 100644 --- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -5,7 +5,7 @@ frappe.ui.form.on("Employee Attendance Tool", { onload: function(frm) { frm.doc.department = frm.doc.branch = frm.doc.company = "All"; - frm.set_value("date", get_today()); + frm.set_value("date", frappe.datetime.get_today()); erpnext.employee_attendance_tool.load_employees(frm); }, diff --git a/erpnext/hr/doctype/employee_loan/employee_loan.js b/erpnext/hr/doctype/employee_loan/employee_loan.js index 71b6356ef66..9720bcba63c 100644 --- a/erpnext/hr/doctype/employee_loan/employee_loan.js +++ b/erpnext/hr/doctype/employee_loan/employee_loan.js @@ -2,8 +2,8 @@ // For license information, please see license.txt frappe.ui.form.on('Employee Loan', { - onload: function(frm) { - frm.set_query("employee_loan_application", function() { + onload: function (frm) { + frm.set_query("employee_loan_application", function () { return { "filters": { "employee": frm.doc.employee, @@ -12,19 +12,19 @@ frappe.ui.form.on('Employee Loan', { } }; }); - - frm.set_query("interest_income_account", function() { + + frm.set_query("interest_income_account", function () { return { "filters": { - "company": frm.doc.company, - "root_type": "Income", - "is_group": 0 + "company": frm.doc.company, + "root_type": "Income", + "is_group": 0 } }; }); - $.each(["payment_account", "employee_loan_account"], function(i, field) { - frm.set_query(field, function() { + $.each(["payment_account", "employee_loan_account"], function (i, field) { + frm.set_query(field, function () { return { "filters": { "company": frm.doc.company, @@ -36,16 +36,16 @@ frappe.ui.form.on('Employee Loan', { }) }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.docstatus == 1 && (frm.doc.status == "Sanctioned" || frm.doc.status == "Partially Disbursed")) { - frm.add_custom_button(__('Make Disbursement Entry'), function() { + frm.add_custom_button(__('Make Disbursement Entry'), function () { frm.trigger("make_jv"); }) } frm.trigger("toggle_fields"); }, - make_jv: function(frm) { + make_jv: function (frm) { frappe.call({ args: { "employee_loan": frm.doc.name, @@ -56,36 +56,36 @@ frappe.ui.form.on('Employee Loan', { "payment_account": frm.doc.payment_account }, method: "erpnext.hr.doctype.employee_loan.employee_loan.make_jv_entry", - callback: function(r) { + callback: function (r) { if (r.message) var doc = frappe.model.sync(r.message)[0]; - frappe.set_route("Form", doc.doctype, doc.name); + frappe.set_route("Form", doc.doctype, doc.name); } }) }, - mode_of_payment: function(frm) { + mode_of_payment: function (frm) { frappe.call({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account", args: { "mode_of_payment": frm.doc.mode_of_payment, "company": frm.doc.company }, - callback: function(r, rt) { - if(r.message) { + callback: function (r, rt) { + if (r.message) { frm.set_value("payment_account", r.message.account); } } }); }, - employee_loan_application: function(frm) { + employee_loan_application: function (frm) { return frappe.call({ method: "erpnext.hr.doctype.employee_loan.employee_loan.get_employee_loan_application", args: { "employee_loan_application": frm.doc.employee_loan_application }, - callback: function(r){ - if(!r.exc && r.message) { + callback: function (r) { + if (!r.exc && r.message) { frm.set_value("loan_type", r.message.loan_type); frm.set_value("loan_amount", r.message.loan_amount); frm.set_value("repayment_method", r.message.repayment_method); @@ -97,12 +97,12 @@ frappe.ui.form.on('Employee Loan', { }) }, - repayment_method: function(frm) { + repayment_method: function (frm) { frm.trigger("toggle_fields") }, - toggle_fields: function(frm) { - frm.toggle_enable("monthly_repayment_amount", frm.doc.repayment_method=="Repay Fixed Amount per Period") - frm.toggle_enable("repayment_periods", frm.doc.repayment_method=="Repay Over Number of Periods") + toggle_fields: function (frm) { + frm.toggle_enable("monthly_repayment_amount", frm.doc.repayment_method == "Repay Fixed Amount per Period") + frm.toggle_enable("repayment_periods", frm.doc.repayment_method == "Repay Over Number of Periods") } }); diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 95877cf0322..4ce91c4bf9b 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -52,7 +52,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) { cur_frm.set_value("approval_status", "Draft") if (doc.__islocal) { - cur_frm.set_value("posting_date", dateutil.get_today()); + cur_frm.set_value("posting_date", frappe.datetime.get_today()); if(doc.amended_from) cur_frm.set_value("approval_status", "Draft"); cur_frm.cscript.clear_sanctioned(doc); @@ -81,15 +81,15 @@ cur_frm.cscript.clear_sanctioned = function(doc) { refresh_many(['sanctioned_amount', 'total_sanctioned_amount']); } -cur_frm.cscript.refresh = function(doc,cdt,cdn){ +cur_frm.cscript.refresh = function(doc,cdt,cdn) { cur_frm.cscript.set_help(doc); if(!doc.__islocal) { cur_frm.toggle_enable("exp_approver", doc.approval_status=="Draft"); - cur_frm.toggle_enable("approval_status", (doc.exp_approver==user && doc.docstatus==0)); + cur_frm.toggle_enable("approval_status", (doc.exp_approver==frappe.session.user && doc.docstatus==0)); - if (doc.docstatus==0 && doc.exp_approver==user && doc.approval_status=="Approved") - cur_frm.savesubmit(); + if (doc.docstatus==0 && doc.exp_approver==frappe.session.user && doc.approval_status=="Approved") + cur_frm.savesubmit(); if (doc.docstatus===1 && doc.approval_status=="Approved") { if (cint(doc.total_amount_reimbursed) < cint(doc.total_sanctioned_amount) && frappe.model.can_create("Journal Entry")) { @@ -97,6 +97,8 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ cur_frm.page.set_inner_btn_group_as_primary(__("Make")); } + /* eslint-disable */ + // no idea how `me` works here if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read("Journal Entry")) { cur_frm.add_custom_button(__('Bank Entries'), function() { frappe.route_options = { @@ -107,17 +109,18 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ frappe.set_route("List", "Journal Entry"); }, __("View")); } + /* eslint-enable */ } } } cur_frm.cscript.set_help = function(doc) { cur_frm.set_intro(""); - if(doc.__islocal && !in_list(roles, "HR User")) { + if(doc.__islocal && !in_list(frappe.user_roles, "HR User")) { cur_frm.set_intro(__("Fill the form and save it")) } else { if(doc.docstatus==0 && doc.approval_status=="Draft") { - if(user==doc.exp_approver) { + if(frappe.session.user==doc.exp_approver) { cur_frm.set_intro(__("You are the Expense Approver for this record. Please Update the 'Status' and Save")); } else { cur_frm.set_intro(__("Expense Claim is pending approval. Only the Expense Approver can update status.")); diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.js b/erpnext/hr/doctype/leave_allocation/leave_allocation.js index b7e1f45a15c..4b4bfafd161 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.js +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.js @@ -5,7 +5,7 @@ cur_frm.add_fetch('employee','employee_name','employee_name'); frappe.ui.form.on("Leave Allocation", { onload: function(frm) { - if(!frm.doc.from_date) frm.set_value("from_date", get_today()); + if(!frm.doc.from_date) frm.set_value("from_date", frappe.datetime.get_today()); frm.set_query("employee", function() { return { diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js index 3bf41bb3411..2eb155dee11 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -7,7 +7,7 @@ cur_frm.add_fetch('employee','company','company'); frappe.ui.form.on("Leave Application", { onload: function(frm) { if (!frm.doc.posting_date) { - frm.set_value("posting_date", get_today()); + frm.set_value("posting_date", frappe.datetime.get_today()); } frm.set_query("leave_approver", function() { @@ -76,9 +76,9 @@ frappe.ui.form.on("Leave Application", { frm.set_value('half_day_date', ''); var half_day_datepicker = frm.fields_dict.half_day_date.datepicker; half_day_datepicker.update({ - minDate: frappe.datetime.str_to_obj(frm.doc.from_date), - maxDate: frappe.datetime.str_to_obj(frm.doc.to_date) - }) + minDate: frappe.datetime.str_to_obj(frm.doc.from_date), + maxDate: frappe.datetime.str_to_obj(frm.doc.to_date) + }) }, get_leave_balance: function(frm) { diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js index 3720f2f6361..0eb64144069 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js @@ -1,19 +1,19 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.onload = function(doc, dt, dn){ - if(!doc.posting_date) - set_multiple(dt, dn, {posting_date: get_today()}); - if(!doc.leave_transaction_type) - set_multiple(dt, dn, {leave_transaction_type: 'Allocation'}); +cur_frm.cscript.onload = function (doc, dt, dn) { + if (!doc.posting_date) + set_multiple(dt, dn, { posting_date: frappe.datetime.get_today() }); + if (!doc.leave_transaction_type) + set_multiple(dt, dn, { leave_transaction_type: 'Allocation' }); } -cur_frm.cscript.to_date = function(doc, cdt, cdn) { - return $c('runserverobj', args={'method':'to_date_validation','docs':doc}, - function(r, rt) { +cur_frm.cscript.to_date = function (doc, cdt, cdn) { + return $c('runserverobj', { 'method': 'to_date_validation', 'docs': doc }, + function (r, rt) { var doc = locals[cdt][cdn]; if (r.message) { - msgprint(__("To date cannot be before from date")); + frappe.msgprint(__("To date cannot be before from date")); doc.to_date = ''; refresh_field('to_date'); } @@ -21,11 +21,11 @@ cur_frm.cscript.to_date = function(doc, cdt, cdn) { ); } -cur_frm.cscript.allocation_type = function (doc, cdt, cdn){ +cur_frm.cscript.allocation_type = function (doc, cdt, cdn) { doc.no_of_days = ''; refresh_field('no_of_days'); } -frappe.ui.form.on("Leave Control Panel", "refresh", function(frm) { +frappe.ui.form.on("Leave Control Panel", "refresh", function (frm) { frm.disable_save(); }); \ No newline at end of file diff --git a/erpnext/hr/doctype/offer_letter/offer_letter.js b/erpnext/hr/doctype/offer_letter/offer_letter.js index 125a425b6cc..c0d397bf219 100755 --- a/erpnext/hr/doctype/offer_letter/offer_letter.js +++ b/erpnext/hr/doctype/offer_letter/offer_letter.js @@ -4,18 +4,18 @@ frappe.provide("erpnext.offer_letter"); frappe.ui.form.on("Offer Letter", { - select_terms: function(frm) { - erpnext.utils.get_terms(frm.doc.select_terms, frm.doc, function(r) { - if(!r.exc) { - me.frm.set_value("terms", r.message); + select_terms: function (frm) { + erpnext.utils.get_terms(frm.doc.select_terms, frm.doc, function (r) { + if (!r.exc) { + frm.set_value("terms", r.message); } }); }, - refresh:function(frm){ - if((!frm.doc.__islocal) && (frm.doc.status=='Accepted') && (frm.doc.docstatus===1)){ + refresh: function (frm) { + if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted') && (frm.doc.docstatus === 1)) { frm.add_custom_button(__('Make Employee'), - function() { + function () { erpnext.offer_letter.make_employee(frm) } ); @@ -24,7 +24,7 @@ frappe.ui.form.on("Offer Letter", { }); -erpnext.offer_letter.make_employee = function(frm) { +erpnext.offer_letter.make_employee = function (frm) { frappe.model.open_mapped_doc({ method: "erpnext.hr.doctype.offer_letter.offer_letter.make_employee", frm: frm diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js index e1bea622234..0ec7f7052ff 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.js +++ b/erpnext/hr/doctype/process_payroll/process_payroll.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Process Payroll", { - onload: function(frm) { + onload: function (frm) { frm.doc.posting_date = frappe.datetime.nowdate(); frm.doc.start_date = ''; frm.doc.end_date = ''; @@ -10,8 +10,8 @@ frappe.ui.form.on("Process Payroll", { frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); }, - setup: function(frm) { - frm.set_query("payment_account", function() { + setup: function (frm) { + frm.set_query("payment_account", function () { var account_types = ["Bank", "Cash"]; return { filters: { @@ -21,57 +21,57 @@ frappe.ui.form.on("Process Payroll", { } } }), - frm.set_query("cost_center", function() { - return { - filters: { - "is_group": 0, - company: frm.doc.company + frm.set_query("cost_center", function () { + return { + filters: { + "is_group": 0, + company: frm.doc.company + } } - } - }), - frm.set_query("project", function() { - return { - filters: { - company: frm.doc.company + }), + frm.set_query("project", function () { + return { + filters: { + company: frm.doc.company + } } - } - }) + }) }, - refresh: function(frm) { + refresh: function (frm) { frm.disable_save(); }, - payroll_frequency: function(frm) { + payroll_frequency: function (frm) { frm.trigger("set_start_end_dates"); }, - start_date: function(frm) { + start_date: function (frm) { frm.trigger("set_start_end_dates"); }, - end_date: function(frm) { + end_date: function (frm) { frm.trigger("set_start_end_dates"); }, - salary_slip_based_on_timesheet: function(frm) { + salary_slip_based_on_timesheet: function (frm) { frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); }, - payment_account: function(frm) { - frm.toggle_display(['make_bank_entry'], (frm.doc.payment_account!="" && frm.doc.payment_account!="undefined")); + payment_account: function (frm) { + frm.toggle_display(['make_bank_entry'], (frm.doc.payment_account != "" && frm.doc.payment_account != "undefined")); }, - set_start_end_dates: function(frm) { - if (!frm.doc.salary_slip_based_on_timesheet){ + set_start_end_dates: function (frm) { + if (!frm.doc.salary_slip_based_on_timesheet) { frappe.call({ - method:'erpnext.hr.doctype.process_payroll.process_payroll.get_start_end_dates', - args:{ + method: 'erpnext.hr.doctype.process_payroll.process_payroll.get_start_end_dates', + args: { payroll_frequency: frm.doc.payroll_frequency, start_date: frm.doc.start_date || frm.doc.posting_date }, - callback: function(r){ - if (r.message){ + callback: function (r) { + if (r.message) { frm.set_value('start_date', r.message.start_date); frm.set_value('end_date', r.message.end_date); } @@ -81,60 +81,60 @@ frappe.ui.form.on("Process Payroll", { }, }) -cur_frm.cscript.display_activity_log = function(msg) { - if(!cur_frm.ss_html) - cur_frm.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div'); - if(msg) { +cur_frm.cscript.display_activity_log = function (msg) { + if (!cur_frm.ss_html) + cur_frm.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper, 'div'); + if (msg) { cur_frm.ss_html.innerHTML = - '

'+__("Activity Log:")+'

'+msg+'
'; + '

' + __("Activity Log:") + '

' + msg + '
'; } else { cur_frm.ss_html.innerHTML = ""; } } -//Create salary slip -//----------------------- -cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) { +// Create salary slip +// ----------------------- +cur_frm.cscript.create_salary_slip = function (doc, cdt, cdn) { cur_frm.cscript.display_activity_log(""); - var callback = function(r, rt){ + var callback = function (r, rt) { if (r.message) cur_frm.cscript.display_activity_log(r.message); } - return $c('runserverobj', args={'method':'create_salary_slips','docs':doc},callback); + return $c('runserverobj', { 'method': 'create_salary_slips', 'docs': doc }, callback); } -cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { +cur_frm.cscript.submit_salary_slip = function (doc, cdt, cdn) { cur_frm.cscript.display_activity_log(""); - frappe.confirm(__("Do you really want to Submit all Salary Slip from {0} to {1}", [doc.start_date, doc.end_date]), function() { + frappe.confirm(__("Do you really want to Submit all Salary Slip from {0} to {1}", [doc.start_date, doc.end_date]), function () { // clear all in locals - if(locals["Salary Slip"]) { - $.each(locals["Salary Slip"], function(name, d) { + if (locals["Salary Slip"]) { + $.each(locals["Salary Slip"], function (name, d) { frappe.model.remove_from_locals("Salary Slip", name); }); } - var callback = function(r, rt){ + var callback = function (r, rt) { if (r.message) cur_frm.cscript.display_activity_log(r.message); } - return $c('runserverobj', args={'method':'submit_salary_slips','docs':doc},callback); + return $c('runserverobj', { 'method': 'submit_salary_slips', 'docs': doc }, callback); }); } -cur_frm.cscript.make_bank_entry = function(doc, cdt, cdn){ - if(doc.company && doc.start_date && doc.end_date){ +cur_frm.cscript.make_bank_entry = function (doc, cdt, cdn) { + if (doc.company && doc.start_date && doc.end_date) { return frappe.call({ doc: cur_frm.doc, method: "make_payment_entry", - callback: function(r) { + callback: function (r) { if (r.message) var doc = frappe.model.sync(r.message)[0]; - frappe.set_route("Form", doc.doctype, doc.name); + frappe.set_route("Form", doc.doctype, doc.name); } }); - } else { - msgprint(__("Company, From Date and To Date is mandatory")); - } + } else { + frappe.msgprint(__("Company, From Date and To Date is mandatory")); + } } \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index 09c5337b500..a96347a8518 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -39,7 +39,7 @@ frappe.ui.form.on("Salary Slip", { refresh: function(frm) { frm.trigger("toggle_fields") frm.trigger("toggle_reqd_fields") - salary_detail_fields = ['formula', 'abbr', 'statistical_component'] + var salary_detail_fields = ['formula', 'abbr', 'statistical_component'] cur_frm.fields_dict['earnings'].grid.set_column_disp(salary_detail_fields,false); cur_frm.fields_dict['deductions'].grid.set_column_disp(salary_detail_fields,false); }, diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index 0bc67a7e6d1..68c5f25fd26 100755 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -7,8 +7,8 @@ cur_frm.add_fetch('company', 'default_letter_head', 'letter_head'); cur_frm.cscript.onload = function(doc, dt, dn){ - e_tbl = doc.earnings || []; - d_tbl = doc.deductions || []; + var e_tbl = doc.earnings || []; + var d_tbl = doc.deductions || []; if (e_tbl.length == 0 && d_tbl.length == 0) return function(r, rt) { refresh_many(['earnings', 'deductions']);}; } @@ -16,7 +16,7 @@ cur_frm.cscript.onload = function(doc, dt, dn){ frappe.ui.form.on('Salary Structure', { onload: function(frm) { frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet), - + frm.set_query("salary_component", "earnings", function() { return { filters: { @@ -40,19 +40,19 @@ frappe.ui.form.on('Salary Structure', { } }); }, - + refresh: function(frm) { frm.trigger("toggle_fields"); frm.fields_dict['earnings'].grid.set_column_disp("default_amount", false); frm.fields_dict['deductions'].grid.set_column_disp("default_amount", false); - + frm.add_custom_button(__("Preview Salary Slip"), function() { frm.trigger('preview_salary_slip'); }, "fa fa-sitemap", "btn-default"); frm.add_custom_button(__("Add Employees"),function () { frm.trigger('add_employees') }) - + }, add_employees:function (frm) { @@ -108,21 +108,24 @@ frappe.ui.form.on('Salary Structure', { salary_slip_based_on_timesheet: function(frm) { frm.trigger("toggle_fields") }, - + preview_salary_slip: function(frm) { var d = new frappe.ui.Dialog({ title: __("Preview Salary Slip"), fields: [ - {"fieldname":"employee", "fieldtype":"Select", "label":__("Employee"), - options: $.map(frm.doc.employees, function(d) { return d.employee }), reqd: 1, label:"Employee"}, - {fieldname:"fetch", "label":__("Show Salary Slip"), "fieldtype":"Button"} + { "fieldname":"employee", "fieldtype":"Select", "label":__("Employee"), + options: $.map(frm.doc.employees, function(d) { return d.employee }), reqd: 1 }, + { fieldname:"fetch", "label":__("Show Salary Slip"), "fieldtype":"Button"} ] }); d.get_input("fetch").on("click", function() { var values = d.get_values(); if(!values) return; - frm.doc.salary_slip_based_on_timesheet?print_format="Salary Slip based on Timesheet":print_format="Salary Slip Standard"; - + var print_format; + frm.doc.salary_slip_based_on_timesheet ? + print_format="Salary Slip based on Timesheet" : + print_format="Salary Slip Standard"; + frappe.call({ method: "erpnext.hr.doctype.salary_structure.salary_structure.make_salary_slip", args: { @@ -140,7 +143,7 @@ frappe.ui.form.on('Salary Structure', { }); d.show(); }, - + toggle_fields: function(frm) { frm.toggle_display(['salary_component', 'hour_rate'], frm.doc.salary_slip_based_on_timesheet); frm.toggle_reqd(['salary_component', 'hour_rate'], frm.doc.salary_slip_based_on_timesheet); @@ -184,11 +187,11 @@ frappe.ui.form.on('Salary Detail', { amount: function(frm) { calculate_totals(frm.doc); }, - + earnings_remove: function(frm) { calculate_totals(frm.doc); - }, - + }, + deductions_remove: function(frm) { calculate_totals(frm.doc); } diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.js b/erpnext/hr/doctype/upload_attendance/upload_attendance.js index c49720c7e5e..f639898e27c 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.js +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.js @@ -7,8 +7,8 @@ frappe.provide("erpnext.hr"); erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ onload: function() { - this.frm.set_value("att_fr_date", get_today()); - this.frm.set_value("att_to_date", get_today()); + this.frm.set_value("att_fr_date", frappe.datetime.get_today()); + this.frm.set_value("att_to_date", frappe.datetime.get_today()); }, refresh: function() { @@ -18,7 +18,7 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({ get_template:function() { if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) { - msgprint(__("Attendance From Date and Attendance To Date is mandatory")); + frappe.msgprint(__("Attendance From Date and Attendance To Date is mandatory")); return; } window.location.href = repl(frappe.request.url + diff --git a/erpnext/hr/doctype/vehicle_log/vehicle_log.js b/erpnext/hr/doctype/vehicle_log/vehicle_log.js index 818a595c938..e8c6b7e6085 100644 --- a/erpnext/hr/doctype/vehicle_log/vehicle_log.js +++ b/erpnext/hr/doctype/vehicle_log/vehicle_log.js @@ -3,7 +3,7 @@ frappe.ui.form.on("Vehicle Log", { refresh: function(frm,cdt,cdn) { - vehicle_log=frappe.model.get_doc(cdt,cdn); + var vehicle_log=frappe.model.get_doc(cdt,cdn); if (vehicle_log.license_plate) { frappe.call({ method: "erpnext.hr.doctype.vehicle_log.vehicle_log.get_make_model", @@ -26,16 +26,16 @@ frappe.ui.form.on("Vehicle Log", { }, expense_claim: function(frm){ - frappe.call({ - method: "erpnext.hr.doctype.vehicle_log.vehicle_log.make_expense_claim", - args:{ - docname: frm.doc.name - }, - callback: function(r){ - var doc = frappe.model.sync(r.message); - frappe.set_route('Form', 'Expense Claim', r.message.name); - } - }) + frappe.call({ + method: "erpnext.hr.doctype.vehicle_log.vehicle_log.make_expense_claim", + args:{ + docname: frm.doc.name + }, + callback: function(r){ + var doc = frappe.model.sync(r.message); + frappe.set_route('Form', 'Expense Claim', r.message.name); + } + }); } }); diff --git a/erpnext/hr/page/team_updates/team_updates.js b/erpnext/hr/page/team_updates/team_updates.js index e701b5fb9c4..d6dd1f498db 100644 --- a/erpnext/hr/page/team_updates/team_updates.js +++ b/erpnext/hr/page/team_updates/team_updates.js @@ -54,17 +54,18 @@ frappe.team_updates = { data.avatar = frappe.avatar(data.sender); data.when = comment_when(data.creation); - var date = dateutil.str_to_obj(data.creation); + var date = frappe.datetime.str_to_obj(data.creation); var last = me.last_feed_date; - if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) { - var diff = dateutil.get_day_diff(dateutil.get_today(), dateutil.obj_to_str(date)); + if((last && frappe.datetime.obj_to_str(last) != frappe.datetime.obj_to_str(date)) || (!last)) { + var diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date)); + var pdate; if(diff < 1) { pdate = 'Today'; } else if(diff < 2) { pdate = 'Yesterday'; } else { - pdate = dateutil.global_date_format(date); + pdate = frappe.datetime.global_date_format(date); } data.date_sep = pdate; data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator"; diff --git a/erpnext/hr/report/salary_register/salary_register.js b/erpnext/hr/report/salary_register/salary_register.js index 8b0faf5219b..794dcb5b6d5 100644 --- a/erpnext/hr/report/salary_register/salary_register.js +++ b/erpnext/hr/report/salary_register/salary_register.js @@ -7,7 +7,7 @@ frappe.query_reports["Salary Register"] = { "fieldname":"date_range", "label": __("Date Range"), "fieldtype": "DateRange", - "default": [frappe.datetime.add_months(get_today(),-1), frappe.datetime.get_today()], + "default": [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()], "reqd": 1 }, { diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js index 84c66b5e055..de7cd8c5899 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js @@ -71,7 +71,7 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({ if (item.start_date && item.end_date && item.periodicity) { if(item.start_date > item.end_date) { - msgprint(__("Row {0}:Start Date must be before End Date", [item.idx])); + frappe.msgprint(__("Row {0}:Start Date must be before End Date", [item.idx])); return; } @@ -97,7 +97,7 @@ cur_frm.cscript.onload = function(doc, dt, dn) { if(!doc.status) set_multiple(dt,dn,{status:'Draft'}); if(doc.__islocal){ - set_multiple(dt,dn,{transaction_date:get_today()}); + set_multiple(dt,dn,{transaction_date: frappe.datetime.get_today()}); } // set add fetch for item_code's item_name and description @@ -108,12 +108,12 @@ cur_frm.cscript.onload = function(doc, dt, dn) { cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) { if (!doc.__islocal) { - return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc}, + return $c('runserverobj', {'method':'generate_schedule', 'docs':doc}, function(r, rt) { refresh_field('schedules'); }); } else { - msgprint(__("Please save the document before generating maintenance schedule")); + frappe.msgprint(__("Please save the document before generating maintenance schedule")); } } diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js index e1f501b38ce..a4f3abcb6e9 100644 --- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js @@ -2,8 +2,6 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.maintenance"); -me.frm.set_query('contact_person', erpnext.queries.contact_query); - frappe.ui.form.on('Maintenance Visit', { setup: function(frm) { @@ -85,7 +83,7 @@ $.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm cur_frm.cscript.onload = function(doc, dt, dn) { if(!doc.status) set_multiple(dt,dn,{status:'Draft'}); - if(doc.__islocal) set_multiple(dt,dn,{mntc_date:get_today()}); + if(doc.__islocal) set_multiple(dt,dn,{mntc_date: frappe.datetime.get_today()}); // set add fetch for item_code's item_name and description cur_frm.add_fetch('item_code', 'item_name', 'item_name'); diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 576e46df507..03e5390d70b 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -63,7 +63,7 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({ item_code: function(doc, cdt, cdn){ var scrap_items = false; - child = locals[cdt][cdn]; + var child = locals[cdt][cdn]; if(child.doctype == 'BOM Scrap Item') { scrap_items = true; } @@ -132,12 +132,12 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; var scrap_items = false; - if(child.doctype == 'BOM Scrap Item') { + if(cdt == 'BOM Scrap Item') { scrap_items = true; } if (d.bom_no) { - msgprint(__("You can not change rate if BOM mentioned agianst any item")); + frappe.msgprint(__("You can not change rate if BOM mentioned agianst any item")); get_bom_material_detail(doc, cdt, cdn, scrap_items); } else { erpnext.bom.calculate_rm_cost(doc); @@ -159,8 +159,8 @@ erpnext.bom.calculate_op_cost = function(doc) { doc.base_operating_cost = 0.0; for(var i=0;i 1){ - var start_period = dateutil.user_to_obj(dateutil.str_to_user(col.id)); - var end_period = dateutil.user_to_obj(dateutil.str_to_user(col.name)); - var astart_date = dateutil.user_to_obj(dateutil.str_to_user(d.actual_start_date)); - var planned_start_date = dateutil.user_to_obj(dateutil.str_to_user(d.planned_start_date)); - var aend_date = dateutil.user_to_obj(dateutil.str_to_user(d.actual_end_date)); - var modified = dateutil.user_to_obj(dateutil.str_to_user(d.modified)); + var start_period = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(col.id)); + var end_period = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(col.name)); + var astart_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.actual_start_date)); + var planned_start_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.planned_start_date)); + var aend_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.actual_end_date)); + var modified = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.modified)); if (dateobj <= start_period || dateobj <= end_period) { all_open_orders[col.field] = flt(all_open_orders[col.field]) + 1; diff --git a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.js b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.js index 8aed965ab82..95c78e6f1f9 100644 --- a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.js +++ b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.js @@ -1,17 +1,17 @@ frappe.query_reports["BOM Stock Report"] = { - "filters": [ - { - "fieldname":"bom", - "label": __("BOM"), - "fieldtype": "Link", - "options": "BOM", + "filters": [ + { + "fieldname": "bom", + "label": __("BOM"), + "fieldtype": "Link", + "options": "BOM", "reqd": 1 - },{ - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", + }, { + "fieldname": "warehouse", + "label": __("Warehouse"), + "fieldtype": "Link", + "options": "Warehouse", "reqd": 1 - } - ] + } + ] } diff --git a/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.js b/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.js index 917af5da9d2..94e326d7c12 100644 --- a/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.js +++ b/erpnext/manufacturing/report/production_order_stock_report/production_order_stock_report.js @@ -3,12 +3,11 @@ frappe.query_reports["Production Order Stock Report"] = { "filters": [ - { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse" - - } + { + "fieldname": "warehouse", + "label": __("Warehouse"), + "fieldtype": "Link", + "options": "Warehouse" + } ] } diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index 5f48a93f2d3..78cdb13ece8 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -13,12 +13,12 @@ frappe.ui.form.on("Project", { } frm.set_query('customer', 'erpnext.controllers.queries.customer_query'); - + frm.set_query("user", "users", function() { - return { - query:"erpnext.projects.doctype.project.project.get_users_for_project" - } - }); + return { + query:"erpnext.projects.doctype.project.project.get_users_for_project" + } + }); // sales order frm.set_query('sales_order', function() { @@ -89,7 +89,7 @@ frappe.ui.form.on("Project Task", { if(doc.task_id) { frappe.set_route("Form", "Task", doc.task_id); } else { - msgprint(__("Save the document first.")); + frappe.msgprint(__("Save the document first.")); } }, status: function(frm, doctype, name) { diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 01fa160f307..7d14d9e167b 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -13,7 +13,7 @@ frappe.ui.form.on("Timesheet", { } frm.fields_dict['time_logs'].grid.get_field('task').get_query = function(frm, cdt, cdn) { - child = locals[cdt][cdn]; + var child = locals[cdt][cdn]; return{ filters: { 'project': child.project, @@ -109,7 +109,7 @@ frappe.ui.form.on("Timesheet Detail", { }, activity_type: function(frm, cdt, cdn) { - child = locals[cdt][cdn]; + var child = locals[cdt][cdn]; frappe.call({ method: "erpnext.projects.doctype.timesheet.timesheet.get_activity_cost", args: { @@ -127,7 +127,7 @@ frappe.ui.form.on("Timesheet Detail", { } }); -calculate_end_time = function(frm, cdt, cdn){ +var calculate_end_time = function(frm, cdt, cdn) { var child = locals[cdt][cdn]; var d = moment(child.from_time); @@ -142,8 +142,9 @@ calculate_end_time = function(frm, cdt, cdn){ } var calculate_billing_costing_amount = function(frm, cdt, cdn){ - child = locals[cdt][cdn] - billing_amount = costing_amount = 0.0; + var child = locals[cdt][cdn] + var billing_amount = 0.0; + var costing_amount = 0.0; if(child.billing_hours && child.billable){ billing_amount = (child.billing_hours * child.billing_rate); @@ -157,10 +158,10 @@ var calculate_billing_costing_amount = function(frm, cdt, cdn){ var calculate_time_and_amount = function(frm) { var tl = frm.doc.time_logs || []; - total_working_hr = 0; - total_billing_hr = 0; - total_billable_amount = 0; - total_costing_amount = 0; + var total_working_hr = 0; + var total_billing_hr = 0; + var total_billable_amount = 0; + var total_costing_amount = 0; for(var i=0; i this.closing_date) { - msgprint(__("Opening Date should be before Closing Date")); + frappe.msgprint(__("Opening Date should be before Closing Date")); return; } this.fiscal_year = null; var me = this; $.each(frappe.report_dump.data["Fiscal Year"], function(i, v) { - if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) && - me.closing_date <= dateutil.str_to_obj(v.year_end_date)) { - me.fiscal_year = v; - } + if (me.opening_date >= frappe.datetime.str_to_obj(v.year_start_date) && + me.closing_date <= frappe.datetime.str_to_obj(v.year_end_date)) { + me.fiscal_year = v; + } }); if (!this.fiscal_year) { - msgprint(__("Opening Date and Closing Date should be within same Fiscal Year")); + frappe.msgprint(__("Opening Date and Closing Date should be within same Fiscal Year")); return; } }, diff --git a/erpnext/public/js/communication.js b/erpnext/public/js/communication.js index 9d54f84d9b7..5ce57b67df3 100644 --- a/erpnext/public/js/communication.js +++ b/erpnext/public/js/communication.js @@ -8,7 +8,7 @@ frappe.ui.form.on("Communication", { }, "Make"); } - if(!inList(["Lead", "Opportunity"], frm.doc.reference_doctype)) { + if(!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) { frm.add_custom_button(__("Lead"), function() { frappe.confirm("Are you sure you want to create Lead from this email", function(){ frm.trigger('make_lead_from_communication'); diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index c1c35536853..644f0f5a0b8 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -89,7 +89,7 @@ frappe.ui.form.on('Salary Structure', { } }) -get_payment_mode_account = function(frm, mode_of_payment, callback){ +var get_payment_mode_account = function(frm, mode_of_payment, callback){ return frappe.call({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account", args: { @@ -108,7 +108,7 @@ get_payment_mode_account = function(frm, mode_of_payment, callback){ cur_frm.cscript.account_head = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && d.account_head){ - msgprint("Please select Charge Type first"); + frappe.msgprint("Please select Charge Type first"); frappe.model.set_value(cdt, cdn, "account_head", ""); } else if(d.account_head && d.charge_type!=="Actual") { frappe.call({ @@ -152,7 +152,7 @@ cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) { } } if(msg) { - validated = false; + frappe.validated = false; refresh_field("taxes"); frappe.throw(msg); } @@ -176,9 +176,10 @@ cur_frm.cscript.validate_inclusive_tax = function(tax) { // inclusive tax cannot be of type Actual actual_type_error(); } else if(tax.charge_type == "On Previous Row Amount" && - !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) { - // referred row should also be an inclusive tax - on_previous_row_error(tax.row_id); + !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate) + ) { + // referred row should also be an inclusive tax + on_previous_row_error(tax.row_id); } else if(tax.charge_type == "On Previous Row Total") { var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id), function(t) { return cint(t.included_in_print_rate) ? null : t; }); diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index a8c80fe237d..06e759f9854 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -18,9 +18,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this.setup_queries(); this._super(); + /* eslint-disable */ + // no idea where me is coming from if(this.frm.get_field('shipping_address')) { - this.frm.set_query("shipping_address", function(){ - if(me.frm.doc.customer){ + this.frm.set_query("shipping_address", function() { + if(me.frm.doc.customer) { return { query: 'frappe.geo.doctype.address.address.address_query', filters: { link_doctype: 'Customer', link_name: me.frm.doc.customer } @@ -29,6 +31,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ return erpnext.queries.company_address_query(me.frm.doc) }); } + /* eslint-enable */ }, setup_queries: function() { @@ -206,73 +209,73 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ shipping_address: function(){ var me = this; erpnext.utils.get_address_display(this.frm, "shipping_address", - "shipping_address_display", is_your_company_address=true) + "shipping_address_display", true); }, tc_name: function() { this.get_terms(); }, link_to_mrs: function() { - my_items = []; - for (var i in cur_frm.doc.items) { - if(!cur_frm.doc.items[i].material_request){ - my_items.push(cur_frm.doc.items[i].item_code); - } - } - frappe.call({ - method: "erpnext.buying.utils.get_linked_material_requests", - args:{ - items: my_items - }, - callback: function(r) { - var i = 0; - var item_length = cur_frm.doc.items.length; - while (i < item_length) { - var qty = cur_frm.doc.items[i].qty; - (r.message[0] || []).forEach(function(d) { - if (d.qty > 0 && qty > 0 && cur_frm.doc.items[i].item_code == d.item_code && !cur_frm.doc.items[i].material_request_item) + var my_items = []; + for (var i in cur_frm.doc.items) { + if(!cur_frm.doc.items[i].material_request){ + my_items.push(cur_frm.doc.items[i].item_code); + } + } + frappe.call({ + method: "erpnext.buying.utils.get_linked_material_requests", + args:{ + items: my_items + }, + callback: function(r) { + var i = 0; + var item_length = cur_frm.doc.items.length; + while (i < item_length) { + var qty = cur_frm.doc.items[i].qty; + (r.message[0] || []).forEach(function(d) { + if (d.qty > 0 && qty > 0 && cur_frm.doc.items[i].item_code == d.item_code && !cur_frm.doc.items[i].material_request_item) + { + cur_frm.doc.items[i].material_request = d.mr_name; + cur_frm.doc.items[i].material_request_item = d.mr_item; + var my_qty = Math.min(qty, d.qty); + qty = qty - my_qty; + d.qty = d.qty - my_qty; + cur_frm.doc.items[i].stock_qty = my_qty*cur_frm.doc.items[i].conversion_factor; + cur_frm.doc.items[i].qty = my_qty; + + frappe.msgprint("Assigning " + d.mr_name + " to " + d.item_code + " (row " + cur_frm.doc.items[i].idx + ")"); + if (qty > 0) + { + frappe.msgprint("Splitting " + qty + " units of " + d.item_code); + var newrow = frappe.model.add_child(cur_frm.doc, cur_frm.doc.items[i].doctype, "items"); + item_length++; + + for (var key in cur_frm.doc.items[i]) { - cur_frm.doc.items[i].material_request = d.mr_name; - cur_frm.doc.items[i].material_request_item = d.mr_item; - my_qty = Math.min(qty, d.qty); - qty = qty - my_qty; - d.qty = d.qty - my_qty; - cur_frm.doc.items[i].stock_qty = my_qty*cur_frm.doc.items[i].conversion_factor; - cur_frm.doc.items[i].qty = my_qty; - - frappe.msgprint("Assigning " + d.mr_name + " to " + d.item_code + " (row " + cur_frm.doc.items[i].idx + ")"); - if (qty > 0) - { - frappe.msgprint("Splitting " + qty + " units of " + d.item_code); - var newrow = frappe.model.add_child(cur_frm.doc, cur_frm.doc.items[i].doctype, "items"); - item_length++; - - for (key in cur_frm.doc.items[i]) - { - newrow[key] = cur_frm.doc.items[i][key]; - } - - newrow.idx = item_length; - newrow["stock_qty"] = newrow.conversion_factor*qty; - newrow["qty"] = qty; - - newrow["material_request"] = ""; - newrow["material_request_item"] = ""; - - } - - - + newrow[key] = cur_frm.doc.items[i][key]; } - }); - i++; + newrow.idx = item_length; + newrow["stock_qty"] = newrow.conversion_factor*qty; + newrow["qty"] = qty; + + newrow["material_request"] = ""; + newrow["material_request_item"] = ""; + + } + + + } - refresh_field("items"); - //cur_frm.save(); - } - }); + + }); + i++; + } + refresh_field("items"); + //cur_frm.save(); } + }); + } }); cur_frm.add_fetch('project', 'cost_center', 'cost_center'); @@ -324,7 +327,7 @@ erpnext.buying.get_items_from_product_bundle = function(frm) { }); dialog.fields_dict.get_items.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; dialog.hide(); return frappe.call({ diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 849275f02cd..e85fc45d09a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -14,7 +14,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ item.rate = flt(item.rate_with_margin , precision("rate", item)); if(item.discount_percentage){ - discount_value = flt(item.rate_with_margin) * flt(item.discount_percentage) / 100; + var discount_value = flt(item.rate_with_margin) * flt(item.discount_percentage) / 100; item.rate = flt((item.rate_with_margin) - (discount_value), precision('rate', item)); } }, @@ -26,8 +26,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ // Advance calculation applicable to Sales /Purchase Invoice if(in_list(["Sales Invoice", "Purchase Invoice"], this.frm.doc.doctype) - && this.frm.doc.docstatus < 2 && !this.frm.doc.is_return) { - this.calculate_total_advance(update_paid_amount); + && this.frm.doc.docstatus < 2 && !this.frm.doc.is_return) { + this.calculate_total_advance(update_paid_amount); } // Sales person's commission @@ -108,13 +108,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ $.each(this.frm.doc["taxes"] || [], function(i, tax) { tax.item_wise_tax_detail = {}; - tax_fields = ["total", "tax_amount_after_discount_amount", + var tax_fields = ["total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] if (cstr(tax.charge_type) != "Actual" && - !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) - tax_fields.push("tax_amount"); + !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) { + tax_fields.push("tax_amount"); + } $.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 }); @@ -190,7 +191,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ }, _get_tax_rate: function(tax, item_tax_map) { - return (keys(item_tax_map).indexOf(tax.account_head) != -1) ? + return (Object.keys(item_tax_map).indexOf(tax.account_head) != -1) ? flt(item_tax_map[tax.account_head], precision("rate", tax)) : tax.rate; }, @@ -236,8 +237,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ // accumulate tax amount into tax.tax_amount if (tax.charge_type != "Actual" && - !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) - tax.tax_amount += current_tax_amount; + !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) { + tax.tax_amount += current_tax_amount; + } // store tax_amount for current item as it will be used for // charge type = 'On Previous Row Amount' @@ -492,7 +494,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ if (tax.charge_type == "Actual") actual_taxes_dict[tax.idx] = tax.tax_amount; else if (actual_taxes_dict[tax.row_id] !== null) { - actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100; + var actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100; actual_taxes_dict[tax.idx] = actual_tax_amount; } }); @@ -571,7 +573,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ set_default_payment: function(total_amount_to_pay, update_paid_amount){ var me = this; - payment_status = true; + var payment_status = true; if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){ $.each(this.frm.doc['payments'] || [], function(index, data){ if(data.type == "Cash" && payment_status && total_amount_to_pay > 0) { @@ -587,7 +589,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ calculate_paid_amount: function(){ var me = this; - var paid_amount = base_paid_amount = 0.0; + var paid_amount = 0.0; + var base_paid_amount = 0.0; if(this.frm.doc.is_pos) { $.each(this.frm.doc['payments'] || [], function(index, data){ data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount")); diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 6357a52102e..25835e0b83e 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -102,7 +102,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ onload: function() { var me = this; if(this.frm.doc.__islocal) { - var today = get_today(), + var today = frappe.datetime.get_today(), currency = frappe.defaults.get_user_default("currency"); $.each({ @@ -195,10 +195,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ var me = this; if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length && !(this.frm.doc.__onload ? this.frm.doc.__onload.load_after_mapping : false)) { - this.apply_default_taxes(); + this.apply_default_taxes(); } else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"] && !this.frm.doc.is_pos) { - me.calculate_taxes_and_totals(); + me.calculate_taxes_and_totals(); } if(frappe.meta.get_docfield(this.frm.doc.doctype + " Item", "item_code")) { this.setup_item_selector(); @@ -243,7 +243,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, send_sms: function() { - var sms_man = new SMSManager(this.frm.doc); + var sms_man = new erpnext.SMSManager(this.frm.doc); }, barcode: function(doc, cdt, cdn) { @@ -281,8 +281,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ currency: me.frm.doc.currency, update_stock: in_list(['Sales Invoice', 'Purchase Invoice'], me.frm.doc.doctype) ? cint(me.frm.doc.update_stock) : 0, conversion_rate: me.frm.doc.conversion_rate, - price_list: me.frm.doc.selling_price_list || - me.frm.doc.buying_price_list, + price_list: me.frm.doc.selling_price_list || me.frm.doc.buying_price_list, price_list_currency: me.frm.doc.price_list_currency, plc_conversion_rate: me.frm.doc.plc_conversion_rate, company: me.frm.doc.company, @@ -423,10 +422,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") && in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)){ - erpnext.utils.get_shipping_address(this.frm, function(){ - set_party_account(set_pricing); - }) - }else{ + erpnext.utils.get_shipping_address(this.frm, function(){ + set_party_account(set_pricing); + }) + } else { set_party_account(set_pricing); } @@ -505,7 +504,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } if(this.frm.doc.currency === this.frm.doc.price_list_currency && this.frm.doc.plc_conversion_rate !== this.frm.doc.conversion_rate) { - this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate); + this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate); } if(flt(this.frm.doc.conversion_rate)>0.0) { @@ -555,7 +554,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } else if(this.frm.doc.price_list_currency === this.frm.doc.currency && this.frm.doc.plc_conversion_rate && cint(this.frm.doc.plc_conversion_rate) != 1 && cint(this.frm.doc.plc_conversion_rate) != cint(this.frm.doc.conversion_rate)) { - this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate); + this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate); } if(!this.in_apply_price_list) { @@ -981,10 +980,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ $.each(["company", "customer"], function(i, fieldname) { if(frappe.meta.has_field(me.frm.doc.doctype, fieldname && me.frm.doc.doctype != "Purchase Order")) { if (!me.frm.doc[fieldname]) { - msgprint(__("Please specify") + ": " + + frappe.msgprint(__("Please specify") + ": " + frappe.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) + ". " + __("It is needed to fetch Item Details.")); - valid = false; + valid = false; } } }); @@ -1076,7 +1075,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ set_gross_profit: function(item) { if (this.frm.doc.doctype == "Sales Order" && item.valuation_rate) { - rate = flt(item.rate) * flt(this.frm.doc.conversion_rate || 1); + 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)); } }, @@ -1085,9 +1084,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ // TODO: remove item selector return; - if(!this.item_selector) { - this.item_selector = new erpnext.ItemSelector({frm: this.frm}); - } + // if(!this.item_selector) { + // this.item_selector = new erpnext.ItemSelector({frm: this.frm}); + // } }, get_advances: function() { @@ -1118,7 +1117,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, get_method_for_payment: function(){ - method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry" + var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry" if(cur_frm.doc.__onload && cur_frm.doc.__onload.make_payment_via_journal_entry){ if(in_list(['Sales Invoice', 'Purchase Invoice'], cur_frm.doc.doctype)){ method = "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_invoice" diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js index 438ad7996fa..77209e093a8 100644 --- a/erpnext/public/js/payment/payments.js +++ b/erpnext/public/js/payment/payments.js @@ -55,7 +55,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ show_payment_details: function(){ var me = this; - multimode_payments = $(this.$body).find('.multimode-payments').empty(); + var multimode_payments = $(this.$body).find('.multimode-payments').empty(); if(this.frm.doc.payments.length){ $.each(this.frm.doc.payments, function(index, data){ $(frappe.render_template('payment_details', { @@ -126,7 +126,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ highlight_selected_row: function(){ var me = this; - selected_row = $(this.$body).find(repl(".pos-payment-row[idx='%(idx)s']",{'idx': this.idx})); + 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); @@ -195,7 +195,7 @@ erpnext.payments = erpnext.stock.StockController.extend({ update_paid_amount: function(update_write_off) { var me = this; if(in_list(['change_amount', 'write_off_amount'], this.idx)){ - value = me.selected_mode.val(); + var value = me.selected_mode.val(); if(me.idx == 'change_amount'){ me.change_amount(value) } else{ diff --git a/erpnext/public/js/purchase_trends_filters.js b/erpnext/public/js/purchase_trends_filters.js index b2d882c6079..117d4eb08cd 100644 --- a/erpnext/public/js/purchase_trends_filters.js +++ b/erpnext/public/js/purchase_trends_filters.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -var get_filters = function(){ +erpnext.get_purchase_trends_filters = function() { return [ { "fieldname":"period", @@ -44,7 +44,7 @@ var get_filters = function(){ "label": __("Fiscal Year"), "fieldtype": "Link", "options":'Fiscal Year', - "default": sys_defaults.fiscal_year + "default": frappe.sys_defaults.fiscal_year }, { "fieldname":"company", diff --git a/erpnext/public/js/sales_trends_filters.js b/erpnext/public/js/sales_trends_filters.js index f28e8f7f225..b272fdd5fb0 100644 --- a/erpnext/public/js/sales_trends_filters.js +++ b/erpnext/public/js/sales_trends_filters.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -var get_filters = function(){ - return[ +erpnext.get_sales_trends_filters = function() { + return[ { "fieldname":"period", "label": __("Period"), @@ -45,7 +45,7 @@ var get_filters = function(){ "label": __("Fiscal Year"), "fieldtype": "Link", "options":'Fiscal Year', - "default": sys_defaults.fiscal_year + "default": frappe.sys_defaults.fiscal_year }, { "fieldname":"company", diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js index 658c4fe00d2..488d3c48d83 100644 --- a/erpnext/public/js/setup_wizard.js +++ b/erpnext/public/js/setup_wizard.js @@ -1,7 +1,7 @@ frappe.provide("erpnext.wiz"); frappe.pages['setup-wizard'].on_page_load = function(wrapper) { - if(sys_defaults.company) { + if(frappe.sys_defaults.company) { frappe.set_route("desk"); return; } @@ -38,17 +38,17 @@ function load_erpnext_slides() { fields: [ {fieldname:'company_name', label: frappe.wiz.domain==='Education' ? - __('Institute Name') : __('Company Name'), + __('Institute Name') : __('Company Name'), fieldtype:'Data', reqd:1}, {fieldname:'company_abbr', label: frappe.wiz.domain==='Education' ? - __('Institute Abbreviation') : __('Company Abbreviation'), + __('Institute Abbreviation') : __('Company Abbreviation'), fieldtype:'Data'}, {fieldname:'company_tagline', label: __('What does it do?'), fieldtype:'Data', placeholder: frappe.wiz.domain==='Education' ? - __('e.g. "Primary School" or "University"') : + __('e.g. "Primary School" or "University"') : __('e.g. "Build tools for builders"'), reqd:1}, {fieldname:'bank_account', label: __('Bank Name'), fieldtype:'Data', reqd:1}, @@ -75,12 +75,12 @@ function load_erpnext_slides() { validate: function() { // validate fiscal year start and end dates if (this.values.fy_start_date=='Invalid date' || this.values.fy_end_date=='Invalid date') { - msgprint(__("Please enter valid Financial Year Start and End Dates")); + frappe.msgprint(__("Please enter valid Financial Year Start and End Dates")); return false; } if ((this.values.company_name || "").toLowerCase() == "company") { - msgprint(__("Company Name cannot be Company")); + frappe.msgprint(__("Company Name cannot be Company")); return false; } @@ -102,7 +102,7 @@ function load_erpnext_slides() { } var year_start_date = current_year + "-" + fy[0]; - if(year_start_date > get_today()) { + if(year_start_date > frappe.datetime.get_today()) { next_year = current_year current_year -= 1; } @@ -145,7 +145,7 @@ function load_erpnext_slides() { slide.get_input("company_abbr").on("change", function() { if(slide.get_input("company_abbr").val().length > 5) { - msgprint("Company Abbreviation cannot have more than 5 characters"); + frappe.msgprint("Company Abbreviation cannot have more than 5 characters"); slide.get_field("company_abbr").set_input(""); } }); @@ -420,7 +420,7 @@ function load_erpnext_slides() { "Thailand": ["10-01", "09-30"], "United Kingdom": ["04-01", "03-31"], }; -}; +} frappe.wiz.on("before_load", function() { load_erpnext_slides(); @@ -447,7 +447,7 @@ frappe.wiz.on("before_load", function() { } }); -test_values_edu = { +var test_values_edu = { "language":"english", "domain":"Education", "country":"India", diff --git a/erpnext/public/js/shopping_cart.js b/erpnext/public/js/shopping_cart.js index 2a69deb6dbd..2c56b026b9a 100644 --- a/erpnext/public/js/shopping_cart.js +++ b/erpnext/public/js/shopping_cart.js @@ -2,9 +2,11 @@ // License: GNU General Public License v3. See license.txt // shopping cart -frappe.provide("shopping_cart"); +frappe.provide("erpnext.shopping_cart"); +var shopping_cart = erpnext.shopping_cart; frappe.ready(function() { + var full_name = frappe.session.user_fullname; // update user if(full_name) { $('.navbar li[data-label="User"] a') @@ -34,6 +36,7 @@ $.extend(shopping_cart, { }, update_cart: function(opts) { + var full_name = frappe.session.user_fullname; if(!full_name || full_name==="Guest") { if(localStorage) { localStorage.setItem("last_visited", window.location.pathname); @@ -110,19 +113,19 @@ $.extend(shopping_cart, { }, - bind_dropdown_cart_buttons: function() { + bind_dropdown_cart_buttons: function () { $(".cart-icon").on('click', '.number-spinner button', function () { var btn = $(this), input = btn.closest('.number-spinner').find('input'), oldValue = input.val().trim(), newVal = 0; - if (btn.attr('data-dir') == 'up') { - newVal = parseInt(oldValue) + 1; - } else { - if (oldValue > 1) { - newVal = parseInt(oldValue) - 1; - } + if (btn.attr('data-dir') == 'up') { + newVal = parseInt(oldValue) + 1; + } else { + if (oldValue > 1) { + newVal = parseInt(oldValue) - 1; + } } input.val(newVal); var item_code = input.attr("data-item-code"); diff --git a/erpnext/public/js/sms_manager.js b/erpnext/public/js/sms_manager.js index d6293ea1079..13e226fbb03 100644 --- a/erpnext/public/js/sms_manager.js +++ b/erpnext/public/js/sms_manager.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -function SMSManager(doc) { +erpnext.SMSManager = function SMSManager(doc) { var me = this; this.setup = function() { var default_msg = { @@ -42,7 +42,7 @@ function SMSManager(doc) { ref_name: ref_name }, callback: function(r) { - if(r.exc) { msgprint(r.exc); return; } + if(r.exc) { frappe.msgprint(r.exc); return; } me.number = r.message; me.show_dialog(); } @@ -92,7 +92,7 @@ function SMSManager(doc) { }, callback: function(r) { $(btn).done_working(); - if(r.exc) {msgprint(r.exc); return; } + if(r.exc) {frappe.msgprint(r.exc); return; } me.dialog.hide(); } }); diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index 28ff55da093..74f5c03c752 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -6,7 +6,6 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ init: function(wrapper, opts) { var args = { title: __("Stock Analytics"), - page: wrapper, parent: $(wrapper).find('.layout-main'), page: wrapper.page, doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", @@ -120,8 +119,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ }, prepare_balances: function() { var me = this; - var from_date = dateutil.str_to_obj(this.from_date); - var to_date = dateutil.str_to_obj(this.to_date); + var from_date = frappe.datetime.str_to_obj(this.from_date); + var to_date = frappe.datetime.str_to_obj(this.to_date); var data = frappe.report_dump.data["Stock Ledger Entry"]; this.item_warehouse = {}; @@ -130,7 +129,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ for(var i=0, j=data.length; i= d.maximum_score) { - frappe.throw(_("Score cannot be greater than Maximum Score")); - } - else { - frappe.call({ - method: "erpnext.schools.api.get_grade", - args: { - grading_scale: frm.doc.grading_scale, - percentage: ((d.score/d.maximum_score) * 100) - }, - callback: function(r) { - if (r.message) { - frappe.model.set_value(cdt, cdn, "grade", r.message); - } - } - }); - } - } + score: function(frm, cdt, cdn) { + var d = locals[cdt][cdn]; + if (d.score >= d.maximum_score) { + frappe.throw(__("Score cannot be greater than Maximum Score")); + } + else { + frappe.call({ + method: "erpnext.schools.api.get_grade", + args: { + grading_scale: frm.doc.grading_scale, + percentage: ((d.score/d.maximum_score) * 100) + }, + callback: function(r) { + if (r.message) { + frappe.model.set_value(cdt, cdn, "grade", r.message); + } + } + }); + } + } }); \ No newline at end of file diff --git a/erpnext/schools/doctype/course_schedule/course_schedule.js b/erpnext/schools/doctype/course_schedule/course_schedule.js index 6521469b24b..7778a6e6157 100644 --- a/erpnext/schools/doctype/course_schedule/course_schedule.js +++ b/erpnext/schools/doctype/course_schedule/course_schedule.js @@ -2,15 +2,15 @@ frappe.provide("schools") cur_frm.add_fetch("student_group", "course", "course") frappe.ui.form.on("Course Schedule", { - refresh: function(frm) { - if (!frm.doc.__islocal) { - frm.add_custom_button(__("Attendance"), function() { - frappe.route_options = { - based_on: "Course Schedule", - course_schedule: frm.doc.name - } - frappe.set_route("Form", "Student Attendance Tool"); - }); - } - } + refresh: function(frm) { + if (!frm.doc.__islocal) { + frm.add_custom_button(__("Attendance"), function() { + frappe.route_options = { + based_on: "Course Schedule", + course_schedule: frm.doc.name + } + frappe.set_route("Form", "Student Attendance Tool"); + }); + } + } }); \ No newline at end of file diff --git a/erpnext/schools/doctype/course_scheduling_tool/course_scheduling_tool.js b/erpnext/schools/doctype/course_scheduling_tool/course_scheduling_tool.js index b835ce05d4d..f92f738ffdf 100644 --- a/erpnext/schools/doctype/course_scheduling_tool/course_scheduling_tool.js +++ b/erpnext/schools/doctype/course_scheduling_tool/course_scheduling_tool.js @@ -8,13 +8,13 @@ cur_frm.add_fetch("student_group", "academic_term", "academic_term"); frappe.ui.form.on("Course Scheduling Tool", { - refresh: function(frm) { - frm.disable_save(); - frm.page.set_primary_action(__("Schedule Course"), function() { - frappe.call({ - method: "schedule_course", - doc: frm.doc - }) - }); - } + refresh: function(frm) { + frm.disable_save(); + frm.page.set_primary_action(__("Schedule Course"), function() { + frappe.call({ + method: "schedule_course", + doc: frm.doc + }) + }); + } }); \ No newline at end of file diff --git a/erpnext/schools/doctype/fee_structure/fee_structure.js b/erpnext/schools/doctype/fee_structure/fee_structure.js index 391c935b058..fa46278859f 100644 --- a/erpnext/schools/doctype/fee_structure/fee_structure.js +++ b/erpnext/schools/doctype/fee_structure/fee_structure.js @@ -1,6 +1,6 @@ frappe.ui.form.on("Fee Component", { amount: function(frm) { - total_amount = 0; + var total_amount = 0; for(var i=0;i frm.doc.paid_amount)) { frm.add_custom_button(__("Collect Fees"), function() { @@ -42,7 +42,7 @@ frappe.ui.form.on("Fees", { }); } }, - + program: function(frm) { if (frm.doc.program && frm.doc.academic_term) { frappe.call({ @@ -86,9 +86,9 @@ frappe.ui.form.on("Fees", { }); } }, - + calculate_total_amount: function(frm) { - total_amount = 0; + var total_amount = 0; for(var i=0;i doc.paid_amount) && doc.due_date < get_today()) { - return [__("Overdue"), "red", ["due_date,<,"+get_today()], ["due_date,<,"+get_today()]]; + return [__("Overdue"), "red", ["due_date,<," + get_today()], ["due_date,<," + get_today()]]; } else if (doc.total_amount > doc.paid_amount) { return [__("Pending"), "orange"]; diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.js b/erpnext/schools/doctype/program_enrollment/program_enrollment.js index 207e6a1ff8c..b843d445bc4 100644 --- a/erpnext/schools/doctype/program_enrollment/program_enrollment.js +++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.js @@ -3,7 +3,7 @@ cur_frm.add_fetch('fee_structure', 'total_amount', 'amount'); -frappe.ui.form.on("Program Enrollment", { +frappe.ui.form.on("Program Enrollment", { onload: function(frm, cdt, cdn){ frm.set_query("academic_term", "fees", function(){ return{ @@ -12,7 +12,7 @@ frappe.ui.form.on("Program Enrollment", { } }; }); - + frm.fields_dict['fees'].grid.get_field('fee_structure').get_query = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; return { @@ -25,7 +25,7 @@ frappe.ui.form.on("Program Enrollment", { return{ query: "erpnext.schools.doctype.program_enrollment.program_enrollment.get_program_courses", filters: { - 'program': frm.doc.program + 'program': frm.doc.program } } }); @@ -48,7 +48,7 @@ frappe.ui.form.on("Program Enrollment", { }); } }, - + student_category: function() { frappe.ui.form.trigger("Program Enrollment", "program"); }, diff --git a/erpnext/schools/doctype/program_enrollment_tool/program_enrollment_tool.js b/erpnext/schools/doctype/program_enrollment_tool/program_enrollment_tool.js index 3dd00c06442..bf6f3e0938c 100644 --- a/erpnext/schools/doctype/program_enrollment_tool/program_enrollment_tool.js +++ b/erpnext/schools/doctype/program_enrollment_tool/program_enrollment_tool.js @@ -7,7 +7,7 @@ frappe.ui.form.on("Program Enrollment Tool", { "refresh": function(frm) { frm.disable_save(); }, - + "get_students": function(frm) { frm.set_value("students",[]); frappe.call({ @@ -20,13 +20,13 @@ frappe.ui.form.on("Program Enrollment Tool", { } }) }, - + "enroll_students": function(frm) { frappe.call({ method: "enroll_students", doc:frm.doc, callback: function(r) { - frm.set_value("students", []); + frm.set_value("students", []); } }) } diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.js b/erpnext/schools/doctype/student_applicant/student_applicant.js index 9b08ee5f6ab..974d9727de1 100644 --- a/erpnext/schools/doctype/student_applicant/student_applicant.js +++ b/erpnext/schools/doctype/student_applicant/student_applicant.js @@ -28,7 +28,7 @@ frappe.ui.form.on("Student Applicant", { frappe.realtime.on("enroll_student_progress", function(data) { if(data.progress) { - frappe.hide_msgprint(true); + frappe.hide_frappe.msgprint(true); frappe.show_progress(__("Enrolling student"), data.progress[0],data.progress[1]); } }) diff --git a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js index 11a79e134e3..706a1487b36 100644 --- a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js +++ b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js @@ -98,17 +98,6 @@ schools.StudentsEditor = Class.extend({ }); }); - var get_present_student = function(student) { - return students.filter(function(s) { - return s.group_roll_number === group_roll_number; - }) - } - var get_absent_student = function(group_roll_number) { - return students.filter(function(s) { - return s.group_roll_number === group_roll_number; - }) - } - student_toolbar.find(".btn-mark-att") .html(__('Mark Attendence')) .on("click", function() { diff --git a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js index dd909b2db07..146f11c4539 100644 --- a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js +++ b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js @@ -7,10 +7,10 @@ frappe.ui.form.on("Student Group Creation Tool", "refresh", function(frm) { }) }); frappe.realtime.on("student_group_creation_progress", function(data) { - if(data.progress) { - frappe.hide_msgprint(true); - frappe.show_progress(__("Creating student groups"), data.progress[0],data.progress[1]); - } + if(data.progress) { + frappe.hide_frappe.msgprint(true); + frappe.show_progress(__("Creating student groups"), data.progress[0],data.progress[1]); + } }); }); diff --git a/erpnext/schools/report/absent_student_report/absent_student_report.js b/erpnext/schools/report/absent_student_report/absent_student_report.js index 7515f2203b1..bf2d10d59e3 100644 --- a/erpnext/schools/report/absent_student_report/absent_student_report.js +++ b/erpnext/schools/report/absent_student_report/absent_student_report.js @@ -8,7 +8,7 @@ frappe.query_reports["Absent Student Report"] = { "fieldname":"date", "label": __("Date"), "fieldtype": "Date", - "default": get_today(), + "default": frappe.datetime.get_today(), "reqd": 1 } ] diff --git a/erpnext/schools/report/student_batch_wise_attendance/student_batch_wise_attendance.js b/erpnext/schools/report/student_batch_wise_attendance/student_batch_wise_attendance.js index 51f7346b89a..ad04356201e 100644 --- a/erpnext/schools/report/student_batch_wise_attendance/student_batch_wise_attendance.js +++ b/erpnext/schools/report/student_batch_wise_attendance/student_batch_wise_attendance.js @@ -2,11 +2,11 @@ // For license information, please see license.txt frappe.query_reports["Student Batch-Wise Attendance"] = { - "filters": [{ - "fieldname": "date", - "label": __("Date"), - "fieldtype": "Date", - "default": get_today(), - "reqd": 1 - }] + "filters": [{ + "fieldname": "date", + "label": __("Date"), + "fieldtype": "Date", + "default": frappe.datetime.get_today(), + "reqd": 1 + }] } \ No newline at end of file diff --git a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js index 57927fa9d97..943238ece26 100644 --- a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js +++ b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.js @@ -3,40 +3,40 @@ frappe.query_reports["Student Monthly Attendance Sheet"] = { - "filters": [{ - "fieldname": "month", - "label": __("Month"), - "fieldtype": "Select", - "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", - "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", - "Dec" - ][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()], - }, - { - "fieldname": "year", - "label": __("Year"), - "fieldtype": "Select", - "reqd": 1 - }, - { - "fieldname": "student_group", - "label": __("Student Group"), - "fieldtype": "Link", - "options": "Student Group", - "reqd": 1 - } - ], + "filters": [{ + "fieldname": "month", + "label": __("Month"), + "fieldtype": "Select", + "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec" + ][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()], + }, + { + "fieldname": "year", + "label": __("Year"), + "fieldtype": "Select", + "reqd": 1 + }, + { + "fieldname": "student_group", + "label": __("Student Group"), + "fieldtype": "Link", + "options": "Student Group", + "reqd": 1 + } + ], - "onload": function() { - return frappe.call({ - method: "erpnext.schools.report.student_monthly_attendance_sheet.student_monthly_attendance_sheet.get_attendance_years", - callback: function(r) { - var year_filter = frappe.query_report_filters_by_name.year; - year_filter.df.options = r.message; - year_filter.df.default = r.message.split("\n")[0]; - year_filter.refresh(); - year_filter.set_input(year_filter.df.default); - } - }); - } + "onload": function() { + return frappe.call({ + method: "erpnext.schools.report.student_monthly_attendance_sheet.student_monthly_attendance_sheet.get_attendance_years", + callback: function(r) { + var year_filter = frappe.query_report_filters_by_name.year; + year_filter.df.options = r.message; + year_filter.df.default = r.message.split("\n")[0]; + year_filter.refresh(); + year_filter.set_input(year_filter.df.default); + } + }); + } } \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index 9aff74ad86e..ab35574e312 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -16,9 +16,13 @@ frappe.provide("erpnext.selling"); // TODO commonify this code erpnext.selling.InstallationNote = frappe.ui.form.Controller.extend({ onload: function() { - if(!this.frm.doc.status) set_multiple(dt,dn,{ status:'Draft'}); - if(this.frm.doc.__islocal) set_multiple(this.frm.doc.doctype, this.frm.doc.name, - {inst_date: get_today()}); + if(!this.frm.doc.status) { + set_multiple(this.frm.doc.doctype, this.frm.doc.name, { status:'Draft'}); + } + if(this.frm.doc.__islocal) { + set_multiple(this.frm.doc.doctype, this.frm.doc.name, + {inst_date: frappe.datetime.get_today()}); + } this.setup_queries(); }, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 940daaa5078..64af35d8ccf 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -94,7 +94,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ validate_company_and_party: function(party_field) { if(!this.frm.doc.quotation_to) { - msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name])); + 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; @@ -149,7 +149,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){ }); dialog.fields_dict.update.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; return cur_frm.call({ method: "declare_order_lost", @@ -157,7 +157,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){ args: args.reason, callback: function(r) { if(r.exc) { - msgprint(__("There were errors.")); + frappe.msgprint(__("There were errors.")); return; } dialog.hide(); diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 7850119c6db..5059d5d9303 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -69,9 +69,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( if (this.frm.has_perm("submit")) { // close if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) { - this.frm.add_custom_button(__('Close'), - function() { me.close_sales_order() }, __("Status")) - } + this.frm.add_custom_button(__('Close'), + function() { me.close_sales_order() }, __("Status")) + } } // delivery note @@ -93,8 +93,8 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( // material request if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && flt(doc.per_delivered, 2) < 100) { - this.frm.add_custom_button(__('Material Request'), - function() { me.make_material_request() }, __("Make")); + this.frm.add_custom_button(__('Material Request'), + function() { me.make_material_request() }, __("Make")); } // make purchase order @@ -196,7 +196,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( title: __('Select Items to Manufacture'), fields: fields, primary_action: function() { - data = d.get_values(); + var data = d.get_values(); me.frm.call({ method: 'make_production_orders', args: { @@ -288,7 +288,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( }); dialog.fields_dict.make_purchase_order.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; dialog.hide(); return frappe.call({ diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js index 53b2818274b..d1ac6d92bfa 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_list.js +++ b/erpnext/selling/doctype/sales_order/sales_order_list.js @@ -2,10 +2,10 @@ frappe.listview_settings['Sales Order'] = { add_fields: ["base_grand_total", "customer_name", "currency", "delivery_date", "per_delivered", "per_billed", "status", "order_type"], get_indicator: function(doc) { - if(doc.status==="Closed"){ - return [__("Closed"), "green", "status,=,Closed"]; + if(doc.status==="Closed"){ + return [__("Closed"), "green", "status,=,Closed"]; - } else if (doc.order_type !== "Maintenance" + } else if (doc.order_type !== "Maintenance" && flt(doc.per_delivered, 2) < 100 && frappe.datetime.get_diff(doc.delivery_date) < 0) { // to bill & overdue return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"]; diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js index bb47f988f49..5e603ba4ac6 100644 --- a/erpnext/selling/page/sales_analytics/sales_analytics.js +++ b/erpnext/selling/page/sales_analytics/sales_analytics.js @@ -18,7 +18,6 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({ init: function(wrapper) { this._super({ title: __("Sales Analytics"), - page: wrapper, parent: $(wrapper).find('.layout-main'), page: wrapper.page, doctypes: ["Item", "Item Group", "Customer", "Customer Group", "Company", "Territory", @@ -194,13 +193,13 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({ }, prepare_balances: function() { var me = this; - var from_date = dateutil.str_to_obj(this.from_date); - var to_date = dateutil.str_to_obj(this.to_date); + var from_date = frappe.datetime.str_to_obj(this.from_date); + var to_date = frappe.datetime.str_to_obj(this.to_date); var is_val = this.value_or_qty == 'Value'; $.each(this.tl[this.based_on], function(i, tl) { if (me.is_default('company') ? true : tl.company === me.company) { - var posting_date = dateutil.str_to_obj(tl.posting_date); + var posting_date = frappe.datetime.str_to_obj(tl.posting_date); if (posting_date >= from_date && posting_date <= to_date) { var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; @@ -217,7 +216,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({ $.each(this.data, function(i, item) { var parent = me.parent_map[item.name]; while(parent) { - parent_group = me.item_by_name[parent]; + var parent_group = me.item_by_name[parent]; $.each(me.columns, function(c, col) { if (col.formatter == me.currency_formatter) { diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.js b/erpnext/selling/report/quotation_trends/quotation_trends.js index 294aea0c7f6..f00ca278b00 100644 --- a/erpnext/selling/report/quotation_trends/quotation_trends.js +++ b/erpnext/selling/report/quotation_trends/quotation_trends.js @@ -3,7 +3,7 @@ frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { frappe.query_reports["Quotation Trends"] = { - filters: get_filters() + filters: erpnext.get_sales_trends_filters() } }); diff --git a/erpnext/selling/report/sales_order_trends/sales_order_trends.js b/erpnext/selling/report/sales_order_trends/sales_order_trends.js index 863afb8d634..ea320d6b481 100644 --- a/erpnext/selling/report/sales_order_trends/sales_order_trends.js +++ b/erpnext/selling/report/sales_order_trends/sales_order_trends.js @@ -3,6 +3,6 @@ frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { frappe.query_reports["Sales Order Trends"] = { - filters: get_filters() + filters: erpnext.get_sales_trends_filters() } }); \ No newline at end of file diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js index f1cb3b74617..8987a74ff83 100644 --- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js +++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js @@ -8,7 +8,7 @@ frappe.query_reports["Sales Person Target Variance Item Group-Wise"] = { label: __("Fiscal Year"), fieldtype: "Link", options: "Fiscal Year", - default: sys_defaults.fiscal_year + default: frappe.sys_defaults.fiscal_year }, { fieldname: "period", diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js index 9258730650b..90244ce9f6d 100644 --- a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js +++ b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js @@ -26,7 +26,7 @@ frappe.query_reports["Sales Person-wise Transaction Summary"] = { fieldname:"to_date", label: __("To Date"), fieldtype: "Date", - default: get_today() + default: frappe.datetime.get_today() }, { fieldname:"company", diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js index 7631fcb02f2..55a13d96802 100644 --- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js +++ b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js @@ -8,7 +8,7 @@ frappe.query_reports["Territory Target Variance Item Group-Wise"] = { label: __("Fiscal Year"), fieldtype: "Link", options: "Fiscal Year", - default: sys_defaults.fiscal_year + default: frappe.sys_defaults.fiscal_year }, { fieldname: "period", diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 1fcf334717b..35044d76611 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -90,7 +90,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if(!item.item_code) { frappe.throw(__("Please enter Item Code to get batch no")); } else { - filters = { + var filters = { 'item_code': item.item_code, 'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(), } @@ -180,7 +180,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ __(frappe.meta.get_label(this.frm.doc.doctype, "total_commission", this.frm.doc.name)) + " > " + __(frappe.meta.get_label(this.frm.doc.doctype, "base_net_total", this.frm.doc.name))); - msgprint(msg); + frappe.msgprint(msg); throw msg; } @@ -219,7 +219,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ serial_no: item.serial_no || "" }, callback:function(r){ - if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) { + if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { me.batch_no(doc, cdt, cdn); } } @@ -241,7 +241,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if(this.frm.doc.commission_rate > 100) { var msg = __(frappe.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name)) + " " + __("cannot be greater than 100"); - msgprint(msg); + frappe.msgprint(msg); throw msg; } @@ -253,13 +253,13 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ calculate_contribution: function() { var me = this; $.each(this.frm.doc.doctype.sales_team || [], function(i, sales_person) { - frappe.model.round_floats_in(sales_person); - if(sales_person.allocated_percentage) { - sales_person.allocated_amount = flt( - me.frm.doc.base_net_total * sales_person.allocated_percentage / 100.0, - precision("allocated_amount", sales_person)); - } - }); + frappe.model.round_floats_in(sales_person); + if(sales_person.allocated_percentage) { + sales_person.allocated_amount = flt( + me.frm.doc.base_net_total * sales_person.allocated_percentage / 100.0, + precision("allocated_amount", sales_person)); + } + }); }, shipping_rule: function() { @@ -282,16 +282,16 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var item = frappe.get_doc(cdt, cdn); if(item.warehouse && item.item_code && item.batch_no) { - return this.frm.call({ - method: "erpnext.stock.get_item_details.get_batch_qty", - child: item, - args: { - "batch_no": item.batch_no, - "warehouse": item.warehouse, - "item_code": item.item_code - }, - "fieldname": "actual_batch_qty" - }); + return this.frm.call({ + method: "erpnext.stock.get_item_details.get_batch_qty", + child: item, + args: { + "batch_no": item.batch_no, + "warehouse": item.warehouse, + "item_code": item.item_code + }, + "fieldname": "actual_batch_qty" + }); } }, @@ -305,15 +305,15 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if ((doc.packed_items || []).length) { $(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true); - if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) { - help_msg = "
" + + if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { + var help_msg = "
" + __("For 'Product Bundle' items, Warehouse, Serial No and Batch No will be considered from the 'Packing List' table. If Warehouse and Batch No are same for all packing items for any 'Product Bundle' item, those values can be entered in the main Item table, values will be copied to 'Packing List' table.")+ "
"; frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = help_msg; } } else { $(cur_frm.fields_dict.packing_list.row.wrapper).toggle(false); - if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) { + if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = ''; } } @@ -339,7 +339,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ margin_rate_or_amount: function(doc, cdt, cdn) { // calculated the revised total margin and rate on margin rate changes - item = locals[cdt][cdn]; + var item = locals[cdt][cdn]; this.apply_pricing_rule_on_item(item) this.calculate_taxes_and_totals(); cur_frm.refresh_fields(); @@ -347,7 +347,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ margin_type: function(doc, cdt, cdn){ // calculate the revised total margin and rate on margin type changes - item = locals[cdt][cdn]; + var item = locals[cdt][cdn]; if(!item.margin_type) { frappe.model.set_value(cdt, cdn, "margin_rate_or_amount", 0); } else { @@ -369,7 +369,7 @@ frappe.ui.form.on(cur_frm.doctype,"project", function(frm) { $.each(frm.doc["items"] || [], function(i, row) { if(r.message) { frappe.model.set_value(row.doctype, row.name, "cost_center", r.message); - msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message)); + frappe.msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message)); } }) } diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index ca60b1184fa..9e8bbe5698f 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -47,31 +47,32 @@ frappe.ui.form.on("Company", { fieldname: "company_name", label: __("Please re-type company name to confirm"), reqd: 1, - description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.")}, - function(data) { - if(data.company_name !== frm.doc.name) { - frappe.msgprint("Company name not same"); - return; - } - frappe.call({ - method: "erpnext.setup.doctype.company.delete_company_transactions.delete_company_transactions", - args: { - company_name: data.company_name - }, - freeze: true, - callback: function(r, rt) { - if(!r.exc) - frappe.msgprint(__("Successfully deleted all transactions related to this company!")); - }, - onerror: function() { - frappe.msgprint(__("Wrong Password")); - } - }); - }, __("Delete all the Transactions for this Company"), __("Delete") - ); - d.get_primary_btn().addClass("btn-danger"); - } - ); + description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.") + }, + function(data) { + if(data.company_name !== frm.doc.name) { + frappe.msgprint("Company name not same"); + return; + } + frappe.call({ + method: "erpnext.setup.doctype.company.delete_company_transactions.delete_company_transactions", + args: { + company_name: data.company_name + }, + freeze: true, + callback: function(r, rt) { + if(!r.exc) + frappe.msgprint(__("Successfully deleted all transactions related to this company!")); + }, + onerror: function() { + frappe.msgprint(__("Wrong Password")); + } + }); + }, + __("Delete all the Transactions for this Company"), __("Delete") + ); + d.get_primary_btn().addClass("btn-danger"); + }); } }); @@ -106,7 +107,7 @@ cur_frm.cscript.change_abbr = function() { }); dialog.fields_dict.update.$input.click(function() { - args = dialog.get_values(); + var args = dialog.get_values(); if(!args) return; return frappe.call({ method: "erpnext.setup.doctype.company.company.replace_abbr", @@ -117,7 +118,7 @@ cur_frm.cscript.change_abbr = function() { }, callback: function(r) { if(r.exc) { - msgprint(__("There were errors.")); + frappe.msgprint(__("There were errors.")); return; } else { cur_frm.set_value("abbr", args.new_abbr); @@ -154,7 +155,7 @@ erpnext.company.setup_queries = function(frm) { erpnext.company.set_custom_query(frm, v); }); - if (sys_defaults.auto_accounting_for_stock) { + if (frappe.sys_defaults.auto_accounting_for_stock) { $.each([ ["stock_adjustment_account", {"root_type": "Expense", "account_type": "Stock Adjustment"}], diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js index d822a757989..fcd0b0ef759 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.js +++ b/erpnext/setup/doctype/email_digest/email_digest.js @@ -23,21 +23,21 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { }); }, "fa fa-eye-open", "btn-default"); - if(user==="Administrator") { + if(frappe.session.user==="Administrator") { cur_frm.add_custom_button(__('Send Now'), function() { doc = locals[dt][dn]; if(doc.__unsaved != 1) { return $c_obj(doc, 'send', '', function(r, rt) { if(r.exc) { - msgprint(err_msg); + frappe.msgprint(err_msg); console.log(r.exc); } else { //console.log(arguments); - msgprint(__('Message Sent')); + frappe.msgprint(__('Message Sent')); } }); } else { - msgprint(save_msg); + frappe.msgprint(save_msg); } }, "fa fa-envelope", "btn-default"); } @@ -47,7 +47,7 @@ cur_frm.cscript.addremove_recipients = function(doc, dt, dn) { // Get user list return $c_obj(doc, 'get_users', '', function(r, rt) { if(r.exc) { - msgprint(r.exc); + frappe.msgprint(r.exc); } else { // Open a dialog and display checkboxes against email addresses doc = locals[dt][dn]; diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.js b/erpnext/setup/doctype/global_defaults/global_defaults.js index 1dd456f4d8d..a78461d9bc5 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.js +++ b/erpnext/setup/doctype/global_defaults/global_defaults.js @@ -4,7 +4,7 @@ $.extend(cur_frm.cscript, { validate: function(doc, cdt, cdn) { return $c_obj(doc, 'get_defaults', '', function(r, rt){ - sys_defaults = r.message; + frappe.sys_defaults = r.message; }); } }); diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index 1f69ad1679b..e9499895fe8 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -171,7 +171,7 @@ erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callb var doc = frappe.model.get_new_doc('Stock Entry'); doc.from_warehouse = dialog.get_value('source'); doc.to_warehouse = dialog.get_value('target'); - row = frappe.model.add_child(doc, 'items'); + var row = frappe.model.add_child(doc, 'items'); row.item_code = dialog.get_value('item_code'); row.f_warehouse = dialog.get_value('target'); row.t_warehouse = dialog.get_value('target'); diff --git a/erpnext/stock/doctype/batch/batch.js b/erpnext/stock/doctype/batch/batch.js index 8a3906ef9d0..1822a06fecd 100644 --- a/erpnext/stock/doctype/batch/batch.js +++ b/erpnext/stock/doctype/batch/batch.js @@ -66,31 +66,31 @@ frappe.ui.form.on('Batch', { rows.find('.btn-move').on('click', function() { var $btn = $(this); frappe.prompt({ - fieldname: 'to_warehouse', - label: __('To Warehouse'), - fieldtype: 'Link', - options: 'Warehouse' - }, - (data) => { - frappe.call({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry_utils.make_stock_entry', - args: { - item_code: frm.doc.item, - batch_no: frm.doc.name, - qty: $btn.attr('data-qty'), - from_warehouse: $btn.attr('data-warehouse'), - to_warehouse: data.to_warehouse - }, - callback: (r) => { - frappe.show_alert(__('Stock Entry {0} created', - ['' + r.message.name+ ''])); - frm.refresh(); - }, - }); - }, - __('Select Target Warehouse'), - __('Move') - ) + fieldname: 'to_warehouse', + label: __('To Warehouse'), + fieldtype: 'Link', + options: 'Warehouse' + }, + (data) => { + frappe.call({ + method: 'erpnext.stock.doctype.stock_entry.stock_entry_utils.make_stock_entry', + args: { + item_code: frm.doc.item, + batch_no: frm.doc.name, + qty: $btn.attr('data-qty'), + from_warehouse: $btn.attr('data-warehouse'), + to_warehouse: data.to_warehouse + }, + callback: (r) => { + frappe.show_alert(__('Stock Entry {0} created', + ['' + r.message.name+ ''])); + frm.refresh(); + }, + }); + }, + __('Select Target Warehouse'), + __('Move') + ); }); // split - ask for new qty and batch ID (optional) @@ -98,34 +98,34 @@ frappe.ui.form.on('Batch', { rows.find('.btn-split').on('click', function() { var $btn = $(this); frappe.prompt([{ - fieldname: 'qty', - label: __('New Batch Qty'), - fieldtype: 'Float', - 'default': $btn.attr('data-qty') - }, - { - fieldname: 'new_batch_id', - label: __('New Batch ID (Optional)'), - fieldtype: 'Data', - }], - (data) => { - frappe.call({ - method: 'erpnext.stock.doctype.batch.batch.split_batch', - args: { - item_code: frm.doc.item, - batch_no: frm.doc.name, - qty: data.qty, - warehouse: $btn.attr('data-warehouse'), - new_batch_id: data.new_batch_id - }, - callback: (r) => { - frm.refresh(); - }, - }); - }, - __('Split Batch'), - __('Split') - ) + fieldname: 'qty', + label: __('New Batch Qty'), + fieldtype: 'Float', + 'default': $btn.attr('data-qty') + }, + { + fieldname: 'new_batch_id', + label: __('New Batch ID (Optional)'), + fieldtype: 'Data', + }], + (data) => { + frappe.call({ + method: 'erpnext.stock.doctype.batch.batch.split_batch', + args: { + item_code: frm.doc.item, + batch_no: frm.doc.name, + qty: data.qty, + warehouse: $btn.attr('data-warehouse'), + new_batch_id: data.new_batch_id + }, + callback: (r) => { + frm.refresh(); + }, + }); + }, + __('Split Batch'), + __('Split') + ); }) frm.dashboard.show(); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index eb8a750c14e..faa1fac5dcc 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -38,7 +38,7 @@ frappe.ui.form.on("Delivery Note", { } }); - if (sys_defaults.auto_accounting_for_stock) { + if (frappe.sys_defaults.auto_accounting_for_stock) { frm.set_query('expense_account', 'items', function(doc, cdt, cdn) { return { filters: { @@ -166,7 +166,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( erpnext.stock.delivery_note.set_print_hide(doc, dt, dn); // unhide expense_account and cost_center is auto_accounting_for_stock enabled - var aii_enabled = cint(sys_defaults.auto_accounting_for_stock) + var aii_enabled = cint(frappe.sys_defaults.auto_accounting_for_stock) this.frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled); }, diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 86c69594488..40ad55a92fc 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -143,7 +143,7 @@ frappe.ui.form.on("Item", { frappe.ui.form.on('Item Reorder', { reorder_levels_add: function(frm, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); - type = frm.doc.default_material_request_type + var type = frm.doc.default_material_request_type row.material_request_type = (type == 'Material Transfer')? 'Transfer' : type; } }) @@ -254,8 +254,8 @@ $.extend(erpnext.item, { weight_to_validate: function(frm){ if((frm.doc.nett_weight || frm.doc.gross_weight) && !frm.doc.weight_uom) { - msgprint(__('Weight is mentioned,\nPlease mention "Weight UOM" too')); - validated = 0; + frappe.msgprint(__('Weight is mentioned,\nPlease mention "Weight UOM" too')); + frappe.validated = 0; } }, @@ -326,7 +326,7 @@ $.extend(erpnext.item, { }); d.set_primary_action(__("Make"), function() { - args = d.get_values(); + var args = d.get_values(); if(!args) return; frappe.call({ method:"erpnext.controllers.item_variant.get_variant", @@ -338,14 +338,14 @@ $.extend(erpnext.item, { // returns variant item if (r.message) { var variant = r.message; - var msgprint_dialog = frappe.msgprint(__("Item Variant {0} already exists with same attributes", + frappe.msgprint_dialog = frappe.msgprint(__("Item Variant {0} already exists with same attributes", [repl('%(item)s', { item_encoded: encodeURIComponent(variant), item: variant })] )); - msgprint_dialog.hide_on_page_refresh = true; - msgprint_dialog.$wrapper.find(".variant-click").on("click", function() { + frappe.msgprint_dialog.hide_on_page_refresh = true; + frappe.msgprint_dialog.$wrapper.find(".variant-click").on("click", function() { d.hide(); }); } else { 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 3ae61b90205..edc34442208 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js +++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js @@ -8,7 +8,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ setup: function() { var me = this; this.frm.fields_dict.purchase_receipts.grid.get_field('receipt_document').get_query = - function(doc, cdt ,cdn) { + function (doc, cdt, cdn) { var d = locals[cdt][cdn] var filters = [ @@ -16,15 +16,15 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ [d.receipt_document_type, 'company', '=', me.frm.doc.company], ] - if(d.receipt_document_type == "Purchase Invoice") { + if (d.receipt_document_type == "Purchase Invoice") { filters.push(["Purchase Invoice", "update_stock", "=", "1"]) } - if(!me.frm.doc.company) msgprint(__("Please enter company first")); + if (!me.frm.doc.company) frappe.msgprint(__("Please enter company first")); return { - filters:filters + filters: filters } - }; + }; this.frm.add_fetch("receipt_document", "supplier", "supplier"); this.frm.add_fetch("receipt_document", "posting_date", "posting_date"); @@ -33,32 +33,33 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ }, refresh: function(frm) { - var help_content = [ - '

', - '', - '', - '
', - '

', - __('Notes'), - ':

', - '
    ', - '
  • ', - __("Charges will be distributed proportionately based on item qty or amount, as per your selection"), - '
  • ', - '
  • ', - __("Remove item if charges is not applicable to that item"), - '
  • ', - '
  • ', - __("Charges are updated in Purchase Receipt against each item"), - '
  • ', - '
  • ', - __("Item valuation rate is recalculated considering landed cost voucher amount"), - '
  • ', - '
  • ', - __("Stock Ledger Entries and GL Entries are reposted for the selected Purchase Receipts"), - '
  • ', - '
', - '
'].join("\n"); + var help_content = + `

+ + +
+

+ + ${__("Notes")}: +

+
    +
  • + ${__("Charges will be distributed proportionately based on item qty or amount, as per your selection")} +
  • +
  • + ${__("Remove item if charges is not applicable to that item")} +
  • +
  • + ${__("Charges are updated in Purchase Receipt against each item")} +
  • +
  • + ${__("Item valuation rate is recalculated considering landed cost voucher amount")} +
  • +
  • + ${__("Stock Ledger Entries and GL Entries are reposted for the selected Purchase Receipts")} +
  • +
+
`; set_field_options("landed_cost_help", help_content); }, @@ -66,7 +67,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ get_items_from_purchase_receipts: function() { var me = this; if(!this.frm.doc.purchase_receipts.length) { - msgprint(__("Please enter Purchase Receipt first")); + frappe.msgprint(__("Please enter Purchase Receipt first")); } else { return this.frm.call({ doc: me.frm.doc, @@ -84,7 +85,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({ }, set_total_taxes_and_charges: function() { - total_taxes_and_charges = 0.0; + var total_taxes_and_charges = 0.0; $.each(this.frm.doc.taxes || [], function(i, d) { total_taxes_and_charges += flt(d.amount) }); diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index b386a478dca..b95d0e7d0af 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -30,14 +30,13 @@ frappe.ui.form.on('Material Request', { }); frappe.ui.form.on("Material Request Item", { - "qty": function(frm, doctype, name) { - var d = locals[doctype][name]; - if (flt(d.qty) < flt(d.min_order_qty)) { - frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty")); - } + "qty": function (frm, doctype, name) { + var d = locals[doctype][name]; + if (flt(d.qty) < flt(d.min_order_qty)) { + frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty")); } } -); +}); erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({ onload: function(doc) { @@ -140,7 +139,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten return {filters: { docstatus:1 }} }}, {"fieldname":"warehouse", "fieldtype":"Link", "label":__("Warehouse"), - options:"Warehouse", reqd: 1, label:"For Warehouse"}, + options:"Warehouse", reqd: 1}, {"fieldname":"fetch_exploded", "fieldtype":"Check", "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}, {fieldname:"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"} diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index 2ea1ba9bab3..69d12eb2d91 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -48,14 +48,14 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) { cur_frm.cscript.validate_case_nos = function(doc) { doc = locals[doc.doctype][doc.name]; if(cint(doc.from_case_no)==0) { - msgprint(__("Case No. cannot be 0")) - validated = false; + frappe.msgprint(__("Case No. cannot be 0")) + frappe.validated = false; } else if(!cint(doc.to_case_no)) { doc.to_case_no = doc.from_case_no; refresh_field('to_case_no'); } else if(cint(doc.to_case_no) < cint(doc.from_case_no)) { - msgprint(__("'To Case No.' cannot be less than 'From Case No.'")); - validated = false; + frappe.msgprint(__("'To Case No.' cannot be less than 'From Case No.'")); + frappe.validated = false; } } @@ -75,14 +75,14 @@ cur_frm.cscript.validate_duplicate_items = function(doc, ps_detail) { for(var i=0; i'+(bold?bstart:'')+title+(bold?bend:'')+'' - +''+ val +'' - +'' + +''+ val +'' + +'' } cur_frm.pformat.net_weight_pkg= function(doc){ diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 5c97e7cd63a..d5986dbccd4 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -53,9 +53,9 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend } if(!this.frm.doc.is_return && this.frm.doc.status!="Closed") { - if(this.frm.doc.docstatus==0) { + if (this.frm.doc.docstatus == 0) { this.frm.add_custom_button(__('Purchase Order'), - function() { + function () { erpnext.utils.map_current_doc({ method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt", source_doctype: "Purchase Order", @@ -70,7 +70,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend company: me.frm.doc.company } }) - }, __("Get items from")); + }, __("Get items from")); } if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") { @@ -153,7 +153,7 @@ cur_frm.fields_dict['items'].grid.get_field('batch_no').get_query= function(doc, } } else - msgprint(__("Please enter Item Code.")); + frappe.msgprint(__("Please enter Item Code.")); } cur_frm.cscript.select_print_heading = function(doc, cdt, cdn) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 4e381ea255b..6303df1722f 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -26,7 +26,7 @@ frappe.ui.form.on('Stock Entry', { if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"], doc.purpose)) { var filters = { 'item_code': item.item_code, - 'posting_date': frm.doc.posting_date || nowdate() + 'posting_date': frm.doc.posting_date || frappe.datetime.nowdate() } } else { var filters = { @@ -143,7 +143,7 @@ frappe.ui.form.on('Stock Entry Detail', { item_code: function(frm, cdt, cdn) { var d = locals[cdt][cdn]; if(d.item_code) { - args = { + var args = { 'item_code' : d.item_code, 'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse), 'transfer_qty' : d.transfer_qty, @@ -173,7 +173,7 @@ frappe.ui.form.on('Stock Entry Detail', { expense_account: function(frm, cdt, cdn) { erpnext.utils.copy_value_in_all_row(frm.doc, cdt, cdn, "items", "expense_account"); }, - cost_center: function(doc, cdt, cdn) { + cost_center: function(frm, cdt, cdn) { erpnext.utils.copy_value_in_all_row(frm.doc, cdt, cdn, "items", "cost_center"); } }); @@ -216,14 +216,14 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); this.frm.fields_dict.items.grid.get_field('expense_account').get_query = - function() { - return { - filters: { - "company": me.frm.doc.company, - "is_group": 0 + function() { + return { + filters: { + "company": me.frm.doc.company, + "is_group": 0 + } } } - } } this.frm.set_indicator_formatter('item_code', @@ -243,9 +243,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }); - if(!this.item_selector && false) { - this.item_selector = new erpnext.ItemSelector({frm: this.frm}); - } + // if(!this.item_selector && false) { + // this.item_selector = new erpnext.ItemSelector({frm: this.frm}); + // } }, refresh: function() { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_list.js b/erpnext/stock/doctype/stock_entry/stock_entry_list.js index 0e5aeb7cc84..69d21dd6f94 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry_list.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry_list.js @@ -4,7 +4,7 @@ frappe.listview_settings['Stock Entry'] = { column_render: { "from_warehouse": function(doc) { var html = ""; - if(doc.from_warehouse) { + if(doc.from_warehouse) { html += ''+doc.from_warehouse+' '; } diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index 636b2afe6cd..a6d53837582 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -133,7 +133,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ set_default_expense_account: function() { var me = this; if(this.frm.doc.company) { - if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) { + if (frappe.sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) { return this.frm.call({ method: "erpnext.accounts.utils.get_company_default", args: { @@ -155,7 +155,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ this.setup_posting_date_time_check(); - if (sys_defaults.auto_accounting_for_stock) { + if (frappe.sys_defaults.auto_accounting_for_stock) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); this.frm.add_fetch("company", "cost_center", "cost_center"); diff --git a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js index eeeb9adc848..a7d7149c382 100644 --- a/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js +++ b/erpnext/stock/report/batch_item_expiry_status/batch_item_expiry_status.js @@ -8,7 +8,7 @@ frappe.query_reports["Batch Item Expiry Status"] = { "label": __("From Date"), "fieldtype": "Date", "width": "80", - "default": sys_defaults.year_start_date, + "default": frappe.sys_defaults.year_start_date, }, { "fieldname":"to_date", diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js index a60b3eb0813..b23c908e07a 100644 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.js @@ -8,7 +8,7 @@ frappe.query_reports["Batch-Wise Balance History"] = { "label": __("From Date"), "fieldtype": "Date", "width": "80", - "default": sys_defaults.year_start_date, + "default": frappe.sys_defaults.year_start_date, }, { "fieldname":"to_date", diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js index 0e129077b7a..ade004cde42 100644 --- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js +++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js @@ -3,7 +3,7 @@ frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { frappe.query_reports["Delivery Note Trends"] = { - filters: get_filters() + filters: erpnext.get_sales_trends_filters() } }); diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js index ba61ee5febd..2482cf846f4 100644 --- a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js +++ b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.js @@ -7,13 +7,13 @@ frappe.query_reports["Itemwise Recommended Reorder Level"] = { "fieldname":"from_date", "label": __("From Date"), "fieldtype": "Date", - "default": sys_defaults.year_start_date + "default": frappe.sys_defaults.year_start_date }, { "fieldname":"to_date", "label": __("To Date"), "fieldtype": "Date", - "default": get_today() + "default": frappe.datetime.get_today() } ] } \ No newline at end of file diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js index d94b49e7dc9..63d53fbfb07 100644 --- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js +++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js @@ -3,7 +3,7 @@ frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { frappe.query_reports["Purchase Receipt Trends"] = { - filters: get_filters() + filters: erpnext.get_sales_trends_filters() } }); diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js index 36d018c6e7f..90f4de01d43 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.js +++ b/erpnext/stock/report/stock_balance/stock_balance.js @@ -9,7 +9,7 @@ frappe.query_reports["Stock Balance"] = { "fieldtype": "Date", "width": "80", "reqd": 1, - "default": sys_defaults.year_start_date, + "default": frappe.sys_defaults.year_start_date, }, { "fieldname":"to_date", diff --git a/erpnext/support/page/support_analytics/support_analytics.js b/erpnext/support/page/support_analytics/support_analytics.js index 01b7b488d3d..bca5987628c 100644 --- a/erpnext/support/page/support_analytics/support_analytics.js +++ b/erpnext/support/page/support_analytics/support_analytics.js @@ -19,7 +19,6 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({ init: function(wrapper) { this._super({ title: __("Support Analtyics"), - page: wrapper, parent: $(wrapper).find('.layout-main'), page: wrapper.page, doctypes: ["Issue", "Fiscal Year"], @@ -67,7 +66,7 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({ $.each(frappe.report_dump.data["Issue"], function(i, d) { - var dateobj = dateutil.str_to_obj(d.creation); + var dateobj = frappe.datetime.str_to_obj(d.creation); var date = d.creation.split(" ")[0]; var col = me.column_map[date]; if(col) { @@ -77,17 +76,17 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({ total_closed[col.field] = flt(total_closed[col.field]) + 1; days_to_close[col.field] = flt(days_to_close[col.field]) - + dateutil.get_diff(d.resolution_date, d.creation); + + frappe.datetime.get_diff(d.resolution_date, d.creation); hours_to_close[col.field] = flt(hours_to_close[col.field]) - + dateutil.get_hour_diff(d.resolution_date, d.creation); + + frappe.datetime.get_hour_diff(d.resolution_date, d.creation); } if (d.first_responded_on) { total_responded[col.field] = flt(total_responded[col.field]) + 1; hours_to_respond[col.field] = flt(hours_to_respond[col.field]) - + dateutil.get_hour_diff(d.first_responded_on, d.creation); + + frappe.datetime.get_hour_diff(d.first_responded_on, d.creation); } } }); diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js index ee98b23a922..51be9541ec3 100644 --- a/erpnext/templates/includes/cart.js +++ b/erpnext/templates/includes/cart.js @@ -4,7 +4,8 @@ // js inside blog page // shopping cart -frappe.provide("shopping_cart"); +frappe.provide("erpnext.shopping_cart"); +var shopping_cart = erpnext.shopping_cart; $.extend(shopping_cart, { show_error: function(title, text) { @@ -18,7 +19,7 @@ $.extend(shopping_cart, { shopping_cart.bind_change_qty(); shopping_cart.bind_dropdown_cart_buttons(); }, - + bind_address_select: function() { $(".cart-addresses").find('input[data-address-name]').on("click", function() { if($(this).prop("checked")) { @@ -65,13 +66,13 @@ $.extend(shopping_cart, { var newVal = $(this).val(); shopping_cart.shopping_cart_update(item_code, newVal); }); - - $(".cart-items").on('click', '.number-spinner button', function () { + + $(".cart-items").on('click', '.number-spinner button', function () { var btn = $(this), input = btn.closest('.number-spinner').find('input'), oldValue = input.val().trim(), newVal = 0; - + if (btn.attr('data-dir') == 'up') { newVal = parseInt(oldValue) + 1; } else { @@ -80,17 +81,17 @@ $.extend(shopping_cart, { } } input.val(newVal); - var item_code = input.attr("data-item-code"); + var item_code = input.attr("data-item-code"); shopping_cart.shopping_cart_update(item_code, newVal); }); }, - + render_tax_row: function($cart_taxes, doc, shipping_rules) { var shipping_selector; if(shipping_rules) { shipping_selector = ''; + return '' }).join("\n") + + ''; } var $tax_row = $(repl('
\ @@ -162,6 +163,6 @@ frappe.ready(function() { }); function show_terms() { - var html = $(".cart-terms").html(); - frappe.msgprint(html); + var html = $(".cart-terms").html(); + frappe.msgprint(html); } diff --git a/erpnext/templates/includes/product_list.js b/erpnext/templates/includes/product_list.js index 28c626f5d49..7f63c170f8c 100644 --- a/erpnext/templates/includes/product_list.js +++ b/erpnext/templates/includes/product_list.js @@ -13,7 +13,6 @@ window.get_product_list = function() { $.ajax({ method: "GET", url: "/", - dataType: "json", data: { cmd: "erpnext.templates.pages.product_search.get_product_list", start: window.start, diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js index 4d1446b3746..e61ead176a1 100644 --- a/erpnext/templates/includes/product_page.js +++ b/erpnext/templates/includes/product_page.js @@ -21,9 +21,9 @@ frappe.ready(function() { $(".item-stock").html("
Not in stock
"); } else if(r.message.in_stock==1) { - qty_display = "In stock" + var qty_display = "In stock"; if (r.message.show_stock_qty) { - qty_display = "Available ("+r.message.stock_qty+ " in stock)" + qty_display = "Available ("+r.message.stock_qty+ " in stock)"; } $(".item-stock").html("
\ "+__(qty_display)+"
"); @@ -40,7 +40,9 @@ frappe.ready(function() { }) $("#item-add-to-cart button").on("click", function() { - shopping_cart.update_cart({ + frappe.provide('erpnext.shopping_cart'); + + erpnext.shopping_cart.update_cart({ item_code: get_item_code(), qty: 1, callback: function(r) { @@ -66,7 +68,7 @@ frappe.ready(function() { var item_code = find_closest_match(attribute, attribute_value); if (!item_code) { - msgprint(__("Cannot find a matching Item. Please select some other value for {0}.", [attribute])) + frappe.msgprint(__("Cannot find a matching Item. Please select some other value for {0}.", [attribute])) throw e; } } @@ -87,7 +89,8 @@ var toggle_update_cart = function(qty) { } function get_item_code() { - if(window.variant_info) { + var variant_info = window.variant_info; + if(variant_info) { var attributes = get_selected_attributes(); var no_of_attributes = Object.keys(attributes).length; @@ -102,9 +105,10 @@ function get_item_code() { var match = true; for(var j in variant.attributes) { if(attributes[variant.attributes[j].attribute] - != variant.attributes[j].attribute_value) { - match = false; - break; + != variant.attributes[j].attribute_value + ) { + match = false; + break; } } if(match) { @@ -113,7 +117,7 @@ function get_item_code() { } throw "Unable to match variant"; } else { - return item_code; + return window.item_code; } } @@ -126,6 +130,7 @@ function find_closest_match(selected_attribute, selected_attribute_value) { var previous_no_of_attributes = 0; var matched; + var variant_info = window.variant_info; for(var i in variant_info) { var variant = variant_info[i]; var match_score = 0; diff --git a/erpnext/templates/pages/projects.js b/erpnext/templates/pages/projects.js index ecacc34fb8d..99f0663ee4b 100644 --- a/erpnext/templates/pages/projects.js +++ b/erpnext/templates/pages/projects.js @@ -47,7 +47,6 @@ frappe.ready(function() { project: '{{ doc.name }}', item_status: item_status, }, - dataType: "json", success: function(data) { if(typeof data.message == 'undefined') { $('.project-'+ item).html("No "+ item_status +" "+ item); @@ -68,8 +67,7 @@ frappe.ready(function() { } var more_items = function(item, item_status){ - if(item_status) - { + if(item_status) { var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-closed-'+ item) ? 'closed' : 'open'; } @@ -83,14 +81,13 @@ frappe.ready(function() { start: start, item_status: item_status, }, - dataType: "json", success: function(data) { $(data.message).appendTo('.project-'+ item); if(typeof data.message == 'undefined') { $(".more-"+ item).toggle(false); } - start = start+10; + start = start+10; } }); }