From 76023f1fdcf6c9553a491b9493fc776560beb51b Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:14:42 +0100 Subject: [PATCH 01/62] refactor(Sales Invoice Item): validate cost center --- .../doctype/pos_invoice_item/pos_invoice_item.py | 4 ++-- .../accounts/doctype/sales_invoice/sales_invoice.py | 8 +------- .../doctype/sales_invoice_item/sales_invoice_item.py | 11 ++++++++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py index 55a577b0c51..44358c319eb 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py @@ -3,10 +3,10 @@ # import frappe -from frappe.model.document import Document +from erpnext.accounts.doctype.sales_invoice_item.sales_invoice_item import SalesInvoiceItem -class POSInvoiceItem(Document): +class POSInvoiceItem(SalesInvoiceItem): # begin: auto-generated types # This code is auto-generated. Do not modify anything in this block. diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index abc0694a63c..77cc53aa854 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -379,13 +379,7 @@ class SalesInvoice(SellingController): def validate_item_cost_centers(self): for item in self.items: - cost_center_company = frappe.get_cached_value("Cost Center", item.cost_center, "company") - if cost_center_company != self.company: - frappe.throw( - _("Row #{0}: Cost Center {1} does not belong to company {2}").format( - frappe.bold(item.idx), frappe.bold(item.cost_center), frappe.bold(self.company) - ) - ) + item.validate_cost_center(self.company) def validate_income_account(self): for item in self.get("items"): diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index c71d08e7f70..989a8ca2c9b 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -2,6 +2,8 @@ # License: GNU General Public License v3. See license.txt +import frappe +from frappe import _ from frappe.model.document import Document @@ -92,4 +94,11 @@ class SalesInvoiceItem(Document): weight_uom: DF.Link | None # end: auto-generated types - pass + def validate_cost_center(self, company: str): + cost_center_company = frappe.get_cached_value("Cost Center", self.cost_center, "company") + if cost_center_company != company: + frappe.throw( + _("Row #{0}: Cost Center {1} does not belong to company {2}").format( + frappe.bold(self.idx), frappe.bold(self.cost_center), frappe.bold(company) + ) + ) From cc83af0dd4bcf77c1d288f1914374442346c1c90 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:14:50 +0100 Subject: [PATCH 02/62] refactor: move code for unlinking sales invoice to Timesheet --- .../accounts/doctype/sales_invoice/sales_invoice.py | 7 +------ erpnext/projects/doctype/timesheet/timesheet.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 77cc53aa854..40262c65a69 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -652,13 +652,8 @@ class SalesInvoice(SellingController): def unlink_sales_invoice_from_timesheets(self): for row in self.timesheets: timesheet = frappe.get_doc("Timesheet", row.time_sheet) - for time_log in timesheet.time_logs: - if time_log.sales_invoice == self.name: - time_log.sales_invoice = None - timesheet.calculate_total_amounts() - timesheet.calculate_percentage_billed() + timesheet.unlink_sales_invoice(self.name) timesheet.flags.ignore_validate_update_after_submit = True - timesheet.set_status() timesheet.db_update_all() @frappe.whitelist() diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index b9d801ce902..b1694cb5149 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -256,6 +256,16 @@ class Timesheet(Document): if not ts_detail.is_billable: ts_detail.billing_rate = 0.0 + def unlink_sales_invoice(self, sales_invoice: str): + """Remove link to Sales Invoice from all time logs.""" + for time_log in self.time_logs: + if time_log.sales_invoice == sales_invoice: + time_log.sales_invoice = None + + self.calculate_total_amounts() + self.calculate_percentage_billed() + self.set_status() + @frappe.whitelist() def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to_time=None): From f99f7fd2cfcc1bc7a65191c3de10dc8c3fb6f94c Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:17:41 +0100 Subject: [PATCH 03/62] refactor(Sales Invoice): convert to guard clause --- .../doctype/sales_invoice/sales_invoice.py | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 40262c65a69..633a231f816 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -591,43 +591,48 @@ class SalesInvoice(SellingController): self.delete_auto_created_batches() def update_status_updater_args(self): - if cint(self.update_stock): - self.status_updater.append( - { - "source_dt": "Sales Invoice Item", - "target_dt": "Sales Order Item", - "target_parent_dt": "Sales Order", - "target_parent_field": "per_delivered", - "target_field": "delivered_qty", - "target_ref_field": "qty", - "source_field": "qty", - "join_field": "so_detail", - "percent_join_field": "sales_order", - "status_field": "delivery_status", - "keyword": "Delivered", - "second_source_dt": "Delivery Note Item", - "second_source_field": "qty", - "second_join_field": "so_detail", - "overflow_type": "delivery", - "extra_cond": """ and exists(select name from `tabSales Invoice` - where name=`tabSales Invoice Item`.parent and update_stock = 1)""", - } - ) - if cint(self.is_return): - self.status_updater.append( - { - "source_dt": "Sales Invoice Item", - "target_dt": "Sales Order Item", - "join_field": "so_detail", - "target_field": "returned_qty", - "target_parent_dt": "Sales Order", - "source_field": "-1 * qty", - "second_source_dt": "Delivery Note Item", - "second_source_field": "-1 * qty", - "second_join_field": "so_detail", - "extra_cond": """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)""", - } - ) + if not cint(self.update_stock): + return + + self.status_updater.append( + { + "source_dt": "Sales Invoice Item", + "target_dt": "Sales Order Item", + "target_parent_dt": "Sales Order", + "target_parent_field": "per_delivered", + "target_field": "delivered_qty", + "target_ref_field": "qty", + "source_field": "qty", + "join_field": "so_detail", + "percent_join_field": "sales_order", + "status_field": "delivery_status", + "keyword": "Delivered", + "second_source_dt": "Delivery Note Item", + "second_source_field": "qty", + "second_join_field": "so_detail", + "overflow_type": "delivery", + "extra_cond": """ and exists(select name from `tabSales Invoice` + where name=`tabSales Invoice Item`.parent and update_stock = 1)""", + } + ) + + if not cint(self.is_return): + return + + self.status_updater.append( + { + "source_dt": "Sales Invoice Item", + "target_dt": "Sales Order Item", + "join_field": "so_detail", + "target_field": "returned_qty", + "target_parent_dt": "Sales Order", + "source_field": "-1 * qty", + "second_source_dt": "Delivery Note Item", + "second_source_field": "-1 * qty", + "second_join_field": "so_detail", + "extra_cond": """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)""", + } + ) def check_credit_limit(self): from erpnext.selling.doctype.customer.customer import check_credit_limit From 75230ece9ac72b094a20eece9e764feed382b708 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:50:32 +0100 Subject: [PATCH 04/62] refactor: set actual and projected qty in Packed Item and Sales Invoice Item --- .../doctype/sales_invoice/sales_invoice.py | 20 ++++--------------- .../sales_invoice_item/sales_invoice_item.py | 9 +++++++++ .../stock/doctype/packed_item/packed_item.py | 11 +++++++++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 633a231f816..fc2608e30a4 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1025,23 +1025,11 @@ class SalesInvoice(SellingController): frappe.throw(_("Could not update stock, invoice contains drop shipping item.")) def update_current_stock(self): - for d in self.get("items"): - if d.item_code and d.warehouse: - bin = frappe.db.sql( - "select actual_qty from `tabBin` where item_code = %s and warehouse = %s", - (d.item_code, d.warehouse), - as_dict=1, - ) - d.actual_qty = bin and flt(bin[0]["actual_qty"]) or 0 + for item in self.items: + item.set_actual_qty() - for d in self.get("packed_items"): - bin = frappe.db.sql( - "select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", - (d.item_code, d.warehouse), - as_dict=1, - ) - d.actual_qty = bin and flt(bin[0]["actual_qty"]) or 0 - d.projected_qty = bin and flt(bin[0]["projected_qty"]) or 0 + for packed_item in self.packed_items: + packed_item.set_actual_and_projected_qty() def update_packing_list(self): if cint(self.update_stock) == 1: diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index 989a8ca2c9b..dc40bba8e20 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -102,3 +102,12 @@ class SalesInvoiceItem(Document): frappe.bold(self.idx), frappe.bold(self.cost_center), frappe.bold(company) ) ) + + def set_actual_qty(self): + if self.item_code and self.warehouse: + self.actual_qty = ( + frappe.db.get_value( + "Bin", {"item_code": self.item_code, "warehouse": self.warehouse}, "actual_qty" + ) + or 0 + ) diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index c115e33e171..bd14e358371 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -51,7 +51,16 @@ class PackedItem(Document): warehouse: DF.Link | None # end: auto-generated types - pass + def set_actual_and_projected_qty(self): + "Set actual and projected qty based on warehouse and item_code" + _bin = frappe.db.get_value( + "Bin", + {"item_code": self.item_code, "warehouse": self.warehouse}, + ["actual_qty", "projected_qty"], + as_dict=True, + ) + self.actual_qty = _bin.actual_qty if _bin else 0 + self.projected_qty = _bin.projected_qty if _bin else 0 def make_packing_list(doc): From 4d7d7dac0133cded5565edc713730a32b968e985 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:40:02 +0100 Subject: [PATCH 05/62] refactor(Sales Invoice): validate_delivery_note --- .../doctype/sales_invoice/sales_invoice.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index fc2608e30a4..857ade7da22 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -8,6 +8,7 @@ from frappe.contacts.doctype.address.address import get_address_display from frappe.model.mapper import get_mapped_doc from frappe.model.utils import get_fetch_values from frappe.utils import add_days, cint, cstr, flt, formatdate, get_link_to_form, getdate, nowdate +from frappe.utils.data import comma_and import erpnext from erpnext.accounts.deferred_revenue import validate_service_stop_date @@ -301,7 +302,8 @@ class SalesInvoice(SellingController): self.validate_dropship_item() self.validate_warehouse() self.update_current_stock() - self.validate_delivery_note() + + self.validate_delivery_note() # validate service stop date to lie in between start and end date validate_service_stop_date(self) @@ -1000,12 +1002,17 @@ class SalesInvoice(SellingController): frappe.throw(_("Warehouse required for stock Item {0}").format(d.item_code)) def validate_delivery_note(self): - for d in self.get("items"): - if d.delivery_note: - msgprint( - _("Stock cannot be updated against Delivery Note {0}").format(d.delivery_note), - raise_exception=1, - ) + """If items are linked with a delivery note, stock cannot be updated again.""" + if not cint(self.update_stock): + return + + notes = [item.delivery_note for item in self.items if item.delivery_note] + if notes: + frappe.throw( + _("Stock cannot be updated against the following Delivery Notes: {0}").format( + comma_and(notes) + ), + ) def validate_write_off_account(self): if flt(self.write_off_amount) and not self.write_off_account: From 701671b2bdc1e75d3a9483623d1701d32156d7c0 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:50:34 +0100 Subject: [PATCH 06/62] refactor: validate_dropship_item --- .../doctype/sales_invoice/sales_invoice.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 857ade7da22..0c530a1208d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -298,8 +298,9 @@ class SalesInvoice(SellingController): if cint(self.is_pos): self.validate_pos() + self.validate_dropship_item() + if cint(self.update_stock): - self.validate_dropship_item() self.validate_warehouse() self.update_current_stock() @@ -1026,10 +1027,16 @@ class SalesInvoice(SellingController): msgprint(_("Please enter Account for Change Amount"), raise_exception=1) def validate_dropship_item(self): - for item in self.items: - if item.sales_order: - if frappe.db.get_value("Sales Order Item", item.so_detail, "delivered_by_supplier"): - frappe.throw(_("Could not update stock, invoice contains drop shipping item.")) + """If items are drop shipped, stock cannot be updated.""" + if not cint(self.update_stock): + return + + if any(item.delivered_by_supplier for item in self.items): + frappe.throw( + _( + "Stock cannot be updated because the invoice contains a drop shipping item. Please disable 'Update Stock' or remove the drop shipping item." + ), + ) def update_current_stock(self): for item in self.items: From 9c0755d3dee425dcbe7f0ab67554e1e64390aa49 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:08:49 +0100 Subject: [PATCH 07/62] refactor: set_income_account_for_fixed_assets --- .../doctype/sales_invoice/sales_invoice.py | 14 ++------------ .../sales_invoice_item/sales_invoice_item.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 0c530a1208d..e1ad2ab685a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -28,7 +28,6 @@ from erpnext.accounts.party import get_due_date, get_party_account, get_party_de from erpnext.accounts.utils import cancel_exchange_gain_loss_journal, get_account_currency from erpnext.assets.doctype.asset.depreciation import ( depreciate_asset, - get_disposal_account_and_cost_center, get_gl_entries_on_asset_disposal, get_gl_entries_on_asset_regain, reset_depreciation_schedule, @@ -1118,17 +1117,8 @@ class SalesInvoice(SellingController): return warehouse def set_income_account_for_fixed_assets(self): - disposal_account = depreciation_cost_center = None - for d in self.get("items"): - if d.is_fixed_asset: - if not disposal_account: - disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center( - self.company - ) - - d.income_account = disposal_account - if not d.cost_center: - d.cost_center = depreciation_cost_center + for item in self.items: + item.set_income_account_for_fixed_asset(self.company) def check_prev_docstatus(self): for d in self.get("items"): diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index dc40bba8e20..cf18529a652 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -6,6 +6,8 @@ import frappe from frappe import _ from frappe.model.document import Document +from erpnext.assets.doctype.asset.depreciation import get_disposal_account_and_cost_center + class SalesInvoiceItem(Document): # begin: auto-generated types @@ -111,3 +113,14 @@ class SalesInvoiceItem(Document): ) or 0 ) + + def set_income_account_for_fixed_asset(self, company: str): + """Set income account for fixed asset item based on company's disposal account and cost center.""" + if not self.is_fixed_asset: + return + + disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center(company) + + self.income_account = disposal_account + if not self.cost_center: + self.cost_center = depreciation_cost_center From 2ff06af15424605eb12ccc73c0f741eae956a04f Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:29:38 +0100 Subject: [PATCH 08/62] refactor: validate_serial_numbers --- .../doctype/sales_invoice/sales_invoice.py | 44 +------------------ .../sales_invoice_item/sales_invoice_item.py | 38 ++++++++++++++++ 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index e1ad2ab685a..a57a9f4a80b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -39,7 +39,6 @@ from erpnext.controllers.selling_controller import SellingController from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data from erpnext.setup.doctype.company.company import update_company_current_month_sales from erpnext.stock.doctype.delivery_note.delivery_note import update_billed_amount_based_on_so -from erpnext.stock.doctype.serial_no.serial_no import get_delivery_note_serial_no, get_serial_nos form_grid_templates = {"items": "templates/form_grid/item_grid.html"} @@ -1642,48 +1641,9 @@ class SalesInvoice(SellingController): """ validate serial number agains Delivery Note and Sales Invoice """ - self.set_serial_no_against_delivery_note() - self.validate_serial_against_delivery_note() - - def set_serial_no_against_delivery_note(self): for item in self.items: - if item.serial_no and item.delivery_note and item.qty != len(get_serial_nos(item.serial_no)): - item.serial_no = get_delivery_note_serial_no(item.item_code, item.qty, item.delivery_note) - - def validate_serial_against_delivery_note(self): - """ - validate if the serial numbers in Sales Invoice Items are same as in - Delivery Note Item - """ - - for item in self.items: - if not item.delivery_note or not item.dn_detail: - continue - - serial_nos = frappe.db.get_value("Delivery Note Item", item.dn_detail, "serial_no") or "" - dn_serial_nos = set(get_serial_nos(serial_nos)) - - serial_nos = item.serial_no or "" - si_serial_nos = set(get_serial_nos(serial_nos)) - serial_no_diff = si_serial_nos - dn_serial_nos - - if serial_no_diff: - dn_link = frappe.utils.get_link_to_form("Delivery Note", item.delivery_note) - serial_no_msg = ", ".join(frappe.bold(d) for d in serial_no_diff) - - msg = _("Row #{0}: The following Serial Nos are not present in Delivery Note {1}:").format( - item.idx, dn_link - ) - msg += " " + serial_no_msg - - frappe.throw(msg=msg, title=_("Serial Nos Mismatch")) - - if item.serial_no and cint(item.qty) != len(si_serial_nos): - frappe.throw( - _("Row #{0}: {1} Serial numbers required for Item {2}. You have provided {3}.").format( - item.idx, item.qty, item.item_code, len(si_serial_nos) - ) - ) + item.set_serial_no_against_delivery_note() + item.validate_serial_against_delivery_note() def update_project(self): if self.project: diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index cf18529a652..cd235bf4aba 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -5,8 +5,10 @@ import frappe from frappe import _ from frappe.model.document import Document +from frappe.utils.data import cint from erpnext.assets.doctype.asset.depreciation import get_disposal_account_and_cost_center +from erpnext.stock.doctype.serial_no.serial_no import get_delivery_note_serial_no, get_serial_nos class SalesInvoiceItem(Document): @@ -124,3 +126,39 @@ class SalesInvoiceItem(Document): self.income_account = disposal_account if not self.cost_center: self.cost_center = depreciation_cost_center + + def set_serial_no_against_delivery_note(self): + """Set serial no based on delivery note.""" + if self.serial_no and self.delivery_note and self.qty != len(get_serial_nos(self.serial_no)): + self.serial_no = get_delivery_note_serial_no(self.item_code, self.qty, self.delivery_note) + + def validate_serial_against_delivery_note(self): + """Ensure the serial numbers in this Sales Invoice Item are same as in the linked Delivery Note.""" + if not self.delivery_note or not self.dn_detail: + return + + serial_nos = frappe.db.get_value("Delivery Note Item", self.dn_detail, "serial_no") or "" + dn_serial_nos = set(get_serial_nos(serial_nos)) + + serial_nos = self.serial_no or "" + si_serial_nos = set(get_serial_nos(serial_nos)) + serial_no_diff = si_serial_nos - dn_serial_nos + + if serial_no_diff: + dn_link = frappe.utils.get_link_to_form("Delivery Note", self.delivery_note) + msg = ( + _("Row #{0}: The following serial numbers are not present in Delivery Note {1}:").format( + self.idx, dn_link + ) + + " " + + ", ".join(frappe.bold(d) for d in serial_no_diff) + ) + + frappe.throw(msg=msg, title=_("Serial Nos Mismatch")) + + if self.serial_no and cint(self.qty) != len(si_serial_nos): + frappe.throw( + _( + "Row #{0}: {1} serial numbers are required for Item {2}. You have provided {3} serial numbers." + ).format(self.idx, self.qty, self.item_code, len(si_serial_nos)) + ) From 0bbf45cd8b500b829ed3165d150694547a80f691 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:46:52 +0100 Subject: [PATCH 09/62] refactor: make_gle_for_change_amount --- .../doctype/sales_invoice/sales_invoice.py | 77 +++++++++---------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a57a9f4a80b..eb6442eee60 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1492,47 +1492,46 @@ class SalesInvoice(SellingController): ) if not skip_change_gl_entries: - self.make_gle_for_change_amount(gl_entries) + gl_entries.extend(self.get_gle_for_change_amount()) - def make_gle_for_change_amount(self, gl_entries): - if self.change_amount: - if self.account_for_change_amount: - gl_entries.append( - self.get_gl_dict( - { - "account": self.debit_to, - "party_type": "Customer", - "party": self.customer, - "against": self.account_for_change_amount, - "debit": flt(self.base_change_amount), - "debit_in_account_currency": flt(self.base_change_amount) - if self.party_account_currency == self.company_currency - else flt(self.change_amount), - "against_voucher": self.return_against - if cint(self.is_return) and self.return_against - else self.name, - "against_voucher_type": self.doctype, - "cost_center": self.cost_center, - "project": self.project, - }, - self.party_account_currency, - item=self, - ) - ) + def get_gle_for_change_amount(self) -> list[dict]: + if not self.change_amount: + return [] - gl_entries.append( - self.get_gl_dict( - { - "account": self.account_for_change_amount, - "against": self.customer, - "credit": self.base_change_amount, - "cost_center": self.cost_center, - }, - item=self, - ) - ) - else: - frappe.throw(_("Select change amount account"), title=_("Mandatory Field")) + if not self.account_for_change_amount: + frappe.throw(_("Please set Account for Change Amount"), title=_("Mandatory Field")) + + return [ + self.get_gl_dict( + { + "account": self.debit_to, + "party_type": "Customer", + "party": self.customer, + "against": self.account_for_change_amount, + "debit": flt(self.base_change_amount), + "debit_in_account_currency": flt(self.base_change_amount) + if self.party_account_currency == self.company_currency + else flt(self.change_amount), + "against_voucher": self.return_against + if cint(self.is_return) and self.return_against + else self.name, + "against_voucher_type": self.doctype, + "cost_center": self.cost_center, + "project": self.project, + }, + self.party_account_currency, + item=self, + ), + self.get_gl_dict( + { + "account": self.account_for_change_amount, + "against": self.customer, + "credit": self.base_change_amount, + "cost_center": self.cost_center, + }, + item=self, + ), + ] def make_write_off_gl_entry(self, gl_entries): # write off entries, applicable if only pos From 1951f71eeb236d4fe1be8159419a87f15e292dae Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Feb 2024 12:57:19 +0530 Subject: [PATCH 10/62] fix: Patch to remove cancelled asset capitalization from asset --- .../asset_capitalization/asset_capitalization.py | 4 ++++ erpnext/patches.txt | 3 ++- ...emove_cancelled_asset_capitalization_from_asset.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v15_0/remove_cancelled_asset_capitalization_from_asset.py diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py index c3a79cdf837..0e2b3698ceb 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py @@ -144,6 +144,10 @@ class AssetCapitalization(StockController): self.make_gl_entries() self.restore_consumed_asset_items() + def on_trash(self): + frappe.db.set_value("Asset", self.target_asset, "capitalized_in", None) + super(AssetCapitalization, self).on_trash() + def cancel_target_asset(self): if self.entry_type == "Capitalization" and self.target_asset: asset_doc = frappe.get_doc("Asset", self.target_asset) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index a259540cd93..61ece471ef0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -357,4 +357,5 @@ erpnext.patches.v15_0.create_advance_payment_status erpnext.patches.v14_0.migrate_gl_to_payment_ledger erpnext.stock.doctype.delivery_note.patches.drop_unused_return_against_index # 2023-12-20 erpnext.patches.v14_0.set_maintain_stock_for_bom_item -erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records \ No newline at end of file +erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records +erpnext.patches.v15_0.remove_cancelled_asset_capitalization_from_asset \ No newline at end of file diff --git a/erpnext/patches/v15_0/remove_cancelled_asset_capitalization_from_asset.py b/erpnext/patches/v15_0/remove_cancelled_asset_capitalization_from_asset.py new file mode 100644 index 00000000000..cb39a9280e4 --- /dev/null +++ b/erpnext/patches/v15_0/remove_cancelled_asset_capitalization_from_asset.py @@ -0,0 +1,11 @@ +import frappe + + +def execute(): + cancelled_asset_capitalizations = frappe.get_all( + "Asset Capitalization", + filters={"docstatus": 2}, + fields=["name", "target_asset"], + ) + for asset_capitalization in cancelled_asset_capitalizations: + frappe.db.set_value("Asset", asset_capitalization.target_asset, "capitalized_in", None) From dd70fb5f7e4e430d8cb2e1cf610d119e77611551 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Thu, 29 Feb 2024 15:31:53 +0530 Subject: [PATCH 11/62] fix: skip timesheet link on return time --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index ef1f6bd8d82..e03ed866478 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -486,7 +486,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e currency() { var me = this; super.currency(); - if (this.frm.doc.timesheets) { + if (!this.frm.doc.is_return && this.frm.doc.timesheets) { this.frm.doc.timesheets.forEach((d) => { let row = frappe.get_doc(d.doctype, d.name) set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 3352e0d90ad..572a9f94493 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -757,6 +757,8 @@ class SalesInvoice(SellingController): def validate_time_sheets_are_submitted(self): for data in self.timesheets: if data.time_sheet: + if self.is_return: + continue status = frappe.db.get_value("Timesheet", data.time_sheet, "status") if status not in ["Submitted", "Payslip"]: frappe.throw(_("Timesheet {0} is already completed or cancelled").format(data.time_sheet)) From 79c492cc4b44d5594b8428ae0dbbf7712462e56d Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Fri, 1 Mar 2024 09:26:49 +0530 Subject: [PATCH 12/62] fix: skip timesheet on return time and revert code --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- erpnext/accounts/doctype/sales_invoice/sales_invoice.json | 3 ++- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index e03ed866478..ef1f6bd8d82 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -486,7 +486,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e currency() { var me = this; super.currency(); - if (!this.frm.doc.is_return && this.frm.doc.timesheets) { + if (this.frm.doc.timesheets) { this.frm.doc.timesheets.forEach((d) => { let row = frappe.get_doc(d.doctype, d.name) set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 5e2187e91fe..88b28adbf14 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -785,6 +785,7 @@ "hide_days": 1, "hide_seconds": 1, "label": "Time Sheets", + "no_copy": 1, "options": "Sales Invoice Timesheet", "print_hide": 1 }, @@ -2182,7 +2183,7 @@ "link_fieldname": "consolidated_invoice" } ], - "modified": "2024-01-02 17:25:46.027523", + "modified": "2024-03-01 09:21:54.201289", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 572a9f94493..3352e0d90ad 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -757,8 +757,6 @@ class SalesInvoice(SellingController): def validate_time_sheets_are_submitted(self): for data in self.timesheets: if data.time_sheet: - if self.is_return: - continue status = frappe.db.get_value("Timesheet", data.time_sheet, "status") if status not in ["Submitted", "Payslip"]: frappe.throw(_("Timesheet {0} is already completed or cancelled").format(data.time_sheet)) From d0140412cdd28385d3b767dd43451943daa80bbe Mon Sep 17 00:00:00 2001 From: Ernesto Ruiz Date: Sat, 2 Mar 2024 15:46:43 -0600 Subject: [PATCH 13/62] chore: Add translate function to text "after" --- erpnext/stock/stock_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 2ae6c197a15..bb0d7b6b628 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -1677,7 +1677,7 @@ def get_valuation_rate( solutions += ( "
  • " + _("If not, you can Cancel / Submit this entry") - + " {0} ".format(frappe.bold("after")) + + " {0} ".format(frappe.bold(_("after"))) + _("performing either one below:") + "
  • " ) From 51909077bd90fe86ab3e1c916412a18e183ab823 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Sun, 3 Mar 2024 18:08:23 +0530 Subject: [PATCH 14/62] feat: add company filter to child table field --- .../cost_center_allocation.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.js b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.js index ab0baab24a0..0da90161f51 100644 --- a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.js +++ b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.js @@ -3,16 +3,21 @@ frappe.ui.form.on('Cost Center Allocation', { setup: function(frm) { - let filters = {"is_group": 0}; - if (frm.doc.company) { - $.extend(filters, { - "company": frm.doc.company - }); - } - frm.set_query('main_cost_center', function() { return { - filters: filters + filters: { + company: frm.doc.company, + is_group: 0 + } + }; + }); + + frm.set_query('cost_center', 'allocation_percentages', function() { + return { + filters: { + company: frm.doc.company, + is_group: 0 + } }; }); } From 6379238893e94fa19da65b08428000e77fa50bd6 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 4 Mar 2024 12:04:41 +0530 Subject: [PATCH 15/62] perf: serial and batch bundle valuation (reposting) (#40255) perf: serial and batch bundle valuation --- erpnext/stock/deprecated_serial_batch.py | 28 +++++++++++---- .../test_landed_cost_voucher.py | 17 --------- .../serial_and_batch_bundle.py | 7 +--- erpnext/stock/serial_batch_bundle.py | 36 ++++++++++--------- erpnext/stock/stock_ledger.py | 19 +++++++++- 5 files changed, 60 insertions(+), 47 deletions(-) diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index ab38c151b64..7be1418823b 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -13,7 +13,9 @@ class DeprecatedSerialNoValuation: ): return - serial_nos = self.get_serial_nos() + serial_nos = self.get_filterd_serial_nos() + if not serial_nos: + return actual_qty = flt(self.sle.actual_qty) @@ -25,8 +27,21 @@ class DeprecatedSerialNoValuation: self.stock_value_change += stock_value_change + def get_filterd_serial_nos(self): + serial_nos = [] + non_filtered_serial_nos = self.get_serial_nos() + + # If the serial no inwarded using the Serial and Batch Bundle, then the serial no should not be considered + for serial_no in non_filtered_serial_nos: + if serial_no and serial_no not in self.serial_no_incoming_rate: + serial_nos.append(serial_no) + + return serial_nos + @deprecated def get_incoming_value_for_serial_nos(self, serial_nos): + from erpnext.stock.utils import get_combine_datetime + # get rate from serial nos within same company incoming_values = 0.0 for serial_no in serial_nos: @@ -42,18 +57,19 @@ class DeprecatedSerialNoValuation: | (table.serial_no.like("%\n" + serial_no + "\n%")) ) & (table.company == self.sle.company) + & (table.warehouse == self.sle.warehouse) & (table.serial_and_batch_bundle.isnull()) + & (table.actual_qty > 0) & (table.is_cancelled == 0) + & table.posting_datetime + <= get_combine_datetime(self.sle.posting_date, self.sle.posting_time) ) .orderby(table.posting_datetime, order=Order.desc) + .limit(1) ).run(as_dict=1) for sle in stock_ledgers: - self.serial_no_incoming_rate[serial_no] += ( - flt(sle.incoming_rate) - if sle.actual_qty > 0 - else (sle.stock_value_difference / sle.actual_qty) * -1 - ) + self.serial_no_incoming_rate[serial_no] += flt(sle.incoming_rate) incoming_values += self.serial_no_incoming_rate[serial_no] return incoming_values diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py index 257f263bd22..4058aa82d7e 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py +++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py @@ -415,23 +415,6 @@ class TestLandedCostVoucher(FrappeTestCase): create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company, charges=charges) new_purchase_rate = serial_no_rate + charges - sn_obj = SerialNoValuation( - sle=frappe._dict( - { - "posting_date": today(), - "posting_time": nowtime(), - "item_code": "_Test Serialized Item", - "warehouse": "Stores - TCP1", - "serial_nos": [serial_no], - } - ) - ) - - new_serial_no_rate = sn_obj.get_incoming_rate_of_serial_no(serial_no) - - # Since the serial no is already delivered the rate must be zero - self.assertFalse(new_serial_no_rate) - stock_value_difference = frappe.db.get_value( "Stock Ledger Entry", filters={ diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 33f0dceba94..d01dfefc926 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -332,13 +332,8 @@ class SerialandBatchBundle(Document): rate = frappe.db.get_value(child_table, self.voucher_detail_no, valuation_field) for d in self.entries: - if not rate or ( - flt(rate, precision) == flt(d.incoming_rate, precision) and d.stock_value_difference - ): - continue - d.incoming_rate = flt(rate, precision) - if self.has_batch_no: + if d.qty: d.stock_value_difference = flt(d.qty) * flt(d.incoming_rate) if save: diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py index 24dd9d1d203..1fcc439fda3 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -4,8 +4,9 @@ from typing import List import frappe from frappe import _, bold from frappe.model.naming import make_autoname -from frappe.query_builder.functions import CombineDatetime, Sum +from frappe.query_builder.functions import CombineDatetime, Sum, Timestamp from frappe.utils import cint, cstr, flt, get_link_to_form, now, nowtime, today +from pypika import Order from erpnext.stock.deprecated_serial_batch import ( DeprecatedBatchNoValuation, @@ -424,19 +425,21 @@ class SerialNoValuation(DeprecatedSerialNoValuation): ) else: - entries = self.get_serial_no_ledgers() - self.serial_no_incoming_rate = defaultdict(float) self.stock_value_change = 0.0 - for ledger in entries: - self.stock_value_change += ledger.incoming_rate - self.serial_no_incoming_rate[ledger.serial_no] += ledger.incoming_rate + serial_nos = self.get_serial_nos() + for serial_no in serial_nos: + incoming_rate = self.get_incoming_rate_from_bundle(serial_no) + if not incoming_rate: + continue + + self.stock_value_change += incoming_rate + self.serial_no_incoming_rate[serial_no] += incoming_rate self.calculate_stock_value_from_deprecarated_ledgers() - def get_serial_no_ledgers(self): - serial_nos = self.get_serial_nos() + def get_incoming_rate_from_bundle(self, serial_no) -> float: bundle = frappe.qb.DocType("Serial and Batch Bundle") bundle_child = frappe.qb.DocType("Serial and Batch Entry") @@ -444,20 +447,18 @@ class SerialNoValuation(DeprecatedSerialNoValuation): frappe.qb.from_(bundle) .inner_join(bundle_child) .on(bundle.name == bundle_child.parent) - .select( - bundle.name, - bundle_child.serial_no, - (bundle_child.incoming_rate * bundle_child.qty).as_("incoming_rate"), - ) + .select((bundle_child.incoming_rate * bundle_child.qty).as_("incoming_rate")) .where( (bundle.is_cancelled == 0) & (bundle.docstatus == 1) - & (bundle_child.serial_no.isin(serial_nos)) - & (bundle.type_of_transaction.isin(["Inward", "Outward"])) + & (bundle_child.serial_no == serial_no) + & (bundle.type_of_transaction == "Inward") + & (bundle_child.qty > 0) & (bundle.item_code == self.sle.item_code) & (bundle_child.warehouse == self.sle.warehouse) ) - .orderby(bundle.posting_date, bundle.posting_time, bundle.creation) + .orderby(Timestamp(bundle.posting_date, bundle.posting_time), order=Order.desc) + .limit(1) ) # Important to exclude the current voucher to calculate correct the stock value difference @@ -474,7 +475,8 @@ class SerialNoValuation(DeprecatedSerialNoValuation): query = query.where(timestamp_condition) - return query.run(as_dict=True) + incoming_rate = query.run() + return flt(incoming_rate[0][0]) if incoming_rate else 0.0 def get_serial_nos(self): if self.sle.get("serial_nos"): diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 2ae6c197a15..2b62baf42b3 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -952,7 +952,12 @@ class update_entries_after(object): get_rate_for_return, # don't move this import to top ) - if self.valuation_method == "Moving Average": + if ( + self.valuation_method == "Moving Average" + and not sle.get("serial_no") + and not sle.get("batch_no") + and not sle.get("serial_and_batch_bundle") + ): rate = get_incoming_rate( { "item_code": sle.item_code, @@ -979,6 +984,18 @@ class update_entries_after(object): voucher_detail_no=sle.voucher_detail_no, sle=sle, ) + + if ( + sle.get("serial_and_batch_bundle") + and rate > 0 + and sle.voucher_type in ["Delivery Note", "Sales Invoice"] + ): + frappe.db.set_value( + sle.voucher_type + " Item", + sle.voucher_detail_no, + "incoming_rate", + rate, + ) elif ( sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"] and sle.voucher_detail_no From 8e2f9787c1fbc98930750d34ce592d2fb56fcc1e Mon Sep 17 00:00:00 2001 From: "Nihantra C. Patel" <141945075+Nihantra-Patel@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:43:33 +0530 Subject: [PATCH 16/62] fix: report path from the Item and Putaway Rule list (#40190) --- erpnext/stock/doctype/item/item_list.js | 3 +-- erpnext/stock/doctype/putaway_rule/putaway_rule_list.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/item/item_list.js b/erpnext/stock/doctype/item/item_list.js index 1b57102d716..67dc86c89b8 100644 --- a/erpnext/stock/doctype/item/item_list.js +++ b/erpnext/stock/doctype/item/item_list.js @@ -18,8 +18,7 @@ frappe.listview_settings['Item'] = { reports: [ { name: 'Stock Summary', - report_type: 'Page', - route: 'stock-balance' + route: '/app/stock-balance' }, { name: 'Stock Ledger', diff --git a/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js b/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js index 725e91ee8d9..753569c8812 100644 --- a/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js +++ b/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js @@ -11,8 +11,7 @@ frappe.listview_settings['Putaway Rule'] = { reports: [ { name: 'Warehouse Capacity Summary', - report_type: 'Page', - route: 'warehouse-capacity-summary' + route: '/app/warehouse-capacity-summary' } ] }; From 34051bc04f93c808066da469dd61a706684ef4f8 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 5 Mar 2024 13:44:02 +0530 Subject: [PATCH 17/62] chore: fixed fetch from (#40270) --- .../asset_capitalization_service_item.json | 5 +++-- .../asset_capitalization_stock_item.json | 4 ++-- erpnext/stock/doctype/delivery_note/delivery_note.json | 9 ++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/erpnext/assets/doctype/asset_capitalization_service_item/asset_capitalization_service_item.json b/erpnext/assets/doctype/asset_capitalization_service_item/asset_capitalization_service_item.json index 0ae1c1428ee..31c9d52bcaa 100644 --- a/erpnext/assets/doctype/asset_capitalization_service_item/asset_capitalization_service_item.json +++ b/erpnext/assets/doctype/asset_capitalization_service_item/asset_capitalization_service_item.json @@ -63,7 +63,7 @@ }, { "columns": 1, - "fetch_from": "stock_item_code.stock_uom", + "fetch_from": "item_code.stock_uom", "fieldname": "uom", "fieldtype": "Link", "in_list_view": 1, @@ -110,7 +110,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-09-08 15:52:08.598100", + "modified": "2024-03-05 11:23:40.766844", "modified_by": "Administrator", "module": "Assets", "name": "Asset Capitalization Service Item", @@ -118,5 +118,6 @@ "permissions": [], "sort_field": "modified", "sort_order": "DESC", + "states": [], "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json index f79a84855d5..c838f8b0f26 100644 --- a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json +++ b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json @@ -65,7 +65,7 @@ }, { "columns": 1, - "fetch_from": "stock_item_code.stock_uom", + "fetch_from": "item_code.stock_uom", "fieldname": "stock_uom", "fieldtype": "Link", "in_list_view": 1, @@ -178,7 +178,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-02-25 15:57:35.007501", + "modified": "2024-03-05 11:22:57.346889", "modified_by": "Administrator", "module": "Assets", "name": "Asset Capitalization Stock Item", diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index 7873d3e6de4..d07a825331d 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -28,7 +28,6 @@ "column_break_18", "project", "dimension_col_break", - "custom_dimensions_section", "currency_and_price_list", "currency", "conversion_rate", @@ -927,7 +926,7 @@ "width": "50%" }, { - "fetch_from": "transporter.name", + "fetch_from": "transporter.supplier_name", "fieldname": "transporter_name", "fieldtype": "Data", "label": "Transporter Name", @@ -1355,10 +1354,6 @@ "fieldname": "column_break_43", "fieldtype": "Column Break" }, - { - "fieldname": "custom_dimensions_section", - "fieldtype": "Section Break" - }, { "fieldname": "shipping_address_section", "fieldtype": "Section Break", @@ -1402,7 +1397,7 @@ "idx": 146, "is_submittable": 1, "links": [], - "modified": "2023-12-18 17:19:39.368239", + "modified": "2024-03-05 11:58:47.784349", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note", From 9904a9868c346028fa3b1809ac575ea1e1c6632b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 5 Mar 2024 14:46:24 +0530 Subject: [PATCH 18/62] fix: incorrect TCS on customer and suppliers with same name --- .../tax_withholding_category/tax_withholding_category.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index c39a9db9800..405f58715bd 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -546,6 +546,7 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers): "GL Entry", { "is_cancelled": 0, + "party_type": "Customer", "party": ["in", parties], "company": inv.company, "voucher_no": ["in", vouchers], @@ -560,6 +561,7 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers): conditions = [] conditions.append(ple.amount.lt(0)) conditions.append(ple.delinked == 0) + conditions.append(ple.party_type == "Customer") conditions.append(ple.party.isin(parties)) conditions.append(ple.voucher_no == ple.against_voucher_no) conditions.append(ple.company == inv.company) @@ -579,6 +581,7 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers): { "is_cancelled": 0, "credit": [">", 0], + "party_type": "Customer", "party": ["in", parties], "posting_date": ["between", (tax_details.from_date, tax_details.to_date)], "company": inv.company, From 9d9b83362af97442986c54a5bf63a0c4fa756c14 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 31 Jan 2024 20:40:26 +0530 Subject: [PATCH 19/62] fix: incorrect advance paid in Sales/Purchase Order --- .../doctype/payment_entry/payment_entry.py | 20 +++++++++++++++---- erpnext/accounts/utils.py | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 77efe78368b..1a89c45e001 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1271,7 +1271,13 @@ class PaymentEntry(AccountsController): references = [x for x in self.get("references") if x.name == entry.name] for ref in references: - if ref.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Journal Entry"): + if ref.reference_doctype in ( + "Sales Invoice", + "Purchase Invoice", + "Journal Entry", + "Sales Order", + "Purchase Order", + ): self.add_advance_gl_for_reference(gl_entries, ref) def add_advance_gl_for_reference(self, gl_entries, invoice): @@ -1285,9 +1291,10 @@ class PaymentEntry(AccountsController): "voucher_detail_no": invoice.name, } - posting_date = frappe.db.get_value( - invoice.reference_doctype, invoice.reference_name, "posting_date" - ) + date_field = "posting_date" + if invoice.reference_doctype in ["Sales Order", "Purchase Order"]: + date_field = "transaction_date" + posting_date = frappe.db.get_value(invoice.reference_doctype, invoice.reference_name, date_field) if getdate(posting_date) < getdate(self.posting_date): posting_date = self.posting_date @@ -2197,6 +2204,11 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre else: outstanding_amount = flt(total_amount) - flt(ref_doc.get("advance_paid")) + if reference_doctype in ["Sales Order", "Purchase Order"]: + party_type = "Customer" if reference_doctype == "Sales Order" else "Supplier" + party_field = "customer" if reference_doctype == "Sales Order" else "supplier" + party = ref_doc.get(party_field) + account = get_party_account(party_type, party, ref_doc.company) else: # Get the exchange rate based on the posting date of the ref doc. exchange_rate = get_exchange_rate(party_account_currency, company_currency, ref_doc.posting_date) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index d4cb57b2143..b436d022983 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -522,7 +522,8 @@ def reconcile_against_document( if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account: # both ledgers must be posted to for `Advance` in separate account feature - doc.make_advance_gl_entries(referenced_row, update_outstanding="No") + doc.make_advance_gl_entries(cancel=1) + doc.make_advance_gl_entries() else: gl_map = doc.build_gl_map() create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1) From 158112896e5a8ead224b397e079d6784a475f49d Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 12 Feb 2024 12:26:58 +0530 Subject: [PATCH 20/62] refactor(test): reference details will have account --- erpnext/accounts/doctype/payment_entry/test_payment_entry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 8a03dd7278a..47cdb1b975f 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -1084,6 +1084,7 @@ class TestPaymentEntry(FrappeTestCase): ref_details = get_reference_details(so.doctype, so.name, pe.paid_from_account_currency) expected_response = { + "account": pe.paid_from, "total_amount": 5000.0, "outstanding_amount": 5000.0, "exchange_rate": 1.0, From cb2529cec806ab1e31e1dcec1385115d26766749 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 12 Feb 2024 14:05:27 +0530 Subject: [PATCH 21/62] refactor(test): use get_party_account for reference details section --- erpnext/accounts/doctype/payment_entry/test_payment_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 47cdb1b975f..5a014b85c99 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -1070,6 +1070,8 @@ class TestPaymentEntry(FrappeTestCase): self.assertRaises(frappe.ValidationError, pe_draft.submit) def test_details_update_on_reference_table(self): + from erpnext.accounts.party import get_party_account + so = make_sales_order( customer="_Test Customer USD", currency="USD", qty=1, rate=100, do_not_submit=True ) @@ -1084,7 +1086,7 @@ class TestPaymentEntry(FrappeTestCase): ref_details = get_reference_details(so.doctype, so.name, pe.paid_from_account_currency) expected_response = { - "account": pe.paid_from, + "account": get_party_account("Customer", so.customer, so.company), "total_amount": 5000.0, "outstanding_amount": 5000.0, "exchange_rate": 1.0, From d9a0494fc33a4f5438d8ff49a92af66a1757a8ea Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 4 Mar 2024 10:28:43 +0530 Subject: [PATCH 22/62] fix: advance paid amount and ledger entries against SO/PO --- .../doctype/payment_entry/payment_entry.py | 2 +- erpnext/accounts/utils.py | 28 ++++++++++++------- erpnext/controllers/accounts_controller.py | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 1a89c45e001..7970a3e0678 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1299,7 +1299,7 @@ class PaymentEntry(AccountsController): if getdate(posting_date) < getdate(self.posting_date): posting_date = self.posting_date - dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit" + dr_or_cr = "credit" if invoice.reference_doctype in ["Sales Invoice", "Sales Order"] else "debit" args_dict["account"] = invoice.account args_dict[dr_or_cr] = invoice.allocated_amount args_dict[dr_or_cr + "_in_account_currency"] = invoice.allocated_amount diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index b436d022983..0755f2e9e84 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -490,7 +490,9 @@ def reconcile_against_document( # For payments with `Advance` in separate account feature enabled, only new ledger entries are posted for each reference. # No need to cancel/delete payment ledger entries - if not (voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account): + if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account: + doc.make_advance_gl_entries(cancel=1) + else: _delete_pl_entries(voucher_type, voucher_no) for entry in entries: @@ -501,14 +503,16 @@ def reconcile_against_document( # update ref in advance entry if voucher_type == "Journal Entry": - referenced_row = update_reference_in_journal_entry(entry, doc, do_not_save=False) + referenced_row, update_advance_paid = update_reference_in_journal_entry( + entry, doc, do_not_save=False + ) # advance section in sales/purchase invoice and reconciliation tool,both pass on exchange gain/loss # amount and account in args # referenced_row is used to deduplicate gain/loss journal entry.update({"referenced_row": referenced_row}) doc.make_exchange_gain_loss_journal([entry], dimensions_dict) else: - referenced_row = update_reference_in_payment_entry( + referenced_row, update_advance_paid = update_reference_in_payment_entry( entry, doc, do_not_save=True, @@ -522,7 +526,7 @@ def reconcile_against_document( if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account: # both ledgers must be posted to for `Advance` in separate account feature - doc.make_advance_gl_entries(cancel=1) + # TODO: find a more efficient way post only for the new linked vouchers doc.make_advance_gl_entries() else: gl_map = doc.build_gl_map() @@ -533,6 +537,10 @@ def reconcile_against_document( update_voucher_outstanding( entry.against_voucher_type, entry.against_voucher, entry.account, entry.party_type, entry.party ) + # update advance paid in Advance Receivable/Payable doctypes + if update_advance_paid: + for t, n in update_advance_paid: + frappe.get_doc(t, n).set_total_advance_paid() frappe.flags.ignore_party_validation = False @@ -622,11 +630,12 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): jv_detail = journal_entry.get("accounts", {"name": d["voucher_detail_no"]})[0] # Update Advance Paid in SO/PO since they might be getting unlinked + update_advance_paid = [] advance_payment_doctypes = frappe.get_hooks( "advance_payment_receivable_doctypes" ) + frappe.get_hooks("advance_payment_payable_doctypes") if jv_detail.get("reference_type") in advance_payment_doctypes: - frappe.get_doc(jv_detail.reference_type, jv_detail.reference_name).set_total_advance_paid() + update_advance_paid.append((jv_detail.reference_type, jv_detail.reference_name)) if flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) != 0: # adjust the unreconciled balance @@ -675,7 +684,7 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): if not do_not_save: journal_entry.save(ignore_permissions=True) - return new_row.name + return new_row.name, update_advance_paid def update_reference_in_payment_entry( @@ -694,6 +703,7 @@ def update_reference_in_payment_entry( "account": d.account, "dimensions": d.dimensions, } + update_advance_paid = [] if d.voucher_detail_no: existing_row = payment_entry.get("references", {"name": d["voucher_detail_no"]})[0] @@ -703,9 +713,7 @@ def update_reference_in_payment_entry( "advance_payment_receivable_doctypes" ) + frappe.get_hooks("advance_payment_payable_doctypes") if existing_row.get("reference_doctype") in advance_payment_doctypes: - frappe.get_doc( - existing_row.reference_doctype, existing_row.reference_name - ).set_total_advance_paid() + update_advance_paid.append((existing_row.reference_doctype, existing_row.reference_name)) if d.allocated_amount <= existing_row.allocated_amount: existing_row.allocated_amount -= d.allocated_amount @@ -735,7 +743,7 @@ def update_reference_in_payment_entry( if not do_not_save: payment_entry.save(ignore_permissions=True) - return row + return row, update_advance_paid def cancel_exchange_gain_loss_journal( diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index a3db19672d8..aa3d3e07f03 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1864,7 +1864,7 @@ class AccountsController(TransactionBase): (ple.against_voucher_type == self.doctype) & (ple.against_voucher_no == self.name) & (ple.party == party) - & (ple.docstatus == 1) + & (ple.delinked == 0) & (ple.company == self.company) ) .run(as_dict=True) From e52c4c8f22d97c62391f9c4d76a513b5347290ce Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 4 Mar 2024 15:13:05 +0530 Subject: [PATCH 23/62] refactor(test): make sure party has USD account 1. Don't reset 'party_account_currency' of SO/PO upon Payment Entry cancellation. This happens when there are no payments against a SO/PO --- .../purchase_order/test_purchase_order.py | 85 ++++++++++++++++++- erpnext/controllers/accounts_controller.py | 5 +- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index d262783ae9a..c667ee821bd 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -762,11 +762,94 @@ class TestPurchaseOrder(FrappeTestCase): pe_doc = frappe.get_doc("Payment Entry", pe.name) pe_doc.cancel() + def create_account(self, account_name, company, currency, parent): + if not frappe.db.get_value( + "Account", filters={"account_name": account_name, "company": company} + ): + account = frappe.get_doc( + { + "doctype": "Account", + "account_name": account_name, + "parent_account": parent, + "company": company, + "account_currency": currency, + "is_group": 0, + "account_type": "Payable", + } + ).insert() + else: + account = frappe.db.get_value( + "Account", + filters={"account_name": account_name, "company": company}, + fieldname="name", + pluck=True, + ) + + return account + + def test_advance_payment_with_separate_party_account_enabled(self): + """ + Test "Advance Paid" on Purchase Order, when "Book Advance Payments in Separate Party Account" is enabled and + the payment entry linked to the Order is allocated to Purchase Invoice. + """ + supplier = "_Test Supplier" + company = "_Test Company" + + # Setup default 'Advance Paid' account + account = self.create_account( + "Advance Paid", company, "INR", "Application of Funds (Assets) - _TC" + ) + company_doc = frappe.get_doc("Company", company) + company_doc.book_advance_payments_in_separate_party_account = True + company_doc.default_advance_paid_account = account.name + company_doc.save() + + po_doc = create_purchase_order(supplier=supplier) + + from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry + + pe = get_payment_entry("Purchase Order", po_doc.name) + pe.save().submit() + + po_doc.reload() + self.assertEqual(po_doc.advance_paid, 5000) + + from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice + + pi = make_purchase_invoice(po_doc.name) + pi.append( + "advances", + { + "reference_type": pe.doctype, + "reference_name": pe.name, + "reference_row": pe.references[0].name, + "advance_amount": 5000, + "allocated_amount": 5000, + }, + ) + pi.save().submit() + pe.reload() + po_doc.reload() + self.assertEqual(po_doc.advance_paid, 0) + + company_doc.book_advance_payments_in_separate_party_account = False + company_doc.save() + @change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1}) def test_advance_paid_upon_payment_entry_cancellation(self): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry - po_doc = create_purchase_order(supplier="_Test Supplier USD", currency="USD", do_not_submit=1) + supplier = "_Test Supplier USD" + company = "_Test Company" + + # Setup default USD payable account for Supplier + account = self.create_account("Creditors USD", company, "USD", "Accounts Payable - _TC") + supplier_doc = frappe.get_doc("Supplier", supplier) + if not [x for x in supplier_doc.accounts if x.company == company]: + supplier_doc.append("accounts", {"company": company, "account": account.name}) + supplier_doc.save() + + po_doc = create_purchase_order(supplier=supplier, currency="USD", do_not_submit=1) po_doc.conversion_rate = 80 po_doc.submit() diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index aa3d3e07f03..c543dfc2cd0 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1880,7 +1880,10 @@ class AccountsController(TransactionBase): advance_paid, precision=self.precision("advance_paid"), currency=advance.account_currency ) - frappe.db.set_value(self.doctype, self.name, "party_account_currency", advance.account_currency) + if advance.account_currency: + frappe.db.set_value( + self.doctype, self.name, "party_account_currency", advance.account_currency + ) if advance.account_currency == self.currency: order_total = self.get("rounded_total") or self.grand_total From 092999f2a65741b96efc085323b6d89d82101197 Mon Sep 17 00:00:00 2001 From: Harsh Khatri <141217727+harshkhatri7287@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:14:32 +0530 Subject: [PATCH 24/62] fix: update status of Email Campaign (#39776) --- erpnext/crm/doctype/email_campaign/email_campaign.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/crm/doctype/email_campaign/email_campaign.py b/erpnext/crm/doctype/email_campaign/email_campaign.py index 17cf0e461d0..0ad19a48c06 100644 --- a/erpnext/crm/doctype/email_campaign/email_campaign.py +++ b/erpnext/crm/doctype/email_campaign/email_campaign.py @@ -144,3 +144,4 @@ def set_email_campaign_status(): for entry in email_campaigns: email_campaign = frappe.get_doc("Email Campaign", entry.name) email_campaign.update_status() + email_campaign.save() From bdc0175fe3743a98926e5d92bab417c1b9a756bc Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Tue, 5 Mar 2024 15:54:35 +0530 Subject: [PATCH 25/62] chore: sync translations from crowdin --- erpnext/locale/de.po | 132 ++--- erpnext/locale/fa.po | 1094 ++++++++++++++++++------------------------ 2 files changed, 531 insertions(+), 695 deletions(-) diff --git a/erpnext/locale/de.po b/erpnext/locale/de.po index e1be2f84e5f..dfc2b8be787 100644 --- a/erpnext/locale/de.po +++ b/erpnext/locale/de.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: frappe\n" "Report-Msgid-Bugs-To: info@erpnext.com\n" "POT-Creation-Date: 2024-01-29 18:13+0053\n" -"PO-Revision-Date: 2024-02-22 19:45\n" +"PO-Revision-Date: 2024-02-29 05:57\n" "Last-Translator: info@erpnext.com\n" "Language-Team: German\n" "MIME-Version: 1.0\n" @@ -17540,7 +17540,7 @@ msgstr "" #: buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py:46 #: buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py:50 msgid "Could not find path for " -msgstr "" +msgstr "Konnte keinen Pfad finden für " #: accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.py:128 #: accounts/report/financial_statements.py:236 @@ -21473,7 +21473,7 @@ msgstr "Standard Provisorisches Konto" #: stock/doctype/item/item.json msgctxt "Item" msgid "Default Purchase Unit of Measure" -msgstr "Standard Maßeinheit Verkauf" +msgstr "Standard Maßeinheit Einkauf" #. Label of a Data field in DocType 'CRM Settings' #: crm/doctype/crm_settings/crm_settings.json @@ -27364,7 +27364,7 @@ msgstr "" #: stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py:195 #: stock/report/stock_ledger_variance/stock_ledger_variance.py:119 msgid "FIFO/LIFO Queue" -msgstr "" +msgstr "FIFO/LIFO-Warteschlange" #: erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.js:62 #: manufacturing/doctype/bom_creator/bom_creator_list.js:13 @@ -60274,11 +60274,11 @@ msgstr "Routing-Name" #: stock/doctype/stock_reconciliation/stock_reconciliation.py:428 msgid "Row #" -msgstr "" +msgstr "Zeile #" #: stock/doctype/stock_reconciliation/stock_reconciliation.py:334 msgid "Row # {0}:" -msgstr "" +msgstr "Zeile # {0}:" #: controllers/sales_and_purchase_return.py:181 msgid "Row # {0}: Cannot return more than {1} for Item {2}" @@ -60304,15 +60304,15 @@ msgstr "Zeile {0} (Zahlungstabelle): Betrag muss positiv sein" #: stock/doctype/item/item.py:480 msgid "Row #{0}: A reorder entry already exists for warehouse {1} with reorder type {2}." -msgstr "" +msgstr "Zeile #{0}: Für das Lager {1} mit dem Nachbestellungstyp {2} ist bereits ein Nachbestellungseintrag vorhanden." #: stock/doctype/quality_inspection/quality_inspection.py:235 msgid "Row #{0}: Acceptance Criteria Formula is incorrect." -msgstr "" +msgstr "Zeile #{0}: Die Formel für die Akzeptanzkriterien ist falsch." #: stock/doctype/quality_inspection/quality_inspection.py:215 msgid "Row #{0}: Acceptance Criteria Formula is required." -msgstr "" +msgstr "Zeile #{0}: Die Formel für die Akzeptanzkriterien ist erforderlich." #: controllers/subcontracting_controller.py:72 #: subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py:413 @@ -60446,7 +60446,7 @@ msgstr "Zeile {0}: Voraussichtlicher Liefertermin kann nicht vor Bestelldatum se #: controllers/stock_controller.py:336 msgid "Row #{0}: Expense Account not set for the Item {1}. {2}" -msgstr "" +msgstr "Zeile #{0}: Aufwandskonto für den Artikel nicht festgelegt {1}. {2}" #: buying/doctype/purchase_order/purchase_order.py:378 msgid "Row #{0}: Finished Good Item Qty can not be zero" @@ -60474,7 +60474,7 @@ msgstr "Zeile #{0}: Für {1} können Sie den Referenzbeleg nur auswählen, wenn #: accounts/doctype/tax_withholding_category/tax_withholding_category.py:44 msgid "Row #{0}: From Date cannot be before To Date" -msgstr "" +msgstr "Zeile #{0}: Von-Datum kann nicht vor Bis-Datum liegen" #: public/js/utils/barcode_scanner.js:489 msgid "Row #{0}: Item added" @@ -60546,7 +60546,7 @@ msgstr "" #: public/js/utils/barcode_scanner.js:487 msgid "Row #{0}: Qty increased by {1}" -msgstr "" +msgstr "Zeile #{0}: Menge erhöht um {1}" #: assets/doctype/asset_capitalization/asset_capitalization.py:264 #: assets/doctype/asset_capitalization/asset_capitalization.py:306 @@ -60555,7 +60555,7 @@ msgstr "Zeile #{0}: Menge muss eine positive Zahl sein" #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:301 msgid "Row #{0}: Qty should be less than or equal to Available Qty to Reserve (Actual Qty - Reserved Qty) {1} for Iem {2} against Batch {3} in Warehouse {4}." -msgstr "" +msgstr "Zeile #{0}: Die Menge sollte kleiner oder gleich der verfügbaren Menge zum Reservieren sein (Ist-Menge – reservierte Menge) {1} für Artikel {2} der Charge {3} im Lager {4}." #: controllers/accounts_controller.py:1018 #: controllers/accounts_controller.py:3166 @@ -60564,15 +60564,15 @@ msgstr "Zeile {0}: Artikelmenge {1} kann nicht Null sein." #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:1017 msgid "Row #{0}: Quantity to reserve for the Item {1} should be greater than 0." -msgstr "" +msgstr "Zeile #{0}: Die zu reservierende Menge für den Artikel {1} sollte größer als 0 sein." #: utilities/transaction_base.py:113 utilities/transaction_base.py:119 msgid "Row #{0}: Rate must be same as {1}: {2} ({3} / {4})" -msgstr "" +msgstr "Zeile #{0}: Einzelpreis muss gleich sein wie {1}: {2} ({3} / {4})" #: controllers/buying_controller.py:470 msgid "Row #{0}: Received Qty must be equal to Accepted + Rejected Qty for Item {1}" -msgstr "" +msgstr "Zeile #{0}: Die erhaltene Menge muss gleich der angenommenen + abgelehnten Menge für Artikel {1} sein" #: accounts/doctype/payment_entry/payment_entry.js:1016 msgid "Row #{0}: Reference Document Type must be one of Purchase Order, Purchase Invoice or Journal Entry" @@ -60655,23 +60655,23 @@ msgstr "" #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:975 msgid "Row #{0}: Stock cannot be reserved in group warehouse {1}." -msgstr "" +msgstr "Zeile #{0}: Bestand kann nicht im Gruppenlager {1} reserviert werden." #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:989 msgid "Row #{0}: Stock is already reserved for the Item {1}." -msgstr "" +msgstr "Zeile #{0}: Für den Artikel {1} ist bereits ein Lagerbestand reserviert." #: stock/doctype/delivery_note/delivery_note.py:605 msgid "Row #{0}: Stock is reserved for item {1} in warehouse {2}." -msgstr "" +msgstr "Zeile #{0}: Der Bestand ist für den Artikel {1} im Lager {2} reserviert." #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:285 msgid "Row #{0}: Stock not available to reserve for Item {1} against Batch {2} in Warehouse {3}." -msgstr "" +msgstr "Zeile #{0}: Bestand nicht verfügbar für Artikel {1} von Charge {2} im Lager {3}." #: stock/doctype/stock_reservation_entry/stock_reservation_entry.py:1003 msgid "Row #{0}: Stock not available to reserve for the Item {1} in Warehouse {2}." -msgstr "" +msgstr "Zeile #{0}: Kein Bestand für den Artikel {1} im Lager {2} verfügbar." #: controllers/stock_controller.py:110 msgid "Row #{0}: The batch {1} has already expired." @@ -60679,7 +60679,7 @@ msgstr "Zeile {0}: Der Stapel {1} ist bereits abgelaufen." #: accounts/doctype/sales_invoice/sales_invoice.py:1687 msgid "Row #{0}: The following Serial Nos are not present in Delivery Note {1}:" -msgstr "" +msgstr "Zeile #{0}: Die folgenden Seriennummern sind nicht im Lieferschein {1} enthalten:" #: manufacturing/doctype/workstation/workstation.py:116 msgid "Row #{0}: Timings conflicts with row {1}" @@ -60691,11 +60691,11 @@ msgstr "" #: accounts/doctype/sales_invoice/sales_invoice.py:1402 msgid "Row #{0}: You must select an Asset for Item {1}." -msgstr "" +msgstr "Zeile #{0}: Sie müssen einen Vermögensgegenstand für Artikel {1} auswählen." #: accounts/doctype/sales_invoice/sales_invoice.py:1696 msgid "Row #{0}: {1} Serial numbers required for Item {2}. You have provided {3}." -msgstr "" +msgstr "Zeile #{0}: {1} Seriennummern erforderlich für Artikel {2}. Sie haben {3} angegeben." #: controllers/buying_controller.py:483 public/js/controllers/buying.js:208 msgid "Row #{0}: {1} can not be negative for item {2}" @@ -60715,7 +60715,7 @@ msgstr "Zeile #{0}: {1} von {2} sollte {3} sein. Bitte aktualisieren Sie die {1} #: buying/utils.py:106 msgid "Row #{1}: Warehouse is mandatory for stock Item {0}" -msgstr "" +msgstr "Zeile #{1}: Lager ist obligatorisch für Artikel {0}" #: assets/doctype/asset_category/asset_category.py:65 msgid "Row #{}: Currency of {} - {} doesn't matches company currency." @@ -60735,7 +60735,7 @@ msgstr "Zeile # {}: Artikelcode: {} ist unter Lager {} nicht verfügbar." #: accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py:99 msgid "Row #{}: Original Invoice {} of return invoice {} is {}." -msgstr "" +msgstr "Zeile #{}: Originalrechnung {} der Rechnungskorrektur {} ist {}." #: accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py:87 msgid "Row #{}: POS Invoice {} has been {}" @@ -60787,7 +60787,7 @@ msgstr "" #: accounts/doctype/purchase_invoice/purchase_invoice.py:433 msgid "Row No {0}: Warehouse is required. Please set a Default Warehouse for Item {1} and Company {2}" -msgstr "" +msgstr "Zeile Nr. {0}: Lager ist erforderlich. Bitte legen Sie ein Standardlager für Artikel {1} und Unternehmen {2} fest" #: manufacturing/doctype/job_card/job_card.py:599 msgid "Row {0} : Operation is required against the raw material item {1}" @@ -60803,11 +60803,11 @@ msgstr "" #: stock/doctype/stock_entry/stock_entry.py:1159 msgid "Row {0}# Item {1} not found in 'Raw Materials Supplied' table in {2} {3}" -msgstr "" +msgstr "Zeile {0}# Artikel {1} wurde in der Tabelle „Gelieferte Rohstoffe“ in {2} {3} nicht gefunden" #: subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py:190 msgid "Row {0}: Accepted Qty and Rejected Qty can't be zero at the same time." -msgstr "" +msgstr "Zeile {0}: Die akzeptierte Menge und die abgelehnte Menge können nicht gleichzeitig Null sein." #: accounts/doctype/journal_entry/journal_entry.py:509 msgid "Row {0}: Account {1} and Party Type {2} have different account types" @@ -60815,7 +60815,7 @@ msgstr "" #: controllers/accounts_controller.py:2536 msgid "Row {0}: Account {1} is a Group Account" -msgstr "" +msgstr "Zeile {0}: Konto {1} ist eine Kontogruppe" #: projects/doctype/timesheet/timesheet.py:117 msgid "Row {0}: Activity Type is mandatory." @@ -60851,7 +60851,7 @@ msgstr "Zeile {0}: Umrechnungsfaktor ist zwingend erfoderlich" #: controllers/accounts_controller.py:2549 msgid "Row {0}: Cost Center {1} does not belong to Company {2}" -msgstr "" +msgstr "Zeile {0}: Die Kostenstelle {1} gehört nicht zum Unternehmen {2}" #: stock/doctype/landed_cost_voucher/landed_cost_voucher.py:116 msgid "Row {0}: Cost center is required for an item {1}" @@ -60945,11 +60945,11 @@ msgstr "" #: controllers/buying_controller.py:400 controllers/selling_controller.py:479 msgid "Row {0}: Item rate has been updated as per valuation rate since its an internal stock transfer" -msgstr "" +msgstr "Zeile {0}: Der Einzelpreis wurde gemäß dem Bewertungskurs aktualisiert, da es sich um eine interne Umlagerung handelt" #: controllers/subcontracting_controller.py:98 msgid "Row {0}: Item {1} must be a stock item." -msgstr "" +msgstr "Zeile {0}: Artikel {1} muss ein Lagerartikel sein." #: controllers/subcontracting_controller.py:103 msgid "Row {0}: Item {1} must be a subcontracted item." @@ -60961,7 +60961,7 @@ msgstr "" #: stock/doctype/packing_slip/packing_slip.py:148 msgid "Row {0}: Packing Slip is already created for Item {1}." -msgstr "" +msgstr "Zeile {0}: Für den Artikel {1} wurde bereits ein Packzettel erstellt." #: accounts/doctype/journal_entry/journal_entry.py:687 msgid "Row {0}: Party / Account does not match with {1} / {2} in {3} {4}" @@ -60989,15 +60989,15 @@ msgstr "" #: controllers/subcontracting_controller.py:118 msgid "Row {0}: Please select a BOM for Item {1}." -msgstr "" +msgstr "Zeile {0}: Bitte wählen Sie eine Stückliste für Artikel {1}." #: controllers/subcontracting_controller.py:111 msgid "Row {0}: Please select an active BOM for Item {1}." -msgstr "" +msgstr "Zeile {0}: Bitte wählen Sie eine aktive Stückliste für Artikel {1}." #: controllers/subcontracting_controller.py:115 msgid "Row {0}: Please select an valid BOM for Item {1}." -msgstr "" +msgstr "Zeile {0}: Bitte wählen Sie eine gültige Stückliste für Artikel {1}." #: regional/italy/utils.py:310 msgid "Row {0}: Please set at Tax Exemption Reason in Sales Taxes and Charges" @@ -62734,7 +62734,7 @@ msgstr "Barcode scannen" #: public/js/utils/serial_no_batch_selector.js:151 msgid "Scan Batch No" -msgstr "" +msgstr "Chargennummer scannen" #. Label of a Check field in DocType 'Pick List' #: stock/doctype/pick_list/pick_list.json @@ -62750,15 +62750,15 @@ msgstr "Scan-Modus" #: public/js/utils/serial_no_batch_selector.js:136 msgid "Scan Serial No" -msgstr "" +msgstr "Seriennummer scannen" #: public/js/utils/barcode_scanner.js:172 msgid "Scan barcode for item {0}" -msgstr "" +msgstr "Barcode für Artikel {0} scannen" #: stock/doctype/stock_reconciliation/stock_reconciliation.js:94 msgid "Scan mode enabled, existing quantity will not be fetched." -msgstr "" +msgstr "Scanmodus aktiviert, vorhandene Menge wird nicht abgerufen." #. Label of a Attach field in DocType 'Cheque Print Template' #: accounts/doctype/cheque_print_template/cheque_print_template.json @@ -62768,7 +62768,7 @@ msgstr "Gescannte Scheck" #: public/js/utils/barcode_scanner.js:238 msgid "Scanned Quantity" -msgstr "" +msgstr "Gescannte Menge" #. Label of a Section Break field in DocType 'Maintenance Schedule' #: maintenance/doctype/maintenance_schedule/maintenance_schedule.json @@ -62837,7 +62837,7 @@ msgstr "Geplante Zeit" #: manufacturing/doctype/job_card/job_card.json msgctxt "Job Card" msgid "Scheduled Time Logs" -msgstr "" +msgstr "Geplante Zeitprotokolle" #: accounts/doctype/bank_statement_import/bank_statement_import.py:84 #: accounts/doctype/ledger_merge/ledger_merge.py:39 @@ -63269,7 +63269,7 @@ msgstr "Ansicht auswählen" #: public/js/bank_reconciliation_tool/dialog_manager.js:248 msgid "Select Vouchers to Match" -msgstr "" +msgstr "Passende Belege auswählen" #: public/js/stock_analytics.js:46 msgid "Select Warehouse..." @@ -63289,7 +63289,7 @@ msgstr "Wählen Sie ein Unternehmen, zu dem dieser Mitarbeiter gehört." #: buying/doctype/supplier/supplier.js:160 msgid "Select a Customer" -msgstr "" +msgstr "Wählen Sie einen Kunden" #: support/doctype/service_level_agreement/service_level_agreement.py:111 msgid "Select a Default Priority." @@ -63309,7 +63309,7 @@ msgstr "Wählen Sie eine Firma aus" #: stock/doctype/item/item.js:809 msgid "Select an Item Group." -msgstr "" +msgstr "Wählen Sie eine Artikelgruppe." #: accounts/report/general_ledger/general_ledger.py:31 msgid "Select an account to print in account currency" @@ -63358,16 +63358,16 @@ msgstr "" #: manufacturing/doctype/work_order/work_order.js:807 msgid "Select the Item to be manufactured." -msgstr "" +msgstr "Wählen Sie den Artikel, der hergestellt werden soll." #: manufacturing/doctype/bom/bom.js:725 msgid "Select the Item to be manufactured. The Item name, UoM, Company, and Currency will be fetched automatically." -msgstr "" +msgstr "Wählen Sie den Artikel, der hergestellt werden soll. Der Name des Artikels, die ME, das Unternehmen und die Währung werden automatisch abgerufen." #: manufacturing/doctype/production_plan/production_plan.js:294 #: manufacturing/doctype/production_plan/production_plan.js:305 msgid "Select the Warehouse" -msgstr "" +msgstr "Wählen Sie das Lager aus" #: accounts/doctype/bank_guarantee/bank_guarantee.py:47 msgid "Select the customer or supplier." @@ -63375,11 +63375,11 @@ msgstr "Wählen Sie den Kunden oder den Lieferanten aus." #: www/book_appointment/index.html:16 msgid "Select the date and your timezone" -msgstr "" +msgstr "Wählen Sie das Datum und Ihre Zeitzone" #: manufacturing/doctype/bom/bom.js:740 msgid "Select the raw materials (Items) required to manufacture the Item" -msgstr "" +msgstr "Wählen Sie die Rohstoffe (Artikel) aus, die zur Herstellung des Artikels benötigt werden" #: manufacturing/doctype/bom/bom.js:338 msgid "Select variant item code for the template item {0}" @@ -63546,13 +63546,13 @@ msgstr "Senden nach (Tage)" #: buying/doctype/request_for_quotation/request_for_quotation.json msgctxt "Request for Quotation" msgid "Send Attached Files" -msgstr "" +msgstr "Angehängte Dateien senden" #. Label of a Check field in DocType 'Request for Quotation' #: buying/doctype/request_for_quotation/request_for_quotation.json msgctxt "Request for Quotation" msgid "Send Document Print" -msgstr "" +msgstr "Ausdruck der Anfrage senden" #. Label of a Check field in DocType 'Request for Quotation Supplier' #: buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.json @@ -63562,7 +63562,7 @@ msgstr "E-Mail absenden" #: accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.js:11 msgid "Send Emails" -msgstr "" +msgstr "E-Mails senden" #: buying/doctype/request_for_quotation/request_for_quotation.js:46 msgid "Send Emails to Suppliers" @@ -63661,19 +63661,19 @@ msgstr "Sequenz-ID" #: telephony/doctype/incoming_call_settings/incoming_call_settings.json msgctxt "Incoming Call Settings" msgid "Sequential" -msgstr "" +msgstr "Sequentiell" #. Label of a Tab Break field in DocType 'Stock Settings' #: stock/doctype/stock_settings/stock_settings.json msgctxt "Stock Settings" msgid "Serial & Batch Item" -msgstr "" +msgstr "Serien- und Chargenartikel" #. Label of a Section Break field in DocType 'Stock Settings' #: stock/doctype/stock_settings/stock_settings.json msgctxt "Stock Settings" msgid "Serial & Batch Item Settings" -msgstr "" +msgstr "Einstellungen für Serien- und Chargenartikel" #. Label of a Link field in DocType 'Stock Reconciliation Item' #: stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json @@ -63695,7 +63695,7 @@ msgstr "" #: stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.json msgctxt "Serial and Batch Bundle" msgid "Serial / Batch No" -msgstr "" +msgstr "Serien-/Chargennr" #: public/js/utils.js:124 msgid "Serial / Batch Nos" @@ -63979,16 +63979,16 @@ msgstr "Seriennummer: {0} wurde bereits in eine andere POS-Rechnung übertragen. #: public/js/utils/serial_no_batch_selector.js:178 #: stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js:48 msgid "Serial Nos" -msgstr "" +msgstr "Seriennummern" #: public/js/utils/serial_no_batch_selector.js:20 #: public/js/utils/serial_no_batch_selector.js:183 msgid "Serial Nos / Batch Nos" -msgstr "" +msgstr "Serien-/Chargennummern" #: accounts/doctype/sales_invoice/sales_invoice.py:1692 msgid "Serial Nos Mismatch" -msgstr "" +msgstr "Seriennummern stimmen nicht überein" #. Label of a Section Break field in DocType 'Item' #: stock/doctype/item/item.json @@ -63998,11 +63998,11 @@ msgstr "Seriennummern und Chargen" #: stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py:1074 msgid "Serial Nos are created successfully" -msgstr "" +msgstr "Seriennummern wurden erfolgreich erstellt" #: stock/stock_ledger.py:1972 msgid "Serial Nos are reserved in Stock Reservation Entries, you need to unreserve them before proceeding." -msgstr "" +msgstr "Seriennummern sind bereits reserviert. Sie müssen die Reservierung aufheben, bevor Sie fortfahren." #. Label of a Data field in DocType 'Item' #: stock/doctype/item/item.json @@ -64762,7 +64762,7 @@ msgstr "Grundpreis manuell einstellen" #: buying/report/supplier_quotation_comparison/supplier_quotation_comparison.js:150 msgid "Set Default Supplier" -msgstr "" +msgstr "Standard-Lieferant festlegen" #. Label of a Button field in DocType 'Payment Entry' #: accounts/doctype/payment_entry/payment_entry.json @@ -64835,7 +64835,7 @@ msgstr "" #: projects/doctype/project/project.js:118 #: projects/doctype/project/project.js:132 msgid "Set Project Status" -msgstr "" +msgstr "Projektstatus festlegen" #: projects/doctype/project/project.js:154 msgid "Set Project and all Tasks to status {0}?" @@ -64923,7 +64923,7 @@ msgstr "" #: selling/doctype/sales_order/sales_order.js:184 msgid "Set Warehouse" -msgstr "" +msgstr "Lager festlegen" #: crm/doctype/opportunity/opportunity_list.js:17 #: support/doctype/issue/issue_list.js:12 diff --git a/erpnext/locale/fa.po b/erpnext/locale/fa.po index 99fd881f3e6..9c062efdc61 100644 --- a/erpnext/locale/fa.po +++ b/erpnext/locale/fa.po @@ -1,20 +1,22 @@ -# Translations template for ERPNext. -# Copyright (C) 2024 Frappe Technologies Pvt. Ltd. -# This file is distributed under the same license as the ERPNext project. -# FIRST AUTHOR , 2024. -# msgid "" msgstr "" -"Project-Id-Version: ERPNext VERSION\n" +"Project-Id-Version: frappe\n" "Report-Msgid-Bugs-To: info@erpnext.com\n" "POT-Creation-Date: 2024-01-29 18:13+0053\n" -"PO-Revision-Date: 2024-01-29 18:13+0053\n" +"PO-Revision-Date: 2024-03-04 11:36\n" "Last-Translator: info@erpnext.com\n" -"Language-Team: info@erpnext.com\n" +"Language-Team: Persian\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.13.1\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Crowdin-Project: frappe\n" +"X-Crowdin-Project-ID: 639578\n" +"X-Crowdin-Language: fa\n" +"X-Crowdin-File: /[frappe.erpnext] develop/erpnext/locale/main.pot\n" +"X-Crowdin-File-ID: 46\n" +"Language: fa_IR\n" #: accounts/doctype/process_statement_of_accounts/process_statement_of_accounts_accounts_receivable.html:85 msgid " " @@ -48,7 +50,7 @@ msgstr " نام" #: public/js/bom_configurator/bom_configurator.bundle.js:108 msgid " Qty" -msgstr " تعداد" +msgstr " مقدار" #: accounts/report/item_wise_sales_register/item_wise_sales_register.py:603 msgid " Rate" @@ -61,7 +63,7 @@ msgstr " ماده خام" #: public/js/bom_configurator/bom_configurator.bundle.js:127 #: public/js/bom_configurator/bom_configurator.bundle.js:157 msgid " Sub Assembly" -msgstr " مجمع فرعی" +msgstr " زیر مونتاژ" #: projects/doctype/project_update/project_update.py:110 msgid " Summary" @@ -69,114 +71,93 @@ msgstr " خلاصه" #: stock/doctype/item/item.py:235 msgid "\"Customer Provided Item\" cannot be Purchase Item also" -msgstr "" +msgstr "\"مورد ارائه شده توسط مشتری\" نمی تواند مورد خرید هم باشد" #: stock/doctype/item/item.py:237 msgid "\"Customer Provided Item\" cannot have Valuation Rate" -msgstr "" +msgstr "\"مورد ارائه شده توسط مشتری\" نمی تواند دارای نرخ ارزیابی باشد" #: stock/doctype/item/item.py:313 msgid "\"Is Fixed Asset\" cannot be unchecked, as Asset record exists against the item" -msgstr "" +msgstr "علامت \"دارایی ثابت است\" را نمی توان بردارید، زیرا سابقه دارایی در برابر آیتم وجود دارد" #. Description of the Onboarding Step 'Accounts Settings' #: accounts/onboarding_step/accounts_settings/accounts_settings.json -msgid "" -"# Account Settings\n" -"\n" -"In ERPNext, Accounting features are configurable as per your business needs. Accounts Settings is the place to define some of your accounting preferences like:\n" -"\n" +msgid "# Account Settings\n\n" +"In ERPNext, Accounting features are configurable as per your business needs. Accounts Settings is the place to define some of your accounting preferences like:\n\n" " - Credit Limit and over billing settings\n" " - Taxation preferences\n" " - Deferred accounting preferences\n" -msgstr "" +msgstr "# تنظیمات حساب\n\n" +"در ERPNext، ویژگی های حسابداری بر اساس نیازهای کسب و کار شما قابل تنظیم هستند. تنظیمات حساب‌ها مکانی برای تعریف برخی از اولویت‌های حسابداری شما است مانند:\n\n" +" - محدودیت اعتبار و تنظیمات بیش از صورتحساب\n" +" - اولویت‌های مالیاتی\n" +" - اولویت‌های حسابداری معوق\n" #. Description of the Onboarding Step 'Configure Account Settings' #: accounts/onboarding_step/configure_account_settings/configure_account_settings.json -msgid "" -"# Account Settings\n" -"\n" -"This is a crucial piece of configuration. There are various account settings in ERPNext to restrict and configure actions in the Accounting module.\n" -"\n" -"The following settings are avaialble for you to configure\n" -"\n" +msgid "# Account Settings\n\n" +"This is a crucial piece of configuration. There are various account settings in ERPNext to restrict and configure actions in the Accounting module.\n\n" +"The following settings are avaialble for you to configure\n\n" "1. Account Freezing \n" "2. Credit and Overbilling\n" "3. Invoicing and Tax Automations\n" -"4. Balance Sheet configurations\n" -"\n" +"4. Balance Sheet configurations\n\n" "There's much more, you can check it all out in this step" msgstr "" #. Description of the Onboarding Step 'Add an Existing Asset' #: assets/onboarding_step/existing_asset/existing_asset.json -msgid "" -"# Add an Existing Asset\n" -"\n" +msgid "# Add an Existing Asset\n\n" "If you are just starting with ERPNext, you will need to enter Assets you already possess. You can add them as existing fixed assets in ERPNext. Please note that you will have to make a Journal Entry separately updating the opening balance in the fixed asset account." msgstr "" #. Description of the Onboarding Step 'Create Your First Sales Invoice ' #: setup/onboarding_step/create_your_first_sales_invoice/create_your_first_sales_invoice.json -msgid "" -"# All about sales invoice\n" -"\n" +msgid "# All about sales invoice\n\n" "A Sales Invoice is a bill that you send to your Customers against which the Customer makes the payment. Sales Invoice is an accounting transaction. On submission of Sales Invoice, the system updates the receivable and books income against a Customer Account." msgstr "" #. Description of the Onboarding Step 'Create Your First Sales Invoice ' #: accounts/onboarding_step/create_your_first_sales_invoice/create_your_first_sales_invoice.json -msgid "" -"# All about sales invoice\n" -"\n" -"A Sales Invoice is a bill that you send to your Customers against which the Customer makes the payment. Sales Invoice is an accounting transaction. On submission of Sales Invoice, the system updates the receivable and books income against a Customer Account.\n" -"\n" -"Here's the flow of how a sales invoice is generally created\n" -"\n" -"\n" +msgid "# All about sales invoice\n\n" +"A Sales Invoice is a bill that you send to your Customers against which the Customer makes the payment. Sales Invoice is an accounting transaction. On submission of Sales Invoice, the system updates the receivable and books income against a Customer Account.\n\n" +"Here's the flow of how a sales invoice is generally created\n\n\n" "![Sales Flow](https://docs.erpnext.com/docs/assets/img/accounts/so-flow.png)" msgstr "" #. Description of the Onboarding Step 'Define Asset Category' #: assets/onboarding_step/asset_category/asset_category.json -msgid "" -"# Asset Category\n" -"\n" -"An Asset Category classifies different assets of a Company.\n" -"\n" +msgid "# Asset Category\n\n" +"An Asset Category classifies different assets of a Company.\n\n" "You can create an Asset Category based on the type of assets. For example, all your desktops and laptops can be part of an Asset Category named \"Electronic Equipment\". Create a separate category for furniture. Also, you can update default properties for each category, like:\n" " - Depreciation type and duration\n" " - Fixed asset account\n" " - Depreciation account\n" -msgstr "" +msgstr "# دسته دارایی\n\n" +"یک دسته دارایی دارایی های مختلف یک شرکت را طبقه بندی می کند.\n\n" +"شما می توانید یک دسته دارایی بر اساس نوع دارایی ایجاد کنید. به عنوان مثال، تمام رایانه های رومیزی و لپ تاپ های شما می توانند بخشی از یک دسته دارایی به نام «تجهیزات الکترونیکی» باشند. یک دسته بندی جداگانه برای مبلمان ایجاد کنید. همچنین، می‌توانید ویژگی‌های پیش‌فرض را برای هر دسته به‌روزرسانی کنید، مانند:\n" +" - نوع و مدت استهلاک\n" +" - حساب دارایی ثابت\n" +" - حساب استهلاک\n" #. Description of the Onboarding Step 'Create an Asset Item' #: assets/onboarding_step/asset_item/asset_item.json -msgid "" -"# Asset Item\n" -"\n" +msgid "# Asset Item\n\n" "Asset items are created based on Asset Category. You can create one or multiple items against once Asset Category. The sales and purchase transaction for Asset is done via Asset Item. " msgstr "" #. Description of the Onboarding Step 'Buying Settings' #: buying/onboarding_step/introduction_to_buying/introduction_to_buying.json -msgid "" -"# Buying Settings\n" -"\n" -"\n" -"Buying module’s features are highly configurable as per your business needs. Buying Settings is the place where you can set your preferences for:\n" -"\n" +msgid "# Buying Settings\n\n\n" +"Buying module’s features are highly configurable as per your business needs. Buying Settings is the place where you can set your preferences for:\n\n" "- Supplier naming and default values\n" -"- Billing and shipping preference in buying transactions\n" -"\n" -"\n" +"- Billing and shipping preference in buying transactions\n\n\n" msgstr "" #. Description of the Onboarding Step 'CRM Settings' #: crm/onboarding_step/crm_settings/crm_settings.json -msgid "" -"# CRM Settings\n" -"\n" +msgid "# CRM Settings\n\n" "CRM module’s features are configurable as per your business needs. CRM Settings is the place where you can set your preferences for:\n" "- Campaign\n" "- Lead\n" @@ -186,9 +167,7 @@ msgstr "" #. Description of the Onboarding Step 'Review Chart of Accounts' #: accounts/onboarding_step/chart_of_accounts/chart_of_accounts.json -msgid "" -"# Chart Of Accounts\n" -"\n" +msgid "# Chart Of Accounts\n\n" "ERPNext sets up a simple chart of accounts for each Company you create, but you can modify it according to business and legal requirements." msgstr "" @@ -196,62 +175,46 @@ msgstr "" #. Description of the Onboarding Step 'Check Stock Projected Qty' #: stock/onboarding_step/check_stock_ledger_report/check_stock_ledger_report.json #: stock/onboarding_step/view_stock_projected_qty/view_stock_projected_qty.json -msgid "" -"# Check Stock Reports\n" +msgid "# Check Stock Reports\n" "Based on the various stock transactions, you can get a host of one-click Stock Reports in ERPNext like Stock Ledger, Stock Balance, Projected Quantity, and Ageing analysis." msgstr "" #. Description of the Onboarding Step 'Cost Centers for Budgeting and Analysis' #: accounts/onboarding_step/cost_centers_for_report_and_budgeting/cost_centers_for_report_and_budgeting.json -msgid "" -"# Cost Centers for Budgeting and Analysis\n" -"\n" -"While your Books of Accounts are framed to fulfill statutory requirements, you can set up Cost Center and Accounting Dimensions to address your companies reporting and budgeting requirements.\n" -"\n" +msgid "# Cost Centers for Budgeting and Analysis\n\n" +"While your Books of Accounts are framed to fulfill statutory requirements, you can set up Cost Center and Accounting Dimensions to address your companies reporting and budgeting requirements.\n\n" "Click here to learn more about how [Cost Center](https://docs.erpnext.com/docs/v13/user/manual/en/accounts/cost-center) and [Dimensions](https://docs.erpnext.com/docs/v13/user/manual/en/accounts/accounting-dimensions) allow you to get advanced financial analytics reports from ERPNext." msgstr "" #. Description of the Onboarding Step 'Finished Items' #: manufacturing/onboarding_step/create_product/create_product.json -msgid "" -"# Create Items for Bill of Materials\n" -"\n" +msgid "# Create Items for Bill of Materials\n\n" "One of the prerequisites of a BOM is the creation of raw materials, sub-assembly, and finished items. Once these items are created, you will be able to proceed to the Bill of Materials master, which is composed of items and routing.\n" msgstr "" #. Description of the Onboarding Step 'Operation' #: manufacturing/onboarding_step/operation/operation.json -msgid "" -"# Create Operations\n" -"\n" +msgid "# Create Operations\n\n" "An Operation refers to any manufacturing operation performed on the raw materials to process it further in the manufacturing path. As an example, if you are into garments manufacturing, you will create Operations like fabric cutting, stitching, and washing as some of the operations." msgstr "" #. Description of the Onboarding Step 'Workstation' #: manufacturing/onboarding_step/workstation/workstation.json -msgid "" -"# Create Workstations\n" -"\n" +msgid "# Create Workstations\n\n" "A Workstation stores information regarding the place where the workstation operations are performed. As an example, if you have ten sewing machines doing stitching jobs, each machine will be added as a workstation." msgstr "" #. Description of the Onboarding Step 'Bill of Materials' #: manufacturing/onboarding_step/create_bom/create_bom.json -msgid "" -"# Create a Bill of Materials\n" -"\n" -"A Bill of Materials (BOM) is a list of items and sub-assemblies with quantities required to manufacture an Item.\n" -"\n" +msgid "# Create a Bill of Materials\n\n" +"A Bill of Materials (BOM) is a list of items and sub-assemblies with quantities required to manufacture an Item.\n\n" "BOM also provides cost estimation for the production of the item. It takes raw-materials cost based on valuation and operations to cost based on routing, which gives total costing for a BOM." msgstr "" #. Description of the Onboarding Step 'Create a Customer' #: setup/onboarding_step/create_a_customer/create_a_customer.json -msgid "" -"# Create a Customer\n" -"\n" -"The Customer master is at the heart of your sales transactions. Customers are linked in Quotations, Sales Orders, Invoices, and Payments. Customers can be either numbered or identified by name (you would typically do this based on the number of customers you have).\n" -"\n" +msgid "# Create a Customer\n\n" +"The Customer master is at the heart of your sales transactions. Customers are linked in Quotations, Sales Orders, Invoices, and Payments. Customers can be either numbered or identified by name (you would typically do this based on the number of customers you have).\n\n" "Through Customer’s master, you can effectively track essentials like:\n" " - Customer’s multiple address and contacts\n" " - Account Receivables\n" @@ -260,27 +223,20 @@ msgstr "" #. Description of the Onboarding Step 'Setup Your Letterhead' #: setup/onboarding_step/letterhead/letterhead.json -msgid "" -"# Create a Letter Head\n" -"\n" +msgid "# Create a Letter Head\n\n" "A Letter Head contains your organization's name, logo, address, etc which appears at the header and footer portion in documents. You can learn more about Setting up Letter Head in ERPNext here.\n" msgstr "" #. Description of the Onboarding Step 'Create your first Quotation' #: setup/onboarding_step/create_a_quotation/create_a_quotation.json -msgid "" -"# Create a Quotation\n" -"\n" +msgid "# Create a Quotation\n\n" "Let’s get started with business transactions by creating your first Quotation. You can create a Quotation for an existing customer or a prospect. It will be an approved document, with items you sell and the proposed price + taxes applied. After completing the instructions, you will get a Quotation in a ready to share print format." msgstr "" #. Description of the Onboarding Step 'Create a Supplier' #: setup/onboarding_step/create_a_supplier/create_a_supplier.json -msgid "" -"# Create a Supplier\n" -"\n" -"Also known as Vendor, is a master at the center of your purchase transactions. Suppliers are linked in Request for Quotation, Purchase Orders, Receipts, and Payments. Suppliers can be either numbered or identified by name.\n" -"\n" +msgid "# Create a Supplier\n\n" +"Also known as Vendor, is a master at the center of your purchase transactions. Suppliers are linked in Request for Quotation, Purchase Orders, Receipts, and Payments. Suppliers can be either numbered or identified by name.\n\n" "Through Supplier’s master, you can effectively track essentials like:\n" " - Supplier’s multiple address and contacts\n" " - Account Receivables\n" @@ -289,20 +245,15 @@ msgstr "" #. Description of the Onboarding Step 'Create a Supplier' #: stock/onboarding_step/create_a_supplier/create_a_supplier.json -msgid "" -"# Create a Supplier\n" +msgid "# Create a Supplier\n" "In this step we will create a **Supplier**. If you have already created a **Supplier** you can skip this step." msgstr "" #. Description of the Onboarding Step 'Work Order' #: manufacturing/onboarding_step/work_order/work_order.json -msgid "" -"# Create a Work Order\n" -"\n" -"A Work Order or a Job order is given to the manufacturing shop floor by the Production Manager to initiate the manufacturing of a certain quantity of an item. Work Order carriers details of production Item, its BOM, quantities to be manufactured, and operations.\n" -"\n" -"Through Work Order, you can track various production status like:\n" -"\n" +msgid "# Create a Work Order\n\n" +"A Work Order or a Job order is given to the manufacturing shop floor by the Production Manager to initiate the manufacturing of a certain quantity of an item. Work Order carriers details of production Item, its BOM, quantities to be manufactured, and operations.\n\n" +"Through Work Order, you can track various production status like:\n\n" "- Issue of raw-material to shop material\n" "- Progress on each Workstation via Job Card\n" "- Manufactured Quantity against Work Order\n" @@ -310,57 +261,41 @@ msgstr "" #. Description of the Onboarding Step 'Create an Item' #: setup/onboarding_step/create_an_item/create_an_item.json -msgid "" -"# Create an Item\n" -"\n" -"Item is a product or a service offered by your company, or something you buy as a part of your supplies or raw materials.\n" -"\n" +msgid "# Create an Item\n\n" +"Item is a product or a service offered by your company, or something you buy as a part of your supplies or raw materials.\n\n" "Items are integral to everything you do in ERPNext - from billing, purchasing to managing inventory. Everything you buy or sell, whether it is a physical product or a service is an Item. Items can be stock, non-stock, variants, serialized, batched, assets, etc.\n" msgstr "" #. Description of the Onboarding Step 'Create an Item' #: stock/onboarding_step/create_an_item/create_an_item.json -msgid "" -"# Create an Item\n" -"The Stock module deals with the movement of items.\n" -"\n" +msgid "# Create an Item\n" +"The Stock module deals with the movement of items.\n\n" "In this step we will create an [**Item**](https://docs.erpnext.com/docs/user/manual/en/stock/item)." msgstr "" #. Description of the Onboarding Step 'Create first Purchase Order' #: buying/onboarding_step/create_your_first_purchase_order/create_your_first_purchase_order.json -msgid "" -"# Create first Purchase Order\n" -"\n" -"Purchase Order is at the heart of your buying transactions. In ERPNext, Purchase Order can can be created against a Purchase Material Request (indent) and Supplier Quotation as well. Purchase Orders is also linked to Purchase Receipt and Purchase Invoices, allowing you to keep a birds-eye view on your purchase deals.\n" -"\n" +msgid "# Create first Purchase Order\n\n" +"Purchase Order is at the heart of your buying transactions. In ERPNext, Purchase Order can can be created against a Purchase Material Request (indent) and Supplier Quotation as well. Purchase Orders is also linked to Purchase Receipt and Purchase Invoices, allowing you to keep a birds-eye view on your purchase deals.\n\n" msgstr "" #. Description of the Onboarding Step 'Create Your First Purchase Invoice ' #: accounts/onboarding_step/create_your_first_purchase_invoice/create_your_first_purchase_invoice.json -msgid "" -"# Create your first Purchase Invoice\n" -"\n" -"A Purchase Invoice is a bill received from a Supplier for a product(s) or service(s) delivery to your company. You can track payables through Purchase Invoice and process Payment Entries against it.\n" -"\n" +msgid "# Create your first Purchase Invoice\n\n" +"A Purchase Invoice is a bill received from a Supplier for a product(s) or service(s) delivery to your company. You can track payables through Purchase Invoice and process Payment Entries against it.\n\n" "Purchase Invoices can also be created against a Purchase Order or Purchase Receipt." msgstr "" #. Description of the Onboarding Step 'Financial Statements' #: accounts/onboarding_step/financial_statements/financial_statements.json -msgid "" -"# Financial Statements\n" -"\n" -"In ERPNext, you can get crucial financial reports like [Balance Sheet] and [Profit and Loss] statements with a click of a button. You can run in the report for a different period and plot analytics charts premised on statement data. For more reports, check sections like Financial Statements, General Ledger, and Profitability reports.\n" -"\n" +msgid "# Financial Statements\n\n" +"In ERPNext, you can get crucial financial reports like [Balance Sheet] and [Profit and Loss] statements with a click of a button. You can run in the report for a different period and plot analytics charts premised on statement data. For more reports, check sections like Financial Statements, General Ledger, and Profitability reports.\n\n" "[Check Accounting reports](https://docs.erpnext.com/docs/v13/user/manual/en/accounts/accounting-reports)" msgstr "" #. Description of the Onboarding Step 'Review Fixed Asset Accounts' #: assets/onboarding_step/fixed_asset_accounts/fixed_asset_accounts.json -msgid "" -"# Fixed Asset Accounts\n" -"\n" +msgid "# Fixed Asset Accounts\n\n" "With the company, a host of fixed asset accounts are pre-configured. To ensure your asset transactions are leading to correct accounting entries, you can review and set up following asset accounts as per your business requirements.\n" " - Fixed asset accounts (Asset account)\n" " - Accumulated depreciation\n" @@ -370,67 +305,54 @@ msgstr "" #. Description of the Onboarding Step 'Production Planning' #: manufacturing/onboarding_step/production_planning/production_planning.json -msgid "" -"# How Production Planning Works\n" -"\n" +msgid "# How Production Planning Works\n\n" "Production Plan helps in production and material planning for the Items planned for manufacturing. These production items can be committed via Sales Order (to Customers) or Material Requests (internally).\n" -msgstr "" +msgstr "# برنامه ریزی تولید چگونه کار می کند\n\n" +"برنامه تولید به برنامه ریزی تولید و مواد برای آیتم‌های برنامه ریزی شده برای ساخت کمک می کند. این آیتم‌های تولیدی را می توان از طریق سفارش فروش (به مشتریان) یا درخواست مواد (داخلی) متعهد شد.\n" #. Description of the Onboarding Step 'Import Data from Spreadsheet' #: setup/onboarding_step/data_import/data_import.json -msgid "" -"# Import Data from Spreadsheet\n" -"\n" +msgid "# Import Data from Spreadsheet\n\n" "In ERPNext, you can easily migrate your historical data using spreadsheets. You can use it for migrating not just masters (like Customer, Supplier, Items), but also for transactions like (outstanding invoices, opening stock and accounting entries, etc)." msgstr "" #: manufacturing/report/work_order_stock_report/work_order_stock_report.py:148 msgid "# In Stock" -msgstr "# در انبار" +msgstr "# در موجودی" #. Description of the Onboarding Step 'Introduction to Stock Entry' #: stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json -msgid "" -"# Introduction to Stock Entry\n" +msgid "# Introduction to Stock Entry\n" "This video will give a quick introduction to [**Stock Entry**](https://docs.erpnext.com/docs/user/manual/en/stock/stock-entry)." msgstr "" #. Description of the Onboarding Step 'Manage Stock Movements' #: stock/onboarding_step/create_a_stock_entry/create_a_stock_entry.json -msgid "" -"# Manage Stock Movements\n" -"Stock entry allows you to register the movement of stock for various purposes like transfer, received, issues, repacked, etc. To address issues related to theft and pilferages, you can always ensure that the movement of goods happens against a document reference Stock Entry in ERPNext.\n" -"\n" +msgid "# Manage Stock Movements\n" +"Stock entry allows you to register the movement of stock for various purposes like transfer, received, issues, repacked, etc. To address issues related to theft and pilferages, you can always ensure that the movement of goods happens against a document reference Stock Entry in ERPNext.\n\n" "Let’s get a quick walk-through on the various scenarios covered in Stock Entry by watching [*this video*](https://www.youtube.com/watch?v=Njt107hlY3I)." msgstr "" #. Description of the Onboarding Step 'How to Navigate in ERPNext' #: setup/onboarding_step/navigation_help/navigation_help.json -msgid "" -"# Navigation in ERPNext\n" -"\n" +msgid "# Navigation in ERPNext\n\n" "Ease of navigating and browsing around the ERPNext is one of our core strengths. In the following video, you will learn how to reach a specific feature in ERPNext via module page or AwesomeBar." msgstr "" #. Description of the Onboarding Step 'Purchase an Asset' #: assets/onboarding_step/asset_purchase/asset_purchase.json -msgid "" -"# Purchase an Asset\n" -"\n" +msgid "# Purchase an Asset\n\n" "Assets purchases process if done following the standard Purchase cycle. If capital work in progress is enabled in Asset Category, Asset will be created as soon as Purchase Receipt is created for it. You can quickly create a Purchase Receipt for Asset and see its impact on books of accounts." msgstr "" #: manufacturing/report/work_order_stock_report/work_order_stock_report.py:141 msgid "# Req'd Items" -msgstr "# موارد درخواست شده" +msgstr "# آیتم‌های درخواست شده" #. Description of the Onboarding Step 'Manufacturing Settings' #: manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json -msgid "" -"# Review Manufacturing Settings\n" -"\n" -"In ERPNext, the Manufacturing module’s features are configurable as per your business needs. Manufacturing Settings is the place where you can set your preferences for:\n" -"\n" +msgid "# Review Manufacturing Settings\n\n" +"In ERPNext, the Manufacturing module’s features are configurable as per your business needs. Manufacturing Settings is the place where you can set your preferences for:\n\n" "- Capacity planning for allocating jobs to workstations\n" "- Raw-material consumption based on BOM or actual\n" "- Default values and over-production allowance\n" @@ -438,9 +360,7 @@ msgstr "" #. Description of the Onboarding Step 'Review Stock Settings' #: stock/onboarding_step/stock_settings/stock_settings.json -msgid "" -"# Review Stock Settings\n" -"\n" +msgid "# Review Stock Settings\n\n" "In ERPNext, the Stock module’s features are configurable as per your business needs. Stock Settings is the place where you can set your preferences for:\n" "- Default values for Item and Pricing\n" "- Default valuation method for inventory valuation\n" @@ -450,19 +370,14 @@ msgstr "" #. Description of the Onboarding Step 'Sales Order' #: selling/onboarding_step/sales_order/sales_order.json -msgid "" -"# Sales Order\n" -"\n" -"A Sales Order is a confirmation of an order from your customer. It is also referred to as Proforma Invoice.\n" -"\n" +msgid "# Sales Order\n\n" +"A Sales Order is a confirmation of an order from your customer. It is also referred to as Proforma Invoice.\n\n" "Sales Order at the heart of your sales and purchase transactions. Sales Orders are linked in Delivery Note, Sales Invoices, Material Request, and Maintenance transactions. Through Sales Order, you can track fulfillment of the overall deal towards the customer." msgstr "" #. Description of the Onboarding Step 'Selling Settings' #: selling/onboarding_step/selling_settings/selling_settings.json -msgid "" -"# Selling Settings\n" -"\n" +msgid "# Selling Settings\n\n" "CRM and Selling module’s features are configurable as per your business needs. Selling Settings is the place where you can set your preferences for:\n" " - Customer naming and default values\n" " - Billing and shipping preference in sales transactions\n" @@ -470,109 +385,78 @@ msgstr "" #. Description of the Onboarding Step 'Set Up a Company' #: setup/onboarding_step/company_set_up/company_set_up.json -msgid "" -"# Set Up a Company\n" -"\n" -"A company is a legal entity for which you will set up your books of account and create accounting transactions. In ERPNext, you can create multiple companies, and establish relationships (group/subsidiary) among them.\n" -"\n" +msgid "# Set Up a Company\n\n" +"A company is a legal entity for which you will set up your books of account and create accounting transactions. In ERPNext, you can create multiple companies, and establish relationships (group/subsidiary) among them.\n\n" "Within the company master, you can capture various default accounts for that Company and set crucial settings related to the accounting methodology followed for a company.\n" msgstr "" #. Description of the Onboarding Step 'Setting up Taxes' #: accounts/onboarding_step/setup_taxes/setup_taxes.json -msgid "" -"# Setting up Taxes\n" -"\n" +msgid "# Setting up Taxes\n\n" "ERPNext lets you configure your taxes so that they are automatically applied in your buying and selling transactions. You can configure them globally or even on Items. ERPNext taxes are pre-configured for most regions." msgstr "" #. Description of the Onboarding Step 'Routing' #: manufacturing/onboarding_step/routing/routing.json -msgid "" -"# Setup Routing\n" -"\n" +msgid "# Setup Routing\n\n" "A Routing stores all Operations along with the description, hourly rate, operation time, batch size, etc. Click below to learn how the Routing template can be created, for quick selection in the BOM." msgstr "" #. Description of the Onboarding Step 'Setup a Warehouse' #: stock/onboarding_step/create_a_warehouse/create_a_warehouse.json -msgid "" -"# Setup a Warehouse\n" -"The warehouse can be your location/godown/store where you maintain the item's inventory, and receive/deliver them to various parties.\n" -"\n" +msgid "# Setup a Warehouse\n" +"The warehouse can be your location/godown/store where you maintain the item's inventory, and receive/deliver them to various parties.\n\n" "In ERPNext, you can maintain a Warehouse in the tree structure, so that location and sub-location of an item can be tracked. Also, you can link a Warehouse to a specific Accounting ledger, where the real-time stock value of that warehouse’s item will be reflected." msgstr "" #. Description of the Onboarding Step 'Track Material Request' #: buying/onboarding_step/create_a_material_request/create_a_material_request.json -msgid "" -"# Track Material Request\n" -"\n" -"\n" -"Also known as Purchase Request or an Indent, is a document identifying a requirement of a set of items (products or services) for various purposes like procurement, transfer, issue, or manufacturing. Once the Material Request is validated, a purchase manager can take the next actions for purchasing items like requesting RFQ from a supplier or directly placing an order with an identified Supplier.\n" -"\n" +msgid "# Track Material Request\n\n\n" +"Also known as Purchase Request or an Indent, is a document identifying a requirement of a set of items (products or services) for various purposes like procurement, transfer, issue, or manufacturing. Once the Material Request is validated, a purchase manager can take the next actions for purchasing items like requesting RFQ from a supplier or directly placing an order with an identified Supplier.\n\n" msgstr "" #. Description of the Onboarding Step 'Update Stock Opening Balance' #: stock/onboarding_step/stock_opening_balance/stock_opening_balance.json -msgid "" -"# Update Stock Opening Balance\n" -"It’s an entry to update the stock balance of an item, in a warehouse, on a date and time you are going live on ERPNext.\n" -"\n" +msgid "# Update Stock Opening Balance\n" +"It’s an entry to update the stock balance of an item, in a warehouse, on a date and time you are going live on ERPNext.\n\n" "Once opening stocks are updated, you can create transactions like manufacturing and stock deliveries, where this opening stock will be consumed." msgstr "" #. Description of the Onboarding Step 'Updating Opening Balances' #: accounts/onboarding_step/updating_opening_balances/updating_opening_balances.json -msgid "" -"# Updating Opening Balances\n" -"\n" +msgid "# Updating Opening Balances\n\n" "Once you close the financial statement in previous accounting software, you can update the same as opening in your ERPNext's Balance Sheet accounts. This will allow you to get complete financial statements from ERPNext in the coming years, and discontinue the parallel accounting system right away." msgstr "" #. Description of the Onboarding Step 'View Warehouses' #: stock/onboarding_step/view_warehouses/view_warehouses.json -msgid "" -"# View Warehouse\n" -"In ERPNext the term 'warehouse' can be thought of as a storage location.\n" -"\n" -"Warehouses are arranged in ERPNext in a tree like structure, where multiple sub-warehouses can be grouped under a single warehouse.\n" -"\n" +msgid "# View Warehouse\n" +"In ERPNext the term 'warehouse' can be thought of as a storage location.\n\n" +"Warehouses are arranged in ERPNext in a tree like structure, where multiple sub-warehouses can be grouped under a single warehouse.\n\n" "In this step we will view the [**Warehouse Tree**](https://docs.erpnext.com/docs/user/manual/en/stock/warehouse#21-tree-view) to view the [**Warehouses**](https://docs.erpnext.com/docs/user/manual/en/stock/warehouse) that are set by default." msgstr "" #. Description of the Onboarding Step 'Create a Sales Item' #: accounts/onboarding_step/create_a_product/create_a_product.json -msgid "" -"## Products and Services\n" -"\n" +msgid "## Products and Services\n\n" "Depending on the nature of your business, you might be selling products or services to your clients or even both. \n" -"ERPNext is optimized for itemized management of your sales and purchase.\n" -"\n" -"The **Item Master** is where you can add all your sales items. If you are in services, you can create an Item for each service that you offer. If you run a manufacturing business, the same master is used for keeping a record of raw materials, sub-assemblies etc.\n" -"\n" +"ERPNext is optimized for itemized management of your sales and purchase.\n\n" +"The **Item Master** is where you can add all your sales items. If you are in services, you can create an Item for each service that you offer. If you run a manufacturing business, the same master is used for keeping a record of raw materials, sub-assemblies etc.\n\n" "Completing the Item Master is very essential for the successful implementation of ERPNext. We have a brief video introducing the item master for you, you can watch it in the next step." msgstr "" #. Description of the Onboarding Step 'Create a Customer' #: accounts/onboarding_step/create_a_customer/create_a_customer.json -msgid "" -"## Who is a Customer?\n" -"\n" -"A customer, who is sometimes known as a client, buyer, or purchaser is the one who receives goods, services, products, or ideas, from a seller for a monetary consideration.\n" -"\n" -"Every customer needs to be assigned a unique id. Customer name itself can be the id or you can set a naming series for ids to be generated in Selling Settings.\n" -"\n" +msgid "## Who is a Customer?\n\n" +"A customer, who is sometimes known as a client, buyer, or purchaser is the one who receives goods, services, products, or ideas, from a seller for a monetary consideration.\n\n" +"Every customer needs to be assigned a unique id. Customer name itself can be the id or you can set a naming series for ids to be generated in Selling Settings.\n\n" "Just like the supplier, let's quickly create a customer." msgstr "" #. Description of the Onboarding Step 'Create a Supplier' #: accounts/onboarding_step/create_a_supplier/create_a_supplier.json -msgid "" -"## Who is a Supplier?\n" -"\n" -"Suppliers are companies or individuals who provide you with products or services. ERPNext has comprehensive features for purchase cycles. \n" -"\n" +msgid "## Who is a Supplier?\n\n" +"Suppliers are companies or individuals who provide you with products or services. ERPNext has comprehensive features for purchase cycles. \n\n" "Let's quickly create a supplier with the minimal details required. You need the name of the supplier, assign the supplier to a group, and select the type of the supplier, viz. Company or Individual." msgstr "" @@ -739,7 +623,7 @@ msgstr "بر اساس و \"گروه بر اساس\" نمی توانند یکسا #: stock/report/product_bundle_balance/product_bundle_balance.py:232 msgid "'Date' is required" -msgstr "تاریخ الزامی است" +msgstr "'تاریخ' الزامی است" #: selling/report/inactive_customers/inactive_customers.py:18 msgid "'Days Since Last Order' must be greater than or equal to zero" @@ -775,7 +659,7 @@ msgstr "'افتتاح'" #: stock/report/batch_wise_balance_history/batch_wise_balance_history.py:101 #: stock/report/stock_analytics/stock_analytics.py:326 msgid "'To Date' is required" -msgstr "تا به امروز مورد نیاز است" +msgstr "«تا تاریخ» مورد نیاز است" #: stock/doctype/packing_slip/packing_slip.py:96 msgid "'To Package No.' cannot be less than 'From Package No.'" @@ -909,19 +793,19 @@ msgstr "1 ساعت" #: crm/doctype/lead/lead.json msgctxt "Lead" msgid "1-10" -msgstr "" +msgstr "1-10" #. Option for the 'No of Employees' (Select) field in DocType 'Opportunity' #: crm/doctype/opportunity/opportunity.json msgctxt "Opportunity" msgid "1-10" -msgstr "" +msgstr "1-10" #. Option for the 'No. of Employees' (Select) field in DocType 'Prospect' #: crm/doctype/prospect/prospect.json msgctxt "Prospect" msgid "1-10" -msgstr "" +msgstr "1-10" #. Option for the 'No of Employees' (Select) field in DocType 'Lead' #: crm/doctype/lead/lead.json @@ -962,7 +846,7 @@ msgstr "" #: regional/report/uae_vat_201/uae_vat_201.py:99 #: regional/report/uae_vat_201/uae_vat_201.py:105 msgid "1{0}" -msgstr "1{0}" +msgstr "" #. Option for the 'Periodicity' (Select) field in DocType 'Asset Maintenance #. Task' @@ -1004,7 +888,7 @@ msgstr "30 دقیقه" #: accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py:119 msgid "30-60" -msgstr "30-60" +msgstr "" #: manufacturing/report/work_order_summary/work_order_summary.py:110 msgid "30-60 Days" @@ -1054,7 +938,7 @@ msgstr "6 ساعت" #: accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py:120 msgid "60-90" -msgstr "60-90" +msgstr "" #: manufacturing/report/work_order_summary/work_order_summary.py:110 msgid "60-90 Days" @@ -1074,8 +958,7 @@ msgstr "از زمان نمی تواند دیرتر از تا زمان< #: accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json #, python-format msgctxt "Process Statement Of Accounts" -msgid "" -"
    \n" +msgid "
    \n" "

    Note

    \n" "
      \n" "
    • \n" @@ -1115,13 +998,12 @@ msgstr "
      هیچ تراکنش بانکی م #: public/js/bank_reconciliation_tool/dialog_manager.js:258 msgid "
      {0}
      " -msgstr "
      {0}
      " +msgstr "" #. Content of the 'settings' (HTML) field in DocType 'Cheque Print Template' #: accounts/doctype/cheque_print_template/cheque_print_template.json msgctxt "Cheque Print Template" -msgid "" -"
      \n" +msgid "
      \n" "

      All dimensions in centimeter only

      \n" "
      " msgstr "" @@ -1129,9 +1011,7 @@ msgstr "" #. Content of the 'about' (HTML) field in DocType 'Product Bundle' #: selling/doctype/product_bundle/product_bundle.json msgctxt "Product Bundle" -msgid "" -"

      About Product Bundle

      \n" -"\n" +msgid "

      About Product Bundle

      \n\n" "

      Aggregate group of Items into another Item. This is useful if you are bundling a certain Items into a package and you maintain stock of the packed Items and not the aggregate Item.

      \n" "

      The package Item will have Is Stock Item as No and Is Sales Item as Yes.

      \n" "

      Example:

      \n" @@ -1141,8 +1021,7 @@ msgstr "" #. Content of the 'Help' (HTML) field in DocType 'Currency Exchange Settings' #: accounts/doctype/currency_exchange_settings/currency_exchange_settings.json msgctxt "Currency Exchange Settings" -msgid "" -"

      Currency Exchange Settings Help

      \n" +msgid "

      Currency Exchange Settings Help

      \n" "

      There are 3 variables that could be used within the endpoint, result key and in values of the parameter.

      \n" "

      Exchange rate between {from_currency} and {to_currency} on {transaction_date} is fetched by the API.

      \n" "

      Example: If your endpoint is exchange.com/2021-08-01, then, you will have to input exchange.com/{transaction_date}

      " @@ -1152,17 +1031,11 @@ msgstr "" #. Letter Text' #: accounts/doctype/dunning_letter_text/dunning_letter_text.json msgctxt "Dunning Letter Text" -msgid "" -"

      Body Text and Closing Text Example

      \n" -"\n" -"
      We have noticed that you have not yet paid invoice {{sales_invoice}} for {{frappe.db.get_value(\"Currency\", currency, \"symbol\")}} {{outstanding_amount}}. This is a friendly reminder that the invoice was due on {{due_date}}. Please pay the amount due immediately to avoid any further dunning cost.
      \n" -"\n" -"

      How to get fieldnames

      \n" -"\n" -"

      The fieldnames you can use in your template are the fields in the document. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)

      \n" -"\n" -"

      Templating

      \n" -"\n" +msgid "

      Body Text and Closing Text Example

      \n\n" +"
      We have noticed that you have not yet paid invoice {{sales_invoice}} for {{frappe.db.get_value(\"Currency\", currency, \"symbol\")}} {{outstanding_amount}}. This is a friendly reminder that the invoice was due on {{due_date}}. Please pay the amount due immediately to avoid any further dunning cost.
      \n\n" +"

      How to get fieldnames

      \n\n" +"

      The fieldnames you can use in your template are the fields in the document. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)

      \n\n" +"

      Templating

      \n\n" "

      Templates are compiled using the Jinja Templating Language. To learn more about Jinja, read this documentation.

      " msgstr "" @@ -1170,21 +1043,14 @@ msgstr "" #. Template' #: crm/doctype/contract_template/contract_template.json msgctxt "Contract Template" -msgid "" -"

      Contract Template Example

      \n" -"\n" -"
      Contract for Customer {{ party_name }}\n"
      -"\n"
      +msgid "

      Contract Template Example

      \n\n" +"
      Contract for Customer {{ party_name }}\n\n"
       "-Valid From : {{ start_date }} \n"
       "-Valid To : {{ end_date }}\n"
      -"
      \n" -"\n" -"

      How to get fieldnames

      \n" -"\n" -"

      The field names you can use in your Contract Template are the fields in the Contract for which you are creating the template. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Contract)

      \n" -"\n" -"

      Templating

      \n" -"\n" +"
      \n\n" +"

      How to get fieldnames

      \n\n" +"

      The field names you can use in your Contract Template are the fields in the Contract for which you are creating the template. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Contract)

      \n\n" +"

      Templating

      \n\n" "

      Templates are compiled using the Jinja Templating Language. To learn more about Jinja, read this documentation.

      " msgstr "" @@ -1192,21 +1058,14 @@ msgstr "" #. and Conditions' #: setup/doctype/terms_and_conditions/terms_and_conditions.json msgctxt "Terms and Conditions" -msgid "" -"

      Standard Terms and Conditions Example

      \n" -"\n" -"
      Delivery Terms for Order number {{ name }}\n"
      -"\n"
      +msgid "

      Standard Terms and Conditions Example

      \n\n" +"
      Delivery Terms for Order number {{ name }}\n\n"
       "-Order Date : {{ transaction_date }} \n"
       "-Expected Delivery Date : {{ delivery_date }}\n"
      -"
      \n" -"\n" -"

      How to get fieldnames

      \n" -"\n" -"

      The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)

      \n" -"\n" -"

      Templating

      \n" -"\n" +"
      \n\n" +"

      How to get fieldnames

      \n\n" +"

      The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)

      \n\n" +"

      Templating

      \n\n" "

      Templates are compiled using the Jinja Templating Language. To learn more about Jinja, read this documentation.

      " msgstr "" @@ -1227,7 +1086,7 @@ msgstr "
      " ); } else { set_time_to_resolve_and_response(frm, data.message.apply_sla_for_resolution); } - } + }, }); } else if (frm.doc.service_level_agreement) { frm.dashboard.clear_headline(); - let agreement_status = (frm.doc.agreement_status == 'Fulfilled') ? - {'indicator': 'green', 'msg': 'Service Level Agreement has been fulfilled'} : - {'indicator': 'red', 'msg': 'Service Level Agreement Failed'}; + let agreement_status = + frm.doc.agreement_status == "Fulfilled" + ? { indicator: "green", msg: "Service Level Agreement has been fulfilled" } + : { indicator: "red", msg: "Service Level Agreement Failed" }; frm.dashboard.set_headline_alert( '
      ' + '
      ' + - ' ' + - '
      ' + - '
      ' + ' " + + "
      " + + "" ); } }, @@ -1067,7 +1156,6 @@ function set_time_to_resolve_and_response(frm, apply_sla_for_resolution) { `; - if (apply_sla_for_resolution) { let time_to_resolve; if (!frm.doc.resolution_date) { @@ -1084,34 +1172,32 @@ function set_time_to_resolve_and_response(frm, apply_sla_for_resolution) { `; } - alert += ''; + alert += ""; frm.dashboard.set_headline_alert(alert); } function get_time_left(timestamp, agreement_status) { const diff = moment(timestamp).diff(frappe.datetime.system_datetime(true)); - const diff_display = diff >= 44500 ? moment.duration(diff).humanize() : 'Failed'; - let indicator = (diff_display == 'Failed' && agreement_status != 'Fulfilled') ? 'red' : 'green'; - return {'diff_display': diff_display, 'indicator': indicator}; + const diff_display = diff >= 44500 ? moment.duration(diff).humanize() : "Failed"; + let indicator = diff_display == "Failed" && agreement_status != "Fulfilled" ? "red" : "green"; + return { diff_display: diff_display, indicator: indicator }; } function get_status(expected, actual) { const time_left = moment(expected).diff(moment(actual)); if (time_left >= 0) { - return {'diff_display': 'Fulfilled', 'indicator': 'green'}; + return { diff_display: "Fulfilled", indicator: "green" }; } else { - return {'diff_display': 'Failed', 'indicator': 'red'}; + return { diff_display: "Failed", indicator: "red" }; } } function attach_selector_button(inner_text, append_loction, context, grid_row) { - let $btn_div = $("
      ").css({"margin-bottom": "10px", "margin-top": "10px"}) - .appendTo(append_loction); - let $btn = $(``) - .appendTo($btn_div); + let $btn_div = $("
      ").css({ "margin-bottom": "10px", "margin-top": "10px" }).appendTo(append_loction); + let $btn = $(``).appendTo($btn_div); - $btn.on("click", function() { + $btn.on("click", function () { context.show_serial_batch_selector(grid_row.frm, grid_row.doc, "", "", true); }); } diff --git a/erpnext/public/js/utils/barcode_scanner.js b/erpnext/public/js/utils/barcode_scanner.js index 4d1c0c1ad3d..d6ef7944cee 100644 --- a/erpnext/public/js/utils/barcode_scanner.js +++ b/erpnext/public/js/utils/barcode_scanner.js @@ -58,13 +58,15 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { return; } - me.update_table(data).then(row => { - this.play_success_sound(); - resolve(row); - }).catch(() => { - this.play_fail_sound(); - reject(); - }); + me.update_table(data) + .then((row) => { + this.play_success_sound(); + resolve(row); + }) + .catch(() => { + this.play_fail_sound(); + reject(); + }); }); }); } @@ -87,7 +89,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { let cur_grid = this.frm.fields_dict[this.items_table_name].grid; frappe.flags.trigger_from_barcode_scanner = true; - const {item_code, barcode, batch_no, serial_no, uom} = data; + const { item_code, barcode, batch_no, serial_no, uom } = data; let row = this.get_row_to_modify_on_scan(item_code, batch_no, uom, barcode); @@ -116,16 +118,17 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { frappe.run_serially([ () => this.set_selector_trigger_flag(data), - () => this.set_item(row, item_code, barcode, batch_no, serial_no).then(qty => { - this.show_scan_message(row.idx, row.item_code, qty); - }), + () => + this.set_item(row, item_code, barcode, batch_no, serial_no).then((qty) => { + this.show_scan_message(row.idx, row.item_code, qty); + }), () => this.set_barcode_uom(row, uom), () => this.set_serial_no(row, serial_no), () => this.set_batch_no(row, batch_no), () => this.set_barcode(row, barcode), () => this.clean_up(), () => this.revert_selector_flag(), - () => resolve(row) + () => resolve(row), ]); }); } @@ -133,7 +136,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { // batch and serial selector is reduandant when all info can be added by scan // this flag on item row is used by transaction.js to avoid triggering selector set_selector_trigger_flag(data) { - const {batch_no, serial_no, has_batch_no, has_serial_no} = data; + const { batch_no, serial_no, has_batch_no, has_serial_no } = data; const require_selecting_batch = has_batch_no && !batch_no; const require_selecting_serial = has_serial_no && !serial_no; @@ -149,17 +152,17 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { } set_item(row, item_code, barcode, batch_no, serial_no) { - return new Promise(resolve => { + return new Promise((resolve) => { const increment = async (value = 1) => { - const item_data = {item_code: item_code, use_serial_batch_fields: 1.0}; + const item_data = { item_code: item_code, use_serial_batch_fields: 1.0 }; frappe.flags.trigger_from_barcode_scanner = true; - item_data[this.qty_field] = Number((row[this.qty_field] || 0)) + Number(value); + item_data[this.qty_field] = Number(row[this.qty_field] || 0) + Number(value); await frappe.model.set_value(row.doctype, row.name, item_data); return value; }; if (this.prompt_qty) { - frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({value}) => { + frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({ value }) => { increment(value).then((value) => resolve(value)); }); } else if (this.frm.has_items) { @@ -175,14 +178,15 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { this.dialog = new frappe.ui.Dialog({ title: __("Scan barcode for item {0}", [item_code]), fields: me.get_fields_for_dialog(row, item_code, barcode, batch_no, serial_no), - }) + }); this.dialog.set_primary_action(__("Update"), () => { - const item_data = {item_code: item_code}; + const item_data = { item_code: item_code }; item_data[this.qty_field] = this.dialog.get_value("scanned_qty"); item_data["has_item_scanned"] = 1; - this.remaining_qty = flt(this.dialog.get_value("qty")) - flt(this.dialog.get_value("scanned_qty")); + this.remaining_qty = + flt(this.dialog.get_value("qty")) - flt(this.dialog.get_value("scanned_qty")); frappe.model.set_value(row.doctype, row.name, item_data); frappe.run_serially([ @@ -190,7 +194,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { () => this.set_barcode(row, this.dialog.get_value("barcode")), () => this.set_serial_no(row, this.dialog.get_value("serial_no")), () => this.add_child_for_remaining_qty(row), - () => this.clean_up() + () => this.clean_up(), ]); this.dialog.hide(); @@ -219,9 +223,9 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { if (r.message) { this.update_dialog_values(item_code, r); } - }) + }); } - } + }, }, { fieldtype: "Section Break", @@ -245,8 +249,8 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { }, { fieldtype: "Section Break", - } - ] + }, + ]; if (batch_no) { fields.push({ @@ -256,7 +260,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { label: __("Batch No"), default: batch_no, read_only: 1, - hidden: 1 + hidden: 1, }); } @@ -278,7 +282,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { label: __("Barcode"), default: barcode, read_only: 1, - hidden: 1 + hidden: 1, }); } @@ -286,18 +290,18 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { } update_dialog_values(scanned_item, r) { - const {item_code, barcode, batch_no, serial_no} = r.message; + const { item_code, barcode, batch_no, serial_no } = r.message; this.dialog.set_value("barcode_scanner", ""); - if (item_code === scanned_item && - (this.dialog.get_value("barcode") === barcode || batch_no || serial_no)) { - + if ( + item_code === scanned_item && + (this.dialog.get_value("barcode") === barcode || batch_no || serial_no) + ) { if (batch_no) { this.dialog.set_value("batch_no", batch_no); } if (serial_no) { - this.validate_duplicate_serial_no(serial_no); let serial_nos = this.dialog.get_value("serial_no") + "\n" + serial_no; this.dialog.set_value("serial_no", serial_nos); @@ -309,8 +313,9 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { } validate_duplicate_serial_no(serial_no) { - let serial_nos = this.dialog.get_value("serial_no") ? - this.dialog.get_value("serial_no").split("\n") : []; + let serial_nos = this.dialog.get_value("serial_no") + ? this.dialog.get_value("serial_no").split("\n") + : []; if (in_list(serial_nos, serial_no)) { frappe.throw(__("Serial No {0} already scanned", [serial_no])); @@ -318,12 +323,19 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { } add_child_for_remaining_qty(prev_row) { - if (this.remaining_qty && this.remaining_qty >0) { + if (this.remaining_qty && this.remaining_qty > 0) { let cur_grid = this.frm.fields_dict[this.items_table_name].grid; let row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name); - let ignore_fields = ["name", "idx", "batch_no", "barcode", - "received_qty", "serial_no", "has_item_scanned"]; + let ignore_fields = [ + "name", + "idx", + "batch_no", + "barcode", + "received_qty", + "serial_no", + "has_item_scanned", + ]; for (let key in prev_row) { if (in_list(ignore_fields, key)) { @@ -379,7 +391,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { if (exist) { this.show_alert(__("Row #{0}: Qty increased by {1}", [idx, qty]), "green"); } else { - this.show_alert(__("Row #{0}: Item added", [idx]), "green") + this.show_alert(__("Row #{0}: Item added", [idx]), "green"); } } @@ -401,17 +413,19 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { const matching_row = (row) => { const item_match = row.item_code == item_code; - const batch_match = (!row[this.batch_no_field] || row[this.batch_no_field] == batch_no); + const batch_match = !row[this.batch_no_field] || row[this.batch_no_field] == batch_no; const uom_match = !uom || row[this.uom_field] == uom; const qty_in_limit = flt(row[this.qty_field]) < flt(row[this.max_qty_field]); const item_scanned = row.has_item_scanned; - return item_match - && uom_match - && !item_scanned - && (!is_batch_no_scan || batch_match) - && (!check_max_qty || qty_in_limit) - } + return ( + item_match && + uom_match && + !item_scanned && + (!is_batch_no_scan || batch_match) && + (!check_max_qty || qty_in_limit) + ); + }; return this.items_table.find(matching_row) || this.get_existing_blank_row(); } @@ -432,7 +446,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { this.scan_barcode_field.set_value(""); refresh_field(this.items_table_name); } - show_alert(msg, indicator, duration=3) { - frappe.show_alert({message: msg, indicator: indicator}, duration); + show_alert(msg, indicator, duration = 3) { + frappe.show_alert({ message: msg, indicator: indicator }, duration); } -}; \ No newline at end of file +}; diff --git a/erpnext/public/js/utils/contact_address_quick_entry.js b/erpnext/public/js/utils/contact_address_quick_entry.js index adabf08c203..2f61dee1994 100644 --- a/erpnext/public/js/utils/contact_address_quick_entry.js +++ b/erpnext/public/js/utils/contact_address_quick_entry.js @@ -1,6 +1,8 @@ -frappe.provide('frappe.ui.form'); +frappe.provide("frappe.ui.form"); -frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm extends frappe.ui.form.QuickEntryForm { +frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm extends ( + frappe.ui.form.QuickEntryForm +) { constructor(doctype, after_insert, init_callback, doc, force) { super(doctype, after_insert, init_callback, doc, force); this.skip_redirect_on_error = true; @@ -17,8 +19,8 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm * Therefor, resulting in the fields being "hidden". */ const map_field_names = { - "email_address": "email_id", - "mobile_number": "mobile_no", + email_address: "email_id", + mobile_number: "mobile_no", }; Object.entries(map_field_names).forEach(([fieldname, new_fieldname]) => { @@ -30,71 +32,73 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm } get_variant_fields() { - var variant_fields = [{ - fieldtype: "Section Break", - label: __("Primary Contact Details"), - collapsible: 1 - }, - { - label: __("Email Id"), - fieldname: "email_address", - fieldtype: "Data", - options: "Email", - }, - { - fieldtype: "Column Break" - }, - { - label: __("Mobile Number"), - fieldname: "mobile_number", - fieldtype: "Data" - }, - { - fieldtype: "Section Break", - label: __("Primary Address Details"), - collapsible: 1 - }, - { - label: __("Address Line 1"), - fieldname: "address_line1", - fieldtype: "Data" - }, - { - label: __("Address Line 2"), - fieldname: "address_line2", - fieldtype: "Data" - }, - { - label: __("ZIP Code"), - fieldname: "pincode", - fieldtype: "Data" - }, - { - fieldtype: "Column Break" - }, - { - label: __("City"), - fieldname: "city", - fieldtype: "Data" - }, - { - label: __("State"), - fieldname: "state", - fieldtype: "Data" - }, - { - label: __("Country"), - fieldname: "country", - fieldtype: "Link", - options: "Country" - }, - { - label: __("Customer POS Id"), - fieldname: "customer_pos_id", - fieldtype: "Data", - hidden: 1 - }]; + var variant_fields = [ + { + fieldtype: "Section Break", + label: __("Primary Contact Details"), + collapsible: 1, + }, + { + label: __("Email Id"), + fieldname: "email_address", + fieldtype: "Data", + options: "Email", + }, + { + fieldtype: "Column Break", + }, + { + label: __("Mobile Number"), + fieldname: "mobile_number", + fieldtype: "Data", + }, + { + fieldtype: "Section Break", + label: __("Primary Address Details"), + collapsible: 1, + }, + { + label: __("Address Line 1"), + fieldname: "address_line1", + fieldtype: "Data", + }, + { + label: __("Address Line 2"), + fieldname: "address_line2", + fieldtype: "Data", + }, + { + label: __("ZIP Code"), + fieldname: "pincode", + fieldtype: "Data", + }, + { + fieldtype: "Column Break", + }, + { + label: __("City"), + fieldname: "city", + fieldtype: "Data", + }, + { + label: __("State"), + fieldname: "state", + fieldtype: "Data", + }, + { + label: __("Country"), + fieldname: "country", + fieldtype: "Link", + options: "Country", + }, + { + label: __("Customer POS Id"), + fieldname: "customer_pos_id", + fieldtype: "Data", + hidden: 1, + }, + ]; return variant_fields; } -} +}; diff --git a/erpnext/public/js/utils/crm_activities.js b/erpnext/public/js/utils/crm_activities.js index ec79a10dfac..a5a225458c0 100644 --- a/erpnext/public/js/utils/crm_activities.js +++ b/erpnext/public/js/utils/crm_activities.js @@ -6,21 +6,21 @@ erpnext.utils.CRMActivities = class CRMActivities { refresh() { var me = this; $(this.open_activities_wrapper).empty(); - let cur_form_footer = this.form_wrapper.find('.form-footer'); + let cur_form_footer = this.form_wrapper.find(".form-footer"); // all activities - if (!$(this.all_activities_wrapper).find('.form-footer').length) { + if (!$(this.all_activities_wrapper).find(".form-footer").length) { this.all_activities_wrapper.empty(); $(cur_form_footer).appendTo(this.all_activities_wrapper); // remove frappe-control class to avoid absolute position for action-btn - $(this.all_activities_wrapper).removeClass('frappe-control'); + $(this.all_activities_wrapper).removeClass("frappe-control"); // hide new event button - $('.timeline-actions').find('.btn-default').hide(); + $(".timeline-actions").find(".btn-default").hide(); // hide new comment box $(".comment-box").hide(); // show only communications by default - $($('.timeline-content').find('.nav-link')[0]).tab('show'); + $($(".timeline-content").find(".nav-link")[0]).tab("show"); } // open activities @@ -28,66 +28,70 @@ erpnext.utils.CRMActivities = class CRMActivities { method: "erpnext.crm.utils.get_open_activities", args: { ref_doctype: this.frm.doc.doctype, - ref_docname: this.frm.doc.name + ref_docname: this.frm.doc.name, }, callback: (r) => { if (!r.exc) { - var activities_html = frappe.render_template('crm_activities', { + var activities_html = frappe.render_template("crm_activities", { tasks: r.message.tasks, - events: r.message.events + events: r.message.events, }); $(activities_html).appendTo(me.open_activities_wrapper); - $(".open-tasks").find(".completion-checkbox").on("click", function() { - me.update_status(this, "ToDo"); - }); + $(".open-tasks") + .find(".completion-checkbox") + .on("click", function () { + me.update_status(this, "ToDo"); + }); - $(".open-events").find(".completion-checkbox").on("click", function() { - me.update_status(this, "Event"); - }); + $(".open-events") + .find(".completion-checkbox") + .on("click", function () { + me.update_status(this, "Event"); + }); me.create_task(); me.create_event(); } - } + }, }); } - create_task () { + create_task() { let me = this; let _create_task = () => { const args = { doc: me.frm.doc, frm: me.frm, - title: __("New Task") + title: __("New Task"), }; let composer = new frappe.views.InteractionComposer(args); - composer.dialog.get_field('interaction_type').set_value("ToDo"); + composer.dialog.get_field("interaction_type").set_value("ToDo"); // hide column having interaction type field - $(composer.dialog.get_field('interaction_type').wrapper).closest('.form-column').hide(); + $(composer.dialog.get_field("interaction_type").wrapper).closest(".form-column").hide(); // hide summary field - $(composer.dialog.get_field('summary').wrapper).closest('.form-section').hide(); + $(composer.dialog.get_field("summary").wrapper).closest(".form-section").hide(); }; $(".new-task-btn").click(_create_task); } - create_event () { + create_event() { let me = this; let _create_event = () => { const args = { doc: me.frm.doc, frm: me.frm, - title: __("New Event") + title: __("New Event"), }; let composer = new frappe.views.InteractionComposer(args); - composer.dialog.get_field('interaction_type').set_value("Event"); - $(composer.dialog.get_field('interaction_type').wrapper).hide(); + composer.dialog.get_field("interaction_type").set_value("Event"); + $(composer.dialog.get_field("interaction_type").wrapper).hide(); }; $(".new-event-btn").click(_create_event); } - async update_status (input_field, doctype) { + async update_status(input_field, doctype) { let completed = $(input_field).prop("checked") ? 1 : 0; let docname = $(input_field).attr("name"); if (completed) { @@ -104,132 +108,129 @@ erpnext.utils.CRMNotes = class CRMNotes { refresh() { var me = this; - this.notes_wrapper.find('.notes-section').remove(); + this.notes_wrapper.find(".notes-section").remove(); let notes = this.frm.doc.notes || []; - notes.sort( - function(a, b) { - return new Date(b.added_on) - new Date(a.added_on); - } - ); + notes.sort(function (a, b) { + return new Date(b.added_on) - new Date(a.added_on); + }); - let notes_html = frappe.render_template( - 'crm_notes', - { - notes: notes - } - ); + let notes_html = frappe.render_template("crm_notes", { + notes: notes, + }); $(notes_html).appendTo(this.notes_wrapper); this.add_note(); - $(".notes-section").find(".edit-note-btn").on("click", function() { - me.edit_note(this); - }); + $(".notes-section") + .find(".edit-note-btn") + .on("click", function () { + me.edit_note(this); + }); - $(".notes-section").find(".delete-note-btn").on("click", function() { - me.delete_note(this); - }); + $(".notes-section") + .find(".delete-note-btn") + .on("click", function () { + me.delete_note(this); + }); } - - add_note () { + add_note() { let me = this; let _add_note = () => { var d = new frappe.ui.Dialog({ - title: __('Add a Note'), + title: __("Add a Note"), fields: [ { - "label": "Note", - "fieldname": "note", - "fieldtype": "Text Editor", - "reqd": 1, - "enable_mentions": true, - } + label: "Note", + fieldname: "note", + fieldtype: "Text Editor", + reqd: 1, + enable_mentions: true, + }, ], - primary_action: function() { + primary_action: function () { var data = d.get_values(); frappe.call({ method: "add_note", doc: me.frm.doc, args: { - note: data.note + note: data.note, }, freeze: true, - callback: function(r) { + callback: function (r) { if (!r.exc) { me.frm.refresh_field("notes"); me.refresh(); } d.hide(); - } + }, }); }, - primary_action_label: __('Add') + primary_action_label: __("Add"), }); d.show(); }; $(".new-note-btn").click(_add_note); } - edit_note (edit_btn) { + edit_note(edit_btn) { var me = this; - let row = $(edit_btn).closest('.comment-content'); + let row = $(edit_btn).closest(".comment-content"); let row_id = row.attr("name"); let row_content = $(row).find(".content").html(); if (row_content) { var d = new frappe.ui.Dialog({ - title: __('Edit Note'), + title: __("Edit Note"), fields: [ { - "label": "Note", - "fieldname": "note", - "fieldtype": "Text Editor", - "default": row_content - } + label: "Note", + fieldname: "note", + fieldtype: "Text Editor", + default: row_content, + }, ], - primary_action: function() { + primary_action: function () { var data = d.get_values(); frappe.call({ method: "edit_note", doc: me.frm.doc, args: { note: data.note, - row_id: row_id + row_id: row_id, }, freeze: true, - callback: function(r) { + callback: function (r) { if (!r.exc) { me.frm.refresh_field("notes"); me.refresh(); d.hide(); } - - } + }, }); }, - primary_action_label: __('Done') + primary_action_label: __("Done"), }); d.show(); } } - delete_note (delete_btn) { + delete_note(delete_btn) { var me = this; - let row_id = $(delete_btn).closest('.comment-content').attr("name"); + let row_id = $(delete_btn).closest(".comment-content").attr("name"); frappe.call({ method: "delete_note", doc: me.frm.doc, args: { - row_id: row_id + row_id: row_id, }, freeze: true, - callback: function(r) { + callback: function (r) { if (!r.exc) { me.frm.refresh_field("notes"); me.refresh(); } - } + }, }); } }; diff --git a/erpnext/public/js/utils/customer_quick_entry.js b/erpnext/public/js/utils/customer_quick_entry.js index b2532085f65..e9b77a356b2 100644 --- a/erpnext/public/js/utils/customer_quick_entry.js +++ b/erpnext/public/js/utils/customer_quick_entry.js @@ -1,3 +1,3 @@ -frappe.provide('frappe.ui.form'); +frappe.provide("frappe.ui.form"); frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm; diff --git a/erpnext/public/js/utils/dimension_tree_filter.js b/erpnext/public/js/utils/dimension_tree_filter.js index 27d00bacb88..36c0f1b51ae 100644 --- a/erpnext/public/js/utils/dimension_tree_filter.js +++ b/erpnext/public/js/utils/dimension_tree_filter.js @@ -1,4 +1,4 @@ -frappe.provide('erpnext.accounts'); +frappe.provide("erpnext.accounts"); erpnext.accounts.dimensions = { setup_dimension_filters(frm, doctype) { @@ -12,36 +12,38 @@ erpnext.accounts.dimensions = { frappe.call({ method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.get_dimensions", args: { - 'with_cost_center_and_project': true + with_cost_center_and_project: true, }, - callback: function(r) { + callback: function (r) { me.accounting_dimensions = r.message[0]; // Ignoring "Project" as it is already handled specifically in Sales Order and Delivery Note - me.accounting_dimensions = me.accounting_dimensions.filter(x=>{return x.document_type != "Project"}); + me.accounting_dimensions = me.accounting_dimensions.filter((x) => { + return x.document_type != "Project"; + }); me.default_dimensions = r.message[1]; me.setup_filters(frm, doctype); - } + }, }); }, setup_filters(frm, doctype) { - if (doctype == 'Payment Entry' && this.accounting_dimensions) { - frm.dimension_filters = this.accounting_dimensions + if (doctype == "Payment Entry" && this.accounting_dimensions) { + frm.dimension_filters = this.accounting_dimensions; } if (this.accounting_dimensions) { this.accounting_dimensions.forEach((dimension) => { - frappe.model.with_doctype(dimension['document_type'], () => { + frappe.model.with_doctype(dimension["document_type"], () => { let parent_fields = []; frappe.meta.get_docfields(doctype).forEach((df) => { - if (df.fieldtype === 'Link' && df.options === 'Account') { + if (df.fieldtype === "Link" && df.options === "Account") { parent_fields.push(df.fieldname); - } else if (df.fieldtype === 'Table') { - this.setup_child_filters(frm, df.options, df.fieldname, dimension['fieldname']); + } else if (df.fieldtype === "Table") { + this.setup_child_filters(frm, df.options, df.fieldname, dimension["fieldname"]); } - if (frappe.meta.has_field(doctype, dimension['fieldname'])) { - this.setup_account_filters(frm, dimension['fieldname'], parent_fields); + if (frappe.meta.has_field(doctype, dimension["fieldname"])) { + this.setup_account_filters(frm, dimension["fieldname"], parent_fields); } }); }); @@ -55,12 +57,12 @@ erpnext.accounts.dimensions = { if (frappe.meta.has_field(doctype, dimension)) { frappe.model.with_doctype(doctype, () => { frappe.meta.get_docfields(doctype).forEach((df) => { - if (df.fieldtype === 'Link' && df.options === 'Account') { + if (df.fieldtype === "Link" && df.options === "Account") { fields.push(df.fieldname); } }); - frm.set_query(dimension, parentfield, function(doc, cdt, cdn) { + frm.set_query(dimension, parentfield, function (doc, cdt, cdn) { let row = locals[cdt][cdn]; return erpnext.queries.get_filtered_dimensions(row, fields, dimension, doc.company); }); @@ -69,7 +71,7 @@ erpnext.accounts.dimensions = { }, setup_account_filters(frm, dimension, fields) { - frm.set_query(dimension, function(doc) { + frm.set_query(dimension, function (doc) { return erpnext.queries.get_filtered_dimensions(doc, fields, dimension, doc.company); }); }, @@ -78,18 +80,26 @@ erpnext.accounts.dimensions = { if (this.accounting_dimensions) { this.accounting_dimensions.forEach((dimension) => { if (frm.is_new()) { - if (frm.doc.company && Object.keys(this.default_dimensions || {}).length > 0 - && this.default_dimensions[frm.doc.company]) { - - let default_dimension = this.default_dimensions[frm.doc.company][dimension['fieldname']]; + if ( + frm.doc.company && + Object.keys(this.default_dimensions || {}).length > 0 && + this.default_dimensions[frm.doc.company] + ) { + let default_dimension = + this.default_dimensions[frm.doc.company][dimension["fieldname"]]; if (default_dimension) { - if (frappe.meta.has_field(doctype, dimension['fieldname'])) { - frm.set_value(dimension['fieldname'], default_dimension); + if (frappe.meta.has_field(doctype, dimension["fieldname"])) { + frm.set_value(dimension["fieldname"], default_dimension); } - $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) { - frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], default_dimension); + $.each(frm.doc.items || frm.doc.accounts || [], function (i, row) { + frappe.model.set_value( + row.doctype, + row.name, + dimension["fieldname"], + default_dimension + ); }); } } @@ -102,8 +112,8 @@ erpnext.accounts.dimensions = { if (frappe.meta.has_field(frm.doctype, fieldname) && this.accounting_dimensions) { this.accounting_dimensions.forEach((dimension) => { let row = frappe.get_doc(cdt, cdn); - frm.script_manager.copy_from_first_row(fieldname, row, [dimension['fieldname']]); + frm.script_manager.copy_from_first_row(fieldname, row, [dimension["fieldname"]]); }); } - } + }, }; diff --git a/erpnext/public/js/utils/item_selector.js b/erpnext/public/js/utils/item_selector.js index e74d291acd3..d8a4ef4651a 100644 --- a/erpnext/public/js/utils/item_selector.js +++ b/erpnext/public/js/utils/item_selector.js @@ -3,7 +3,7 @@ erpnext.ItemSelector = class ItemSelector { $.extend(this, opts); if (!this.item_field) { - this.item_field = 'item_code'; + this.item_field = "item_code"; } if (!this.item_query) { @@ -16,39 +16,43 @@ erpnext.ItemSelector = class ItemSelector { setup() { var me = this; - if(!this.grid.add_items_button) { - this.grid.add_items_button = this.grid.add_custom_button(__('Add Items'), function() { - if(!me.dialog) { + if (!this.grid.add_items_button) { + this.grid.add_items_button = this.grid.add_custom_button(__("Add Items"), function () { + if (!me.dialog) { me.make_dialog(); } me.dialog.show(); me.render_items(); - setTimeout(function() { me.dialog.input.focus(); }, 1000); + setTimeout(function () { + me.dialog.input.focus(); + }, 1000); }); } } make_dialog() { this.dialog = new frappe.ui.Dialog({ - title: __('Add Items') + title: __("Add Items"), }); var body = $(this.dialog.body); - body.html('

      \ -
      '); + body.html( + '

      \ +
      ' + ); - this.dialog.input = body.find('.form-control'); - this.dialog.results = body.find('.results'); + this.dialog.input = body.find(".form-control"); + this.dialog.results = body.find(".results"); var me = this; - this.dialog.results.on('click', '.image-view-item', function() { - me.add_item($(this).attr('data-name')); + this.dialog.results.on("click", ".image-view-item", function () { + me.add_item($(this).attr("data-name")); }); - this.dialog.input.on('keyup', function() { - if(me.timeout_id) { + this.dialog.input.on("keyup", function () { + if (me.timeout_id) { clearTimeout(me.timeout_id); } - me.timeout_id = setTimeout(function() { + me.timeout_id = setTimeout(function () { me.render_items(); me.timeout_id = undefined; }, 500); @@ -61,33 +65,34 @@ erpnext.ItemSelector = class ItemSelector { // find row with item if exists $.each(this.frm.doc.items || [], (i, d) => { - if(d[this.item_field]===item_code) { - frappe.model.set_value(d.doctype, d.name, 'qty', d.qty + 1); - frappe.show_alert({message: __("Added {0} ({1})", [item_code, d.qty]), indicator: 'green'}); + if (d[this.item_field] === item_code) { + frappe.model.set_value(d.doctype, d.name, "qty", d.qty + 1); + frappe.show_alert({ message: __("Added {0} ({1})", [item_code, d.qty]), indicator: "green" }); added = true; return false; } }); - if(!added) { + if (!added) { var d = null; frappe.run_serially([ - () => { d = this.grid.add_new_row(); }, + () => { + d = this.grid.add_new_row(); + }, () => frappe.model.set_value(d.doctype, d.name, this.item_field, item_code), () => frappe.timeout(0.1), () => { - frappe.model.set_value(d.doctype, d.name, 'qty', 1); - frappe.show_alert({message: __("Added {0} ({1})", [item_code, 1]), indicator: 'green'}); - } + frappe.model.set_value(d.doctype, d.name, "qty", 1); + frappe.show_alert({ message: __("Added {0} ({1})", [item_code, 1]), indicator: "green" }); + }, ]); } - } render_items() { let args = { query: this.item_query, - filters: {} + filters: {}, }; args.txt = this.dialog.input.val(); args.as_dict = 1; @@ -97,14 +102,14 @@ erpnext.ItemSelector = class ItemSelector { } var me = this; - frappe.link_search("Item", args, function(results) { - $.each(results, function(i, d) { - if(!d.image) { + frappe.link_search("Item", args, function (results) { + $.each(results, function (i, d) { + if (!d.image) { d.abbr = frappe.get_abbr(d.item_name); d.color = frappe.get_palette(d.item_name); } }); - me.dialog.results.html(frappe.render_template('item_selector', {'data': results})); + me.dialog.results.html(frappe.render_template("item_selector", { data: results })); }); } }; diff --git a/erpnext/public/js/utils/landed_taxes_and_charges_common.js b/erpnext/public/js/utils/landed_taxes_and_charges_common.js index c71f77d45e9..2cb30160453 100644 --- a/erpnext/public/js/utils/landed_taxes_and_charges_common.js +++ b/erpnext/public/js/utils/landed_taxes_and_charges_common.js @@ -1,62 +1,74 @@ - erpnext.landed_cost_taxes_and_charges = { - setup_triggers: function(doctype) { + setup_triggers: function (doctype) { frappe.ui.form.on(doctype, { - refresh: function(frm) { - let tax_field = frm.doc.doctype == 'Landed Cost Voucher' ? 'taxes' : 'additional_costs'; - frm.set_query("expense_account", tax_field, function() { + refresh: function (frm) { + let tax_field = frm.doc.doctype == "Landed Cost Voucher" ? "taxes" : "additional_costs"; + frm.set_query("expense_account", tax_field, function () { return { filters: { - "account_type": ['in', ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation", "Expenses Included In Asset Valuation"]], - "company": frm.doc.company - } + account_type: [ + "in", + [ + "Tax", + "Chargeable", + "Income Account", + "Expenses Included In Valuation", + "Expenses Included In Asset Valuation", + ], + ], + company: frm.doc.company, + }, }; }); }, - set_account_currency: function(frm, cdt, cdn) { + set_account_currency: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; if (row.expense_account) { - frappe.db.get_value('Account', row.expense_account, 'account_currency', function(value) { + frappe.db.get_value("Account", row.expense_account, "account_currency", function (value) { frappe.model.set_value(cdt, cdn, "account_currency", value.account_currency); frm.events.set_exchange_rate(frm, cdt, cdn); }); } }, - set_exchange_rate: function(frm, cdt, cdn) { + set_exchange_rate: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency; if (row.account_currency == company_currency) { row.exchange_rate = 1; - frm.set_df_property('taxes', 'hidden', 1, row.name, 'exchange_rate'); + frm.set_df_property("taxes", "hidden", 1, row.name, "exchange_rate"); } else if (!row.exchange_rate || row.exchange_rate == 1) { - frm.set_df_property('taxes', 'hidden', 0, row.name, 'exchange_rate'); + frm.set_df_property("taxes", "hidden", 0, row.name, "exchange_rate"); frappe.call({ method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_exchange_rate", args: { posting_date: frm.doc.posting_date, account: row.expense_account, account_currency: row.account_currency, - company: frm.doc.company + company: frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (r.message) { frappe.model.set_value(cdt, cdn, "exchange_rate", r.message); } - } + }, }); } - frm.refresh_field('taxes'); + frm.refresh_field("taxes"); }, - set_base_amount: function(frm, cdt, cdn) { + set_base_amount: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; - frappe.model.set_value(cdt, cdn, "base_amount", - flt(flt(row.amount)*row.exchange_rate, precision("base_amount", row))); - } + frappe.model.set_value( + cdt, + cdn, + "base_amount", + flt(flt(row.amount) * row.exchange_rate, precision("base_amount", row)) + ); + }, }); - } -} + }, +}; diff --git a/erpnext/public/js/utils/ledger_preview.js b/erpnext/public/js/utils/ledger_preview.js index 85d4a7d51e9..6a610dd5065 100644 --- a/erpnext/public/js/utils/ledger_preview.js +++ b/erpnext/public/js/utils/ledger_preview.js @@ -1,60 +1,78 @@ -frappe.provide('erpnext.accounts'); +frappe.provide("erpnext.accounts"); erpnext.accounts.ledger_preview = { show_accounting_ledger_preview(frm) { let me = this; - if(!frm.is_new() && frm.doc.docstatus == 0) { - frm.add_custom_button(__('Accounting Ledger'), function() { - frappe.call({ - "type": "GET", - "method": "erpnext.controllers.stock_controller.show_accounting_ledger_preview", - "args": { - "company": frm.doc.company, - "doctype": frm.doc.doctype, - "docname": frm.doc.name - }, - "callback": function(response) { - me.make_dialog("Accounting Ledger Preview", "accounting_ledger_preview_html", response.message.gl_columns, response.message.gl_data); - } - }) - }, __("Preview")); + if (!frm.is_new() && frm.doc.docstatus == 0) { + frm.add_custom_button( + __("Accounting Ledger"), + function () { + frappe.call({ + type: "GET", + method: "erpnext.controllers.stock_controller.show_accounting_ledger_preview", + args: { + company: frm.doc.company, + doctype: frm.doc.doctype, + docname: frm.doc.name, + }, + callback: function (response) { + me.make_dialog( + "Accounting Ledger Preview", + "accounting_ledger_preview_html", + response.message.gl_columns, + response.message.gl_data + ); + }, + }); + }, + __("Preview") + ); } }, show_stock_ledger_preview(frm) { - let me = this - if(!frm.is_new() && frm.doc.docstatus == 0) { - frm.add_custom_button(__('Stock Ledger'), function() { - frappe.call({ - "type": "GET", - "method": "erpnext.controllers.stock_controller.show_stock_ledger_preview", - "args": { - "company": frm.doc.company, - "doctype": frm.doc.doctype, - "docname": frm.doc.name - }, - "callback": function(response) { - me.make_dialog("Stock Ledger Preview", "stock_ledger_preview_html", response.message.sl_columns, response.message.sl_data); - } - }) - }, __("Preview")); + let me = this; + if (!frm.is_new() && frm.doc.docstatus == 0) { + frm.add_custom_button( + __("Stock Ledger"), + function () { + frappe.call({ + type: "GET", + method: "erpnext.controllers.stock_controller.show_stock_ledger_preview", + args: { + company: frm.doc.company, + doctype: frm.doc.doctype, + docname: frm.doc.name, + }, + callback: function (response) { + me.make_dialog( + "Stock Ledger Preview", + "stock_ledger_preview_html", + response.message.sl_columns, + response.message.sl_data + ); + }, + }); + }, + __("Preview") + ); } }, make_dialog(label, fieldname, columns, data) { let me = this; let dialog = new frappe.ui.Dialog({ - "size": "extra-large", - "title": __(label), - "fields": [ + size: "extra-large", + title: __(label), + fields: [ { - "fieldtype": "HTML", - "fieldname": fieldname, + fieldtype: "HTML", + fieldname: fieldname, }, - ] + ], }); - setTimeout(function() { + setTimeout(function () { me.get_datatable(columns, data, dialog.get_field(fieldname).wrapper); }, 200); @@ -70,9 +88,6 @@ erpnext.accounts.ledger_preview = { inlineFilters: true, }; - new frappe.DataTable( - wrapper, - datatable_options - ); - } -} \ No newline at end of file + new frappe.DataTable(wrapper, datatable_options); + }, +}; diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index cba615c0d22..801376b2ed7 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -3,18 +3,19 @@ frappe.provide("erpnext.utils"); -const SALES_DOCTYPES = ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice']; -const PURCHASE_DOCTYPES = ['Supplier Quotation','Purchase Order', 'Purchase Receipt', 'Purchase Invoice']; +const SALES_DOCTYPES = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]; +const PURCHASE_DOCTYPES = ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]; -erpnext.utils.get_party_details = function(frm, method, args, callback) { +erpnext.utils.get_party_details = function (frm, method, args, callback) { if (!method) { method = "erpnext.accounts.party.get_party_details"; } if (!args) { - if ((frm.doctype != "Purchase Order" && frm.doc.customer) - || (frm.doc.party_name && in_list(['Quotation', 'Opportunity'], frm.doc.doctype))) { - + if ( + (frm.doctype != "Purchase Order" && frm.doc.customer) || + (frm.doc.party_name && in_list(["Quotation", "Opportunity"], frm.doc.doctype)) + ) { let party_type = "Customer"; if (frm.doc.quotation_to && in_list(["Lead", "Prospect"], frm.doc.quotation_to)) { party_type = frm.doc.quotation_to; @@ -23,14 +24,14 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) { args = { party: frm.doc.customer || frm.doc.party_name, party_type: party_type, - price_list: frm.doc.selling_price_list + price_list: frm.doc.selling_price_list, }; } else if (frm.doc.supplier) { args = { party: frm.doc.supplier, party_type: "Supplier", bill_date: frm.doc.bill_date, - price_list: frm.doc.buying_price_list + price_list: frm.doc.buying_price_list, }; } @@ -38,14 +39,14 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) { if (in_list(SALES_DOCTYPES, frm.doc.doctype)) { args = { party: frm.doc.customer || frm.doc.party_name, - party_type: 'Customer' + party_type: "Customer", }; } if (in_list(PURCHASE_DOCTYPES, frm.doc.doctype)) { args = { party: frm.doc.supplier, - party_type: 'Supplier' + party_type: "Supplier", }; } } @@ -72,13 +73,26 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) { } } - if (frappe.meta.get_docfield(frm.doc.doctype, "taxes")) { - if (!erpnext.utils.validate_mandatory(frm, "Posting / Transaction Date", - args.posting_date, args.party_type=="Customer" ? "customer": "supplier")) return; + if ( + !erpnext.utils.validate_mandatory( + frm, + "Posting / Transaction Date", + args.posting_date, + args.party_type == "Customer" ? "customer" : "supplier" + ) + ) + return; } - if (!erpnext.utils.validate_mandatory(frm, "Company", frm.doc.company, args.party_type=="Customer" ? "customer": "supplier")) { + if ( + !erpnext.utils.validate_mandatory( + frm, + "Company", + frm.doc.company, + args.party_type == "Customer" ? "customer" : "supplier" + ) + ) { return; } @@ -88,7 +102,7 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) { frappe.call({ method: method, args: args, - callback: function(r) { + callback: function (r) { if (r.message) { frm.supplier_tds = r.message.supplier_tds; frm.updating_party_details = true; @@ -99,28 +113,28 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) { if (callback) callback(); frm.refresh(); erpnext.utils.add_item(frm); - } + }, ]); } - } + }, }); -} +}; -erpnext.utils.add_item = function(frm) { +erpnext.utils.add_item = function (frm) { if (frm.is_new()) { var prev_route = frappe.get_prev_route(); - if (prev_route[1]==='Item' && !(frm.doc.items && frm.doc.items.length)) { + if (prev_route[1] === "Item" && !(frm.doc.items && frm.doc.items.length)) { // add row - var item = frm.add_child('items'); - frm.refresh_field('items'); + var item = frm.add_child("items"); + frm.refresh_field("items"); // set item - frappe.model.set_value(item.doctype, item.name, 'item_code', prev_route[2]); + frappe.model.set_value(item.doctype, item.name, "item_code", prev_route[2]); } } -} +}; -erpnext.utils.get_address_display = function(frm, address_field, display_field, is_your_company_address) { +erpnext.utils.get_address_display = function (frm, address_field, display_field, is_your_company_address) { if (frm.updating_party_details) return; if (!address_field) { @@ -135,29 +149,46 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field, if (frm.doc[address_field]) { frappe.call({ method: "frappe.contacts.doctype.address.address.get_address_display", - args: {"address_dict": frm.doc[address_field] }, - callback: function(r) { + args: { address_dict: frm.doc[address_field] }, + callback: function (r) { if (r.message) { - frm.set_value(display_field, r.message) + frm.set_value(display_field, r.message); } - } - }) + }, + }); } else { - frm.set_value(display_field, ''); + frm.set_value(display_field, ""); } }; -erpnext.utils.set_taxes_from_address = function(frm, triggered_from_field, billing_address_field, shipping_address_field) { +erpnext.utils.set_taxes_from_address = function ( + frm, + triggered_from_field, + billing_address_field, + shipping_address_field +) { if (frm.updating_party_details) return; if (frappe.meta.get_docfield(frm.doc.doctype, "taxes")) { - if (!erpnext.utils.validate_mandatory(frm, "Lead / Customer / Supplier", - frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, triggered_from_field)) { + if ( + !erpnext.utils.validate_mandatory( + frm, + "Lead / Customer / Supplier", + frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, + triggered_from_field + ) + ) { return; } - if (!erpnext.utils.validate_mandatory(frm, "Posting / Transaction Date", - frm.doc.posting_date || frm.doc.transaction_date, triggered_from_field)) { + if ( + !erpnext.utils.validate_mandatory( + frm, + "Posting / Transaction Date", + frm.doc.posting_date || frm.doc.transaction_date, + triggered_from_field + ) + ) { return; } } else { @@ -167,35 +198,47 @@ erpnext.utils.set_taxes_from_address = function(frm, triggered_from_field, billi frappe.call({ method: "erpnext.accounts.party.get_address_tax_category", args: { - "tax_category": frm.doc.tax_category, - "billing_address": frm.doc[billing_address_field], - "shipping_address": frm.doc[shipping_address_field] + tax_category: frm.doc.tax_category, + billing_address: frm.doc[billing_address_field], + shipping_address: frm.doc[shipping_address_field], }, - callback: function(r) { - if (!r.exc){ + callback: function (r) { + if (!r.exc) { if (frm.doc.tax_category != r.message) { frm.set_value("tax_category", r.message); } else { erpnext.utils.set_taxes(frm, triggered_from_field); } } - } + }, }); }; -erpnext.utils.set_taxes = function(frm, triggered_from_field) { +erpnext.utils.set_taxes = function (frm, triggered_from_field) { if (frappe.meta.get_docfield(frm.doc.doctype, "taxes")) { if (!erpnext.utils.validate_mandatory(frm, "Company", frm.doc.company, triggered_from_field)) { return; } - if (!erpnext.utils.validate_mandatory(frm, "Lead / Customer / Supplier", - frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, triggered_from_field)) { + if ( + !erpnext.utils.validate_mandatory( + frm, + "Lead / Customer / Supplier", + frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, + triggered_from_field + ) + ) { return; } - if (!erpnext.utils.validate_mandatory(frm, "Posting / Transaction Date", - frm.doc.posting_date || frm.doc.transaction_date, triggered_from_field)) { + if ( + !erpnext.utils.validate_mandatory( + frm, + "Posting / Transaction Date", + frm.doc.posting_date || frm.doc.transaction_date, + triggered_from_field + ) + ) { return; } } else { @@ -204,15 +247,15 @@ erpnext.utils.set_taxes = function(frm, triggered_from_field) { var party_type, party; if (frm.doc.lead) { - party_type = 'Lead'; + party_type = "Lead"; party = frm.doc.lead; } else if (frm.doc.customer) { - party_type = 'Customer'; + party_type = "Customer"; party = frm.doc.customer; } else if (frm.doc.supplier) { - party_type = 'Supplier'; + party_type = "Supplier"; party = frm.doc.supplier; - } else if (frm.doc.quotation_to){ + } else if (frm.doc.quotation_to) { party_type = frm.doc.quotation_to; party = frm.doc.party_name; } @@ -224,21 +267,22 @@ erpnext.utils.set_taxes = function(frm, triggered_from_field) { frappe.call({ method: "erpnext.accounts.party.set_taxes", args: { - "party": party, - "party_type": party_type, - "posting_date": frm.doc.posting_date || frm.doc.transaction_date, - "company": frm.doc.company, - "customer_group": frm.doc.customer_group, - "supplier_group": frm.doc.supplier_group, - "tax_category": frm.doc.tax_category, - "billing_address": ((frm.doc.customer || frm.doc.lead) ? (frm.doc.customer_address) : (frm.doc.supplier_address)), - "shipping_address": frm.doc.shipping_address_name + party: party, + party_type: party_type, + posting_date: frm.doc.posting_date || frm.doc.transaction_date, + company: frm.doc.company, + customer_group: frm.doc.customer_group, + supplier_group: frm.doc.supplier_group, + tax_category: frm.doc.tax_category, + billing_address: + frm.doc.customer || frm.doc.lead ? frm.doc.customer_address : frm.doc.supplier_address, + shipping_address: frm.doc.shipping_address_name, }, - callback: function(r) { - if (r.message){ - frm.set_value("taxes_and_charges", r.message) + callback: function (r) { + if (r.message) { + frm.set_value("taxes_and_charges", r.message); } - } + }, }); }; @@ -266,20 +310,23 @@ erpnext.utils.get_contact_details = function (frm) { } }; -erpnext.utils.validate_mandatory = function(frm, label, value, trigger_on) { +erpnext.utils.validate_mandatory = function (frm, label, value, trigger_on) { if (!value) { frm.doc[trigger_on] = ""; refresh_field(trigger_on); - frappe.throw({message:__("Please enter {0} first", [label]), title:__("Mandatory")}); + frappe.throw({ message: __("Please enter {0} first", [label]), title: __("Mandatory") }); return false; } return true; -} +}; -erpnext.utils.get_shipping_address = function(frm, callback) { +erpnext.utils.get_shipping_address = function (frm, callback) { if (frm.doc.company) { - if ((frm.doc.inter_company_order_reference || frm.doc.internal_invoice_reference || - frm.doc.internal_order_reference)) { + if ( + frm.doc.inter_company_order_reference || + frm.doc.internal_invoice_reference || + frm.doc.internal_order_reference + ) { if (callback) { return callback(); } @@ -288,20 +335,20 @@ erpnext.utils.get_shipping_address = function(frm, callback) { method: "erpnext.accounts.custom.address.get_shipping_address", args: { company: frm.doc.company, - address: frm.doc.shipping_address + address: frm.doc.shipping_address, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value("shipping_address", r.message[0]) //Address title or name - frm.set_value("shipping_address_display", r.message[1]) //Address to be displayed on the page + frm.set_value("shipping_address", r.message[0]); //Address title or name + frm.set_value("shipping_address_display", r.message[1]); //Address to be displayed on the page } - if (callback){ + if (callback) { return callback(); } - } + }, }); } else { frappe.msgprint(__("Select company first")); } -} +}; diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index a957530ec8b..f2b7331cf3b 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -4,7 +4,7 @@ frappe.provide("erpnext.selling"); erpnext.sales_common = { - setup_selling_controller:function() { + setup_selling_controller: function () { erpnext.selling.SellingController = class SellingController extends erpnext.TransactionController { setup() { super.setup(); @@ -15,107 +15,123 @@ erpnext.sales_common = { onload() { super.onload(); this.setup_queries(); - this.frm.set_query('shipping_rule', function() { + this.frm.set_query("shipping_rule", function () { return { filters: { - "shipping_rule_type": "Selling" - } + shipping_rule_type: "Selling", + }, }; }); - this.frm.set_query('project', function(doc) { + this.frm.set_query("project", function (doc) { return { query: "erpnext.controllers.queries.get_project_name", filters: { - 'customer': doc.customer - } - } + customer: doc.customer, + }, + }; }); } setup_queries() { var me = this; - $.each([["customer", "customer"], - ["lead", "lead"]], - function(i, opts) { - if(me.frm.fields_dict[opts[0]]) - me.frm.set_query(opts[0], erpnext.queries[opts[1]]); - }); + $.each( + [ + ["customer", "customer"], + ["lead", "lead"], + ], + function (i, opts) { + if (me.frm.fields_dict[opts[0]]) me.frm.set_query(opts[0], erpnext.queries[opts[1]]); + } + ); - me.frm.set_query('contact_person', erpnext.queries.contact_query); - me.frm.set_query('customer_address', erpnext.queries.address_query); - me.frm.set_query('shipping_address_name', erpnext.queries.address_query); - me.frm.set_query('dispatch_address_name', erpnext.queries.dispatch_address_query); + me.frm.set_query("contact_person", erpnext.queries.contact_query); + me.frm.set_query("customer_address", erpnext.queries.address_query); + me.frm.set_query("shipping_address_name", erpnext.queries.address_query); + me.frm.set_query("dispatch_address_name", erpnext.queries.dispatch_address_query); erpnext.accounts.dimensions.setup_dimension_filters(me.frm, me.frm.doctype); - if(this.frm.fields_dict.selling_price_list) { - this.frm.set_query("selling_price_list", function() { + if (this.frm.fields_dict.selling_price_list) { + this.frm.set_query("selling_price_list", function () { return { filters: { selling: 1 } }; }); } - if(this.frm.fields_dict.tc_name) { - this.frm.set_query("tc_name", function() { + if (this.frm.fields_dict.tc_name) { + this.frm.set_query("tc_name", function () { return { filters: { selling: 1 } }; }); } - if(!this.frm.fields_dict["items"]) { + if (!this.frm.fields_dict["items"]) { return; } - if(this.frm.fields_dict["items"].grid.get_field('item_code')) { - this.frm.set_query("item_code", "items", function() { + if (this.frm.fields_dict["items"].grid.get_field("item_code")) { + this.frm.set_query("item_code", "items", function () { return { query: "erpnext.controllers.queries.item_query", - filters: {'is_sales_item': 1, 'customer': me.frm.doc.customer, 'has_variants': 0} - } + filters: { is_sales_item: 1, customer: me.frm.doc.customer, has_variants: 0 }, + }; }); } - if(this.frm.fields_dict["packed_items"] && - this.frm.fields_dict["packed_items"].grid.get_field('batch_no')) { - this.frm.set_query("batch_no", "packed_items", function(doc, cdt, cdn) { - return me.set_query_for_batch(doc, cdt, cdn) + if ( + this.frm.fields_dict["packed_items"] && + this.frm.fields_dict["packed_items"].grid.get_field("batch_no") + ) { + this.frm.set_query("batch_no", "packed_items", function (doc, cdt, cdn) { + return me.set_query_for_batch(doc, cdt, cdn); }); } - if(this.frm.fields_dict["items"].grid.get_field('item_code')) { - this.frm.set_query("item_tax_template", "items", function(doc, cdt, cdn) { - return me.set_query_for_item_tax_template(doc, cdt, cdn) + if (this.frm.fields_dict["items"].grid.get_field("item_code")) { + this.frm.set_query("item_tax_template", "items", function (doc, cdt, cdn) { + return me.set_query_for_item_tax_template(doc, cdt, cdn); }); } - } refresh() { super.refresh(); - frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'} + frappe.dynamic_link = { doc: this.frm.doc, fieldname: "customer", doctype: "Customer" }; - this.frm.toggle_display("customer_name", - (this.frm.doc.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); + this.frm.toggle_display( + "customer_name", + this.frm.doc.customer_name && this.frm.doc.customer_name !== this.frm.doc.customer + ); this.toggle_editable_price_list_rate(); } customer() { var me = this; - erpnext.utils.get_party_details(this.frm, null, null, function() { + erpnext.utils.get_party_details(this.frm, null, null, function () { me.apply_price_list(); }); } customer_address() { erpnext.utils.get_address_display(this.frm, "customer_address"); - erpnext.utils.set_taxes_from_address(this.frm, "customer_address", "customer_address", "shipping_address_name"); + erpnext.utils.set_taxes_from_address( + this.frm, + "customer_address", + "customer_address", + "shipping_address_name" + ); } shipping_address_name() { erpnext.utils.get_address_display(this.frm, "shipping_address_name", "shipping_address"); - erpnext.utils.set_taxes_from_address(this.frm, "shipping_address_name", "customer_address", "shipping_address_name"); + erpnext.utils.set_taxes_from_address( + this.frm, + "shipping_address_name", + "customer_address", + "shipping_address_name" + ); } dispatch_address_name() { @@ -138,18 +154,17 @@ erpnext.sales_common = { discount_percentage(doc, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); item.discount_amount = 0.0; - this.apply_discount_on_item(doc, cdt, cdn, 'discount_percentage'); + this.apply_discount_on_item(doc, cdt, cdn, "discount_percentage"); } discount_amount(doc, cdt, cdn) { - - if(doc.name === cdn) { + if (doc.name === cdn) { return; } var item = frappe.get_doc(cdt, cdn); item.discount_percentage = 0.0; - this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount'); + this.apply_discount_on_item(doc, cdt, cdn, "discount_amount"); } commission_rate() { @@ -157,40 +172,48 @@ erpnext.sales_common = { } total_commission() { - frappe.model.round_floats_in(this.frm.doc, ["amount_eligible_for_commission", "total_commission"]); + frappe.model.round_floats_in(this.frm.doc, [ + "amount_eligible_for_commission", + "total_commission", + ]); const { amount_eligible_for_commission } = this.frm.doc; - if(!amount_eligible_for_commission) return; + if (!amount_eligible_for_commission) return; this.frm.set_value( - "commission_rate", flt( - this.frm.doc.total_commission * 100.0 / amount_eligible_for_commission - ) + "commission_rate", + flt((this.frm.doc.total_commission * 100.0) / amount_eligible_for_commission) ); } allocated_percentage(doc, cdt, cdn) { var sales_person = frappe.get_doc(cdt, cdn); - if(sales_person.allocated_percentage) { + if (sales_person.allocated_percentage) { + sales_person.allocated_percentage = flt( + sales_person.allocated_percentage, + precision("allocated_percentage", sales_person) + ); - sales_person.allocated_percentage = flt(sales_person.allocated_percentage, - precision("allocated_percentage", sales_person)); - - sales_person.allocated_amount = flt(this.frm.doc.amount_eligible_for_commission * - sales_person.allocated_percentage / 100.0, - precision("allocated_amount", sales_person)); - refresh_field(["allocated_amount"], sales_person); + sales_person.allocated_amount = flt( + (this.frm.doc.amount_eligible_for_commission * sales_person.allocated_percentage) / + 100.0, + precision("allocated_amount", sales_person) + ); + refresh_field(["allocated_amount"], sales_person); this.calculate_incentive(sales_person); - refresh_field(["allocated_percentage", "allocated_amount", "commission_rate","incentives"], sales_person.name, - sales_person.parentfield); + refresh_field( + ["allocated_percentage", "allocated_amount", "commission_rate", "incentives"], + sales_person.name, + sales_person.parentfield + ); } } sales_person(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); this.calculate_incentive(row); - refresh_field("incentives",row.name,row.parentfield); + refresh_field("incentives", row.name, row.parentfield); } warehouse(doc, cdt, cdn) { @@ -200,35 +223,47 @@ erpnext.sales_common = { } toggle_editable_price_list_rate() { - var df = frappe.meta.get_docfield(this.frm.doc.doctype + " Item", "price_list_rate", this.frm.doc.name); + var df = frappe.meta.get_docfield( + this.frm.doc.doctype + " Item", + "price_list_rate", + this.frm.doc.name + ); var editable_price_list_rate = cint(frappe.defaults.get_default("editable_price_list_rate")); - if(df && editable_price_list_rate) { - const parent_field = frappe.meta.get_parentfield(this.frm.doc.doctype, this.frm.doc.doctype + " Item"); + if (df && editable_price_list_rate) { + const parent_field = frappe.meta.get_parentfield( + this.frm.doc.doctype, + this.frm.doc.doctype + " Item" + ); if (!this.frm.fields_dict[parent_field]) return; this.frm.fields_dict[parent_field].grid.update_docfield_property( - 'price_list_rate', 'read_only', 0 + "price_list_rate", + "read_only", + 0 ); } } calculate_commission() { - if(!this.frm.fields_dict.commission_rate || this.frm.doc.docstatus === 1) return; + if (!this.frm.fields_dict.commission_rate || this.frm.doc.docstatus === 1) return; - if(this.frm.doc.commission_rate > 100) { + if (this.frm.doc.commission_rate > 100) { this.frm.set_value("commission_rate", 100); - frappe.throw(`${__(frappe.meta.get_label( - this.frm.doc.doctype, "commission_rate", this.frm.doc.name - ))} ${__("cannot be greater than 100")}`); + frappe.throw( + `${__( + frappe.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name) + )} ${__("cannot be greater than 100")}` + ); } this.frm.doc.amount_eligible_for_commission = this.frm.doc.items.reduce( - (sum, item) => item.grant_commission ? sum + item.base_net_amount : sum, 0 - ) + (sum, item) => (item.grant_commission ? sum + item.base_net_amount : sum), + 0 + ); this.frm.doc.total_commission = flt( - this.frm.doc.amount_eligible_for_commission * this.frm.doc.commission_rate / 100.0, + (this.frm.doc.amount_eligible_for_commission * this.frm.doc.commission_rate) / 100.0, precision("total_commission") ); @@ -237,25 +272,24 @@ erpnext.sales_common = { calculate_contribution() { var me = this; - $.each(this.frm.doc.doctype.sales_team || [], function(i, sales_person) { + $.each(this.frm.doc.doctype.sales_team || [], function (i, sales_person) { frappe.model.round_floats_in(sales_person); if (!sales_person.allocated_percentage) return; sales_person.allocated_amount = flt( - me.frm.doc.amount_eligible_for_commission - * sales_person.allocated_percentage - / 100.0, + (me.frm.doc.amount_eligible_for_commission * sales_person.allocated_percentage) / + 100.0, precision("allocated_amount", sales_person) ); }); } calculate_incentive(row) { - if(row.allocated_amount) - { + if (row.allocated_amount) { row.incentives = flt( - row.allocated_amount * row.commission_rate / 100.0, - precision("incentives", row)); + (row.allocated_amount * row.commission_rate) / 100.0, + precision("incentives", row) + ); } } @@ -265,37 +299,41 @@ erpnext.sales_common = { } set_product_bundle_help(doc) { - if(!this.frm.fields_dict.packing_list) return; + if (!this.frm.fields_dict.packing_list) return; if ((doc.packed_items || []).length) { $(this.frm.fields_dict.packing_list.row.wrapper).toggle(true); - 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; + 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 { $(this.frm.fields_dict.packing_list.row.wrapper).toggle(false); - if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { - frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = ''; + if (in_list(["Delivery Note", "Sales Invoice"], doc.doctype)) { + frappe.meta.get_docfield(doc.doctype, "product_bundle_help", doc.name).options = ""; } } - refresh_field('product_bundle_help'); + refresh_field("product_bundle_help"); } company_address() { var me = this; - if(this.frm.doc.company_address) { + if (this.frm.doc.company_address) { frappe.call({ method: "frappe.contacts.doctype.address.address.get_address_display", - args: {"address_dict": this.frm.doc.company_address }, - callback: function(r) { - if(r.message) { - me.frm.set_value("company_address_display", r.message) + args: { address_dict: this.frm.doc.company_address }, + callback: function (r) { + if (r.message) { + me.frm.set_value("company_address_display", r.message); } - } - }) + }, + }); } else { this.frm.set_value("company_address_display", ""); } @@ -314,79 +352,96 @@ erpnext.sales_common = { let me = this; let path = "assets/erpnext/js/utils/serial_no_batch_selector.js"; - frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]) - .then((r) => { - if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { - item.has_serial_no = r.message.has_serial_no; - item.has_batch_no = r.message.has_batch_no; - item.type_of_transaction = item.qty > 0 ? "Outward":"Inward"; + frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]).then((r) => { + if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { + item.has_serial_no = r.message.has_serial_no; + item.has_batch_no = r.message.has_batch_no; + item.type_of_transaction = item.qty > 0 ? "Outward" : "Inward"; - item.title = item.has_serial_no ? - __("Select Serial No") : __("Select Batch No"); + item.title = item.has_serial_no ? __("Select Serial No") : __("Select Batch No"); - if (item.has_serial_no && item.has_batch_no) { - item.title = __("Select Serial and Batch"); - } - - frappe.require(path, function() { - new erpnext.SerialBatchPackageSelector( - me.frm, item, (r) => { - if (r) { - let qty = Math.abs(r.total_qty); - if (doc.is_return) { - qty = qty * -1; - } - - frappe.model.set_value(item.doctype, item.name, { - "serial_and_batch_bundle": r.name, - "use_serial_batch_fields": 0, - "qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item)) - }); - } - } - ); - }); + if (item.has_serial_no && item.has_batch_no) { + item.title = __("Select Serial and Batch"); } - }); + + frappe.require(path, function () { + new erpnext.SerialBatchPackageSelector(me.frm, item, (r) => { + if (r) { + let qty = Math.abs(r.total_qty); + if (doc.is_return) { + qty = qty * -1; + } + + frappe.model.set_value(item.doctype, item.name, { + serial_and_batch_bundle: r.name, + use_serial_batch_fields: 0, + qty: + qty / + flt( + item.conversion_factor || 1, + precision("conversion_factor", item) + ), + }); + } + }); + }); + } + }); } update_auto_repeat_reference(doc) { if (doc.auto_repeat) { frappe.call({ - method:"frappe.automation.doctype.auto_repeat.auto_repeat.update_reference", - args:{ + method: "frappe.automation.doctype.auto_repeat.auto_repeat.update_reference", + args: { docname: doc.auto_repeat, - reference:doc.name + reference: doc.name, }, - callback: function(r){ - if (r.message=="success") { - frappe.show_alert({message:__("Auto repeat document updated"), indicator:'green'}); + callback: function (r) { + if (r.message == "success") { + frappe.show_alert({ + message: __("Auto repeat document updated"), + indicator: "green", + }); } else { - frappe.show_alert({message:__("An error occurred during the update process"), indicator:'red'}); + frappe.show_alert({ + message: __("An error occurred during the update process"), + indicator: "red", + }); } - } - }) + }, + }); } } project() { let me = this; - if(in_list(["Delivery Note", "Sales Invoice", "Sales Order"], this.frm.doc.doctype)) { - if(this.frm.doc.project) { + if (in_list(["Delivery Note", "Sales Invoice", "Sales Order"], this.frm.doc.doctype)) { + if (this.frm.doc.project) { frappe.call({ - method:'erpnext.projects.doctype.project.project.get_cost_center_name' , - args: {project: this.frm.doc.project}, - callback: function(r, rt) { - if(!r.exc) { - $.each(me.frm.doc["items"] || [], function(i, row) { - if(r.message) { - frappe.model.set_value(row.doctype, row.name, "cost_center", r.message); - frappe.msgprint(__("Cost Center For Item with Item Code {0} has been Changed to {1}", [row.item_name, r.message])); + method: "erpnext.projects.doctype.project.project.get_cost_center_name", + args: { project: this.frm.doc.project }, + callback: function (r, rt) { + if (!r.exc) { + $.each(me.frm.doc["items"] || [], function (i, row) { + if (r.message) { + frappe.model.set_value( + row.doctype, + row.name, + "cost_center", + r.message + ); + frappe.msgprint( + __( + "Cost Center For Item with Item Code {0} has been Changed to {1}", + [row.item_name, r.message] + ) + ); } - }) + }); } - } - }) + }, + }); } } } @@ -396,57 +451,60 @@ erpnext.sales_common = { this.frm.set_value("additional_discount_percentage", 0); } }; - } -} + }, +}; erpnext.pre_sales = { - set_as_lost: function(doctype) { + set_as_lost: function (doctype) { frappe.ui.form.on(doctype, { - set_as_lost_dialog: function(frm) { + set_as_lost_dialog: function (frm) { var dialog = new frappe.ui.Dialog({ title: __("Set as Lost"), fields: [ { - "fieldtype": "Table MultiSelect", - "label": __("Lost Reasons"), - "fieldname": "lost_reason", - "options": frm.doctype === 'Opportunity' ? 'Opportunity Lost Reason Detail': 'Quotation Lost Reason Detail', - "reqd": 1 + fieldtype: "Table MultiSelect", + label: __("Lost Reasons"), + fieldname: "lost_reason", + options: + frm.doctype === "Opportunity" + ? "Opportunity Lost Reason Detail" + : "Quotation Lost Reason Detail", + reqd: 1, }, { - "fieldtype": "Table MultiSelect", - "label": __("Competitors"), - "fieldname": "competitors", - "options": "Competitor Detail" + fieldtype: "Table MultiSelect", + label: __("Competitors"), + fieldname: "competitors", + options: "Competitor Detail", }, { - "fieldtype": "Small Text", - "label": __("Detailed Reason"), - "fieldname": "detailed_reason" + fieldtype: "Small Text", + label: __("Detailed Reason"), + fieldname: "detailed_reason", }, ], - primary_action: function() { + primary_action: function () { let values = dialog.get_values(); frm.call({ doc: frm.doc, - method: 'declare_enquiry_lost', + method: "declare_enquiry_lost", args: { - 'lost_reasons_list': values.lost_reason, - 'competitors': values.competitors ? values.competitors : [], - 'detailed_reason': values.detailed_reason + lost_reasons_list: values.lost_reason, + competitors: values.competitors ? values.competitors : [], + detailed_reason: values.detailed_reason, }, - callback: function(r) { + callback: function (r) { dialog.hide(); frm.reload_doc(); }, }); }, - primary_action_label: __('Declare Lost') + primary_action_label: __("Declare Lost"), }); dialog.show(); - } + }, }); - } -} + }, +}; diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index d0064b30c34..24133b8cdc3 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -4,30 +4,30 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { this.item = item; this.qty = item.qty; this.callback = callback; - this.bundle = this.item?.is_rejected ? - this.item.rejected_serial_and_batch_bundle : this.item.serial_and_batch_bundle; + this.bundle = this.item?.is_rejected + ? this.item.rejected_serial_and_batch_bundle + : this.item.serial_and_batch_bundle; this.make(); this.render_data(); } make() { - let label = this.item?.has_serial_no ? __('Serial Nos') : __('Batch Nos'); - let primary_label = this.bundle - ? __('Update') : __('Add'); + let label = this.item?.has_serial_no ? __("Serial Nos") : __("Batch Nos"); + let primary_label = this.bundle ? __("Update") : __("Add"); if (this.item?.has_serial_no && this.item?.batch_no) { - label = __('Serial Nos / Batch Nos'); + label = __("Serial Nos / Batch Nos"); } - primary_label += ' ' + label; + primary_label += " " + label; this.dialog = new frappe.ui.Dialog({ title: this.item?.title || primary_label, fields: this.get_dialog_fields(), primary_action_label: primary_label, primary_action: () => this.update_bundle_entries(), - secondary_action_label: __('Edit Full Form'), + secondary_action_label: __("Edit Full Form"), secondary_action: () => this.edit_full_form(), }); @@ -45,21 +45,21 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { if (qty > 0) { this.dialog.set_value("qty", qty).then(() => { if (this.item.serial_no && !this.item.serial_and_batch_bundle) { - let serial_nos = this.item.serial_no.split('\n'); + let serial_nos = this.item.serial_no.split("\n"); if (serial_nos.length > 1) { - serial_nos.forEach(serial_no => { + serial_nos.forEach((serial_no) => { this.dialog.fields_dict.entries.df.data.push({ serial_no: serial_no, - batch_no: this.item.batch_no + batch_no: this.item.batch_no, }); }); } else { this.dialog.set_value("scan_serial_no", this.item.serial_no); } - frappe.model.set_value(this.item.doctype, this.item.name, 'serial_no', ''); + frappe.model.set_value(this.item.doctype, this.item.name, "serial_no", ""); } else if (this.item.batch_no && !this.item.serial_and_batch_bundle) { this.dialog.set_value("scan_batch_no", this.item.batch_no); - frappe.model.set_value(this.item.doctype, this.item.name, 'batch_no', ''); + frappe.model.set_value(this.item.doctype, this.item.name, "batch_no", ""); } this.dialog.fields_dict.entries.grid.refresh(); @@ -68,20 +68,20 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } get_serial_no_filters() { - let warehouse = this.item?.type_of_transaction === "Outward" ? - (this.item.warehouse || this.item.s_warehouse) : ""; + let warehouse = + this.item?.type_of_transaction === "Outward" ? this.item.warehouse || this.item.s_warehouse : ""; - if (this.frm.doc.doctype === 'Stock Entry') { + if (this.frm.doc.doctype === "Stock Entry") { warehouse = this.item.s_warehouse || this.item.t_warehouse; } - if (!warehouse && this.frm.doc.doctype === 'Stock Reconciliation') { + if (!warehouse && this.frm.doc.doctype === "Stock Reconciliation") { warehouse = this.get_warehouse(); } return { - 'item_code': this.item.item_code, - 'warehouse': ["=", warehouse] + item_code: this.item.item_code, + warehouse: ["=", warehouse], }; } @@ -89,71 +89,70 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { let fields = []; fields.push({ - fieldtype: 'Link', - fieldname: 'warehouse', - label: __('Warehouse'), - options: 'Warehouse', + fieldtype: "Link", + fieldname: "warehouse", + label: __("Warehouse"), + options: "Warehouse", default: this.get_warehouse(), onchange: () => { - this.item.warehouse = this.dialog.get_value('warehouse'); - this.get_auto_data() + this.item.warehouse = this.dialog.get_value("warehouse"); + this.get_auto_data(); }, get_query: () => { return { filters: { - 'is_group': 0, - 'company': this.frm.doc.company, - } + is_group: 0, + company: this.frm.doc.company, + }, }; - } + }, }); - if (this.frm.doc.doctype === 'Stock Entry' - && this.frm.doc.purpose === 'Manufacture') { + if (this.frm.doc.doctype === "Stock Entry" && this.frm.doc.purpose === "Manufacture") { fields.push({ - fieldtype: 'Column Break', + fieldtype: "Column Break", }); fields.push({ - fieldtype: 'Link', - fieldname: 'work_order', - label: __('For Work Order'), - options: 'Work Order', + fieldtype: "Link", + fieldname: "work_order", + label: __("For Work Order"), + options: "Work Order", read_only: 1, default: this.frm.doc.work_order, }); fields.push({ - fieldtype: 'Section Break', + fieldtype: "Section Break", }); } fields.push({ - fieldtype: 'Column Break', + fieldtype: "Column Break", }); if (this.item.has_serial_no) { fields.push({ - fieldtype: 'Data', - options: 'Barcode', - fieldname: 'scan_serial_no', - label: __('Scan Serial No'), + fieldtype: "Data", + options: "Barcode", + fieldname: "scan_serial_no", + label: __("Scan Serial No"), get_query: () => { return { - filters: this.get_serial_no_filters() + filters: this.get_serial_no_filters(), }; }, - onchange: () => this.scan_barcode_data() + onchange: () => this.scan_barcode_data(), }); } if (this.item.has_batch_no && !this.item.has_serial_no) { fields.push({ - fieldtype: 'Data', - options: 'Barcode', - fieldname: 'scan_batch_no', - label: __('Scan Batch No'), - onchange: () => this.scan_barcode_data() + fieldtype: "Data", + options: "Barcode", + fieldname: "scan_batch_no", + label: __("Scan Batch No"), + onchange: () => this.scan_barcode_data(), }); } @@ -164,12 +163,12 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } fields.push({ - fieldtype: 'Section Break', + fieldtype: "Section Break", }); fields.push({ - fieldname: 'entries', - fieldtype: 'Table', + fieldname: "entries", + fieldtype: "Table", allow_bulk_edit: true, data: [], fields: this.get_dialog_table_fields(), @@ -179,94 +178,95 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } get_attach_field() { - let label = this.item?.has_serial_no ? __('Serial Nos') : __('Batch Nos'); - let primary_label = this.bundle - ? __('Update') : __('Add'); + let label = this.item?.has_serial_no ? __("Serial Nos") : __("Batch Nos"); + let primary_label = this.bundle ? __("Update") : __("Add"); if (this.item?.has_serial_no && this.item?.has_batch_no) { - label = __('Serial Nos / Batch Nos'); + label = __("Serial Nos / Batch Nos"); } let fields = [ { - fieldtype: 'Section Break', - label: __('{0} {1} via CSV File', [primary_label, label]) - } - ] + fieldtype: "Section Break", + label: __("{0} {1} via CSV File", [primary_label, label]), + }, + ]; if (this.item?.has_serial_no) { - fields = [...fields, + fields = [ + ...fields, { - fieldtype: 'Check', - label: __('Import Using CSV file'), - fieldname: 'import_using_csv_file', + fieldtype: "Check", + label: __("Import Using CSV file"), + fieldname: "import_using_csv_file", default: 0, }, { - fieldtype: 'Section Break', - label: __('{0} {1} Manually', [primary_label, label]), - depends_on: 'eval:doc.import_using_csv_file === 0', + fieldtype: "Section Break", + label: __("{0} {1} Manually", [primary_label, label]), + depends_on: "eval:doc.import_using_csv_file === 0", }, { - fieldtype: 'Small Text', - label: __('Enter Serial Nos'), - fieldname: 'upload_serial_nos', - depends_on: 'eval:doc.import_using_csv_file === 0', - description: __('Enter each serial no in a new line'), + fieldtype: "Small Text", + label: __("Enter Serial Nos"), + fieldname: "upload_serial_nos", + depends_on: "eval:doc.import_using_csv_file === 0", + description: __("Enter each serial no in a new line"), }, { - fieldtype: 'Column Break', - depends_on: 'eval:doc.import_using_csv_file === 0', + fieldtype: "Column Break", + depends_on: "eval:doc.import_using_csv_file === 0", }, { - fieldtype: 'Button', - fieldname: 'make_serial_nos', - label: __('Create Serial Nos'), - depends_on: 'eval:doc.import_using_csv_file === 0', + fieldtype: "Button", + fieldname: "make_serial_nos", + label: __("Create Serial Nos"), + depends_on: "eval:doc.import_using_csv_file === 0", click: () => { this.create_serial_nos(); - } + }, }, { - fieldtype: 'Section Break', - depends_on: 'eval:doc.import_using_csv_file === 1', - } + fieldtype: "Section Break", + depends_on: "eval:doc.import_using_csv_file === 1", + }, ]; } - fields = [...fields, + fields = [ + ...fields, { - fieldtype: 'Button', - fieldname: 'download_csv', - label: __('Download CSV Template'), - click: () => this.download_csv_file() + fieldtype: "Button", + fieldname: "download_csv", + label: __("Download CSV Template"), + click: () => this.download_csv_file(), }, { - fieldtype: 'Column Break', + fieldtype: "Column Break", }, { - fieldtype: 'Attach', - fieldname: 'attach_serial_batch_csv', - label: __('Attach CSV File'), - onchange: () => this.upload_csv_file() - } + fieldtype: "Attach", + fieldname: "attach_serial_batch_csv", + label: __("Attach CSV File"), + onchange: () => this.upload_csv_file(), + }, ]; return fields; } create_serial_nos() { - let {upload_serial_nos} = this.dialog.get_values(); + let { upload_serial_nos } = this.dialog.get_values(); if (!upload_serial_nos) { - frappe.throw(__('Please enter Serial Nos')); + frappe.throw(__("Please enter Serial Nos")); } frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.create_serial_nos', + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.create_serial_nos", args: { item_code: this.item.item_code, - serial_nos: upload_serial_nos + serial_nos: upload_serial_nos, }, callback: (r) => { if (r.message) { @@ -274,20 +274,22 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { this.set_data(r.message); this.update_bundle_entries(); } - } + }, }); } download_csv_file() { - let csvFileData = ['Serial No']; + let csvFileData = ["Serial No"]; if (this.item.has_serial_no && this.item.has_batch_no) { - csvFileData = ['Serial No', 'Batch No', 'Quantity']; + csvFileData = ["Serial No", "Batch No", "Quantity"]; } else if (this.item.has_batch_no) { - csvFileData = ['Batch No', 'Quantity']; + csvFileData = ["Batch No", "Quantity"]; } - const method = `/api/method/erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.download_blank_csv_template?content=${encodeURIComponent(JSON.stringify(csvFileData))}`; + const method = `/api/method/erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.download_blank_csv_template?content=${encodeURIComponent( + JSON.stringify(csvFileData) + )}`; const w = window.open(frappe.urllib.get_full_url(method)); if (!w) { frappe.msgprint(__("Please enable pop-ups")); @@ -295,13 +297,13 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } upload_csv_file() { - const file_path = this.dialog.get_value("attach_serial_batch_csv") + const file_path = this.dialog.get_value("attach_serial_batch_csv"); frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.upload_csv_file', + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.upload_csv_file", args: { item_code: this.item.item_code, - file_path: file_path + file_path: file_path, }, callback: (r) => { if (r.message.serial_nos && r.message.serial_nos.length) { @@ -309,102 +311,106 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } else if (r.message.batch_nos && r.message.batch_nos.length) { this.set_data(r.message.batch_nos); } - } + }, }); } get_filter_fields() { return [ { - fieldtype: 'Section Break', - label: __('Auto Fetch') + fieldtype: "Section Break", + label: __("Auto Fetch"), }, { - fieldtype: 'Float', - fieldname: 'qty', - label: __('Qty to Fetch'), - onchange: () => this.get_auto_data() + fieldtype: "Float", + fieldname: "qty", + label: __("Qty to Fetch"), + onchange: () => this.get_auto_data(), }, { - fieldtype: 'Column Break', + fieldtype: "Column Break", }, { - fieldtype: 'Select', - options: ['FIFO', 'LIFO', 'Expiry'], - default: 'FIFO', - fieldname: 'based_on', - label: __('Fetch Based On'), - onchange: () => this.get_auto_data() + fieldtype: "Select", + options: ["FIFO", "LIFO", "Expiry"], + default: "FIFO", + fieldname: "based_on", + label: __("Fetch Based On"), + onchange: () => this.get_auto_data(), }, { - fieldtype: 'Section Break', + fieldtype: "Section Break", }, - ] - + ]; } get_dialog_table_fields() { - let fields = [] + let fields = []; if (this.item.has_serial_no) { fields.push({ - fieldtype: 'Link', - options: 'Serial No', - fieldname: 'serial_no', - label: __('Serial No'), + fieldtype: "Link", + options: "Serial No", + fieldname: "serial_no", + label: __("Serial No"), in_list_view: 1, get_query: () => { return { - filters: this.get_serial_no_filters() - } - } - }) + filters: this.get_serial_no_filters(), + }; + }, + }); } - let batch_fields = [] + let batch_fields = []; if (this.item.has_batch_no) { batch_fields = [ { - fieldtype: 'Link', - options: 'Batch', - fieldname: 'batch_no', - label: __('Batch No'), + fieldtype: "Link", + options: "Batch", + fieldname: "batch_no", + label: __("Batch No"), in_list_view: 1, get_query: () => { let is_inward = false; - if ((["Purchase Receipt", "Purchase Invoice"].includes(this.frm.doc.doctype) && !this.frm.doc.is_return) - || (this.frm.doc.doctype === 'Stock Entry' && this.frm.doc.purpose === 'Material Receipt')) { + if ( + (["Purchase Receipt", "Purchase Invoice"].includes(this.frm.doc.doctype) && + !this.frm.doc.is_return) || + (this.frm.doc.doctype === "Stock Entry" && + this.frm.doc.purpose === "Material Receipt") + ) { is_inward = true; } return { - query : "erpnext.controllers.queries.get_batch_no", + query: "erpnext.controllers.queries.get_batch_no", filters: { - 'item_code': this.item.item_code, - 'warehouse': this.item.s_warehouse || this.item.t_warehouse || this.item.warehouse, - 'is_inward': is_inward - } - } + item_code: this.item.item_code, + warehouse: + this.item.s_warehouse || this.item.t_warehouse || this.item.warehouse, + is_inward: is_inward, + }, + }; }, - } - ] + }, + ]; if (!this.item.has_serial_no) { batch_fields.push({ - fieldtype: 'Float', - fieldname: 'qty', - label: __('Quantity'), + fieldtype: "Float", + fieldname: "qty", + label: __("Quantity"), in_list_view: 1, - }) + }); } } fields = [...fields, ...batch_fields]; fields.push({ - fieldtype: 'Data', - fieldname: 'name', - label: __('Name'), + fieldtype: "Data", + fieldname: "name", + label: __("Name"), hidden: 1, }); @@ -425,26 +431,26 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } if (!based_on) { - based_on = 'FIFO'; + based_on = "FIFO"; } if (qty) { frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_auto_data', + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_auto_data", args: { item_code: this.item.item_code, warehouse: this.item.warehouse || this.item.s_warehouse, has_serial_no: this.item.has_serial_no, has_batch_no: this.item.has_batch_no, qty: qty, - based_on: based_on + based_on: based_on, }, callback: (r) => { if (r.message) { this.dialog.fields_dict.entries.df.data = r.message; this.dialog.fields_dict.entries.grid.refresh(); } - } + }, }); } } @@ -454,7 +460,7 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { if (scan_serial_no || scan_batch_no) { frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.is_serial_batch_no_exists', + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.is_serial_batch_no_exists", args: { item_code: this.item.item_code, type_of_transaction: this.item.type_of_transaction, @@ -463,9 +469,8 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { }, callback: (r) => { this.update_serial_batch_no(); - } - - }) + }, + }); } } @@ -473,25 +478,25 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { const { scan_serial_no, scan_batch_no } = this.dialog.get_values(); if (scan_serial_no) { - let existing_row = this.dialog.fields_dict.entries.df.data.filter(d => { + let existing_row = this.dialog.fields_dict.entries.df.data.filter((d) => { if (d.serial_no === scan_serial_no) { - return d + return d; } }); if (existing_row?.length) { - frappe.throw(__('Serial No {0} already exists', [scan_serial_no])); + frappe.throw(__("Serial No {0} already exists", [scan_serial_no])); } if (!this.item.has_batch_no) { this.dialog.fields_dict.entries.df.data.push({ - serial_no: scan_serial_no + serial_no: scan_serial_no, }); - this.dialog.fields_dict.scan_serial_no.set_value(''); + this.dialog.fields_dict.scan_serial_no.set_value(""); } else { frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_batch_no_from_serial_no', + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_batch_no_from_serial_no", args: { serial_no: scan_serial_no, }, @@ -499,19 +504,18 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { if (r.message) { this.dialog.fields_dict.entries.df.data.push({ serial_no: scan_serial_no, - batch_no: r.message + batch_no: r.message, }); - this.dialog.fields_dict.scan_serial_no.set_value(''); + this.dialog.fields_dict.scan_serial_no.set_value(""); } - } - - }) + }, + }); } } else if (scan_batch_no) { - let existing_row = this.dialog.fields_dict.entries.df.data.filter(d => { + let existing_row = this.dialog.fields_dict.entries.df.data.filter((d) => { if (d.batch_no === scan_batch_no) { - return d + return d; } }); @@ -520,11 +524,11 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } else { this.dialog.fields_dict.entries.df.data.push({ batch_no: scan_batch_no, - qty: 1 + qty: 1, }); } - this.dialog.fields_dict.scan_batch_no.set_value(''); + this.dialog.fields_dict.scan_batch_no.set_value(""); } this.dialog.fields_dict.entries.grid.refresh(); @@ -532,33 +536,33 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { update_bundle_entries() { let entries = this.dialog.get_values().entries; - let warehouse = this.dialog.get_value('warehouse'); + let warehouse = this.dialog.get_value("warehouse"); - if (entries && !entries.length || !entries) { - frappe.throw(__('Please add atleast one Serial No / Batch No')); + if ((entries && !entries.length) || !entries) { + frappe.throw(__("Please add atleast one Serial No / Batch No")); } - frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.add_serial_batch_ledgers', - args: { - entries: entries, - child_row: this.item, - doc: this.frm.doc, - warehouse: warehouse, - } - }).then(r => { - this.callback && this.callback(r.message); - this.frm.save(); - this.dialog.hide(); - }) + frappe + .call({ + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.add_serial_batch_ledgers", + args: { + entries: entries, + child_row: this.item, + doc: this.frm.doc, + warehouse: warehouse, + }, + }) + .then((r) => { + this.callback && this.callback(r.message); + this.frm.save(); + this.dialog.hide(); + }); } edit_full_form() { - let bundle_id = this.item.serial_and_batch_bundle + let bundle_id = this.item.serial_and_batch_bundle; if (!bundle_id) { - let _new = frappe.model.get_new_doc( - "Serial and Batch Bundle", null, null, true - ); + let _new = frappe.model.get_new_doc("Serial and Batch Bundle", null, null, true); _new.item_code = this.item.item_code; _new.warehouse = this.get_warehouse(); @@ -575,34 +579,36 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { } get_warehouse() { - return (this.item?.type_of_transaction === "Outward" ? - (this.item.warehouse || this.item.s_warehouse) - : (this.item.warehouse || this.item.t_warehouse)); + return this.item?.type_of_transaction === "Outward" + ? this.item.warehouse || this.item.s_warehouse + : this.item.warehouse || this.item.t_warehouse; } render_data() { if (this.bundle) { - frappe.call({ - method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_serial_batch_ledgers', - args: { - item_code: this.item.item_code, - name: this.bundle, - voucher_no: !this.frm.is_new() ? this.item.parent : "", - } - }).then(r => { - if (r.message) { - this.set_data(r.message); - } - }) + frappe + .call({ + method: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.get_serial_batch_ledgers", + args: { + item_code: this.item.item_code, + name: this.bundle, + voucher_no: !this.frm.is_new() ? this.item.parent : "", + }, + }) + .then((r) => { + if (r.message) { + this.set_data(r.message); + } + }); } } set_data(data) { - data.forEach(d => { + data.forEach((d) => { d.qty = Math.abs(d.qty); this.dialog.fields_dict.entries.df.data.push(d); }); this.dialog.fields_dict.entries.grid.refresh(); } -} \ No newline at end of file +}; diff --git a/erpnext/public/js/utils/supplier_quick_entry.js b/erpnext/public/js/utils/supplier_quick_entry.js index 687b01454a2..968ef74c3a0 100644 --- a/erpnext/public/js/utils/supplier_quick_entry.js +++ b/erpnext/public/js/utils/supplier_quick_entry.js @@ -1,3 +1,3 @@ -frappe.provide('frappe.ui.form'); +frappe.provide("frappe.ui.form"); frappe.ui.form.SupplierQuickEntryForm = frappe.ui.form.ContactAddressQuickEntryForm; diff --git a/erpnext/public/js/utils/unreconcile.js b/erpnext/public/js/utils/unreconcile.js index 79490a162d3..6864e2865d3 100644 --- a/erpnext/public/js/utils/unreconcile.js +++ b/erpnext/public/js/utils/unreconcile.js @@ -1,27 +1,34 @@ -frappe.provide('erpnext.accounts'); +frappe.provide("erpnext.accounts"); erpnext.accounts.unreconcile_payment = { add_unreconcile_btn(frm) { if (frm.doc.docstatus == 1) { - if(((frm.doc.doctype == "Journal Entry") && (frm.doc.voucher_type != "Journal Entry")) - || !["Purchase Invoice", "Sales Invoice", "Journal Entry", "Payment Entry"].includes(frm.doc.doctype) - ) { + if ( + (frm.doc.doctype == "Journal Entry" && frm.doc.voucher_type != "Journal Entry") || + !["Purchase Invoice", "Sales Invoice", "Journal Entry", "Payment Entry"].includes( + frm.doc.doctype + ) + ) { return; } frappe.call({ - "method": "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.doc_has_references", - "args": { - "doctype": frm.doc.doctype, - "docname": frm.doc.name + method: "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.doc_has_references", + args: { + doctype: frm.doc.doctype, + docname: frm.doc.name, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.add_custom_button(__("UnReconcile"), function() { - erpnext.accounts.unreconcile_payment.build_unreconcile_dialog(frm); - }, __('Actions')); + frm.add_custom_button( + __("UnReconcile"), + function () { + erpnext.accounts.unreconcile_payment.build_unreconcile_dialog(frm); + }, + __("Actions") + ); } - } + }, }); } }, @@ -30,18 +37,18 @@ erpnext.accounts.unreconcile_payment = { // assuming each row is an individual voucher // pass this to server side method that creates unreconcile doc for each row let selection_map = []; - if (['Sales Invoice', 'Purchase Invoice'].includes(frm.doc.doctype)) { - selection_map = selections.map(function(elem) { + if (["Sales Invoice", "Purchase Invoice"].includes(frm.doc.doctype)) { + selection_map = selections.map(function (elem) { return { company: elem.company, voucher_type: elem.voucher_type, voucher_no: elem.voucher_no, against_voucher_type: frm.doc.doctype, - against_voucher_no: frm.doc.name + against_voucher_no: frm.doc.name, }; }); - } else if (['Payment Entry', 'Journal Entry'].includes(frm.doc.doctype)) { - selection_map = selections.map(function(elem) { + } else if (["Payment Entry", "Journal Entry"].includes(frm.doc.doctype)) { + selection_map = selections.map(function (elem) { return { company: elem.company, voucher_type: frm.doc.doctype, @@ -55,18 +62,41 @@ erpnext.accounts.unreconcile_payment = { }, build_unreconcile_dialog(frm) { - if (['Sales Invoice', 'Purchase Invoice', 'Payment Entry', 'Journal Entry'].includes(frm.doc.doctype)) { + if ( + ["Sales Invoice", "Purchase Invoice", "Payment Entry", "Journal Entry"].includes(frm.doc.doctype) + ) { let child_table_fields = [ - { label: __("Voucher Type"), fieldname: "voucher_type", fieldtype: "Dynamic Link", options: "DocType", in_list_view: 1, read_only: 1}, - { label: __("Voucher No"), fieldname: "voucher_no", fieldtype: "Link", options: "voucher_type", in_list_view: 1, read_only: 1 }, - { label: __("Allocated Amount"), fieldname: "allocated_amount", fieldtype: "Currency", in_list_view: 1, read_only: 1 , options: "account_currency"}, - { label: __("Currency"), fieldname: "account_currency", fieldtype: "Currency", read_only: 1}, - ] + { + label: __("Voucher Type"), + fieldname: "voucher_type", + fieldtype: "Dynamic Link", + options: "DocType", + in_list_view: 1, + read_only: 1, + }, + { + label: __("Voucher No"), + fieldname: "voucher_no", + fieldtype: "Link", + options: "voucher_type", + in_list_view: 1, + read_only: 1, + }, + { + label: __("Allocated Amount"), + fieldname: "allocated_amount", + fieldtype: "Currency", + in_list_view: 1, + read_only: 1, + options: "account_currency", + }, + { label: __("Currency"), fieldname: "account_currency", fieldtype: "Currency", read_only: 1 }, + ]; let unreconcile_dialog_fields = [ { - label: __('Allocations'), - fieldname: 'allocations', - fieldtype: 'Table', + label: __("Allocations"), + fieldname: "allocations", + fieldtype: "Table", read_only: 1, fields: child_table_fields, }, @@ -74,54 +104,57 @@ erpnext.accounts.unreconcile_payment = { // get linked payments frappe.call({ - "method": "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.get_linked_payments_for_doc", - "args": { - "company": frm.doc.company, - "doctype": frm.doc.doctype, - "docname": frm.doc.name + method: "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.get_linked_payments_for_doc", + args: { + company: frm.doc.company, + doctype: frm.doc.doctype, + docname: frm.doc.name, }, - callback: function(r) { + callback: function (r) { if (r.message) { // populate child table with allocations unreconcile_dialog_fields[0].data = r.message; - unreconcile_dialog_fields[0].get_data = function(){ return r.message}; + unreconcile_dialog_fields[0].get_data = function () { + return r.message; + }; let d = new frappe.ui.Dialog({ - title: 'UnReconcile Allocations', + title: "UnReconcile Allocations", fields: unreconcile_dialog_fields, - size: 'large', + size: "large", cannot_add_rows: true, - primary_action_label: 'UnReconcile', + primary_action_label: "UnReconcile", primary_action(values) { - - let selected_allocations = values.allocations.filter(x=>x.__checked); + let selected_allocations = values.allocations.filter((x) => x.__checked); if (selected_allocations.length > 0) { - let selection_map = erpnext.accounts.unreconcile_payment.build_selection_map(frm, selected_allocations); - erpnext.accounts.unreconcile_payment.create_unreconcile_docs(selection_map); + let selection_map = + erpnext.accounts.unreconcile_payment.build_selection_map( + frm, + selected_allocations + ); + erpnext.accounts.unreconcile_payment.create_unreconcile_docs( + selection_map + ); d.hide(); - } else { frappe.msgprint("No Selection"); } - } + }, }); d.show(); } - } + }, }); } }, create_unreconcile_docs(selection_map) { frappe.call({ - "method": "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.create_unreconcile_doc_for_selection", - "args": { - "selections": selection_map + method: "erpnext.accounts.doctype.unreconcile_payment.unreconcile_payment.create_unreconcile_doc_for_selection", + args: { + selections: selection_map, }, }); - } - - - -} + }, +}; diff --git a/erpnext/public/js/website_theme.js b/erpnext/public/js/website_theme.js index 0009cacf61e..9c2b8cd11b9 100644 --- a/erpnext/public/js/website_theme.js +++ b/erpnext/public/js/website_theme.js @@ -1,14 +1,15 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors // MIT License. See license.txt -frappe.ui.form.on('Website Theme', { +frappe.ui.form.on("Website Theme", { validate(frm) { let theme_scss = frm.doc.theme_scss; - if (theme_scss && theme_scss.includes('frappe/public/scss/website') - && !theme_scss.includes('erpnext/public/scss/website') + if ( + theme_scss && + theme_scss.includes("frappe/public/scss/website") && + !theme_scss.includes("erpnext/public/scss/website") ) { - frm.set_value('theme_scss', - `${frm.doc.theme_scss}\n@import "erpnext/public/scss/website";`); + frm.set_value("theme_scss", `${frm.doc.theme_scss}\n@import "erpnext/public/scss/website";`); } - } + }, }); diff --git a/erpnext/public/js/website_utils.js b/erpnext/public/js/website_utils.js index 2bb5255eebc..981899f8744 100644 --- a/erpnext/public/js/website_utils.js +++ b/erpnext/public/js/website_utils.js @@ -1,14 +1,14 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -if(!window.erpnext) window.erpnext = {}; +if (!window.erpnext) window.erpnext = {}; -erpnext.subscribe_to_newsletter = function(opts, btn) { +erpnext.subscribe_to_newsletter = function (opts, btn) { return frappe.call({ type: "POST", method: "frappe.email.doctype.newsletter.newsletter.subscribe", btn: btn, - args: {"email": opts.email}, - callback: opts.callback + args: { email: opts.email }, + callback: opts.callback, }); -} +}; diff --git a/erpnext/public/scss/erpnext.scss b/erpnext/public/scss/erpnext.scss index 1626b7c894d..e45ae5038f5 100644 --- a/erpnext/public/scss/erpnext.scss +++ b/erpnext/public/scss/erpnext.scss @@ -51,7 +51,7 @@ } // assessment tool -.frappe-control[data-fieldname='result_html'] { +.frappe-control[data-fieldname="result_html"] { overflow: scroll; } .assessment-result-tool { @@ -70,7 +70,9 @@ text-overflow: ellipsis; } - .total-score, .grade, .score { + .total-score, + .grade, + .score { text-align: right; } } @@ -78,13 +80,13 @@ /* pos */ body[data-route="pos"] { - .pos-bill-toolbar { padding: 10px 0px; height: 51px; } - .pos-bill-item:hover, .list-customers-table > .pos-list-row:hover { + .pos-bill-item:hover, + .list-customers-table > .pos-list-row:hover { background-color: #f5f7fa; cursor: pointer; } @@ -135,50 +137,52 @@ body[data-route="pos"] { } .pos-payment-row .col-xs-6 { - padding :15px; + padding: 15px; } .pos-payment-row { - border-bottom:1px solid var(--border-color); + border-bottom: 1px solid var(--border-color); margin: 2px 0px 5px 0px; height: 60px; margin-top: 0px; margin-bottom: 0px; } - .pos-payment-row:hover, .pos-keyboard-key:hover{ + .pos-payment-row:hover, + .pos-keyboard-key:hover { background-color: var(--bg-color); cursor: pointer; } - .pos-keyboard-key, .delete-btn { + .pos-keyboard-key, + .delete-btn { border: 1px solid var(--border-color); - height:85px; - width:85px; - margin:10px 10px; - font-size:24px; - font-weight:200; - background-color: #FDFDFD; + height: 85px; + width: 85px; + margin: 10px 10px; + font-size: 24px; + font-weight: 200; + background-color: #fdfdfd; border-color: #e8e8e8; } .numeric-keypad { border: 1px solid var(--border-color); - height:69px; - width:69px; - font-size:20px; - font-weight:200; - background-color: #FDFDFD; + height: 69px; + width: 69px; + font-size: 20px; + font-weight: 200; + background-color: #fdfdfd; border-color: #e8e8e8; - margin-left:-4px; + margin-left: -4px; } .pos-pay { - height:69px; - width:69px; - font-size:17px; - font-weight:200; - margin-left:-4px; + height: 69px; + width: 69px; + font-size: 17px; + font-weight: 200; + margin-left: -4px; } .numeric-keypad { @@ -188,7 +192,7 @@ body[data-route="pos"] { font-weight: 200; border-radius: 0; background-color: #fff; - margin-left:-4px; + margin-left: -4px; @media (max-width: var(--xl-width)) { height: 45px; @@ -253,7 +257,8 @@ body[data-route="pos"] { .amount-row h3 { font-size: 15px; } - .pos-keyboard-key, .delete-btn { + .pos-keyboard-key, + .delete-btn { height: 50px; } .multimode-payments { @@ -277,7 +282,8 @@ body[data-route="pos"] { padding: 15px 10px; } - .write_off_amount, .change_amount { + .write_off_amount, + .change_amount { margin: 15px; width: 130px; } @@ -301,10 +307,11 @@ body[data-route="pos"] { } .subject { - width: 40% + width: 40%; } - .list-row-checkbox, .list-select-all { + .list-row-checkbox, + .list-select-all { margin-right: 7px; } } @@ -397,7 +404,7 @@ body[data-route="pos"] { padding-top: 0; } - &> .pos-list-row { + & > .pos-list-row { border: none; @media (max-width: var(--xl-width)) { @@ -442,13 +449,12 @@ body[data-route="pos"] { padding: 5px 9px; border-radius: 3px; color: #fff; - } // Healthcare .exercise-card { - box-shadow: 0 1px 3px rgba(0,0,0,0.30); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); border-radius: 2px; padding: 6px 6px 6px 8px; margin-top: 10px; @@ -491,7 +497,9 @@ body[data-route="pos"] { padding: 10px; } -.plant-floor, .workstation-wrapper, .workstation-card p { +.plant-floor, +.workstation-wrapper, +.workstation-card p { border-radius: var(--border-radius-md); border: 1px solid var(--border-color); box-shadow: none; @@ -511,13 +519,13 @@ body[data-route="pos"] { .plant-floor-container { display: grid; - grid-template-columns: repeat(6,minmax(0,1fr)); + grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--margin-xl); } @media screen and (max-width: 620px) { .plant-floor-container { - grid-template-columns: repeat(2,minmax(0,1fr)); + grid-template-columns: repeat(2, minmax(0, 1fr)); } } @@ -535,8 +543,8 @@ body[data-route="pos"] { .workstation-abbr { display: flex; background-color: var(--control-bg); - height:100%; - width:100%; + height: 100%; + width: 100%; align-items: center; justify-content: center; -} \ No newline at end of file +} diff --git a/erpnext/public/scss/order-page.scss b/erpnext/public/scss/order-page.scss index 6f5fe5d4d7a..2b1dae282a3 100644 --- a/erpnext/public/scss/order-page.scss +++ b/erpnext/public/scss/order-page.scss @@ -1,115 +1,113 @@ #page-order { - .main-column { - .page-content-wrapper { + .main-column { + .page-content-wrapper { + .breadcrumb-container { + @media screen and (min-width: 567px) { + padding-left: var(--padding-sm); + } + } - .breadcrumb-container { - @media screen and (min-width: 567px) { - padding-left: var(--padding-sm); - } - } + .container.my-4 { + background-color: var(--fg-color); - .container.my-4 { - background-color: var(--fg-color); - - @media screen and (min-width: 567px) { - padding: 1.25rem 1.5rem; - border-radius: var(--border-radius-md); - box-shadow: var(--card-shadow); - } - } - } - } + @media screen and (min-width: 567px) { + padding: 1.25rem 1.5rem; + border-radius: var(--border-radius-md); + box-shadow: var(--card-shadow); + } + } + } + } } .indicator-container { - @media screen and (max-width: 567px) { - padding-bottom: 0.8rem; - } + @media screen and (max-width: 567px) { + padding-bottom: 0.8rem; + } } .order-items { - padding: 1.5rem 0; - border-bottom: 1px solid var(--border-color); - color: var(--gray-700); + padding: 1.5rem 0; + border-bottom: 1px solid var(--border-color); + color: var(--gray-700); - @media screen and (max-width: 567px) { - align-items: flex-start !important; - } - .col-2 { - @media screen and (max-width: 567px) { - flex: auto; - max-width: 28%; - } - } + @media screen and (max-width: 567px) { + align-items: flex-start !important; + } + .col-2 { + @media screen and (max-width: 567px) { + flex: auto; + max-width: 28%; + } + } - .order-item-name { - font-size: var(--text-base); - font-weight: 500; - } + .order-item-name { + font-size: var(--text-base); + font-weight: 500; + } - .btn:focus, - .btn:hover { - background-color: var(--control-bg); - } + .btn:focus, + .btn:hover { + background-color: var(--control-bg); + } + .col-6 { + @media screen and (max-width: 567px) { + max-width: 100%; + } - .col-6 { - @media screen and (max-width: 567px) { - max-width: 100%; - } - - &.order-item-name { - font-size: var(--text-base); - } - } + &.order-item-name { + font-size: var(--text-base); + } + } } .item-grand-total { - font-size: var(--text-base); + font-size: var(--text-base); } .list-item-name, .item-total, .order-container, .order-qty { - font-size: var(--text-md); + font-size: var(--text-md); } .d-s-n { - @media screen and (max-width: 567px) { - display: none; - } + @media screen and (max-width: 567px) { + display: none; + } } .d-l-n { - @media screen and (min-width: 567px) { - display: none; - } + @media screen and (min-width: 567px) { + display: none; + } } .border-btm { - border-bottom: 1px solid var(--border-color); + border-bottom: 1px solid var(--border-color); } .order-taxes { - display: flex; + display: flex; - @media screen and (min-width: 567px) { - justify-content: flex-end; - } + @media screen and (min-width: 567px) { + justify-content: flex-end; + } - .col-4 { - padding-right: 0; + .col-4 { + padding-right: 0; - .col-8 { - padding-left: 0; - padding-right: 0; - } + .col-8 { + padding-left: 0; + padding-right: 0; + } - @media screen and (max-width: 567px) { - padding-left: 0; - flex: auto; - max-width: 100%; - } - } -} \ No newline at end of file + @media screen and (max-width: 567px) { + padding-left: 0; + flex: auto; + max-width: 100%; + } + } +} diff --git a/erpnext/public/scss/point-of-sale.scss b/erpnext/public/scss/point-of-sale.scss index ba64b59b46b..75bbabd98e2 100644 --- a/erpnext/public/scss/point-of-sale.scss +++ b/erpnext/public/scss/point-of-sale.scss @@ -184,7 +184,6 @@ font-weight: 700; } } - } } } @@ -261,12 +260,12 @@ flex-direction: column; margin-right: auto; - >.customer-name { + > .customer-name { font-weight: 700; font-size: var(--text-lg); } - >.customer-desc { + > .customer-desc { font-weight: 500; font-size: var(--text-sm); } @@ -277,7 +276,6 @@ align-items: center; cursor: pointer; } - } > .customer-fields-container { @@ -407,7 +405,6 @@ font-size: var(--text-lg); } - > .item-name-desc { @extend .nowrap; display: flex; @@ -455,7 +452,6 @@ } } } - } } @@ -854,7 +850,7 @@ display: flex; flex: 1; height: 100%; - position: relative; + position: relative; justify-content: flex-end; > .fields-section { @@ -1130,7 +1126,6 @@ } } - > .summary-btns { display: flex; justify-content: space-between; @@ -1142,7 +1137,7 @@ > .new-btn { background-color: var(--blue-500); - color:white; + color: white; font-weight: 500; } } @@ -1156,13 +1151,14 @@ grid-template-columns: repeat(1, minmax(0, 1fr)); > .items-selector { - grid-column: span 6 / span 1 !important; + grid-column: span 6 / span 1 !important; > .items-container { - grid-template-columns: repeat(2, minmax(0, 1fr)) !important; + grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } } - > .item-details-container, .customer-cart-container { + > .item-details-container, + .customer-cart-container { grid-column: span 6 / span 1; } @@ -1179,7 +1175,7 @@ } } - > .past-order-summary{ + > .past-order-summary { > .invoice-summary-wrapper { width: 100%; } diff --git a/erpnext/public/scss/website.scss b/erpnext/public/scss/website.scss index b5e97f1c34b..dd2ae210c76 100644 --- a/erpnext/public/scss/website.scss +++ b/erpnext/public/scss/website.scss @@ -1,4 +1,4 @@ -@import './order-page'; +@import "./order-page"; .filter-options { max-height: 300px; @@ -52,7 +52,8 @@ border-bottom: 1px solid var(--border-color); position: relative; - &:only-child, &:last-child { + &:only-child, + &:last-child { border: 0; } @@ -80,7 +81,8 @@ } } -.list-item-name, .item-total { +.list-item-name, +.item-total { font-size: var(--font-size-sm); } @@ -88,4 +90,4 @@ @media screen and (max-width: 567px) { margin-top: 1rem; } -} \ No newline at end of file +} diff --git a/erpnext/quality_management/doctype/non_conformance/non_conformance.js b/erpnext/quality_management/doctype/non_conformance/non_conformance.js index e7f5eee623e..5524d7472b2 100644 --- a/erpnext/quality_management/doctype/non_conformance/non_conformance.js +++ b/erpnext/quality_management/doctype/non_conformance/non_conformance.js @@ -1,8 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Non Conformance', { +frappe.ui.form.on("Non Conformance", { // refresh: function(frm) { - // } }); diff --git a/erpnext/quality_management/doctype/quality_action/quality_action.js b/erpnext/quality_management/doctype/quality_action/quality_action.js index b44f2a20344..8261fab1ab5 100644 --- a/erpnext/quality_management/doctype/quality_action/quality_action.js +++ b/erpnext/quality_management/doctype/quality_action/quality_action.js @@ -1,6 +1,4 @@ // Copyright (c) 2018, Frappe and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Action', { - -}); +frappe.ui.form.on("Quality Action", {}); diff --git a/erpnext/quality_management/doctype/quality_feedback/quality_feedback.js b/erpnext/quality_management/doctype/quality_feedback/quality_feedback.js index 6fb326776ed..8166c257d46 100644 --- a/erpnext/quality_management/doctype/quality_feedback/quality_feedback.js +++ b/erpnext/quality_management/doctype/quality_feedback/quality_feedback.js @@ -1,10 +1,10 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Feedback', { - template: function(frm) { +frappe.ui.form.on("Quality Feedback", { + template: function (frm) { if (frm.doc.template) { - frm.call('set_parameters'); + frm.call("set_parameters"); } - } + }, }); diff --git a/erpnext/quality_management/doctype/quality_feedback_template/quality_feedback_template.js b/erpnext/quality_management/doctype/quality_feedback_template/quality_feedback_template.js index 490eed97065..054572a80eb 100644 --- a/erpnext/quality_management/doctype/quality_feedback_template/quality_feedback_template.js +++ b/erpnext/quality_management/doctype/quality_feedback_template/quality_feedback_template.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Feedback Template', { +frappe.ui.form.on("Quality Feedback Template", { // refresh: function(frm) { - // } }); diff --git a/erpnext/quality_management/doctype/quality_goal/quality_goal.js b/erpnext/quality_management/doctype/quality_goal/quality_goal.js index 40cb4d92464..5b7cae5d22a 100644 --- a/erpnext/quality_management/doctype/quality_goal/quality_goal.js +++ b/erpnext/quality_management/doctype/quality_goal/quality_goal.js @@ -1,7 +1,7 @@ // Copyright (c) 2018, Frappe and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Goal', { +frappe.ui.form.on("Quality Goal", { // refresh: function(frm) { // } }); diff --git a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.js b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.js index eb7a8c32d73..00ab1e4c37a 100644 --- a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.js +++ b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.js @@ -1,6 +1,4 @@ // Copyright (c) 2018, Frappe and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Meeting', { - -}); +frappe.ui.form.on("Quality Meeting", {}); diff --git a/erpnext/quality_management/doctype/quality_meeting/quality_meeting_list.js b/erpnext/quality_management/doctype/quality_meeting/quality_meeting_list.js index 5fd1b30eb45..ae3112f3d09 100644 --- a/erpnext/quality_management/doctype/quality_meeting/quality_meeting_list.js +++ b/erpnext/quality_management/doctype/quality_meeting/quality_meeting_list.js @@ -1,11 +1,10 @@ -frappe.listview_settings['Quality Meeting'] = { +frappe.listview_settings["Quality Meeting"] = { add_fields: ["status"], - get_indicator: function(doc) { - if(doc.status == "Open") { + get_indicator: function (doc) { + if (doc.status == "Open") { return [__("Open"), "red", "status=,Open"]; - } - else if(doc.status == "Close") { + } else if (doc.status == "Close") { return [__("Close"), "green", ",status=,Close"]; } - } + }, }; diff --git a/erpnext/quality_management/doctype/quality_meeting_agenda/quality_meeting_agenda.js b/erpnext/quality_management/doctype/quality_meeting_agenda/quality_meeting_agenda.js index 09989dc643f..ad037c25651 100644 --- a/erpnext/quality_management/doctype/quality_meeting_agenda/quality_meeting_agenda.js +++ b/erpnext/quality_management/doctype/quality_meeting_agenda/quality_meeting_agenda.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Meeting Agenda', { +frappe.ui.form.on("Quality Meeting Agenda", { // refresh: function(frm) { - // } }); diff --git a/erpnext/quality_management/doctype/quality_procedure/quality_procedure.js b/erpnext/quality_management/doctype/quality_procedure/quality_procedure.js index 79fd2ebdbe9..a2c16dddadb 100644 --- a/erpnext/quality_management/doctype/quality_procedure/quality_procedure.js +++ b/erpnext/quality_management/doctype/quality_procedure/quality_procedure.js @@ -1,23 +1,23 @@ // Copyright (c) 2018, Frappe and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Procedure', { - refresh: function(frm) { - frm.set_query('procedure', 'processes', (frm) =>{ +frappe.ui.form.on("Quality Procedure", { + refresh: function (frm) { + frm.set_query("procedure", "processes", (frm) => { return { filters: { - name: ['not in', [frm.parent_quality_procedure, frm.name]] - } + name: ["not in", [frm.parent_quality_procedure, frm.name]], + }, }; }); - frm.set_query('parent_quality_procedure', function(){ + frm.set_query("parent_quality_procedure", function () { return { filters: { is_group: 1, - name: ['!=', frm.doc.name] - } + name: ["!=", frm.doc.name], + }, }; }); - } + }, }); diff --git a/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js b/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js index 2851fcc5969..25f9a5906a1 100644 --- a/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js +++ b/erpnext/quality_management/doctype/quality_procedure/quality_procedure_tree.js @@ -1,18 +1,18 @@ frappe.treeview_settings["Quality Procedure"] = { - ignore_fields:["parent_quality_procedure"], - get_tree_nodes: 'erpnext.quality_management.doctype.quality_procedure.quality_procedure.get_children', - add_tree_node: 'erpnext.quality_management.doctype.quality_procedure.quality_procedure.add_node', + ignore_fields: ["parent_quality_procedure"], + get_tree_nodes: "erpnext.quality_management.doctype.quality_procedure.quality_procedure.get_children", + add_tree_node: "erpnext.quality_management.doctype.quality_procedure.quality_procedure.add_node", filters: [ { fieldname: "parent_quality_procedure", fieldtype: "Link", options: "Quality Procedure", label: __("Quality Procedure"), - get_query: function() { + get_query: function () { return { - filters: [["Quality Procedure", 'is_group', '=', 1]] + filters: [["Quality Procedure", "is_group", "=", 1]], }; - } + }, }, ], breadcrumb: "Quality Management", @@ -22,13 +22,13 @@ frappe.treeview_settings["Quality Procedure"] = { menu_items: [ { label: __("New Quality Procedure"), - action: function() { + action: function () { frappe.new_doc("Quality Procedure", true); }, - condition: 'frappe.boot.user.can_create.indexOf("Quality Procedure") !== -1' - } + condition: 'frappe.boot.user.can_create.indexOf("Quality Procedure") !== -1', + }, ], - onload: function(treeview) { + onload: function (treeview) { treeview.make_tree(); }, }; diff --git a/erpnext/quality_management/doctype/quality_review/quality_review.js b/erpnext/quality_management/doctype/quality_review/quality_review.js index 0e6b7034101..504f8fceb2e 100644 --- a/erpnext/quality_management/doctype/quality_review/quality_review.js +++ b/erpnext/quality_management/doctype/quality_review/quality_review.js @@ -1,15 +1,15 @@ // Copyright (c) 2018, Frappe and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Review', { - goal: function(frm) { +frappe.ui.form.on("Quality Review", { + goal: function (frm) { frappe.call({ - "method": "frappe.client.get", + method: "frappe.client.get", args: { doctype: "Quality Goal", - name: frm.doc.goal + name: frm.doc.goal, }, - callback: function(data){ + callback: function (data) { frm.fields_dict.reviews.grid.remove_all(); let objectives = data.message.objectives; for (var i in objectives) { @@ -19,7 +19,7 @@ frappe.ui.form.on('Quality Review', { frm.fields_dict.reviews.get_value()[i].uom = objectives[i].uom; } frm.refresh(); - } + }, }); }, }); diff --git a/erpnext/quality_management/doctype/quality_review/quality_review_list.js b/erpnext/quality_management/doctype/quality_review/quality_review_list.js index b0be783de56..3be6c10a89d 100644 --- a/erpnext/quality_management/doctype/quality_review/quality_review_list.js +++ b/erpnext/quality_management/doctype/quality_review/quality_review_list.js @@ -1,12 +1,10 @@ -frappe.listview_settings['Quality Review'] = { +frappe.listview_settings["Quality Review"] = { add_fields: ["action"], - get_indicator: function(doc) - { - if(doc.action == "No Action") { + get_indicator: function (doc) { + if (doc.action == "No Action") { return [__("No Action"), "green", "action,=,No Action"]; - } - else if(doc.action == "Action Initialised") { + } else if (doc.action == "Action Initialised") { return [__("Action Initialised"), "red", "action,=,Action Initialised"]; } - } + }, }; diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.js b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.js index 5918ec8b316..5fbb5cb7e01 100644 --- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.js +++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.js @@ -1,39 +1,39 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Import Supplier Invoice', { - onload: function(frm) { +frappe.ui.form.on("Import Supplier Invoice", { + onload: function (frm) { frappe.realtime.on("import_invoice_update", function (data) { frm.dashboard.show_progress(data.title, (data.count / data.total) * 100, data.message); if (data.count == data.total) { - window.setTimeout(title => frm.dashboard.hide_progress(title), 1500, data.title); + window.setTimeout((title) => frm.dashboard.hide_progress(title), 1500, data.title); } }); }, - setup: function(frm) { - frm.set_query("tax_account", function(doc) { + setup: function (frm) { + frm.set_query("tax_account", function (doc) { return { filters: { - account_type: 'Tax', - company: doc.company - } + account_type: "Tax", + company: doc.company, + }, }; }); - frm.set_query("default_buying_price_list", function(doc) { + frm.set_query("default_buying_price_list", function (doc) { return { filters: { - currency: frappe.get_doc(":Company", doc.company).default_currency - } + currency: frappe.get_doc(":Company", doc.company).default_currency, + }, }; }); }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("toggle_read_only_fields"); }, - toggle_read_only_fields: function(frm) { + toggle_read_only_fields: function (frm) { if (in_list(["File Import Completed", "Processing File Data"], frm.doc.status)) { cur_frm.set_read_only(); cur_frm.refresh_fields(); @@ -41,6 +41,5 @@ frappe.ui.form.on('Import Supplier Invoice', { } else { frm.set_df_property("import_invoices", "hidden", 0); } - } - + }, }); diff --git a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.js b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.js index 8257bf8a969..02eaff53bb9 100644 --- a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.js +++ b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.js @@ -1,8 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Lower Deduction Certificate', { +frappe.ui.form.on("Lower Deduction Certificate", { // refresh: function(frm) { - // } }); diff --git a/erpnext/regional/doctype/south_africa_vat_settings/south_africa_vat_settings.js b/erpnext/regional/doctype/south_africa_vat_settings/south_africa_vat_settings.js index e37a61ac853..86384e41b34 100644 --- a/erpnext/regional/doctype/south_africa_vat_settings/south_africa_vat_settings.js +++ b/erpnext/regional/doctype/south_africa_vat_settings/south_africa_vat_settings.js @@ -1,23 +1,23 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('South Africa VAT Settings', { - refresh: function(frm) { - frm.set_query("company", function() { +frappe.ui.form.on("South Africa VAT Settings", { + refresh: function (frm) { + frm.set_query("company", function () { return { filters: { country: "South Africa", - } + }, }; }); - frm.set_query("account", "vat_accounts", function() { + frm.set_query("account", "vat_accounts", function () { return { filters: { company: frm.doc.company, account_type: "Tax", - is_group: 0 - } + is_group: 0, + }, }; }); - } + }, }); diff --git a/erpnext/regional/doctype/uae_vat_settings/uae_vat_settings.js b/erpnext/regional/doctype/uae_vat_settings/uae_vat_settings.js index 66531412faf..c7d0f054b51 100644 --- a/erpnext/regional/doctype/uae_vat_settings/uae_vat_settings.js +++ b/erpnext/regional/doctype/uae_vat_settings/uae_vat_settings.js @@ -1,14 +1,14 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('UAE VAT Settings', { - onload: function(frm) { - frm.set_query('account', 'uae_vat_accounts', function() { +frappe.ui.form.on("UAE VAT Settings", { + onload: function (frm) { + frm.set_query("account", "uae_vat_accounts", function () { return { filters: { - 'company': frm.doc.company - } + company: frm.doc.company, + }, }; }); - } + }, }); diff --git a/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js index 4fc1be1ff54..c8834892075 100644 --- a/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js +++ b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js @@ -1,53 +1,54 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Electronic Invoice Register"] = { - "filters": [ + filters: [ { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), - "width": "80" + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), + width: "80", }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), }, { - "fieldname":"customer", - "label": __("Customer"), - "fieldtype": "Link", - "options": "Customer" + fieldname: "customer", + label: __("Customer"), + fieldtype: "Link", + options: "Customer", }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), }, ], - "onload": function(reportview) { - reportview.page.add_inner_button(__("Export E-Invoices"), function() { + onload: function (reportview) { + reportview.page.add_inner_button(__("Export E-Invoices"), function () { //TODO: refactor condition to disallow export if report has no data. if (!reportview.data.length) { frappe.msgprint(__("No data to export")); - return + return; } var w = window.open( frappe.urllib.get_full_url( - "/api/method/erpnext.regional.italy.utils.export_invoices?" - + "filters=" + JSON.stringify(reportview.get_filter_values()) + "/api/method/erpnext.regional.italy.utils.export_invoices?" + + "filters=" + + JSON.stringify(reportview.get_filter_values()) ) ); if (!w) { - frappe.msgprint(__("Please enable pop-ups")); return; + frappe.msgprint(__("Please enable pop-ups")); + return; } - }) - } -} + }); + }, +}; diff --git a/erpnext/regional/report/irs_1099/irs_1099.js b/erpnext/regional/report/irs_1099/irs_1099.js index b3508e40a9f..385468b58aa 100644 --- a/erpnext/regional/report/irs_1099/irs_1099.js +++ b/erpnext/regional/report/irs_1099/irs_1099.js @@ -2,33 +2,33 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["IRS 1099"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1, - "width": 80, + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, + width: 80, }, { - "fieldname": "fiscal_year", - "label": __("Fiscal Year"), - "fieldtype": "Link", - "options": "Fiscal Year", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()), - "reqd": 1, - "width": 80, + fieldname: "fiscal_year", + label: __("Fiscal Year"), + fieldtype: "Link", + options: "Fiscal Year", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()), + reqd: 1, + width: 80, }, { - "fieldname": "supplier_group", - "label": __("Supplier Group"), - "fieldtype": "Link", - "options": "Supplier Group", - "default": "", - "reqd": 0, - "width": 80 + fieldname: "supplier_group", + label: __("Supplier Group"), + fieldtype: "Link", + options: "Supplier Group", + default: "", + reqd: 0, + width: 80, }, ], @@ -36,12 +36,15 @@ frappe.query_reports["IRS 1099"] = { query_report.page.add_inner_button(__("Print IRS 1099 Forms"), () => { build_1099_print(query_report); }); - } + }, }; function build_1099_print(query_report) { let filters = JSON.stringify(query_report.get_values()); - let w = window.open('/api/method/erpnext.regional.report.irs_1099.irs_1099.irs_1099_print?' + - '&filters=' + encodeURIComponent(filters)); + let w = window.open( + "/api/method/erpnext.regional.report.irs_1099.irs_1099.irs_1099_print?" + + "&filters=" + + encodeURIComponent(filters) + ); // w.print(); } diff --git a/erpnext/regional/report/uae_vat_201/uae_vat_201.js b/erpnext/regional/report/uae_vat_201/uae_vat_201.js index eaefc0420a8..49060fdf66a 100644 --- a/erpnext/regional/report/uae_vat_201/uae_vat_201.js +++ b/erpnext/regional/report/uae_vat_201/uae_vat_201.js @@ -1,36 +1,38 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["UAE VAT 201"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -3), + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -3), }, { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.get_today(), }, ], - "formatter": function(value, row, column, data, default_formatter) { - if (data - && (data.legend=='VAT on Sales and All Other Outputs' || data.legend=='VAT on Expenses and All Other Inputs') - && data.legend==value) { + formatter: function (value, row, column, data, default_formatter) { + if ( + data && + (data.legend == "VAT on Sales and All Other Outputs" || + data.legend == "VAT on Expenses and All Other Inputs") && + data.legend == value + ) { value = $(`${value}`); var $value = $(value).css("font-weight", "bold"); value = $value.wrap("

      ").parent().html(); diff --git a/erpnext/regional/report/vat_audit_report/vat_audit_report.js b/erpnext/regional/report/vat_audit_report/vat_audit_report.js index 41318f3160c..de4fde596cd 100644 --- a/erpnext/regional/report/vat_audit_report/vat_audit_report.js +++ b/erpnext/regional/report/vat_audit_report/vat_audit_report.js @@ -1,31 +1,30 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["VAT Audit Report"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -2), - "width": "80" + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -2), + width: "80", }, { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.get_today() - } - ] + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.get_today(), + }, + ], }; diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index ddc7e2af8fb..50248a985aa 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -2,15 +2,15 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Customer", { - setup: function(frm) { + setup: function (frm) { frm.custom_make_buttons = { - "Opportunity": "Opportunity", - "Quotation": "Quotation", + Opportunity: "Opportunity", + Quotation: "Quotation", "Sales Order": "Sales Order", "Pricing Rule": "Pricing Rule", }; frm.make_methods = { - "Quotation": () => + Quotation: () => frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.customer.customer.make_quotation", frm: frm, @@ -21,163 +21,181 @@ frappe.ui.form.on("Customer", { so.customer = frm.doc.name; // Set the current customer as the SO customer frappe.set_route("Form", "Sales Order", so.name); }), - "Opportunity": () => + Opportunity: () => frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.customer.customer.make_opportunity", frm: frm, }), - "Pricing Rule": () => - erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name), + "Pricing Rule": () => erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name), }; - frm.add_fetch('lead_name', 'company_name', 'customer_name'); - frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate'); - frm.set_query('customer_group', {'is_group': 0}); - frm.set_query('default_price_list', { 'selling': 1}); - frm.set_query('account', 'accounts', function(doc, cdt, cdn) { - let d = locals[cdt][cdn]; + frm.add_fetch("lead_name", "company_name", "customer_name"); + frm.add_fetch("default_sales_partner", "commission_rate", "default_commission_rate"); + frm.set_query("customer_group", { is_group: 0 }); + frm.set_query("default_price_list", { selling: 1 }); + frm.set_query("account", "accounts", function (doc, cdt, cdn) { + let d = locals[cdt][cdn]; let filters = { - 'account_type': 'Receivable', - 'root_type': 'Asset', - 'company': d.company, - "is_group": 0 + account_type: "Receivable", + root_type: "Asset", + company: d.company, + is_group: 0, }; - if(doc.party_account_currency) { - $.extend(filters, {"account_currency": doc.party_account_currency}); + if (doc.party_account_currency) { + $.extend(filters, { account_currency: doc.party_account_currency }); } return { - filters: filters - } + filters: filters, + }; }); - frm.set_query('advance_account', 'accounts', function (doc, cdt, cdn) { + frm.set_query("advance_account", "accounts", function (doc, cdt, cdn) { let d = locals[cdt][cdn]; return { filters: { - "account_type": 'Receivable', - "root_type": "Liability", - "company": d.company, - "is_group": 0 - } - } + account_type: "Receivable", + root_type: "Liability", + company: d.company, + is_group: 0, + }, + }; }); - if (frm.doc.__islocal == 1) { frm.set_value("represents_company", ""); } - frm.set_query('customer_primary_contact', function(doc) { + frm.set_query("customer_primary_contact", function (doc) { return { query: "erpnext.selling.doctype.customer.customer.get_customer_primary_contact", filters: { - 'customer': doc.name - } - } - }) - frm.set_query('customer_primary_address', function(doc) { + customer: doc.name, + }, + }; + }); + frm.set_query("customer_primary_address", function (doc) { return { filters: { - 'link_doctype': 'Customer', - 'link_name': doc.name - } - } - }) - - frm.set_query('default_bank_account', function() { - return { - filters: { - 'is_company_account': 1 - } - } + link_doctype: "Customer", + link_name: doc.name, + }, + }; }); - frm.set_query("user", "portal_users", function() { + frm.set_query("default_bank_account", function () { return { filters: { - "ignore_user_type": true, - } + is_company_account: 1, + }, + }; + }); + + frm.set_query("user", "portal_users", function () { + return { + filters: { + ignore_user_type: true, + }, }; }); }, - customer_primary_address: function(frm){ - if(frm.doc.customer_primary_address){ + customer_primary_address: function (frm) { + if (frm.doc.customer_primary_address) { frappe.call({ - method: 'frappe.contacts.doctype.address.address.get_address_display', + method: "frappe.contacts.doctype.address.address.get_address_display", args: { - "address_dict": frm.doc.customer_primary_address + address_dict: frm.doc.customer_primary_address, }, - callback: function(r) { + callback: function (r) { frm.set_value("primary_address", r.message); - } + }, }); } - if(!frm.doc.customer_primary_address){ + if (!frm.doc.customer_primary_address) { frm.set_value("primary_address", ""); } }, - is_internal_customer: function(frm) { + is_internal_customer: function (frm) { if (frm.doc.is_internal_customer == 1) { frm.toggle_reqd("represents_company", true); - } - else { + } else { frm.toggle_reqd("represents_company", false); } }, - customer_primary_contact: function(frm){ - if(!frm.doc.customer_primary_contact){ + customer_primary_contact: function (frm) { + if (!frm.doc.customer_primary_contact) { frm.set_value("mobile_no", ""); frm.set_value("email_id", ""); } }, - loyalty_program: function(frm) { - if(frm.doc.loyalty_program) { - frm.set_value('loyalty_program_tier', null); + loyalty_program: function (frm) { + if (frm.doc.loyalty_program) { + frm.set_value("loyalty_program_tier", null); } }, - refresh: function(frm) { - if(frappe.defaults.get_default("cust_master_name")!="Naming Series") { + refresh: function (frm) { + if (frappe.defaults.get_default("cust_master_name") != "Naming Series") { frm.toggle_display("naming_series", false); } else { erpnext.toggle_naming_series(); } - if(!frm.doc.__islocal) { + if (!frm.doc.__islocal) { frappe.contacts.render_address_and_contact(frm); // custom buttons - frm.add_custom_button(__('Accounts Receivable'), function () { - frappe.set_route('query-report', 'Accounts Receivable', { party_type: "Customer", party: frm.doc.name }); - }, __('View')); + frm.add_custom_button( + __("Accounts Receivable"), + function () { + frappe.set_route("query-report", "Accounts Receivable", { + party_type: "Customer", + party: frm.doc.name, + }); + }, + __("View") + ); - frm.add_custom_button(__('Accounting Ledger'), function () { - frappe.set_route('query-report', 'General Ledger', - {party_type: 'Customer', party: frm.doc.name, party_name: frm.doc.customer_name}); - }, __('View')); + frm.add_custom_button( + __("Accounting Ledger"), + function () { + frappe.set_route("query-report", "General Ledger", { + party_type: "Customer", + party: frm.doc.name, + party_name: frm.doc.customer_name, + }); + }, + __("View") + ); for (const doctype in frm.make_methods) { frm.add_custom_button(__(doctype), frm.make_methods[doctype], __("Create")); } - frm.add_custom_button(__('Get Customer Group Details'), function () { - frm.trigger("get_customer_group_details"); - }, __('Actions')); + frm.add_custom_button( + __("Get Customer Group Details"), + function () { + frm.trigger("get_customer_group_details"); + }, + __("Actions") + ); if (cint(frappe.defaults.get_default("enable_common_party_accounting"))) { - frm.add_custom_button(__('Link with Supplier'), function () { - frm.trigger('show_party_link_dialog'); - }, __('Actions')); + frm.add_custom_button( + __("Link with Supplier"), + function () { + frm.trigger("show_party_link_dialog"); + }, + __("Actions") + ); } // indicator erpnext.utils.set_party_dashboard_indicators(frm); - } else { frappe.contacts.clear_address_and_contact(frm); } @@ -186,55 +204,58 @@ frappe.ui.form.on("Customer", { grid.set_column_disp("allocated_amount", false); grid.set_column_disp("incentives", false); }, - validate: function(frm) { - if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); - + validate: function (frm) { + if (frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); }, - get_customer_group_details: function(frm) { + get_customer_group_details: function (frm) { frappe.call({ method: "get_customer_group_details", doc: frm.doc, - callback: function() { + callback: function () { frm.refresh(); - } + }, }); - }, - show_party_link_dialog: function(frm) { + show_party_link_dialog: function (frm) { const dialog = new frappe.ui.Dialog({ - title: __('Select a Supplier'), - fields: [{ - fieldtype: 'Link', label: __('Supplier'), - options: 'Supplier', fieldname: 'supplier', reqd: 1 - }], - primary_action: function({ supplier }) { + title: __("Select a Supplier"), + fields: [ + { + fieldtype: "Link", + label: __("Supplier"), + options: "Supplier", + fieldname: "supplier", + reqd: 1, + }, + ], + primary_action: function ({ supplier }) { frappe.call({ - method: 'erpnext.accounts.doctype.party_link.party_link.create_party_link', + method: "erpnext.accounts.doctype.party_link.party_link.create_party_link", args: { - primary_role: 'Customer', + primary_role: "Customer", primary_party: frm.doc.name, - secondary_party: supplier + secondary_party: supplier, }, freeze: true, - callback: function() { + callback: function () { dialog.hide(); frappe.msgprint({ - message: __('Successfully linked to Supplier'), - alert: true + message: __("Successfully linked to Supplier"), + alert: true, }); }, - error: function() { + error: function () { dialog.hide(); frappe.msgprint({ - message: __('Linking to Supplier Failed. Please try again.'), - title: __('Linking Failed'), - indicator: 'red' + message: __("Linking to Supplier Failed. Please try again."), + title: __("Linking Failed"), + indicator: "red", }); - } + }, }); }, - primary_action_label: __('Create Link') + primary_action_label: __("Create Link"), }); dialog.show(); - } + }, }); diff --git a/erpnext/selling/doctype/customer/customer_list.js b/erpnext/selling/doctype/customer/customer_list.js index 38fc9ad1f13..6149c6f873d 100644 --- a/erpnext/selling/doctype/customer/customer_list.js +++ b/erpnext/selling/doctype/customer/customer_list.js @@ -1,3 +1,3 @@ -frappe.listview_settings['Customer'] = { +frappe.listview_settings["Customer"] = { add_fields: ["customer_name", "territory", "customer_group", "customer_type", "image"], }; diff --git a/erpnext/selling/doctype/industry_type/industry_type.js b/erpnext/selling/doctype/industry_type/industry_type.js index 3680906057f..273e30fd197 100644 --- a/erpnext/selling/doctype/industry_type/industry_type.js +++ b/erpnext/selling/doctype/industry_type/industry_type.js @@ -1,13 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - - //--------- ONLOAD ------------- -cur_frm.cscript.onload = function(doc, cdt, cdn) { +cur_frm.cscript.onload = function (doc, cdt, cdn) {}; -} - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - -} +cur_frm.cscript.refresh = function (doc, cdt, cdn) {}; diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index 8128c77f8d4..4e13fa76d5c 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -1,51 +1,51 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Installation Note', { - setup: function(frm) { - frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'} - frm.set_query('customer_address', erpnext.queries.address_query); - frm.set_query('contact_person', erpnext.queries.contact_query); - frm.set_query('customer', erpnext.queries.customer); +frappe.ui.form.on("Installation Note", { + setup: function (frm) { + frappe.dynamic_link = { doc: frm.doc, fieldname: "customer", doctype: "Customer" }; + frm.set_query("customer_address", erpnext.queries.address_query); + frm.set_query("contact_person", erpnext.queries.contact_query); + frm.set_query("customer", erpnext.queries.customer); frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ["in", [doc.name, ""]], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); }, - onload: function(frm) { - if(!frm.doc.status) { - frm.set_value({ status:'Draft'}); + onload: function (frm) { + if (!frm.doc.status) { + frm.set_value({ status: "Draft" }); } - if(frm.doc.__islocal) { - frm.set_value({inst_date: frappe.datetime.get_today()}); + if (frm.doc.__islocal) { + frm.set_value({ inst_date: frappe.datetime.get_today() }); } - let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); + let sbb_field = frm.get_docfield("items", "serial_and_batch_bundle"); if (sbb_field) { sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } + item_code: row.doc.item_code, + voucher_type: frm.doc.doctype, + }; }; } }, - customer: function(frm) { + customer: function (frm) { erpnext.utils.get_party_details(frm); }, - customer_address: function(frm) { + customer_address: function (frm) { erpnext.utils.get_address_display(frm); }, - contact_person: function(frm) { + contact_person: function (frm) { erpnext.utils.get_contact_details(frm); - } + }, }); frappe.provide("erpnext.selling"); @@ -54,9 +54,10 @@ frappe.provide("erpnext.selling"); erpnext.selling.InstallationNote = class InstallationNote extends frappe.ui.form.Controller { refresh() { var me = this; - if (this.frm.doc.docstatus===0) { - this.frm.add_custom_button(__('From Delivery Note'), - function() { + if (this.frm.doc.docstatus === 0) { + this.frm.add_custom_button( + __("From Delivery Note"), + function () { erpnext.utils.map_current_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note", source_doctype: "Delivery Note", @@ -69,13 +70,15 @@ erpnext.selling.InstallationNote = class InstallationNote extends frappe.ui.form docstatus: 1, status: ["not in", ["Stopped", "Closed"]], per_installed: ["<", 99.99], - company: me.frm.doc.company - } - }) - }, "fa fa-download", "btn-default" + company: me.frm.doc.company, + }, + }); + }, + "fa fa-download", + "btn-default" ); } } }; -extend_cscript(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.selling.InstallationNote({ frm: cur_frm })); diff --git a/erpnext/selling/doctype/party_specific_item/party_specific_item.js b/erpnext/selling/doctype/party_specific_item/party_specific_item.js index 077b93631ec..0decc70d7ac 100644 --- a/erpnext/selling/doctype/party_specific_item/party_specific_item.js +++ b/erpnext/selling/doctype/party_specific_item/party_specific_item.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Party Specific Item', { +frappe.ui.form.on("Party Specific Item", { // refresh: function(frm) { - // } }); diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 1bc8d6857e9..6e2b7262641 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -6,34 +6,33 @@ erpnext.accounts.taxes.setup_tax_filters("Sales Taxes and Charges"); erpnext.pre_sales.set_as_lost("Quotation"); erpnext.sales_common.setup_selling_controller(); -frappe.ui.form.on('Quotation', { - setup: function(frm) { - frm.custom_make_buttons = { - 'Sales Order': 'Sales Order' - }, +frappe.ui.form.on("Quotation", { + setup: function (frm) { + (frm.custom_make_buttons = { + "Sales Order": "Sales Order", + }), + frm.set_query("quotation_to", function () { + return { + filters: { + name: ["in", ["Customer", "Lead", "Prospect"]], + }, + }; + }); - frm.set_query("quotation_to", function() { - return{ - "filters": { - "name": ["in", ["Customer", "Lead", "Prospect"]], - } - } - }); + frm.set_df_property("packed_items", "cannot_add_rows", true); + frm.set_df_property("packed_items", "cannot_delete_rows", true); - frm.set_df_property('packed_items', 'cannot_add_rows', true); - frm.set_df_property('packed_items', 'cannot_delete_rows', true); - - frm.set_query('company_address', function(doc) { - if(!doc.company) { - frappe.throw(__('Please set Company')); + frm.set_query("company_address", function (doc) { + if (!doc.company) { + frappe.throw(__("Please set Company")); } return { - query: 'frappe.contacts.doctype.address.address.address_query', + query: "frappe.contacts.doctype.address.address.address_query", filters: { - link_doctype: 'Company', - link_name: doc.company - } + link_doctype: "Company", + link_name: doc.company, + }, }; }); @@ -41,40 +40,40 @@ frappe.ui.form.on('Quotation', { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ["in", [doc.name, ""]], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("set_label"); frm.trigger("set_dynamic_field_label"); - let sbb_field = frm.get_docfield('packed_items', 'serial_and_batch_bundle'); + let sbb_field = frm.get_docfield("packed_items", "serial_and_batch_bundle"); if (sbb_field) { sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'warehouse': row.doc.warehouse, - 'voucher_type': frm.doc.doctype, - } + item_code: row.doc.item_code, + warehouse: row.doc.warehouse, + voucher_type: frm.doc.doctype, + }; }; } }, - quotation_to: function(frm) { + quotation_to: function (frm) { frm.trigger("set_label"); frm.trigger("toggle_reqd_lead_customer"); frm.trigger("set_dynamic_field_label"); }, - set_label: function(frm) { + set_label: function (frm) { frm.fields_dict.customer_address.set_label(__(frm.doc.quotation_to + " Address")); - } + }, }); erpnext.selling.QuotationController = class QuotationController extends erpnext.selling.SellingController { @@ -83,11 +82,11 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. } party_name() { var me = this; - erpnext.utils.get_party_details(this.frm, null, null, function() { + erpnext.utils.get_party_details(this.frm, null, null, function () { me.apply_price_list(); }); - if(me.frm.doc.quotation_to=="Lead" && me.frm.doc.party_name) { + if (me.frm.doc.quotation_to == "Lead" && me.frm.doc.party_name) { me.frm.trigger("get_lead_details"); } } @@ -95,43 +94,48 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. super.refresh(doc, dt, dn); frappe.dynamic_link = { doc: this.frm.doc, - fieldname: 'party_name', - doctype: doc.quotation_to == 'Customer' ? 'Customer' : 'Lead', + fieldname: "party_name", + doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead", }; var me = this; if (doc.__islocal && !doc.valid_till) { - if(frappe.boot.sysdefaults.quotation_valid_till){ - this.frm.set_value('valid_till', frappe.datetime.add_days(doc.transaction_date, frappe.boot.sysdefaults.quotation_valid_till)); + if (frappe.boot.sysdefaults.quotation_valid_till) { + this.frm.set_value( + "valid_till", + frappe.datetime.add_days( + doc.transaction_date, + frappe.boot.sysdefaults.quotation_valid_till + ) + ); } else { - this.frm.set_value('valid_till', frappe.datetime.add_months(doc.transaction_date, 1)); + this.frm.set_value("valid_till", frappe.datetime.add_months(doc.transaction_date, 1)); } } if (doc.docstatus == 1 && !["Lost", "Ordered"].includes(doc.status)) { - if (frappe.boot.sysdefaults.allow_sales_order_creation_for_expired_quotation - || (!doc.valid_till) - || frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) >= 0) { - this.frm.add_custom_button( - __("Sales Order"), - () => this.make_sales_order(), - __("Create") - ); - } + if ( + frappe.boot.sysdefaults.allow_sales_order_creation_for_expired_quotation || + !doc.valid_till || + frappe.datetime.get_diff(doc.valid_till, frappe.datetime.get_today()) >= 0 + ) { + this.frm.add_custom_button(__("Sales Order"), () => this.make_sales_order(), __("Create")); + } - if(doc.status!=="Ordered") { - this.frm.add_custom_button(__('Set as Lost'), () => { - this.frm.trigger('set_as_lost_dialog'); - }); - } + if (doc.status !== "Ordered") { + this.frm.add_custom_button(__("Set as Lost"), () => { + this.frm.trigger("set_as_lost_dialog"); + }); + } - cur_frm.page.set_inner_btn_group_as_primary(__('Create')); + cur_frm.page.set_inner_btn_group_as_primary(__("Create")); } - if (this.frm.doc.docstatus===0) { - this.frm.add_custom_button(__('Opportunity'), - function() { + if (this.frm.doc.docstatus === 0) { + this.frm.add_custom_button( + __("Opportunity"), + function () { erpnext.utils.map_current_doc({ method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation", source_doctype: "Opportunity", @@ -142,26 +146,28 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. fieldname: "party_name", fieldtype: "Link", options: me.frm.doc.quotation_to, - default: me.frm.doc.party_name || undefined + default: me.frm.doc.party_name || undefined, }, { label: "Opportunity Type", fieldname: "opportunity_type", fieldtype: "Link", options: "Opportunity Type", - default: me.frm.doc.order_type || undefined - } + default: me.frm.doc.order_type || undefined, + }, ], get_query_filters: { status: ["not in", ["Lost", "Closed"]], - company: me.frm.doc.company - } - }) - }, __("Get Items From"), "btn-default"); + company: me.frm.doc.company, + }, + }); + }, + __("Get Items From"), + "btn-default" + ); } this.toggle_reqd_lead_customer(); - } make_sales_order() { @@ -173,20 +179,20 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. } else { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.quotation.quotation.make_sales_order", - frm: me.frm + frm: me.frm, }); } } - set_dynamic_field_label(){ + set_dynamic_field_label() { if (this.frm.doc.quotation_to == "Customer") { this.frm.set_df_property("party_name", "label", "Customer"); this.frm.fields_dict.party_name.get_query = null; } else if (this.frm.doc.quotation_to == "Lead") { this.frm.set_df_property("party_name", "label", "Lead"); - this.frm.fields_dict.party_name.get_query = function() { - return{ query: "erpnext.controllers.queries.lead_query" } - } + this.frm.fields_dict.party_name.get_query = function () { + return { query: "erpnext.controllers.queries.lead_query" }; + }; } else if (this.frm.doc.quotation_to == "Prospect") { this.frm.set_df_property("party_name", "label", "Prospect"); } @@ -197,8 +203,8 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. // to overwrite the customer_filter trigger from queries.js this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to); - this.frm.set_query('customer_address', this.address_query); - this.frm.set_query('shipping_address_name', this.address_query); + this.frm.set_query("customer_address", this.address_query); + this.frm.set_query("shipping_address_name", this.address_query); } tc_name() { @@ -207,17 +213,22 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. address_query(doc) { return { - query: 'frappe.contacts.doctype.address.address.address_query', + query: "frappe.contacts.doctype.address.address.address_query", filters: { link_doctype: frappe.dynamic_link.doctype, - link_name: doc.party_name - } + link_name: doc.party_name, + }, }; } validate_company_and_party(party_field) { - if(!this.frm.doc.quotation_to) { - frappe.msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name])); + if (!this.frm.doc.quotation_to) { + frappe.msgprint( + __("Please select a value for {0} quotation_to {1}", [ + this.frm.doc.doctype, + this.frm.doc.name, + ]) + ); return false; } else if (this.frm.doc.quotation_to == "Lead") { return true; @@ -228,85 +239,84 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. get_lead_details() { var me = this; - if(!this.frm.doc.quotation_to === "Lead") { + if (!this.frm.doc.quotation_to === "Lead") { return; } frappe.call({ method: "erpnext.crm.doctype.lead.lead.get_lead_details", args: { - 'lead': this.frm.doc.party_name, - 'posting_date': this.frm.doc.transaction_date, - 'company': this.frm.doc.company, + lead: this.frm.doc.party_name, + posting_date: this.frm.doc.transaction_date, + company: this.frm.doc.company, }, - callback: function(r) { - if(r.message) { + callback: function (r) { + if (r.message) { me.frm.updating_party_details = true; me.frm.set_value(r.message); me.frm.refresh(); me.frm.updating_party_details = false; - } - } - }) + }, + }); } show_alternative_items_dialog() { let me = this; const table_fields = [ - { - fieldtype:"Data", - fieldname:"name", - label: __("Name"), - read_only: 1, - }, - { - fieldtype:"Link", - fieldname:"item_code", - options: "Item", - label: __("Item Code"), - read_only: 1, - in_list_view: 1, - columns: 2, - formatter: (value, df, options, doc) => { - return doc.is_alternative ? `${value}` : value; - } - }, - { - fieldtype:"Data", - fieldname:"description", - label: __("Description"), - in_list_view: 1, - read_only: 1, - }, - { - fieldtype:"Currency", - fieldname:"amount", - label: __("Amount"), - options: "currency", - in_list_view: 1, - read_only: 1, - }, - { - fieldtype:"Check", - fieldname:"is_alternative", - label: __("Is Alternative"), - read_only: 1, - }]; + { + fieldtype: "Data", + fieldname: "name", + label: __("Name"), + read_only: 1, + }, + { + fieldtype: "Link", + fieldname: "item_code", + options: "Item", + label: __("Item Code"), + read_only: 1, + in_list_view: 1, + columns: 2, + formatter: (value, df, options, doc) => { + return doc.is_alternative ? `${value}` : value; + }, + }, + { + fieldtype: "Data", + fieldname: "description", + label: __("Description"), + in_list_view: 1, + read_only: 1, + }, + { + fieldtype: "Currency", + fieldname: "amount", + label: __("Amount"), + options: "currency", + in_list_view: 1, + read_only: 1, + }, + { + fieldtype: "Check", + fieldname: "is_alternative", + label: __("Is Alternative"), + read_only: 1, + }, + ]; - - this.data = this.frm.doc.items.filter( - (item) => item.is_alternative || item.has_alternative_item - ).map((item) => { - return { - "name": item.name, - "item_code": item.item_code, - "description": item.description, - "amount": item.amount, - "is_alternative": item.is_alternative, - } - }); + this.data = this.frm.doc.items + .filter((item) => item.is_alternative || item.has_alternative_item) + .map((item) => { + return { + name: item.name, + item_code: item.item_code, + description: item.description, + amount: item.amount, + is_alternative: item.is_alternative, + }; + }); const dialog = new frappe.ui.Dialog({ title: __("Select Alternative Items for Sales Order"), @@ -314,7 +324,7 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. { fieldname: "info", fieldtype: "HTML", - read_only: 1 + read_only: 1, }, { fieldname: "alternative_items", @@ -328,20 +338,20 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. get_data: () => { return this.data; }, - fields: table_fields + fields: table_fields, }, ], - primary_action: function() { + primary_action: function () { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.quotation.quotation.make_sales_order", frm: me.frm, args: { - selected_items: dialog.fields_dict.alternative_items.grid.get_selected_children() - } + selected_items: dialog.fields_dict.alternative_items.grid.get_selected_children(), + }, }); dialog.hide(); }, - primary_action_label: __('Continue') + primary_action_label: __("Continue"), }); dialog.fields_dict.info.$wrapper.html( @@ -349,19 +359,24 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. ${__("Alternative Items")}

      ` - ) + ); dialog.show(); } }; cur_frm.script_manager.make(erpnext.selling.QuotationController); -frappe.ui.form.on("Quotation Item", "items_on_form_rendered", "packed_items_on_form_rendered", function(frm, cdt, cdn) { - // enable tax_amount field if Actual -}) +frappe.ui.form.on( + "Quotation Item", + "items_on_form_rendered", + "packed_items_on_form_rendered", + function (frm, cdt, cdn) { + // enable tax_amount field if Actual + } +); -frappe.ui.form.on("Quotation Item", "stock_balance", function(frm, cdt, cdn) { +frappe.ui.form.on("Quotation Item", "stock_balance", function (frm, cdt, cdn) { var d = frappe.model.get_doc(cdt, cdn); - frappe.route_options = {"item_code": d.item_code}; + frappe.route_options = { item_code: d.item_code }; frappe.set_route("query-report", "Stock Balance"); -}) +}); diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js index 32fce1f2ad8..ae744b9cba3 100644 --- a/erpnext/selling/doctype/quotation/quotation_list.js +++ b/erpnext/selling/doctype/quotation/quotation_list.js @@ -1,38 +1,37 @@ -frappe.listview_settings['Quotation'] = { - add_fields: ["customer_name", "base_grand_total", "status", - "company", "currency", 'valid_till'], +frappe.listview_settings["Quotation"] = { + add_fields: ["customer_name", "base_grand_total", "status", "company", "currency", "valid_till"], - onload: function(listview) { + onload: function (listview) { if (listview.page.fields_dict.quotation_to) { - listview.page.fields_dict.quotation_to.get_query = function() { + listview.page.fields_dict.quotation_to.get_query = function () { return { - "filters": { - "name": ["in", ["Customer", "Lead"]], - } + filters: { + name: ["in", ["Customer", "Lead"]], + }, }; }; } - listview.page.add_action_item(__("Sales Order"), ()=>{ + listview.page.add_action_item(__("Sales Order"), () => { erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Order"); }); - listview.page.add_action_item(__("Sales Invoice"), ()=>{ + listview.page.add_action_item(__("Sales Invoice"), () => { erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Invoice"); }); }, - get_indicator: function(doc) { - if(doc.status==="Open") { + get_indicator: function (doc) { + if (doc.status === "Open") { return [__("Open"), "orange", "status,=,Open"]; - } else if (doc.status==="Partially Ordered") { + } else if (doc.status === "Partially Ordered") { return [__("Partially Ordered"), "yellow", "status,=,Partially Ordered"]; - } else if(doc.status==="Ordered") { + } else if (doc.status === "Ordered") { return [__("Ordered"), "green", "status,=,Ordered"]; - } else if(doc.status==="Lost") { + } else if (doc.status === "Lost") { return [__("Lost"), "gray", "status,=,Lost"]; - } else if(doc.status==="Expired") { + } else if (doc.status === "Expired") { return [__("Expired"), "gray", "status,=,Expired"]; } - } + }, }; diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 1713a7b2c5c..161a06474cd 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -6,77 +6,98 @@ erpnext.accounts.taxes.setup_tax_validations("Sales Order"); erpnext.sales_common.setup_selling_controller(); frappe.ui.form.on("Sales Order", { - setup: function(frm) { + setup: function (frm) { frm.custom_make_buttons = { - 'Delivery Note': 'Delivery Note', - 'Pick List': 'Pick List', - 'Sales Invoice': 'Sales Invoice', - 'Material Request': 'Material Request', - 'Purchase Order': 'Purchase Order', - 'Project': 'Project', - 'Payment Entry': "Payment", - 'Work Order': "Work Order" - } - frm.add_fetch('customer', 'tax_id', 'tax_id'); + "Delivery Note": "Delivery Note", + "Pick List": "Pick List", + "Sales Invoice": "Sales Invoice", + "Material Request": "Material Request", + "Purchase Order": "Purchase Order", + Project: "Project", + "Payment Entry": "Payment", + "Work Order": "Work Order", + }; + frm.add_fetch("customer", "tax_id", "tax_id"); // formatter for material request item - frm.set_indicator_formatter('item_code', - function(doc) { return (doc.stock_qty<=doc.delivered_qty) ? "green" : "orange" }) + frm.set_indicator_formatter("item_code", function (doc) { + return doc.stock_qty <= doc.delivered_qty ? "green" : "orange"; + }); - frm.set_query('company_address', function(doc) { - if(!doc.company) { - frappe.throw(__('Please set Company')); + frm.set_query("company_address", function (doc) { + if (!doc.company) { + frappe.throw(__("Please set Company")); } return { - query: 'frappe.contacts.doctype.address.address.address_query', + query: "frappe.contacts.doctype.address.address.address_query", filters: { - link_doctype: 'Company', - link_name: doc.company - } + link_doctype: "Company", + link_name: doc.company, + }, }; - }) + }); - frm.set_query("bom_no", "items", function(doc, cdt, cdn) { + frm.set_query("bom_no", "items", function (doc, cdt, cdn) { var row = locals[cdt][cdn]; return { filters: { - "item": row.item_code - } - } + item: row.item_code, + }, + }; }); - frm.set_df_property('packed_items', 'cannot_add_rows', true); - frm.set_df_property('packed_items', 'cannot_delete_rows', true); + frm.set_df_property("packed_items", "cannot_add_rows", true); + frm.set_df_property("packed_items", "cannot_delete_rows", true); }, - refresh: function(frm) { - if(frm.doc.docstatus === 1) { - if (frm.doc.status !== 'Closed' && flt(frm.doc.per_delivered, 2) < 100 && flt(frm.doc.per_billed, 2) < 100) { - frm.add_custom_button(__('Update Items'), () => { + refresh: function (frm) { + if (frm.doc.docstatus === 1) { + if ( + frm.doc.status !== "Closed" && + flt(frm.doc.per_delivered, 2) < 100 && + flt(frm.doc.per_billed, 2) < 100 + ) { + frm.add_custom_button(__("Update Items"), () => { erpnext.utils.update_child_items({ frm: frm, child_docname: "items", child_doctype: "Sales Order Detail", cannot_add_row: false, - has_reserved_stock: frm.doc.__onload && frm.doc.__onload.has_reserved_stock - }) + has_reserved_stock: frm.doc.__onload && frm.doc.__onload.has_reserved_stock, + }); }); // Stock Reservation > Reserve button should only be visible if the SO has unreserved stock and no Pick List is created against the SO. - if (frm.doc.__onload && frm.doc.__onload.has_unreserved_stock && flt(frm.doc.per_picked) === 0) { - frm.add_custom_button(__('Reserve'), () => frm.events.create_stock_reservation_entries(frm), __('Stock Reservation')); + if ( + frm.doc.__onload && + frm.doc.__onload.has_unreserved_stock && + flt(frm.doc.per_picked) === 0 + ) { + frm.add_custom_button( + __("Reserve"), + () => frm.events.create_stock_reservation_entries(frm), + __("Stock Reservation") + ); } } // Stock Reservation > Unreserve button will be only visible if the SO has un-delivered reserved stock. if (frm.doc.__onload && frm.doc.__onload.has_reserved_stock) { - frm.add_custom_button(__('Unreserve'), () => frm.events.cancel_stock_reservation_entries(frm), __('Stock Reservation')); + frm.add_custom_button( + __("Unreserve"), + () => frm.events.cancel_stock_reservation_entries(frm), + __("Stock Reservation") + ); } - frm.doc.items.forEach(item => { + frm.doc.items.forEach((item) => { if (flt(item.stock_reserved_qty) > 0) { - frm.add_custom_button(__('Reserved Stock'), () => frm.events.show_reserved_stock(frm), __('Stock Reservation')); + frm.add_custom_button( + __("Reserved Stock"), + () => frm.events.show_reserved_stock(frm), + __("Stock Reservation") + ); return; } }); @@ -94,11 +115,11 @@ frappe.ui.form.on("Sales Order", { frm.set_value("reserve_stock", 0); frm.set_df_property("reserve_stock", "read_only", 1); frm.set_df_property("reserve_stock", "hidden", 1); - frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'hidden', 1); - frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'default', 0); - frm.fields_dict.items.grid.update_docfield_property('reserve_stock', 'read_only', 1); + frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "hidden", 1); + frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "default", 0); + frm.fields_dict.items.grid.update_docfield_property("reserve_stock", "read_only", 1); } - }) + }); } } @@ -109,47 +130,47 @@ frappe.ui.form.on("Sales Order", { }, get_items_from_internal_purchase_order(frm) { - frm.add_custom_button(__('Purchase Order'), () => { - erpnext.utils.map_current_doc({ - method: 'erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order', - source_doctype: 'Purchase Order', - target: frm, - setters: [ - { - label: 'Supplier', - fieldname: 'supplier', - fieldtype: 'Link', - options: 'Supplier' - } - ], - get_query_filters: { - company: frm.doc.company, - is_internal_supplier: 1, - docstatus: 1, - status: ['!=', 'Completed'] - } - }); - }, __('Get Items From')); + frm.add_custom_button( + __("Purchase Order"), + () => { + erpnext.utils.map_current_doc({ + method: "erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order", + source_doctype: "Purchase Order", + target: frm, + setters: [ + { + label: "Supplier", + fieldname: "supplier", + fieldtype: "Link", + options: "Supplier", + }, + ], + get_query_filters: { + company: frm.doc.company, + is_internal_supplier: 1, + docstatus: 1, + status: ["!=", "Completed"], + }, + }); + }, + __("Get Items From") + ); }, - onload: function(frm) { - if (!frm.doc.transaction_date){ - frm.set_value('transaction_date', frappe.datetime.get_today()) + onload: function (frm) { + if (!frm.doc.transaction_date) { + frm.set_value("transaction_date", frappe.datetime.get_today()); } - erpnext.queries.setup_queries(frm, "Warehouse", function() { + erpnext.queries.setup_queries(frm, "Warehouse", function () { return { - filters: [ - ["Warehouse", "company", "in", ["", cstr(frm.doc.company)]], - ] + filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]], }; }); - frm.set_query('warehouse', 'items', function(doc, cdt, cdn) { - let row = locals[cdt][cdn]; + frm.set_query("warehouse", "items", function (doc, cdt, cdn) { + let row = locals[cdt][cdn]; let query = { - filters: [ - ["Warehouse", "company", "in", ["", cstr(frm.doc.company)]], - ] + filters: [["Warehouse", "company", "in", ["", cstr(frm.doc.company)]]], }; if (row.item_code) { query.query = "erpnext.controllers.queries.warehouse_query"; @@ -160,15 +181,15 @@ frappe.ui.form.on("Sales Order", { // On cancel and amending a sales order with advance payment, reset advance paid amount if (frm.is_new()) { - frm.set_value("advance_paid", 0) + frm.set_value("advance_paid", 0); } - frm.ignore_doctypes_on_cancel_all = ['Purchase Order']; + frm.ignore_doctypes_on_cancel_all = ["Purchase Order"]; }, - delivery_date: function(frm) { - $.each(frm.doc.items || [], function(i, d) { - if(!d.delivery_date) d.delivery_date = frm.doc.delivery_date; + delivery_date: function (frm) { + $.each(frm.doc.items || [], function (i, d) { + if (!d.delivery_date) d.delivery_date = frm.doc.delivery_date; }); refresh_field("items"); }, @@ -186,9 +207,7 @@ frappe.ui.form.on("Sales Order", { default: frm.doc.set_warehouse, get_query: () => { return { - filters: [ - ["Warehouse", "is_group", "!=", 1] - ] + filters: [["Warehouse", "is_group", "!=", 1]], }; }, onchange: () => { @@ -200,7 +219,7 @@ frappe.ui.form.on("Sales Order", { } }, }, - {fieldtype: "Column Break"}, + { fieldtype: "Column Break" }, { fieldname: "add_item", fieldtype: "Link", @@ -210,19 +229,24 @@ frappe.ui.form.on("Sales Order", { return { query: "erpnext.controllers.queries.get_filtered_child_rows", filters: { - "parenttype": frm.doc.doctype, - "parent": frm.doc.name, - "reserve_stock": 1, - } - } + parenttype: frm.doc.doctype, + parent: frm.doc.name, + reserve_stock: 1, + }, + }; }, onchange: () => { let sales_order_item = dialog.get_value("add_item"); if (sales_order_item) { - frm.doc.items.forEach(item => { + frm.doc.items.forEach((item) => { if (item.name === sales_order_item) { - let unreserved_qty = (flt(item.stock_qty) - (item.stock_reserved_qty ? flt(item.stock_reserved_qty) : (flt(item.delivered_qty) * flt(item.conversion_factor)))) / flt(item.conversion_factor); + let unreserved_qty = + (flt(item.stock_qty) - + (item.stock_reserved_qty + ? flt(item.stock_reserved_qty) + : flt(item.delivered_qty) * flt(item.conversion_factor))) / + flt(item.conversion_factor); if (unreserved_qty > 0) { dialog.fields_dict.items.df.data.forEach((row) => { @@ -233,10 +257,10 @@ frappe.ui.form.on("Sales Order", { } dialog.fields_dict.items.df.data.push({ - 'sales_order_item': item.name, - 'item_code': item.item_code, - 'warehouse': dialog.get_value("set_warehouse") || item.warehouse, - 'qty_to_reserve': Math.max(unreserved_qty, 0) + sales_order_item: item.name, + item_code: item.item_code, + warehouse: dialog.get_value("set_warehouse") || item.warehouse, + qty_to_reserve: Math.max(unreserved_qty, 0), }); dialog.fields_dict.items.grid.refresh(); dialog.set_value("add_item", undefined); @@ -245,7 +269,7 @@ frappe.ui.form.on("Sales Order", { } }, }, - {fieldtype: "Section Break"}, + { fieldtype: "Section Break" }, { fieldname: "items", fieldtype: "Table", @@ -265,25 +289,26 @@ frappe.ui.form.on("Sales Order", { return { query: "erpnext.controllers.queries.get_filtered_child_rows", filters: { - "parenttype": frm.doc.doctype, - "parent": frm.doc.name, - "reserve_stock": 1, - } - } + parenttype: frm.doc.doctype, + parent: frm.doc.name, + reserve_stock: 1, + }, + }; }, onchange: (event) => { if (event) { let name = $(event.currentTarget).closest(".grid-row").attr("data-name"); - let item_row = dialog.fields_dict.items.grid.grid_rows_by_docname[name].doc; + let item_row = + dialog.fields_dict.items.grid.grid_rows_by_docname[name].doc; - frm.doc.items.forEach(item => { + frm.doc.items.forEach((item) => { if (item.name === item_row.sales_order_item) { item_row.item_code = item.item_code; } }); dialog.fields_dict.items.grid.refresh(); } - } + }, }, { fieldname: "item_code", @@ -303,9 +328,7 @@ frappe.ui.form.on("Sales Order", { in_list_view: 1, get_query: () => { return { - filters: [ - ["Warehouse", "is_group", "!=", 1] - ] + filters: [["Warehouse", "is_group", "!=", 1]], }; }, }, @@ -314,14 +337,14 @@ frappe.ui.form.on("Sales Order", { fieldtype: "Float", label: __("Qty"), reqd: 1, - in_list_view: 1 - } + in_list_view: 1, + }, ], }, ], primary_action_label: __("Reserve Stock"), primary_action: () => { - var data = {items: dialog.fields_dict.items.grid.data}; + var data = { items: dialog.fields_dict.items.grid.data }; if (data.items && data.items.length > 0) { frappe.call({ @@ -329,14 +352,14 @@ frappe.ui.form.on("Sales Order", { method: "create_stock_reservation_entries", args: { items_details: data.items, - notify: true + notify: true, }, freeze: true, freeze_message: __("Reserving Stock..."), callback: (r) => { frm.doc.__onload.has_unreserved_stock = false; frm.reload_doc(); - } + }, }); } @@ -344,16 +367,21 @@ frappe.ui.form.on("Sales Order", { }, }); - frm.doc.items.forEach(item => { + frm.doc.items.forEach((item) => { if (item.reserve_stock) { - let unreserved_qty = (flt(item.stock_qty) - (item.stock_reserved_qty ? flt(item.stock_reserved_qty) : (flt(item.delivered_qty) * flt(item.conversion_factor)))) / flt(item.conversion_factor); + let unreserved_qty = + (flt(item.stock_qty) - + (item.stock_reserved_qty + ? flt(item.stock_reserved_qty) + : flt(item.delivered_qty) * flt(item.conversion_factor))) / + flt(item.conversion_factor); if (unreserved_qty > 0) { dialog.fields_dict.items.df.data.push({ - 'sales_order_item': item.name, - 'item_code': item.item_code, - 'warehouse': item.warehouse, - 'qty_to_reserve': unreserved_qty + sales_order_item: item.name, + item_code: item.item_code, + warehouse: item.warehouse, + qty_to_reserve: unreserved_qty, }); } } @@ -410,28 +438,28 @@ frappe.ui.form.on("Sales Order", { label: __("Qty"), reqd: 1, read_only: 1, - in_list_view: 1 - } - ] - } + in_list_view: 1, + }, + ], + }, ], primary_action_label: __("Unreserve Stock"), primary_action: () => { - var data = {sr_entries: dialog.fields_dict.sr_entries.grid.data}; + var data = { sr_entries: dialog.fields_dict.sr_entries.grid.data }; if (data.sr_entries && data.sr_entries.length > 0) { frappe.call({ doc: frm.doc, method: "cancel_stock_reservation_entries", args: { - sre_list: data.sr_entries.map(item => item.sre), + sre_list: data.sr_entries.map((item) => item.sre), }, freeze: true, - freeze_message: __('Unreserving Stock...'), + freeze_message: __("Unreserving Stock..."), callback: (r) => { frm.doc.__onload.has_reserved_stock = false; frm.reload_doc(); - } + }, }); } @@ -439,35 +467,39 @@ frappe.ui.form.on("Sales Order", { }, }); - frappe.call({ - method: 'erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry.get_stock_reservation_entries_for_voucher', - args: { - voucher_type: frm.doctype, - voucher_no: frm.docname, - }, - callback: (r) => { - if (!r.exc && r.message) { - r.message.forEach(sre => { - if (flt(sre.reserved_qty) > flt(sre.delivered_qty)) { - dialog.fields_dict.sr_entries.df.data.push({ - 'sre': sre.name, - 'item_code': sre.item_code, - 'warehouse': sre.warehouse, - 'qty': (flt(sre.reserved_qty) - flt(sre.delivered_qty)) - }); - } - }); - } - } - }).then(r => { - dialog.fields_dict.sr_entries.grid.refresh(); - dialog.show(); - }); + frappe + .call({ + method: "erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry.get_stock_reservation_entries_for_voucher", + args: { + voucher_type: frm.doctype, + voucher_no: frm.docname, + }, + callback: (r) => { + if (!r.exc && r.message) { + r.message.forEach((sre) => { + if (flt(sre.reserved_qty) > flt(sre.delivered_qty)) { + dialog.fields_dict.sr_entries.df.data.push({ + sre: sre.name, + item_code: sre.item_code, + warehouse: sre.warehouse, + qty: flt(sre.reserved_qty) - flt(sre.delivered_qty), + }); + } + }); + } + }, + }) + .then((r) => { + dialog.fields_dict.sr_entries.grid.refresh(); + dialog.show(); + }); }, show_reserved_stock(frm) { // Get the latest modified date from the items table. - var to_date = moment(new Date(Math.max(...frm.doc.items.map(e => new Date(e.modified))))).format('YYYY-MM-DD'); + var to_date = moment(new Date(Math.max(...frm.doc.items.map((e) => new Date(e.modified))))).format( + "YYYY-MM-DD" + ); frappe.route_options = { company: frm.doc.company, @@ -475,13 +507,13 @@ frappe.ui.form.on("Sales Order", { to_date: to_date, voucher_type: frm.doc.doctype, voucher_no: frm.doc.name, - } + }; frappe.set_route("query-report", "Reserved Stock"); - } + }, }); frappe.ui.form.on("Sales Order Item", { - item_code: function(frm,cdt,cdn) { + item_code: function (frm, cdt, cdn) { var row = locals[cdt][cdn]; if (frm.doc.delivery_date) { row.delivery_date = frm.doc.delivery_date; @@ -490,11 +522,11 @@ frappe.ui.form.on("Sales Order Item", { frm.script_manager.copy_from_first_row("items", row, ["delivery_date"]); } }, - delivery_date: function(frm, cdt, cdn) { - if(!frm.doc.delivery_date) { + delivery_date: function (frm, cdt, cdn) { + if (!frm.doc.delivery_date) { erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "items", "delivery_date"); } - } + }, }); erpnext.selling.SalesOrderController = class SalesOrderController extends erpnext.selling.SellingController { @@ -507,111 +539,185 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex super.refresh(); let allow_delivery = false; - if (doc.docstatus==1) { + if (doc.docstatus == 1) { + if (this.frm.has_perm("submit")) { + if (doc.status === "On Hold") { + // un-hold + this.frm.add_custom_button( + __("Resume"), + function () { + me.frm.cscript.update_status("Resume", "Draft"); + }, + __("Status") + ); - if(this.frm.has_perm("submit")) { - if(doc.status === 'On Hold') { - // un-hold - this.frm.add_custom_button(__('Resume'), function() { - me.frm.cscript.update_status('Resume', 'Draft') - }, __("Status")); - - if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed, 2) < 100) { - // close - this.frm.add_custom_button(__('Close'), () => this.close_sales_order(), __("Status")) - } + if (flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed, 2) < 100) { + // close + this.frm.add_custom_button(__("Close"), () => this.close_sales_order(), __("Status")); + } + } else if (doc.status === "Closed") { + // un-close + this.frm.add_custom_button( + __("Re-open"), + function () { + me.frm.cscript.update_status("Re-open", "Draft"); + }, + __("Status") + ); } - else if(doc.status === 'Closed') { - // un-close - this.frm.add_custom_button(__('Re-open'), function() { - me.frm.cscript.update_status('Re-open', 'Draft') - }, __("Status")); - } } - if(doc.status !== 'Closed') { - if(doc.status !== 'On Hold') { - allow_delivery = this.frm.doc.items.some(item => item.delivered_by_supplier === 0 && item.qty > flt(item.delivered_qty)) - && !this.frm.doc.skip_delivery_note + if (doc.status !== "Closed") { + if (doc.status !== "On Hold") { + allow_delivery = + this.frm.doc.items.some( + (item) => item.delivered_by_supplier === 0 && item.qty > flt(item.delivered_qty) + ) && !this.frm.doc.skip_delivery_note; if (this.frm.has_perm("submit")) { - if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed, 2) < 100) { + if (flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed, 2) < 100) { // hold - this.frm.add_custom_button(__('Hold'), () => this.hold_sales_order(), __("Status")) + this.frm.add_custom_button( + __("Hold"), + () => this.hold_sales_order(), + __("Status") + ); // close - this.frm.add_custom_button(__('Close'), () => this.close_sales_order(), __("Status")) + this.frm.add_custom_button( + __("Close"), + () => this.close_sales_order(), + __("Status") + ); } } if (!doc.__onload || !doc.__onload.has_reserved_stock) { // Don't show the `Reserve` button if the Sales Order has Picked Items. if (flt(doc.per_picked, 2) < 100 && flt(doc.per_delivered, 2) < 100) { - this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create')); + this.frm.add_custom_button( + __("Pick List"), + () => this.create_pick_list(), + __("Create") + ); } } const order_is_a_sale = ["Sales", "Shopping Cart"].indexOf(doc.order_type) !== -1; const order_is_maintenance = ["Maintenance"].indexOf(doc.order_type) !== -1; // order type has been customised then show all the action buttons - const order_is_a_custom_sale = ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1; + const order_is_a_custom_sale = + ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1; // delivery note - if(flt(doc.per_delivered, 2) < 100 && (order_is_a_sale || order_is_a_custom_sale) && allow_delivery) { - this.frm.add_custom_button(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(true), __('Create')); - this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create')); + if ( + flt(doc.per_delivered, 2) < 100 && + (order_is_a_sale || order_is_a_custom_sale) && + allow_delivery + ) { + this.frm.add_custom_button( + __("Delivery Note"), + () => this.make_delivery_note_based_on_delivery_date(true), + __("Create") + ); + this.frm.add_custom_button( + __("Work Order"), + () => this.make_work_order(), + __("Create") + ); } // sales invoice - if(flt(doc.per_billed, 2) < 100) { - this.frm.add_custom_button(__('Sales Invoice'), () => me.make_sales_invoice(), __('Create')); + if (flt(doc.per_billed, 2) < 100) { + this.frm.add_custom_button( + __("Sales Invoice"), + () => me.make_sales_invoice(), + __("Create") + ); } // material request - if(!doc.order_type || (order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered, 2) < 100) { - this.frm.add_custom_button(__('Material Request'), () => this.make_material_request(), __('Create')); - this.frm.add_custom_button(__('Request for Raw Materials'), () => this.make_raw_material_request(), __('Create')); + if ( + !doc.order_type || + ((order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered, 2) < 100) + ) { + this.frm.add_custom_button( + __("Material Request"), + () => this.make_material_request(), + __("Create") + ); + this.frm.add_custom_button( + __("Request for Raw Materials"), + () => this.make_raw_material_request(), + __("Create") + ); } // Make Purchase Order if (!this.frm.doc.is_internal_customer) { - this.frm.add_custom_button(__('Purchase Order'), () => this.make_purchase_order(), __('Create')); + this.frm.add_custom_button( + __("Purchase Order"), + () => this.make_purchase_order(), + __("Create") + ); } // maintenance - if(flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) { - this.frm.add_custom_button(__('Maintenance Visit'), () => this.make_maintenance_visit(), __('Create')); - this.frm.add_custom_button(__('Maintenance Schedule'), () => this.make_maintenance_schedule(), __('Create')); + if (flt(doc.per_delivered, 2) < 100 && (order_is_maintenance || order_is_a_custom_sale)) { + this.frm.add_custom_button( + __("Maintenance Visit"), + () => this.make_maintenance_visit(), + __("Create") + ); + this.frm.add_custom_button( + __("Maintenance Schedule"), + () => this.make_maintenance_schedule(), + __("Create") + ); } // project - if(flt(doc.per_delivered, 2) < 100) { - this.frm.add_custom_button(__('Project'), () => this.make_project(), __('Create')); + if (flt(doc.per_delivered, 2) < 100) { + this.frm.add_custom_button(__("Project"), () => this.make_project(), __("Create")); } if (doc.docstatus === 1 && !doc.inter_company_order_reference) { let me = this; let internal = me.frm.doc.is_internal_customer; if (internal) { - let button_label = (me.frm.doc.company === me.frm.doc.represents_company) ? "Internal Purchase Order" : - "Inter Company Purchase Order"; + let button_label = + me.frm.doc.company === me.frm.doc.represents_company + ? "Internal Purchase Order" + : "Inter Company Purchase Order"; - me.frm.add_custom_button(button_label, function() { - me.make_inter_company_order(); - }, __('Create')); + me.frm.add_custom_button( + button_label, + function () { + me.make_inter_company_order(); + }, + __("Create") + ); } } } // payment request - if(flt(doc.per_billed, precision('per_billed', doc)) < 100 + frappe.boot.sysdefaults.over_billing_allowance) { - this.frm.add_custom_button(__('Payment Request'), () => this.make_payment_request(), __('Create')); - this.frm.add_custom_button(__('Payment'), () => this.make_payment_entry(), __('Create')); + if ( + flt(doc.per_billed, precision("per_billed", doc)) < + 100 + frappe.boot.sysdefaults.over_billing_allowance + ) { + this.frm.add_custom_button( + __("Payment Request"), + () => this.make_payment_request(), + __("Create") + ); + this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create")); } - this.frm.page.set_inner_btn_group_as_primary(__('Create')); + this.frm.page.set_inner_btn_group_as_primary(__("Create")); } } - if (this.frm.doc.docstatus===0) { - this.frm.add_custom_button(__('Quotation'), - function() { + if (this.frm.doc.docstatus === 0) { + this.frm.add_custom_button( + __("Quotation"), + function () { let d = erpnext.utils.map_current_doc({ method: "erpnext.selling.doctype.quotation.quotation.make_sales_order", source_doctype: "Quotation", @@ -622,14 +728,14 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex fieldname: "party_name", fieldtype: "Link", options: "Customer", - default: me.frm.doc.customer || undefined - } + default: me.frm.doc.customer || undefined, + }, ], get_query_filters: { company: me.frm.doc.company, docstatus: 1, - status: ["!=", "Lost"] - } + status: ["!=", "Lost"], + }, }); setTimeout(() => { @@ -639,8 +745,9 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex `); }, 200); - - }, __("Get Items From")); + }, + __("Get Items From") + ); } this.order_type(doc); @@ -649,8 +756,8 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex create_pick_list() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.create_pick_list", - frm: this.frm - }) + frm: this.frm, + }); } make_work_order() { @@ -661,86 +768,99 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex sales_order: this.frm.docname, }, freeze: true, - callback: function(r) { - if(!r.message) { + callback: function (r) { + if (!r.message) { frappe.msgprint({ - title: __('Work Order not created'), - message: __('No Items with Bill of Materials to Manufacture'), - indicator: 'orange' + title: __("Work Order not created"), + message: __("No Items with Bill of Materials to Manufacture"), + indicator: "orange", }); return; - } - else { - const fields = [{ - label: 'Items', - fieldtype: 'Table', - fieldname: 'items', - description: __('Select BOM and Qty for Production'), - fields: [{ - fieldtype: 'Read Only', - fieldname: 'item_code', - label: __('Item Code'), - in_list_view: 1 - }, { - fieldtype: 'Link', - fieldname: 'bom', - options: 'BOM', - reqd: 1, - label: __('Select BOM'), - in_list_view: 1, - get_query: function (doc) { - return { filters: { item: doc.item_code } }; - } - }, { - fieldtype: 'Float', - fieldname: 'pending_qty', - reqd: 1, - label: __('Qty'), - in_list_view: 1 - }, { - fieldtype: 'Data', - fieldname: 'sales_order_item', - reqd: 1, - label: __('Sales Order Item'), - hidden: 1 - }], - data: r.message, - get_data: () => { - return r.message - } - }] + } else { + const fields = [ + { + label: "Items", + fieldtype: "Table", + fieldname: "items", + description: __("Select BOM and Qty for Production"), + fields: [ + { + fieldtype: "Read Only", + fieldname: "item_code", + label: __("Item Code"), + in_list_view: 1, + }, + { + fieldtype: "Link", + fieldname: "bom", + options: "BOM", + reqd: 1, + label: __("Select BOM"), + in_list_view: 1, + get_query: function (doc) { + return { filters: { item: doc.item_code } }; + }, + }, + { + fieldtype: "Float", + fieldname: "pending_qty", + reqd: 1, + label: __("Qty"), + in_list_view: 1, + }, + { + fieldtype: "Data", + fieldname: "sales_order_item", + reqd: 1, + label: __("Sales Order Item"), + hidden: 1, + }, + ], + data: r.message, + get_data: () => { + return r.message; + }, + }, + ]; var d = new frappe.ui.Dialog({ - title: __('Select Items to Manufacture'), + title: __("Select Items to Manufacture"), fields: fields, - primary_action: function() { - var data = {items: d.fields_dict.items.grid.get_selected_children()}; + primary_action: function () { + var data = { items: d.fields_dict.items.grid.get_selected_children() }; me.frm.call({ - method: 'make_work_orders', + method: "make_work_orders", args: { items: data, company: me.frm.doc.company, sales_order: me.frm.docname, - project: me.frm.project + project: me.frm.project, }, freeze: true, - callback: function(r) { - if(r.message) { + callback: function (r) { + if (r.message) { frappe.msgprint({ - message: __('Work Orders Created: {0}', [r.message.map(function(d) { - return repl('%(name)s', {name:d}) - }).join(', ')]), - indicator: 'green' - }) + message: __("Work Orders Created: {0}", [ + r.message + .map(function (d) { + return repl( + '%(name)s', + { name: d } + ); + }) + .join(", "), + ]), + indicator: "green", + }); } d.hide(); - } + }, }); }, - primary_action_label: __('Create') + primary_action_label: __("Create"), }); d.show(); } - } + }, }); } @@ -755,8 +875,8 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex make_material_request() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request", - frm: this.frm - }) + frm: this.frm, + }); } skip_delivery_note() { @@ -764,8 +884,10 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex } toggle_delivery_date() { - this.frm.fields_dict.items.grid.toggle_reqd("delivery_date", - (this.frm.doc.order_type == "Sales" && !this.frm.doc.skip_delivery_note)); + this.frm.fields_dict.items.grid.toggle_reqd( + "delivery_date", + this.frm.doc.order_type == "Sales" && !this.frm.doc.skip_delivery_note + ); } make_raw_material_request() { @@ -774,104 +896,135 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex method: "erpnext.selling.doctype.sales_order.sales_order.get_work_order_items", args: { sales_order: this.frm.docname, - for_raw_material_request: 1 + for_raw_material_request: 1, }, - callback: function(r) { - if(!r.message) { + callback: function (r) { + if (!r.message) { frappe.msgprint({ - message: __('No Items with Bill of Materials.'), - indicator: 'orange' + message: __("No Items with Bill of Materials."), + indicator: "orange", }); return; - } - else { + } else { me.make_raw_material_request_dialog(r); } - } + }, }); } make_raw_material_request_dialog(r) { var me = this; var fields = [ - {fieldtype:'Check', fieldname:'include_exploded_items', - label: __('Include Exploded Items')}, - {fieldtype:'Check', fieldname:'ignore_existing_ordered_qty', - label: __('Ignore Existing Ordered Qty')}, + { fieldtype: "Check", fieldname: "include_exploded_items", label: __("Include Exploded Items") }, { - fieldtype:'Table', fieldname: 'items', - description: __('Select BOM, Qty and For Warehouse'), + fieldtype: "Check", + fieldname: "ignore_existing_ordered_qty", + label: __("Ignore Existing Ordered Qty"), + }, + { + fieldtype: "Table", + fieldname: "items", + description: __("Select BOM, Qty and For Warehouse"), fields: [ - {fieldtype:'Read Only', fieldname:'item_code', - label: __('Item Code'), in_list_view:1}, - {fieldtype:'Link', fieldname:'warehouse', options: 'Warehouse', - label: __('For Warehouse'), in_list_view:1}, - {fieldtype:'Link', fieldname:'bom', options: 'BOM', reqd: 1, - label: __('BOM'), in_list_view:1, get_query: function(doc) { - return {filters: {item: doc.item_code}}; - } + { + fieldtype: "Read Only", + fieldname: "item_code", + label: __("Item Code"), + in_list_view: 1, + }, + { + fieldtype: "Link", + fieldname: "warehouse", + options: "Warehouse", + label: __("For Warehouse"), + in_list_view: 1, + }, + { + fieldtype: "Link", + fieldname: "bom", + options: "BOM", + reqd: 1, + label: __("BOM"), + in_list_view: 1, + get_query: function (doc) { + return { filters: { item: doc.item_code } }; + }, + }, + { + fieldtype: "Float", + fieldname: "required_qty", + reqd: 1, + label: __("Qty"), + in_list_view: 1, }, - {fieldtype:'Float', fieldname:'required_qty', reqd: 1, - label: __('Qty'), in_list_view:1}, ], data: r.message, - get_data: function() { - return r.message - } - } - ] + get_data: function () { + return r.message; + }, + }, + ]; var d = new frappe.ui.Dialog({ title: __("Items for Raw Material Request"), fields: fields, - primary_action: function() { + primary_action: function () { var data = d.get_values(); me.frm.call({ - method: 'erpnext.selling.doctype.sales_order.sales_order.make_raw_material_request', + method: "erpnext.selling.doctype.sales_order.sales_order.make_raw_material_request", args: { items: data, company: me.frm.doc.company, sales_order: me.frm.docname, - project: me.frm.project + project: me.frm.project, }, freeze: true, - callback: function(r) { - if(r.message) { - frappe.msgprint(__('Material Request {0} submitted.', - ['' + r.message.name+ ''])); + callback: function (r) { + if (r.message) { + frappe.msgprint( + __("Material Request {0} submitted.", [ + '' + + r.message.name + + "", + ]) + ); } d.hide(); me.frm.reload_doc(); - } + }, }); }, - primary_action_label: __('Create') + primary_action_label: __("Create"), }); d.show(); } - make_delivery_note_based_on_delivery_date(for_reserved_stock=false) { + make_delivery_note_based_on_delivery_date(for_reserved_stock = false) { var me = this; - var delivery_dates = this.frm.doc.items.map(i => i.delivery_date); - delivery_dates = [ ...new Set(delivery_dates) ]; + var delivery_dates = this.frm.doc.items.map((i) => i.delivery_date); + delivery_dates = [...new Set(delivery_dates)]; var today = new Date(); var item_grid = this.frm.fields_dict["items"].grid; - if(!item_grid.get_selected().length && delivery_dates.length > 1) { + if (!item_grid.get_selected().length && delivery_dates.length > 1) { var dialog = new frappe.ui.Dialog({ title: __("Select Items based on Delivery Date"), - fields: [{fieldtype: "HTML", fieldname: "dates_html"}] + fields: [{ fieldtype: "HTML", fieldname: "dates_html" }], }); var html = $(`
      - ${__('Delivery Date')} + ${__("Delivery Date")}
      - ${delivery_dates.map(date => ` + ${delivery_dates + .map( + (date) => `
      - `).join("")} + ` + ) + .join("")}
      `); var wrapper = dialog.fields_dict.dates_html.$wrapper; wrapper.html(html); - dialog.set_primary_action(__("Select"), function() { - var dates = wrapper.find('input[type=checkbox]:checked') - .map((i, el) => $(el).attr('data-date')).toArray(); + dialog.set_primary_action(__("Select"), function () { + var dates = wrapper + .find("input[type=checkbox]:checked") + .map((i, el) => $(el).attr("data-date")) + .toArray(); - if(!dates) return; + if (!dates) return; me.make_delivery_note(dates, for_reserved_stock); dialog.hide(); @@ -906,61 +1063,64 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex } } - make_delivery_note(delivery_dates, for_reserved_stock=false) { + make_delivery_note(delivery_dates, for_reserved_stock = false) { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note", frm: this.frm, args: { delivery_dates, - for_reserved_stock: for_reserved_stock + for_reserved_stock: for_reserved_stock, }, freeze: true, - freeze_message: __("Creating Delivery Note ...") - }) + freeze_message: __("Creating Delivery Note ..."), + }); } make_sales_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice", - frm: this.frm - }) + frm: this.frm, + }); } make_maintenance_schedule() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_schedule", - frm: this.frm - }) + frm: this.frm, + }); } make_project() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_project", - frm: this.frm - }) + frm: this.frm, + }); } make_inter_company_order() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_inter_company_purchase_order", - frm: this.frm + frm: this.frm, }); } make_maintenance_visit() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit", - frm: this.frm - }) + frm: this.frm, + }); } - make_purchase_order(){ - let pending_items = this.frm.doc.items.some((item) =>{ + make_purchase_order() { + let pending_items = this.frm.doc.items.some((item) => { let pending_qty = flt(item.stock_qty) - flt(item.ordered_qty); return pending_qty > 0; - }) - if(!pending_items){ - frappe.throw({message: __("Purchase Order already created for all Sales Order items"), title: __("Note")}); + }); + if (!pending_items) { + frappe.throw({ + message: __("Purchase Order already created for all Sales Order items"), + title: __("Note"), + }); } var me = this; @@ -969,115 +1129,122 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex size: "large", fields: [ { - "fieldtype": "Check", - "label": __("Against Default Supplier"), - "fieldname": "against_default_supplier", - "default": 0 + fieldtype: "Check", + label: __("Against Default Supplier"), + fieldname: "against_default_supplier", + default: 0, }, { - fieldname: 'items_for_po', fieldtype: 'Table', label: 'Select Items', + fieldname: "items_for_po", + fieldtype: "Table", + label: "Select Items", fields: [ { - fieldtype:'Data', - fieldname:'item_code', - label: __('Item'), - read_only:1, - in_list_view:1 - }, - { - fieldtype:'Data', - fieldname:'item_name', - label: __('Item name'), - read_only:1, - in_list_view:1 - }, - { - fieldtype:'Float', - fieldname:'pending_qty', - label: __('Pending Qty'), + fieldtype: "Data", + fieldname: "item_code", + label: __("Item"), read_only: 1, - in_list_view:1 + in_list_view: 1, }, { - fieldtype:'Link', - read_only:1, - fieldname:'uom', - label: __('UOM'), - in_list_view:1, + fieldtype: "Data", + fieldname: "item_name", + label: __("Item name"), + read_only: 1, + in_list_view: 1, }, { - fieldtype:'Data', - fieldname:'supplier', - label: __('Supplier'), - read_only:1, - in_list_view:1 + fieldtype: "Float", + fieldname: "pending_qty", + label: __("Pending Qty"), + read_only: 1, + in_list_view: 1, }, - ] - } + { + fieldtype: "Link", + read_only: 1, + fieldname: "uom", + label: __("UOM"), + in_list_view: 1, + }, + { + fieldtype: "Data", + fieldname: "supplier", + label: __("Supplier"), + read_only: 1, + in_list_view: 1, + }, + ], + }, ], - primary_action_label: 'Create Purchase Order', - primary_action (args) { + primary_action_label: "Create Purchase Order", + primary_action(args) { if (!args) return; let selected_items = dialog.fields_dict.items_for_po.grid.get_selected_children(); - if(selected_items.length == 0) { - frappe.throw({message: 'Please select Items from the Table', title: __('Items Required'), indicator:'blue'}) + if (selected_items.length == 0) { + frappe.throw({ + message: "Please select Items from the Table", + title: __("Items Required"), + indicator: "blue", + }); } dialog.hide(); - var method = args.against_default_supplier ? "make_purchase_order_for_default_supplier" : "make_purchase_order" + var method = args.against_default_supplier + ? "make_purchase_order_for_default_supplier" + : "make_purchase_order"; return frappe.call({ method: "erpnext.selling.doctype.sales_order.sales_order." + method, freeze_message: __("Creating Purchase Order ..."), args: { - "source_name": me.frm.doc.name, - "selected_items": selected_items + source_name: me.frm.doc.name, + selected_items: selected_items, }, freeze: true, - callback: function(r) { - if(!r.exc) { + callback: function (r) { + if (!r.exc) { if (!args.against_default_supplier) { frappe.model.sync(r.message); frappe.set_route("Form", r.message.doctype, r.message.name); - } - else { + } else { frappe.route_options = { - "sales_order": me.frm.doc.name - } + sales_order: me.frm.doc.name, + }; frappe.set_route("List", "Purchase Order"); } } - } - }) - } + }, + }); + }, }); dialog.fields_dict["against_default_supplier"].df.onchange = () => set_po_items_data(dialog); - function set_po_items_data (dialog) { + function set_po_items_data(dialog) { var against_default_supplier = dialog.get_value("against_default_supplier"); var items_for_po = dialog.get_value("items_for_po"); if (against_default_supplier) { - let items_with_supplier = items_for_po.filter((item) => item.supplier) + let items_with_supplier = items_for_po.filter((item) => item.supplier); dialog.fields_dict["items_for_po"].df.data = items_with_supplier; dialog.get_field("items_for_po").refresh(); } else { let po_items = []; - me.frm.doc.items.forEach(d => { + me.frm.doc.items.forEach((d) => { let ordered_qty = me.get_ordered_qty(d, me.frm.doc); let pending_qty = (flt(d.stock_qty) - ordered_qty) / flt(d.conversion_factor); if (pending_qty > 0) { po_items.push({ - "doctype": "Sales Order Item", - "name": d.name, - "item_name": d.item_name, - "item_code": d.item_code, - "pending_qty": pending_qty, - "uom": d.uom, - "supplier": d.supplier + doctype: "Sales Order Item", + name: d.name, + item_name: d.item_name, + item_code: d.item_code, + pending_qty: pending_qty, + uom: d.uom, + supplier: d.supplier, }); } }); @@ -1090,7 +1257,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex set_po_items_data(dialog); dialog.get_field("items_for_po").grid.only_sortable(); dialog.get_field("items_for_po").refresh(); - dialog.wrapper.find('.grid-heading-row .grid-row-check').click(); + dialog.wrapper.find(".grid-heading-row .grid-row-check").click(); dialog.show(); } @@ -1098,71 +1265,66 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex let ordered_qty = item.ordered_qty; if (so.packed_items && so.packed_items.length) { // calculate ordered qty based on packed items in case of product bundle - let packed_items = so.packed_items.filter( - (pi) => pi.parent_detail_docname == item.name - ); + let packed_items = so.packed_items.filter((pi) => pi.parent_detail_docname == item.name); if (packed_items && packed_items.length) { - ordered_qty = packed_items.reduce( - (sum, pi) => sum + flt(pi.ordered_qty), - 0 - ); + ordered_qty = packed_items.reduce((sum, pi) => sum + flt(pi.ordered_qty), 0); ordered_qty = ordered_qty / packed_items.length; } } return ordered_qty; } - hold_sales_order(){ + hold_sales_order() { var me = this; var d = new frappe.ui.Dialog({ - title: __('Reason for Hold'), + title: __("Reason for Hold"), fields: [ { - "fieldname": "reason_for_hold", - "fieldtype": "Text", - "reqd": 1, - } + fieldname: "reason_for_hold", + fieldtype: "Text", + reqd: 1, + }, ], - primary_action: function() { + primary_action: function () { var data = d.get_values(); frappe.call({ method: "frappe.desk.form.utils.add_comment", args: { reference_doctype: me.frm.doctype, reference_name: me.frm.docname, - content: __('Reason for hold:') + ' ' + data.reason_for_hold, + content: __("Reason for hold:") + " " + data.reason_for_hold, comment_email: frappe.session.user, - comment_by: frappe.session.user_fullname + comment_by: frappe.session.user_fullname, }, - callback: function(r) { - if(!r.exc) { - me.update_status('Hold', 'On Hold') + callback: function (r) { + if (!r.exc) { + me.update_status("Hold", "On Hold"); d.hide(); } - } + }, }); - } + }, }); d.show(); } - close_sales_order(){ - this.frm.cscript.update_status("Close", "Closed") + close_sales_order() { + this.frm.cscript.update_status("Close", "Closed"); } - update_status(label, status){ + update_status(label, status) { var doc = this.frm.doc; var me = this; frappe.ui.form.is_saving = true; frappe.call({ method: "erpnext.selling.doctype.sales_order.sales_order.update_status", - args: {status: status, name: doc.name}, - callback: function(r){ + args: { status: status, name: doc.name }, + callback: function (r) { me.frm.reload_doc(); }, - always: function() { + always: function () { frappe.ui.form.is_saving = false; - } + }, }); } }; -extend_cscript(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.selling.SalesOrderController({ frm: cur_frm })); diff --git a/erpnext/selling/doctype/sales_order/sales_order_calendar.js b/erpnext/selling/doctype/sales_order/sales_order_calendar.js index cb412cfb4a7..f4c0e2ba72a 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_calendar.js +++ b/erpnext/selling/doctype/sales_order/sales_order_calendar.js @@ -3,43 +3,44 @@ frappe.views.calendar["Sales Order"] = { field_map: { - "start": "delivery_date", - "end": "delivery_date", - "id": "name", - "title": "customer_name", - "allDay": "allDay" + start: "delivery_date", + end: "delivery_date", + id: "name", + title: "customer_name", + allDay: "allDay", }, gantt: true, filters: [ { - "fieldtype": "Link", - "fieldname": "customer", - "options": "Customer", - "label": __("Customer") + fieldtype: "Link", + fieldname: "customer", + options: "Customer", + label: __("Customer"), }, { - "fieldtype": "Select", - "fieldname": "delivery_status", - "options": "Not Delivered\nFully Delivered\nPartly Delivered\nClosed\nNot Applicable", - "label": __("Delivery Status") + fieldtype: "Select", + fieldname: "delivery_status", + options: "Not Delivered\nFully Delivered\nPartly Delivered\nClosed\nNot Applicable", + label: __("Delivery Status"), }, { - "fieldtype": "Select", - "fieldname": "billing_status", - "options": "Not Billed\nFully Billed\nPartly Billed\nClosed", - "label": __("Billing Status") + fieldtype: "Select", + fieldname: "billing_status", + options: "Not Billed\nFully Billed\nPartly Billed\nClosed", + label: __("Billing Status"), }, ], get_events_method: "erpnext.selling.doctype.sales_order.sales_order.get_events", - get_css_class: function(data) { - if(data.status=="Closed") { - return "success"; - } if(data.delivery_status=="Not Delivered") { - return "danger"; - } else if(data.delivery_status=="Partly Delivered") { - return "warning"; - } else if(data.delivery_status=="Fully Delivered") { + get_css_class: function (data) { + if (data.status == "Closed") { return "success"; } - } -} + if (data.delivery_status == "Not Delivered") { + return "danger"; + } else if (data.delivery_status == "Partly Delivered") { + return "warning"; + } else if (data.delivery_status == "Fully Delivered") { + return "success"; + } + }, +}; diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js index 53de329b070..14ba051fc25 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_list.js +++ b/erpnext/selling/doctype/sales_order/sales_order_list.js @@ -1,6 +1,17 @@ -frappe.listview_settings['Sales Order'] = { - add_fields: ["base_grand_total", "customer_name", "currency", "delivery_date", - "per_delivered", "per_billed", "status", "advance_payment_status", "order_type", "name", "skip_delivery_note"], +frappe.listview_settings["Sales Order"] = { + add_fields: [ + "base_grand_total", + "customer_name", + "currency", + "delivery_date", + "per_delivered", + "per_billed", + "status", + "advance_payment_status", + "order_type", + "name", + "skip_delivery_note", + ], get_indicator: function (doc) { if (doc.status === "Closed") { // Closed @@ -14,70 +25,84 @@ frappe.listview_settings['Sales Order'] = { return [__("To Pay"), "gray", "advance_payment_status,=,Requested"]; } else if (!doc.skip_delivery_note && flt(doc.per_delivered, 2) < 100) { if (frappe.datetime.get_diff(doc.delivery_date) < 0) { - // not delivered & overdue - return [__("Overdue"), "red", - "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"]; + // not delivered & overdue + return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"]; } else if (flt(doc.grand_total) === 0) { // not delivered (zeroount order) - return [__("To Deliver"), "orange", - "per_delivered,<,100|grand_total,=,0|status,!=,Closed"]; + return [__("To Deliver"), "orange", "per_delivered,<,100|grand_total,=,0|status,!=,Closed"]; } else if (flt(doc.per_billed, 2) < 100) { // not delivered & not billed - return [__("To Deliver and Bill"), "orange", - "per_delivered,<,100|per_billed,<,100|status,!=,Closed"]; + return [ + __("To Deliver and Bill"), + "orange", + "per_delivered,<,100|per_billed,<,100|status,!=,Closed", + ]; } else { // not billed - return [__("To Deliver"), "orange", - "per_delivered,<,100|per_billed,=,100|status,!=,Closed"]; + return [__("To Deliver"), "orange", "per_delivered,<,100|per_billed,=,100|status,!=,Closed"]; } - } else if ((flt(doc.per_delivered, 2) === 100) && flt(doc.grand_total) !== 0 - && flt(doc.per_billed, 2) < 100) { + } else if ( + flt(doc.per_delivered, 2) === 100 && + flt(doc.grand_total) !== 0 && + flt(doc.per_billed, 2) < 100 + ) { // to bill - return [__("To Bill"), "orange", - "per_delivered,=,100|per_billed,<,100|status,!=,Closed"]; - } else if (doc.skip_delivery_note && flt(doc.per_billed, 2) < 100){ + return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"]; + } else if (doc.skip_delivery_note && flt(doc.per_billed, 2) < 100) { return [__("To Bill"), "orange", "per_billed,<,100|status,!=,Closed"]; } }, - onload: function(listview) { + onload: function (listview) { var method = "erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_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" }); }); - listview.page.add_action_item(__("Sales Invoice"), ()=>{ + listview.page.add_action_item(__("Sales Invoice"), () => { erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Sales Invoice"); }); - listview.page.add_action_item(__("Delivery Note"), ()=>{ - frappe.db.get_single_value("Selling Settings", "enable_cutoff_date_on_bulk_delivery_note_creation").then((value) => { - if (value) { - var dialog = new frappe.ui.Dialog({ - title: __("Select Items up to Delivery Date"), - fields: [{fieldtype: "Date", fieldname: "delivery_date", default: frappe.datetime.add_days(frappe.datetime.nowdate(), 1)}] - }); - dialog.set_primary_action(__("Select"), function(values) { - var until_delivery_date = values.delivery_date; - erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Delivery Note", { - until_delivery_date + listview.page.add_action_item(__("Delivery Note"), () => { + frappe.db + .get_single_value("Selling Settings", "enable_cutoff_date_on_bulk_delivery_note_creation") + .then((value) => { + if (value) { + var dialog = new frappe.ui.Dialog({ + title: __("Select Items up to Delivery Date"), + fields: [ + { + fieldtype: "Date", + fieldname: "delivery_date", + default: frappe.datetime.add_days(frappe.datetime.nowdate(), 1), + }, + ], }); - dialog.hide(); - }); - dialog.show(); - } else { - erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Delivery Note"); - } - }) + dialog.set_primary_action(__("Select"), function (values) { + var until_delivery_date = values.delivery_date; + erpnext.bulk_transaction_processing.create( + listview, + "Sales Order", + "Delivery Note", + { + until_delivery_date, + } + ); + dialog.hide(); + }); + dialog.show(); + } else { + erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Delivery Note"); + } + }); }); - listview.page.add_action_item(__("Advance Payment"), ()=>{ + listview.page.add_action_item(__("Advance Payment"), () => { erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Payment Entry"); }); - - } + }, }; diff --git a/erpnext/selling/doctype/sales_partner_type/sales_partner_type.js b/erpnext/selling/doctype/sales_partner_type/sales_partner_type.js index 3e183f6e6fc..ac5a8134f3c 100644 --- a/erpnext/selling/doctype/sales_partner_type/sales_partner_type.js +++ b/erpnext/selling/doctype/sales_partner_type/sales_partner_type.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Sales Partner Type', { - refresh: function() { - - } +frappe.ui.form.on("Sales Partner Type", { + refresh: function () {}, }); diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.js b/erpnext/selling/doctype/selling_settings/selling_settings.js index cf6fb2806ee..4471458fb10 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.js +++ b/erpnext/selling/doctype/selling_settings/selling_settings.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Selling Settings', { - refresh: function(frm) { - - } +frappe.ui.form.on("Selling Settings", { + refresh: function (frm) {}, }); diff --git a/erpnext/selling/doctype/sms_center/sms_center.js b/erpnext/selling/doctype/sms_center/sms_center.js index 974cfc79181..f513213e71c 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.js +++ b/erpnext/selling/doctype/sms_center/sms_center.js @@ -8,10 +8,10 @@ extend_cscript(cur_frm.cscript, { if (total_characters > 160) { total_msg = cint(total_characters / 160); - total_msg = (total_characters % 160 == 0 ? total_msg : total_msg + 1); + total_msg = total_characters % 160 == 0 ? total_msg : total_msg + 1; } this.frm.set_value("total_characters", total_characters); this.frm.set_value("total_messages", this.frm.doc.message ? total_msg : 0); - } + }, }); diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index 6db4150be94..6e4d1d0a373 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -1,19 +1,19 @@ -frappe.provide('erpnext.PointOfSale'); +frappe.provide("erpnext.PointOfSale"); -frappe.pages['point-of-sale'].on_page_load = function(wrapper) { +frappe.pages["point-of-sale"].on_page_load = function (wrapper) { frappe.ui.make_app_page({ parent: wrapper, - title: __('Point of Sale'), - single_column: true + title: __("Point of Sale"), + single_column: true, }); - frappe.require('point-of-sale.bundle.js', function() { + frappe.require("point-of-sale.bundle.js", function () { wrapper.pos = new erpnext.PointOfSale.Controller(wrapper); window.cur_pos = wrapper.pos; }); }; -frappe.pages['point-of-sale'].refresh = function(wrapper) { +frappe.pages["point-of-sale"].refresh = function (wrapper) { if (document.scannerDetectionData) { onScan.detachFrom(document); wrapper.pos.wrapper.html(""); diff --git a/erpnext/selling/page/point_of_sale/pos_controller.js b/erpnext/selling/page/point_of_sale/pos_controller.js index 80e1c20ad9e..f361976c890 100644 --- a/erpnext/selling/page/point_of_sale/pos_controller.js +++ b/erpnext/selling/page/point_of_sale/pos_controller.js @@ -1,13 +1,15 @@ erpnext.PointOfSale.Controller = class { constructor(wrapper) { - this.wrapper = $(wrapper).find('.layout-main-section'); + this.wrapper = $(wrapper).find(".layout-main-section"); this.page = wrapper.page; this.check_opening_entry(); } fetch_opening_entry() { - return frappe.call("erpnext.selling.page.point_of_sale.point_of_sale.check_opening_entry", { "user": frappe.session.user }); + return frappe.call("erpnext.selling.page.point_of_sale.point_of_sale.check_opening_entry", { + user: frappe.session.user, + }); } check_opening_entry() { @@ -25,50 +27,62 @@ erpnext.PointOfSale.Controller = class { const me = this; const table_fields = [ { - fieldname: "mode_of_payment", fieldtype: "Link", - in_list_view: 1, label: "Mode of Payment", - options: "Mode of Payment", reqd: 1 + fieldname: "mode_of_payment", + fieldtype: "Link", + in_list_view: 1, + label: "Mode of Payment", + options: "Mode of Payment", + reqd: 1, }, { - fieldname: "opening_amount", fieldtype: "Currency", - in_list_view: 1, label: "Opening Amount", + fieldname: "opening_amount", + fieldtype: "Currency", + in_list_view: 1, + label: "Opening Amount", options: "company:company_currency", change: function () { - dialog.fields_dict.balance_details.df.data.some(d => { + dialog.fields_dict.balance_details.df.data.some((d) => { if (d.idx == this.doc.idx) { d.opening_amount = this.value; dialog.fields_dict.balance_details.grid.refresh(); return true; } }); - } - } + }, + }, ]; const fetch_pos_payment_methods = () => { const pos_profile = dialog.fields_dict.pos_profile.get_value(); if (!pos_profile) return; frappe.db.get_doc("POS Profile", pos_profile).then(({ payments }) => { dialog.fields_dict.balance_details.df.data = []; - payments.forEach(pay => { + payments.forEach((pay) => { const { mode_of_payment } = pay; - dialog.fields_dict.balance_details.df.data.push({ mode_of_payment, opening_amount: '0' }); + dialog.fields_dict.balance_details.df.data.push({ mode_of_payment, opening_amount: "0" }); }); dialog.fields_dict.balance_details.grid.refresh(); }); - } + }; const dialog = new frappe.ui.Dialog({ - title: __('Create POS Opening Entry'), + title: __("Create POS Opening Entry"), static: true, fields: [ { - fieldtype: 'Link', label: __('Company'), default: frappe.defaults.get_default('company'), - options: 'Company', fieldname: 'company', reqd: 1 + fieldtype: "Link", + label: __("Company"), + default: frappe.defaults.get_default("company"), + options: "Company", + fieldname: "company", + reqd: 1, }, { - fieldtype: 'Link', label: __('POS Profile'), - options: 'POS Profile', fieldname: 'pos_profile', reqd: 1, + fieldtype: "Link", + label: __("POS Profile"), + options: "POS Profile", + fieldname: "pos_profile", + reqd: 1, get_query: () => pos_profile_query(), - onchange: () => fetch_pos_payment_methods() + onchange: () => fetch_pos_payment_methods(), }, { fieldname: "balance_details", @@ -78,34 +92,38 @@ erpnext.PointOfSale.Controller = class { in_place_edit: true, reqd: 1, data: [], - fields: table_fields - } + fields: table_fields, + }, ], - primary_action: async function({ company, pos_profile, balance_details }) { + primary_action: async function ({ company, pos_profile, balance_details }) { if (!balance_details.length) { frappe.show_alert({ message: __("Please add Mode of payments and opening balance details."), - indicator: 'red' - }) + indicator: "red", + }); return frappe.utils.play_sound("error"); } // filter balance details for empty rows - balance_details = balance_details.filter(d => d.mode_of_payment); + balance_details = balance_details.filter((d) => d.mode_of_payment); const method = "erpnext.selling.page.point_of_sale.point_of_sale.create_opening_voucher"; - const res = await frappe.call({ method, args: { pos_profile, company, balance_details }, freeze:true }); + const res = await frappe.call({ + method, + args: { pos_profile, company, balance_details }, + freeze: true, + }); !res.exc && me.prepare_app_defaults(res.message); dialog.hide(); }, - primary_action_label: __('Submit') + primary_action_label: __("Submit"), }); dialog.show(); const pos_profile_query = () => { return { - query: 'erpnext.accounts.doctype.pos_profile.pos_profile.pos_profile_query', - filters: { company: dialog.fields_dict.company.get_value() } - } + query: "erpnext.accounts.doctype.pos_profile.pos_profile.pos_profile_query", + filters: { company: dialog.fields_dict.company.get_value() }, + }; }; } @@ -117,19 +135,19 @@ erpnext.PointOfSale.Controller = class { this.item_stock_map = {}; this.settings = {}; - frappe.db.get_value('Stock Settings', undefined, 'allow_negative_stock').then(({ message }) => { + frappe.db.get_value("Stock Settings", undefined, "allow_negative_stock").then(({ message }) => { this.allow_negative_stock = flt(message.allow_negative_stock) || false; }); frappe.call({ method: "erpnext.selling.page.point_of_sale.point_of_sale.get_pos_profile_data", - args: { "pos_profile": this.pos_profile }, + args: { pos_profile: this.pos_profile }, callback: (res) => { const profile = res.message; Object.assign(this.settings, profile); - this.settings.customer_groups = profile.customer_groups.map(group => group.name); + this.settings.customer_groups = profile.customer_groups.map((group) => group.name); this.make_app(); - } + }, }); } @@ -139,7 +157,8 @@ erpnext.PointOfSale.Controller = class { Opened at ${moment(this.pos_opening_time).format("Do MMMM, h:mma")} - `); + ` + ); } make_app() { @@ -150,11 +169,9 @@ erpnext.PointOfSale.Controller = class { } prepare_dom() { - this.wrapper.append( - `
      ` - ); + this.wrapper.append(`
      `); - this.$components_wrapper = this.wrapper.find('.point-of-sale-app'); + this.$components_wrapper = this.wrapper.find(".point-of-sale-app"); } prepare_components() { @@ -169,13 +186,18 @@ erpnext.PointOfSale.Controller = class { prepare_menu() { this.page.clear_menu(); - this.page.add_menu_item(__("Open Form View"), this.open_form_view.bind(this), false, 'Ctrl+F'); + this.page.add_menu_item(__("Open Form View"), this.open_form_view.bind(this), false, "Ctrl+F"); - this.page.add_menu_item(__("Toggle Recent Orders"), this.toggle_recent_order.bind(this), false, 'Ctrl+O'); + this.page.add_menu_item( + __("Toggle Recent Orders"), + this.toggle_recent_order.bind(this), + false, + "Ctrl+O" + ); - this.page.add_menu_item(__("Save as Draft"), this.save_draft_invoice.bind(this), false, 'Ctrl+S'); + this.page.add_menu_item(__("Save as Draft"), this.save_draft_invoice.bind(this), false, "Ctrl+S"); - this.page.add_menu_item(__('Close the POS'), this.close_pos.bind(this), false, 'Shift+Ctrl+C'); + this.page.add_menu_item(__("Close the POS"), this.close_pos.bind(this), false, "Shift+Ctrl+C"); } open_form_view() { @@ -184,7 +206,7 @@ erpnext.PointOfSale.Controller = class { } toggle_recent_order() { - const show = this.recent_order_list.$component.is(':hidden'); + const show = this.recent_order_list.$component.is(":hidden"); this.toggle_recent_order_list(show); } @@ -194,31 +216,33 @@ erpnext.PointOfSale.Controller = class { if (this.frm.doc.items.length == 0) { frappe.show_alert({ message: __("You must add atleast one item to save it as draft."), - indicator:'red' + indicator: "red", }); frappe.utils.play_sound("error"); return; } - this.frm.save(undefined, undefined, undefined, () => { - frappe.show_alert({ - message: __("There was an error saving the document."), - indicator: 'red' + this.frm + .save(undefined, undefined, undefined, () => { + frappe.show_alert({ + message: __("There was an error saving the document."), + indicator: "red", + }); + frappe.utils.play_sound("error"); + }) + .then(() => { + frappe.run_serially([ + () => frappe.dom.freeze(), + () => this.make_new_invoice(), + () => frappe.dom.unfreeze(), + ]); }); - frappe.utils.play_sound("error"); - }).then(() => { - frappe.run_serially([ - () => frappe.dom.freeze(), - () => this.make_new_invoice(), - () => frappe.dom.unfreeze(), - ]); - }); } close_pos() { if (!this.$components_wrapper.is(":visible")) return; - let voucher = frappe.model.get_new_doc('POS Closing Entry'); + let voucher = frappe.model.get_new_doc("POS Closing Entry"); voucher.pos_profile = this.frm.doc.pos_profile; voucher.user = frappe.session.user; voucher.company = this.frm.doc.company; @@ -226,7 +250,7 @@ erpnext.PointOfSale.Controller = class { voucher.period_end_date = frappe.datetime.now_datetime(); voucher.posting_date = frappe.datetime.now_date(); voucher.posting_time = frappe.datetime.now_time(); - frappe.set_route('Form', 'POS Closing Entry', voucher.name); + frappe.set_route("Form", "POS Closing Entry", voucher.name); } init_item_selector() { @@ -235,11 +259,11 @@ erpnext.PointOfSale.Controller = class { pos_profile: this.pos_profile, settings: this.settings, events: { - item_selected: args => this.on_cart_update(args), + item_selected: (args) => this.on_cart_update(args), - get_frm: () => this.frm || {} - } - }) + get_frm: () => this.frm || {}, + }, + }); } init_item_cart() { @@ -264,9 +288,9 @@ erpnext.PointOfSale.Controller = class { this.customer_details = details; // will add/remove LP payment method this.payment.render_loyalty_points_payment_mode(); - } - } - }) + }, + }, + }); } init_item_details() { @@ -287,7 +311,7 @@ erpnext.PointOfSale.Controller = class { const args = { field, value, - item: this.item_details.current_item + item: this.item_details.current_item, }; return this.on_cart_update(args); } @@ -304,24 +328,28 @@ erpnext.PointOfSale.Controller = class { this.cart.toggle_numpad_field_edit(fieldname); }, set_value_in_current_cart_item: (selector, value) => { - this.cart.update_selector_value_in_cart_item(selector, value, this.item_details.current_item); + this.cart.update_selector_value_in_cart_item( + selector, + value, + this.item_details.current_item + ); }, clone_new_batch_item_in_frm: (batch_serial_map, item) => { // called if serial nos are 'auto_selected' and if those serial nos belongs to multiple batches // for each unique batch new item row is added in the form & cart - Object.keys(batch_serial_map).forEach(batch => { - const item_to_clone = this.frm.doc.items.find(i => i.name == item.name); + Object.keys(batch_serial_map).forEach((batch) => { + const item_to_clone = this.frm.doc.items.find((i) => i.name == item.name); const new_row = this.frm.add_child("items", { ...item_to_clone }); // update new serialno and batch new_row.batch_no = batch; new_row.serial_no = batch_serial_map[batch].join(`\n`); new_row.qty = batch_serial_map[batch].length; - this.frm.doc.items.forEach(row => { + this.frm.doc.items.forEach((row) => { if (item.item_code === row.item_code) { this.update_cart_html(row); } }); - }) + }); }, remove_item_from_cart: () => this.remove_item_from_cart(), get_item_stock_map: () => this.item_stock_map, @@ -330,8 +358,8 @@ erpnext.PointOfSale.Controller = class { this.cart.prev_action = null; this.cart.toggle_item_highlight(); }, - get_available_stock: (item_code, warehouse) => this.get_available_stock(item_code, warehouse) - } + get_available_stock: (item_code, warehouse) => this.get_available_stock(item_code, warehouse), + }, }); } @@ -345,7 +373,9 @@ erpnext.PointOfSale.Controller = class { toggle_other_sections: (show) => { if (show) { - this.item_details.$component.is(':visible') ? this.item_details.$component.css('display', 'none') : ''; + this.item_details.$component.is(":visible") + ? this.item_details.$component.css("display", "none") + : ""; this.item_selector.toggle_component(false); } else { this.item_selector.toggle_component(true); @@ -353,18 +383,17 @@ erpnext.PointOfSale.Controller = class { }, submit_invoice: () => { - this.frm.savesubmit() - .then((r) => { - this.toggle_components(false); - this.order_summary.toggle_component(true); - this.order_summary.load_summary_of(this.frm.doc, true); - frappe.show_alert({ - indicator: 'green', - message: __('POS invoice {0} created successfully', [r.doc.name]) - }); + this.frm.savesubmit().then((r) => { + this.toggle_components(false); + this.order_summary.toggle_component(true); + this.order_summary.load_summary_of(this.frm.doc, true); + frappe.show_alert({ + indicator: "green", + message: __("POS invoice {0} created successfully", [r.doc.name]), }); - } - } + }); + }, + }, }); } @@ -373,13 +402,13 @@ erpnext.PointOfSale.Controller = class { wrapper: this.$components_wrapper, events: { open_invoice_data: (name) => { - frappe.db.get_doc('POS Invoice', name).then((doc) => { + frappe.db.get_doc("POS Invoice", name).then((doc) => { this.order_summary.load_summary_of(doc); }); }, - reset_summary: () => this.order_summary.toggle_summary_placeholder(true) - } - }) + reset_summary: () => this.order_summary.toggle_summary_placeholder(true), + }, + }); } init_order_summary() { @@ -390,11 +419,11 @@ erpnext.PointOfSale.Controller = class { process_return: (name) => { this.recent_order_list.toggle_component(false); - frappe.db.get_doc('POS Invoice', name).then((doc) => { + frappe.db.get_doc("POS Invoice", name).then((doc) => { frappe.run_serially([ () => this.make_return_invoice(doc), () => this.cart.load_invoice(), - () => this.item_selector.toggle_component(true) + () => this.item_selector.toggle_component(true), ]); }); }, @@ -402,9 +431,9 @@ erpnext.PointOfSale.Controller = class { this.recent_order_list.toggle_component(false); frappe.run_serially([ () => this.frm.refresh(name), - () => this.frm.call('reset_mode_of_payments'), + () => this.frm.call("reset_mode_of_payments"), () => this.cart.load_invoice(), - () => this.item_selector.toggle_component(true) + () => this.item_selector.toggle_component(true), ]); }, delete_order: (name) => { @@ -419,9 +448,9 @@ erpnext.PointOfSale.Controller = class { () => this.item_selector.toggle_component(true), () => frappe.dom.unfreeze(), ]); - } - } - }) + }, + }, + }); } toggle_recent_order_list(show) { @@ -435,7 +464,7 @@ erpnext.PointOfSale.Controller = class { this.item_selector.toggle_component(show); // do not show item details or payment if recent order is toggled off - !show ? (this.item_details.toggle_component(false) || this.payment.toggle_component(false)) : ''; + !show ? this.item_details.toggle_component(false) || this.payment.toggle_component(false) : ""; } make_new_invoice() { @@ -445,23 +474,23 @@ erpnext.PointOfSale.Controller = class { () => this.set_pos_profile_data(), () => this.set_pos_profile_status(), () => this.cart.load_invoice(), - () => frappe.dom.unfreeze() + () => frappe.dom.unfreeze(), ]); } make_sales_invoice_frm() { - const doctype = 'POS Invoice'; - return new Promise(resolve => { + const doctype = "POS Invoice"; + return new Promise((resolve) => { if (this.frm) { this.frm = this.get_new_frm(this.frm); this.frm.doc.items = []; - this.frm.doc.is_pos = 1 + this.frm.doc.is_pos = 1; resolve(); } else { frappe.model.with_doctype(doctype, () => { this.frm = this.get_new_frm(); this.frm.doc.items = []; - this.frm.doc.is_pos = 1 + this.frm.doc.is_pos = 1; resolve(); }); } @@ -469,8 +498,8 @@ erpnext.PointOfSale.Controller = class { } get_new_frm(_frm) { - const doctype = 'POS Invoice'; - const page = $('
      '); + const doctype = "POS Invoice"; + const page = $("
      "); const frm = _frm || new frappe.ui.form.Form(doctype, page, false); const name = frappe.model.make_new_doc_and_get_name(doctype, true); frm.refresh(name); @@ -485,8 +514,8 @@ erpnext.PointOfSale.Controller = class { return frappe.call({ method: "erpnext.accounts.doctype.pos_invoice.pos_invoice.make_sales_return", args: { - 'source_name': doc.name, - 'target_doc': this.frm.doc + source_name: doc.name, + target_doc: this.frm.doc, }, callback: (r) => { frappe.model.sync(r.message); @@ -494,13 +523,16 @@ erpnext.PointOfSale.Controller = class { this.set_pos_profile_data().then(() => { frappe.dom.unfreeze(); }); - } + }, }); } set_pos_profile_data() { if (this.company && !this.frm.doc.company) this.frm.doc.company = this.company; - if ((this.pos_profile && !this.frm.doc.pos_profile) | (this.frm.doc.is_return && this.pos_profile != this.frm.doc.pos_profile)) { + if ( + (this.pos_profile && !this.frm.doc.pos_profile) | + (this.frm.doc.is_return && this.pos_profile != this.frm.doc.pos_profile) + ) { this.frm.doc.pos_profile = this.pos_profile; } @@ -521,16 +553,15 @@ erpnext.PointOfSale.Controller = class { item_row = this.get_item_from_frm(item); const item_row_exists = !$.isEmptyObject(item_row); - const from_selector = field === 'qty' && value === "+1"; - if (from_selector) - value = flt(item_row.stock_qty) + flt(value); + const from_selector = field === "qty" && value === "+1"; + if (from_selector) value = flt(item_row.stock_qty) + flt(value); if (item_row_exists) { - if (field === 'qty') - value = flt(value); + if (field === "qty") value = flt(value); - if (['qty', 'conversion_factor'].includes(field) && value > 0 && !this.allow_negative_stock) { - const qty_needed = field === 'qty' ? value * item_row.conversion_factor : item_row.qty * value; + if (["qty", "conversion_factor"].includes(field) && value > 0 && !this.allow_negative_stock) { + const qty_needed = + field === "qty" ? value * item_row.conversion_factor : item_row.qty * value; await this.check_stock_availability(item_row, qty_needed, this.frm.doc.set_warehouse); } @@ -538,20 +569,17 @@ erpnext.PointOfSale.Controller = class { await frappe.model.set_value(item_row.doctype, item_row.name, field, value); this.update_cart_html(item_row); } - } else { - if (!this.frm.doc.customer) - return this.raise_customer_selection_alert(); + if (!this.frm.doc.customer) return this.raise_customer_selection_alert(); const { item_code, batch_no, serial_no, rate, uom } = item; - if (!item_code) - return; + if (!item_code) return; if (rate == undefined || rate == 0) { frappe.show_alert({ - message: __('Price is not set for the item.'), - indicator: 'orange' + message: __("Price is not set for the item."), + indicator: "orange", }); frappe.utils.play_sound("error"); return; @@ -560,15 +588,14 @@ erpnext.PointOfSale.Controller = class { if (serial_no) { await this.check_serial_no_availablilty(item_code, this.frm.doc.set_warehouse, serial_no); - new_item['serial_no'] = serial_no; + new_item["serial_no"] = serial_no; } - if (field === 'serial_no') - new_item['qty'] = value.split(`\n`).length || 0; + if (field === "serial_no") new_item["qty"] = value.split(`\n`).length || 0; - item_row = this.frm.add_child('items', new_item); + item_row = this.frm.add_child("items", new_item); - if (field === 'qty' && value !== 0 && !this.allow_negative_stock) { + if (field === "qty" && value !== 0 && !this.allow_negative_stock) { const qty_needed = value * item_row.conversion_factor; await this.check_stock_availability(item_row, qty_needed, this.frm.doc.set_warehouse); } @@ -577,13 +604,14 @@ erpnext.PointOfSale.Controller = class { this.update_cart_html(item_row); - if (this.item_details.$component.is(':visible')) - this.edit_item_details_of(item_row); + if (this.item_details.$component.is(":visible")) this.edit_item_details_of(item_row); - if (this.check_serial_batch_selection_needed(item_row) && !this.item_details.$component.is(':visible')) + if ( + this.check_serial_batch_selection_needed(item_row) && + !this.item_details.$component.is(":visible") + ) this.edit_item_details_of(item_row); } - } catch (error) { console.log(error); } finally { @@ -595,8 +623,8 @@ erpnext.PointOfSale.Controller = class { raise_customer_selection_alert() { frappe.dom.unfreeze(); frappe.show_alert({ - message: __('You must select a customer before adding an item.'), - indicator: 'orange' + message: __("You must select a customer before adding an item."), + indicator: "orange", }); frappe.utils.play_sound("error"); } @@ -604,17 +632,18 @@ erpnext.PointOfSale.Controller = class { get_item_from_frm({ name, item_code, batch_no, uom, rate }) { let item_row = null; if (name) { - item_row = this.frm.doc.items.find(i => i.name == name); + item_row = this.frm.doc.items.find((i) => i.name == name); } else { // if item is clicked twice from item selector // then "item_code, batch_no, uom, rate" will help in getting the exact item // to increase the qty by one - const has_batch_no = (batch_no !== 'null' && batch_no !== null); + const has_batch_no = batch_no !== "null" && batch_no !== null; item_row = this.frm.doc.items.find( - i => i.item_code === item_code - && (!has_batch_no || (has_batch_no && i.batch_no === batch_no)) - && (i.uom === uom) - && (i.rate === flt(rate)) + (i) => + i.item_code === item_code && + (!has_batch_no || (has_batch_no && i.batch_no === batch_no)) && + i.uom === uom && + i.rate === flt(rate) ); } @@ -642,16 +671,19 @@ erpnext.PointOfSale.Controller = class { const no_serial_selected = !item_row.serial_no; const no_batch_selected = !item_row.batch_no; - if ((serialized && no_serial_selected) || (batched && no_batch_selected) || - (serialized && batched && (no_batch_selected || no_serial_selected))) { + if ( + (serialized && no_serial_selected) || + (batched && no_batch_selected) || + (serialized && batched && (no_batch_selected || no_serial_selected)) + ) { return true; } return false; } async trigger_new_item_events(item_row) { - await this.frm.script_manager.trigger('item_code', item_row.doctype, item_row.name); - await this.frm.script_manager.trigger('qty', item_row.doctype, item_row.name); + await this.frm.script_manager.trigger("item_code", item_row.doctype, item_row.name); + await this.frm.script_manager.trigger("qty", item_row.doctype, item_row.name); } async check_stock_availability(item_row, qty_needed, warehouse) { @@ -663,21 +695,27 @@ erpnext.PointOfSale.Controller = class { const bold_uom = item_row.stock_uom.bold(); const bold_item_code = item_row.item_code.bold(); const bold_warehouse = warehouse.bold(); - const bold_available_qty = available_qty.toString().bold() + const bold_available_qty = available_qty.toString().bold(); if (!(available_qty > 0)) { if (is_stock_item) { frappe.model.clear_doc(item_row.doctype, item_row.name); frappe.throw({ title: __("Not Available"), - message: __('Item Code: {0} is not available under warehouse {1}.', [bold_item_code, bold_warehouse]) + message: __("Item Code: {0} is not available under warehouse {1}.", [ + bold_item_code, + bold_warehouse, + ]), }); } else { return; } } else if (is_stock_item && available_qty < qty_needed) { frappe.throw({ - message: __('Stock quantity not enough for Item Code: {0} under warehouse {1}. Available quantity {2} {3}.', [bold_item_code, bold_warehouse, bold_available_qty, bold_uom]), - indicator: 'orange' + message: __( + "Stock quantity not enough for Item Code: {0} under warehouse {1}. Available quantity {2} {3}.", + [bold_item_code, bold_warehouse, bold_available_qty, bold_uom] + ), + indicator: "orange", }); frappe.utils.play_sound("error"); } @@ -686,13 +724,15 @@ erpnext.PointOfSale.Controller = class { async check_serial_no_availablilty(item_code, warehouse, serial_no) { const method = "erpnext.stock.doctype.serial_no.serial_no.get_pos_reserved_serial_nos"; - const args = {filters: { item_code, warehouse }} + const args = { filters: { item_code, warehouse } }; const res = await frappe.call({ method, args }); if (res.message.includes(serial_no)) { frappe.throw({ title: __("Not Available"), - message: __('Serial No: {0} has already been transacted into another POS Invoice.', [serial_no.bold()]) + message: __("Serial No: {0} has already been transacted into another POS Invoice.", [ + serial_no.bold(), + ]), }); } } @@ -702,21 +742,20 @@ erpnext.PointOfSale.Controller = class { return frappe.call({ method: "erpnext.accounts.doctype.pos_invoice.pos_invoice.get_stock_availability", args: { - 'item_code': item_code, - 'warehouse': warehouse, + item_code: item_code, + warehouse: warehouse, }, callback(res) { - if (!me.item_stock_map[item_code]) - me.item_stock_map[item_code] = {}; + if (!me.item_stock_map[item_code]) me.item_stock_map[item_code] = {}; me.item_stock_map[item_code][warehouse] = res.message; - } + }, }); } update_item_field(value, field_or_action) { - if (field_or_action === 'checkout') { + if (field_or_action === "checkout") { this.item_details.toggle_item_details_section(null); - } else if (field_or_action === 'remove') { + } else if (field_or_action === "remove") { this.remove_item_from_cart(); } else { const field_control = this.item_details[`${field_or_action}_control`]; @@ -730,26 +769,28 @@ erpnext.PointOfSale.Controller = class { frappe.dom.freeze(); const { doctype, name, current_item } = this.item_details; - return frappe.model.set_value(doctype, name, 'qty', 0) + return frappe.model + .set_value(doctype, name, "qty", 0) .then(() => { frappe.model.clear_doc(doctype, name); this.update_cart_html(current_item, true); this.item_details.toggle_item_details_section(null); frappe.dom.unfreeze(); }) - .catch(e => console.log(e)); + .catch((e) => console.log(e)); } async save_and_checkout() { if (this.frm.is_dirty()) { let save_error = false; - await this.frm.save(null, null, null, () => save_error = true); + await this.frm.save(null, null, null, () => (save_error = true)); // only move to payment section if save is successful !save_error && this.payment.checkout(); // show checkout button on error - save_error && setTimeout(() => { - this.cart.toggle_checkout_btn(true); - }, 300); // wait for save to finish + save_error && + setTimeout(() => { + this.cart.toggle_checkout_btn(true); + }, 300); // wait for save to finish } else { this.payment.checkout(); } diff --git a/erpnext/selling/page/point_of_sale/pos_item_cart.js b/erpnext/selling/page/point_of_sale/pos_item_cart.js index bd8579203c0..d95ef5893d9 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_cart.js +++ b/erpnext/selling/page/point_of_sale/pos_item_cart.js @@ -18,11 +18,9 @@ erpnext.PointOfSale.ItemCart = class { } prepare_dom() { - this.wrapper.append( - `
      ` - ) + this.wrapper.append(`
      `); - this.$component = this.wrapper.find('.customer-cart-container'); + this.$component = this.wrapper.find(".customer-cart-container"); } init_child_components() { @@ -31,16 +29,14 @@ erpnext.PointOfSale.ItemCart = class { } init_customer_selector() { - this.$component.append( - `
      ` - ) - this.$customer_section = this.$component.find('.customer-section'); + this.$component.append(`
      `); + this.$customer_section = this.$component.find(".customer-section"); this.make_customer_selector(); } reset_customer_selector() { const frm = this.events.get_frm(); - frm.set_value('customer', ''); + frm.set_value("customer", ""); this.make_customer_selector(); this.customer_field.set_focus(); } @@ -49,11 +45,11 @@ erpnext.PointOfSale.ItemCart = class { this.$component.append( `
      -
      ${__('Item Cart')}
      +
      ${__("Item Cart")}
      -
      ${__('Item')}
      -
      ${__('Quantity')}
      -
      ${__('Amount')}
      +
      ${__("Item")}
      +
      ${__("Quantity")}
      +
      ${__("Amount")}
      @@ -61,7 +57,7 @@ erpnext.PointOfSale.ItemCart = class {
      ` ); - this.$cart_container = this.$component.find('.cart-container'); + this.$cart_container = this.$component.find(".cart-container"); this.make_cart_totals_section(); this.make_cart_items_section(); @@ -69,39 +65,35 @@ erpnext.PointOfSale.ItemCart = class { } make_cart_items_section() { - this.$cart_header = this.$component.find('.cart-header'); - this.$cart_items_wrapper = this.$component.find('.cart-items-section'); + this.$cart_header = this.$component.find(".cart-header"); + this.$cart_items_wrapper = this.$component.find(".cart-items-section"); this.make_no_items_placeholder(); } make_no_items_placeholder() { - this.$cart_header.css('display', 'none'); - this.$cart_items_wrapper.html( - `
      ${__('No items in cart')}
      ` - ); + this.$cart_header.css("display", "none"); + this.$cart_items_wrapper.html(`
      ${__("No items in cart")}
      `); } get_discount_icon() { - return ( - ` + return ` - ` - ); + `; } make_cart_totals_section() { - this.$totals_section = this.$component.find('.cart-totals-section'); + this.$totals_section = this.$component.find(".cart-totals-section"); this.$totals_section.append( `
      - ${this.get_discount_icon()} ${__('Add Discount')} + ${this.get_discount_icon()} ${__("Add Discount")}
      -
      ${__('Total Items')}
      +
      ${__("Total Items")}
      0.00
      @@ -110,39 +102,39 @@ erpnext.PointOfSale.ItemCart = class {
      -
      ${__('Grand Total')}
      +
      ${__("Grand Total")}
      0.00
      -
      ${__('Checkout')}
      -
      ${__('Edit Cart')}
      ` - ) +
      ${__("Checkout")}
      +
      ${__("Edit Cart")}
      ` + ); this.$add_discount_elem = this.$component.find(".add-discount-wrapper"); } make_cart_numpad() { - this.$numpad_section = this.$component.find('.numpad-section'); + this.$numpad_section = this.$component.find(".numpad-section"); this.number_pad = new erpnext.PointOfSale.NumberPad({ wrapper: this.$numpad_section, events: { - numpad_event: this.on_numpad_event.bind(this) + numpad_event: this.on_numpad_event.bind(this), }, cols: 5, keys: [ - [ 1, 2, 3, 'Quantity' ], - [ 4, 5, 6, 'Discount' ], - [ 7, 8, 9, 'Rate' ], - [ '.', 0, 'Delete', 'Remove' ] + [1, 2, 3, "Quantity"], + [4, 5, 6, "Discount"], + [7, 8, 9, "Rate"], + [".", 0, "Delete", "Remove"], ], css_classes: [ - [ '', '', '', 'col-span-2' ], - [ '', '', '', 'col-span-2' ], - [ '', '', '', 'col-span-2' ], - [ '', '', '', 'col-span-2 remove-btn' ] + ["", "", "", "col-span-2"], + ["", "", "", "col-span-2"], + ["", "", "", "col-span-2"], + ["", "", "", "col-span-2 remove-btn"], ], - fieldnames_map: { 'Quantity': 'qty', 'Discount': 'discount_percentage' } - }) + fieldnames_map: { Quantity: "qty", Discount: "discount_percentage" }, + }); this.$numpad_section.prepend( `
      @@ -150,49 +142,49 @@ erpnext.PointOfSale.ItemCart = class {
      ` - ) + ); this.$numpad_section.append( - `
      ${__('Checkout')}
      ` - ) + `
      ${__("Checkout")}
      ` + ); } bind_events() { const me = this; - this.$customer_section.on('click', '.reset-customer-btn', function () { + this.$customer_section.on("click", ".reset-customer-btn", function () { me.reset_customer_selector(); }); - this.$customer_section.on('click', '.close-details-btn', function () { + this.$customer_section.on("click", ".close-details-btn", function () { me.toggle_customer_info(false); }); - this.$customer_section.on('click', '.customer-display', function(e) { - if ($(e.target).closest('.reset-customer-btn').length) return; + this.$customer_section.on("click", ".customer-display", function (e) { + if ($(e.target).closest(".reset-customer-btn").length) return; - const show = me.$cart_container.is(':visible'); + const show = me.$cart_container.is(":visible"); me.toggle_customer_info(show); }); - this.$cart_items_wrapper.on('click', '.cart-item-wrapper', function() { + this.$cart_items_wrapper.on("click", ".cart-item-wrapper", function () { const $cart_item = $(this); me.toggle_item_highlight(this); - const payment_section_hidden = !me.$totals_section.find('.edit-cart-btn').is(':visible'); + const payment_section_hidden = !me.$totals_section.find(".edit-cart-btn").is(":visible"); if (!payment_section_hidden) { // payment section is visible // edit cart first and then open item details section me.$totals_section.find(".edit-cart-btn").click(); } - const item_row_name = unescape($cart_item.attr('data-row-name')); + const item_row_name = unescape($cart_item.attr("data-row-name")); me.events.cart_item_clicked({ name: item_row_name }); - this.numpad_value = ''; + this.numpad_value = ""; }); - this.$component.on('click', '.checkout-btn', async function() { - if ($(this).attr('style').indexOf('--blue-500') == -1) return; + this.$component.on("click", ".checkout-btn", async function () { + if ($(this).attr("style").indexOf("--blue-500") == -1) return; await me.events.checkout(); me.toggle_checkout_btn(false); @@ -200,18 +192,18 @@ erpnext.PointOfSale.ItemCart = class { me.allow_discount_change && me.$add_discount_elem.removeClass("d-none"); }); - this.$totals_section.on('click', '.edit-cart-btn', () => { + this.$totals_section.on("click", ".edit-cart-btn", () => { this.events.edit_cart(); this.toggle_checkout_btn(true); }); - this.$component.on('click', '.add-discount-wrapper', () => { - const can_edit_discount = this.$add_discount_elem.find('.edit-discount-btn').length; + this.$component.on("click", ".add-discount-wrapper", () => { + const can_edit_discount = this.$add_discount_elem.find(".edit-discount-btn").length; - if(!this.discount_field || can_edit_discount) this.show_discount_control(); + if (!this.discount_field || can_edit_discount) this.show_discount_control(); }); - frappe.ui.form.on("POS Invoice", "paid_amount", frm => { + frappe.ui.form.on("POS Invoice", "paid_amount", (frm) => { // called when discount is applied this.update_totals_section(frm); }); @@ -220,43 +212,49 @@ erpnext.PointOfSale.ItemCart = class { attach_shortcuts() { for (let row of this.number_pad.keys) { for (let btn of row) { - if (typeof btn !== 'string') continue; // do not make shortcuts for numbers + if (typeof btn !== "string") continue; // do not make shortcuts for numbers let shortcut_key = `ctrl+${frappe.scrub(String(btn))[0]}`; - if (btn === 'Delete') shortcut_key = 'ctrl+backspace'; - if (btn === 'Remove') shortcut_key = 'shift+ctrl+backspace' - if (btn === '.') shortcut_key = 'ctrl+>'; + if (btn === "Delete") shortcut_key = "ctrl+backspace"; + if (btn === "Remove") shortcut_key = "shift+ctrl+backspace"; + if (btn === ".") shortcut_key = "ctrl+>"; // to account for fieldname map - const fieldname = this.number_pad.fieldnames[btn] ? this.number_pad.fieldnames[btn] : - typeof btn === 'string' ? frappe.scrub(btn) : btn; + const fieldname = this.number_pad.fieldnames[btn] + ? this.number_pad.fieldnames[btn] + : typeof btn === "string" + ? frappe.scrub(btn) + : btn; - let shortcut_label = shortcut_key.split('+').map(frappe.utils.to_title_case).join('+'); - shortcut_label = frappe.utils.is_mac() ? shortcut_label.replace('Ctrl', '⌘') : shortcut_label; - this.$numpad_section.find(`.numpad-btn[data-button-value="${fieldname}"]`).attr("title", shortcut_label); + let shortcut_label = shortcut_key.split("+").map(frappe.utils.to_title_case).join("+"); + shortcut_label = frappe.utils.is_mac() ? shortcut_label.replace("Ctrl", "⌘") : shortcut_label; + this.$numpad_section + .find(`.numpad-btn[data-button-value="${fieldname}"]`) + .attr("title", shortcut_label); frappe.ui.keys.on(`${shortcut_key}`, () => { const cart_is_visible = this.$component.is(":visible"); if (cart_is_visible && this.item_is_selected && this.$numpad_section.is(":visible")) { this.$numpad_section.find(`.numpad-btn[data-button-value="${fieldname}"]`).click(); } - }) + }); } } - const ctrl_label = frappe.utils.is_mac() ? '⌘' : 'Ctrl'; + const ctrl_label = frappe.utils.is_mac() ? "⌘" : "Ctrl"; this.$component.find(".checkout-btn").attr("title", `${ctrl_label}+Enter`); frappe.ui.keys.add_shortcut({ shortcut: "ctrl+enter", action: () => this.$component.find(".checkout-btn").click(), - condition: () => this.$component.is(":visible") && !this.$totals_section.find('.edit-cart-btn').is(':visible'), + condition: () => + this.$component.is(":visible") && !this.$totals_section.find(".edit-cart-btn").is(":visible"), description: __("Checkout Order / Submit Order / New Order"), ignore_inputs: true, - page: cur_page.page.page + page: cur_page.page.page, }); this.$component.find(".edit-cart-btn").attr("title", `${ctrl_label}+E`); frappe.ui.keys.on("ctrl+e", () => { const item_cart_visible = this.$component.is(":visible"); - const checkout_btn_invisible = !this.$totals_section.find('.checkout-btn').is('visible'); + const checkout_btn_invisible = !this.$totals_section.find(".checkout-btn").is("visible"); if (item_cart_visible && checkout_btn_invisible) { this.$component.find(".edit-cart-btn").click(); } @@ -268,7 +266,7 @@ erpnext.PointOfSale.ItemCart = class { condition: () => this.$add_discount_elem.is(":visible"), description: __("Add Order Discount"), ignore_inputs: true, - page: cur_page.page.page + page: cur_page.page.page, }); frappe.ui.keys.on("escape", () => { const item_cart_visible = this.$component.is(":visible"); @@ -284,11 +282,11 @@ erpnext.PointOfSale.ItemCart = class { if (!item || item_is_highlighted) { this.item_is_selected = false; - this.$cart_container.find('.cart-item-wrapper').css("background-color", ""); + this.$cart_container.find(".cart-item-wrapper").css("background-color", ""); } else { $cart_item.css("background-color", "var(--control-bg)"); this.item_is_selected = true; - this.$cart_container.find('.cart-item-wrapper').not(item).css("background-color", ""); + this.$cart_container.find(".cart-item-wrapper").not(item).css("background-color", ""); } } @@ -297,38 +295,38 @@ erpnext.PointOfSale.ItemCart = class {
      `); const me = this; - const query = { query: 'erpnext.controllers.queries.customer_query' }; + const query = { query: "erpnext.controllers.queries.customer_query" }; const allowed_customer_group = this.allowed_customer_groups || []; if (allowed_customer_group.length) { query.filters = { - customer_group: ['in', allowed_customer_group] - } + customer_group: ["in", allowed_customer_group], + }; } this.customer_field = frappe.ui.form.make_control({ df: { - label: __('Customer'), - fieldtype: 'Link', - options: 'Customer', - placeholder: __('Search by customer name, phone, email.'), + label: __("Customer"), + fieldtype: "Link", + options: "Customer", + placeholder: __("Search by customer name, phone, email."), get_query: () => query, - onchange: function() { + onchange: function () { if (this.value) { const frm = me.events.get_frm(); frappe.dom.freeze(); - frappe.model.set_value(frm.doc.doctype, frm.doc.name, 'customer', this.value); - frm.script_manager.trigger('customer', frm.doc.doctype, frm.doc.name).then(() => { + frappe.model.set_value(frm.doc.doctype, frm.doc.name, "customer", this.value); + frm.script_manager.trigger("customer", frm.doc.doctype, frm.doc.name).then(() => { frappe.run_serially([ () => me.fetch_customer_details(this.value), () => me.events.customer_details_updated(me.customer_info), () => me.update_customer_section(), () => me.update_totals_section(), - () => frappe.dom.unfreeze() + () => frappe.dom.unfreeze(), ]); - }) + }); } }, }, - parent: this.$customer_section.find('.customer-field'), + parent: this.$customer_section.find(".customer-field"), render_input: true, }); this.customer_field.toggle_label(false); @@ -337,66 +335,81 @@ erpnext.PointOfSale.ItemCart = class { fetch_customer_details(customer) { if (customer) { return new Promise((resolve) => { - frappe.db.get_value('Customer', customer, ["email_id", "mobile_no", "image", "loyalty_program"]).then(({ message }) => { - const { loyalty_program } = message; - // if loyalty program then fetch loyalty points too - if (loyalty_program) { - frappe.call({ - method: "erpnext.accounts.doctype.loyalty_program.loyalty_program.get_loyalty_program_details_with_points", - args: { customer, loyalty_program, "silent": true }, - callback: (r) => { - const { loyalty_points, conversion_factor } = r.message; - if (!r.exc) { - this.customer_info = { ...message, customer, loyalty_points, conversion_factor }; - resolve(); - } - } - }); - } else { - this.customer_info = { ...message, customer }; - resolve(); - } - }); + frappe.db + .get_value("Customer", customer, ["email_id", "mobile_no", "image", "loyalty_program"]) + .then(({ message }) => { + const { loyalty_program } = message; + // if loyalty program then fetch loyalty points too + if (loyalty_program) { + frappe.call({ + method: "erpnext.accounts.doctype.loyalty_program.loyalty_program.get_loyalty_program_details_with_points", + args: { customer, loyalty_program, silent: true }, + callback: (r) => { + const { loyalty_points, conversion_factor } = r.message; + if (!r.exc) { + this.customer_info = { + ...message, + customer, + loyalty_points, + conversion_factor, + }; + resolve(); + } + }, + }); + } else { + this.customer_info = { ...message, customer }; + resolve(); + } + }); }); } else { return new Promise((resolve) => { - this.customer_info = {} + this.customer_info = {}; resolve(); }); } } show_discount_control() { - this.$add_discount_elem.css({ 'padding': '0px', 'border': 'none' }); - this.$add_discount_elem.html( - `
      ` - ); + this.$add_discount_elem.css({ padding: "0px", border: "none" }); + this.$add_discount_elem.html(`
      `); const me = this; const frm = me.events.get_frm(); let discount = frm.doc.additional_discount_percentage; this.discount_field = frappe.ui.form.make_control({ df: { - label: __('Discount'), - fieldtype: 'Data', - placeholder: ( discount ? discount + '%' : __('Enter discount percentage.') ), - input_class: 'input-xs', - onchange: function() { + label: __("Discount"), + fieldtype: "Data", + placeholder: discount ? discount + "%" : __("Enter discount percentage."), + input_class: "input-xs", + onchange: function () { if (flt(this.value) != 0) { - frappe.model.set_value(frm.doc.doctype, frm.doc.name, 'additional_discount_percentage', flt(this.value)); + frappe.model.set_value( + frm.doc.doctype, + frm.doc.name, + "additional_discount_percentage", + flt(this.value) + ); me.hide_discount_control(this.value); } else { - frappe.model.set_value(frm.doc.doctype, frm.doc.name, 'additional_discount_percentage', 0); + frappe.model.set_value( + frm.doc.doctype, + frm.doc.name, + "additional_discount_percentage", + 0 + ); me.$add_discount_elem.css({ - 'border': '1px dashed var(--gray-500)', - 'padding': 'var(--padding-sm) var(--padding-md)' + border: "1px dashed var(--gray-500)", + padding: "var(--padding-sm) var(--padding-md)", }); - me.$add_discount_elem.html(`${me.get_discount_icon()} ${__('Add Discount')}`); + me.$add_discount_elem.html(`${me.get_discount_icon()} ${__("Add Discount")}`); me.discount_field = undefined; } }, }, - parent: this.$add_discount_elem.find('.add-discount-field'), + parent: this.$add_discount_elem.find(".add-discount-field"), render_input: true, }); this.discount_field.toggle_label(false); @@ -405,14 +418,12 @@ erpnext.PointOfSale.ItemCart = class { hide_discount_control(discount) { if (!discount) { - this.$add_discount_elem.css({ 'padding': '0px', 'border': 'none' }); - this.$add_discount_elem.html( - `
      ` - ); + this.$add_discount_elem.css({ padding: "0px", border: "none" }); + this.$add_discount_elem.html(`
      `); } else { this.$add_discount_elem.css({ - 'border': '1px dashed var(--dark-green-500)', - 'padding': 'var(--padding-sm) var(--padding-md)' + border: "1px dashed var(--dark-green-500)", + padding: "var(--padding-sm) var(--padding-md)", }); this.$add_discount_elem.html( `
      @@ -424,7 +435,7 @@ erpnext.PointOfSale.ItemCart = class { update_customer_section() { const me = this; - const { customer, email_id='', mobile_no='', image } = this.customer_info || {}; + const { customer, email_id = "", mobile_no = "", image } = this.customer_info || {}; if (customer) { this.$customer_section.html( @@ -450,7 +461,7 @@ erpnext.PointOfSale.ItemCart = class { function get_customer_description() { if (!email_id && !mobile_no) { - return `
      ${__('Click to add email / phone')}
      `; + return `
      ${__("Click to add email / phone")}
      `; } else if (email_id && !mobile_no) { return `
      ${email_id}
      `; } else if (mobile_no && !email_id) { @@ -459,7 +470,6 @@ erpnext.PointOfSale.ItemCart = class { return `
      ${email_id} - ${mobile_no}
      `; } } - } get_customer_image() { @@ -476,7 +486,9 @@ erpnext.PointOfSale.ItemCart = class { this.render_net_total(frm.doc.net_total); this.render_total_item_qty(frm.doc.items); - const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? frm.doc.grand_total : frm.doc.rounded_total; + const grand_total = cint(frappe.sys_defaults.disable_rounded_total) + ? frm.doc.grand_total + : frm.doc.rounded_total; this.render_grand_total(grand_total); this.render_taxes(frm.doc.taxes); @@ -484,13 +496,13 @@ erpnext.PointOfSale.ItemCart = class { render_net_total(value) { const currency = this.events.get_frm().doc.currency; - this.$totals_section.find('.net-total-container').html( - `
      ${__('Net Total')}
      ${format_currency(value, currency)}
      ` - ) + this.$totals_section + .find(".net-total-container") + .html(`
      ${__("Net Total")}
      ${format_currency(value, currency)}
      `); - this.$numpad_section.find('.numpad-net-total').html( - `
      ${__('Net Total')}: ${format_currency(value, currency)}
      ` - ); + this.$numpad_section + .find(".numpad-net-total") + .html(`
      ${__("Net Total")}: ${format_currency(value, currency)}
      `); } render_total_item_qty(items) { @@ -499,41 +511,47 @@ erpnext.PointOfSale.ItemCart = class { total_item_qty = total_item_qty + item.qty; }); - this.$totals_section.find('.item-qty-total-container').html( - `
      ${__('Total Quantity')}
      ${total_item_qty}
      ` - ); + this.$totals_section + .find(".item-qty-total-container") + .html(`
      ${__("Total Quantity")}
      ${total_item_qty}
      `); - this.$numpad_section.find('.numpad-item-qty-total').html( - `
      ${__('Total Quantity')}: ${total_item_qty}
      ` - ); + this.$numpad_section + .find(".numpad-item-qty-total") + .html(`
      ${__("Total Quantity")}: ${total_item_qty}
      `); } render_grand_total(value) { const currency = this.events.get_frm().doc.currency; - this.$totals_section.find('.grand-total-container').html( - `
      ${__('Grand Total')}
      ${format_currency(value, currency)}
      ` - ) + this.$totals_section + .find(".grand-total-container") + .html(`
      ${__("Grand Total")}
      ${format_currency(value, currency)}
      `); - this.$numpad_section.find('.numpad-grand-total').html( - `
      ${__('Grand Total')}: ${format_currency(value, currency)}
      ` - ); + this.$numpad_section + .find(".numpad-grand-total") + .html(`
      ${__("Grand Total")}: ${format_currency(value, currency)}
      `); } render_taxes(taxes) { if (taxes && taxes.length) { const currency = this.events.get_frm().doc.currency; - const taxes_html = taxes.map(t => { - if (t.tax_amount_after_discount_amount == 0.0) return; - // if tax rate is 0, don't print it. - const description = /[0-9]+/.test(t.description) ? t.description : ((t.rate != 0) ? `${t.description} @ ${t.rate}%`: t.description); - return `
      + const taxes_html = taxes + .map((t) => { + if (t.tax_amount_after_discount_amount == 0.0) return; + // if tax rate is 0, don't print it. + const description = /[0-9]+/.test(t.description) + ? t.description + : t.rate != 0 + ? `${t.description} @ ${t.rate}%` + : t.description; + return `
      ${description}
      ${format_currency(t.tax_amount_after_discount_amount, currency)}
      `; - }).join(''); - this.$totals_section.find('.taxes-container').css('display', 'flex').html(taxes_html); + }) + .join(""); + this.$totals_section.find(".taxes-container").css("display", "flex").html(taxes_html); } else { - this.$totals_section.find('.taxes-container').css('display', 'none').html(''); + this.$totals_section.find(".taxes-container").css("display", "none").html(""); } } @@ -544,7 +562,7 @@ erpnext.PointOfSale.ItemCart = class { get_item_from_frm(item) { const doc = this.events.get_frm().doc; - return doc.items.find(i => i.name == item.name); + return doc.items.find((i) => i.name == item.name); } update_item_html(item, remove_item) { @@ -557,7 +575,7 @@ erpnext.PointOfSale.ItemCart = class { this.render_cart_item(item_row, $item); } - const no_of_cart_items = this.$cart_items_wrapper.find('.cart-item-wrapper').length; + const no_of_cart_items = this.$cart_items_wrapper.find(".cart-item-wrapper").length; this.highlight_checkout_btn(no_of_cart_items > 0); this.update_empty_cart_section(no_of_cart_items); @@ -571,7 +589,7 @@ erpnext.PointOfSale.ItemCart = class { this.$cart_items_wrapper.append( `
      ` - ) + ); $item_to_update = this.get_cart_item(item_data); } @@ -584,7 +602,7 @@ erpnext.PointOfSale.ItemCart = class { ${get_description_html()}
      ${get_rate_discount_html()}` - ) + ); set_dynamic_rate_header_width(); @@ -593,8 +611,7 @@ erpnext.PointOfSale.ItemCart = class { me.$cart_header.find(".rate-amount-header").css("width", ""); me.$cart_items_wrapper.find(".item-rate-amount").css("width", ""); let max_width = rate_cols.reduce((max_width, elm) => { - if ($(elm).width() > max_width) - max_width = $(elm).width(); + if ($(elm).width() > max_width) max_width = $(elm).width(); return max_width; }, 0); @@ -614,7 +631,7 @@ erpnext.PointOfSale.ItemCart = class {
      ${format_currency(item_data.amount, currency)}
      ${format_currency(item_data.rate, currency)}
      -
      ` +
      `; } else { return `
      @@ -622,17 +639,20 @@ erpnext.PointOfSale.ItemCart = class {
      ${format_currency(item_data.rate, currency)}
      -
      ` +
      `; } } function get_description_html() { if (item_data.description) { - if (item_data.description.indexOf('
      ') != -1) { + if (item_data.description.indexOf("
      ") != -1) { try { item_data.description = $(item_data.description).text(); } catch (error) { - item_data.description = item_data.description.replace(/
      /g, ' ').replace(/<\/div>/g, ' ').replace(/ +/g, ' '); + item_data.description = item_data.description + .replace(/
      /g, " ") + .replace(/<\/div>/g, " ") + .replace(/ +/g, " "); } } item_data.description = frappe.ellipsis(item_data.description, 45); @@ -657,7 +677,7 @@ erpnext.PointOfSale.ItemCart = class { } handle_broken_image($img) { - const item_abbr = $($img).attr('alt'); + const item_abbr = $($img).attr("alt"); $($img).parent().replaceWith(`
      ${item_abbr}
      `); } @@ -668,44 +688,48 @@ erpnext.PointOfSale.ItemCart = class { toggle_checkout_btn(show_checkout) { if (show_checkout) { - this.$totals_section.find('.checkout-btn').css('display', 'flex'); - this.$totals_section.find('.edit-cart-btn').css('display', 'none'); + this.$totals_section.find(".checkout-btn").css("display", "flex"); + this.$totals_section.find(".edit-cart-btn").css("display", "none"); } else { - this.$totals_section.find('.checkout-btn').css('display', 'none'); - this.$totals_section.find('.edit-cart-btn').css('display', 'flex'); + this.$totals_section.find(".checkout-btn").css("display", "none"); + this.$totals_section.find(".edit-cart-btn").css("display", "flex"); } } highlight_checkout_btn(toggle) { if (toggle) { - this.$add_discount_elem.css('display', 'flex'); - this.$cart_container.find('.checkout-btn').css({ - 'background-color': 'var(--blue-500)' + this.$add_discount_elem.css("display", "flex"); + this.$cart_container.find(".checkout-btn").css({ + "background-color": "var(--blue-500)", }); } else { - this.$add_discount_elem.css('display', 'none'); - this.$cart_container.find('.checkout-btn').css({ - 'background-color': 'var(--blue-200)' + this.$add_discount_elem.css("display", "none"); + this.$cart_container.find(".checkout-btn").css({ + "background-color": "var(--blue-200)", }); } } update_empty_cart_section(no_of_cart_items) { - const $no_item_element = this.$cart_items_wrapper.find('.no-item-wrapper'); + const $no_item_element = this.$cart_items_wrapper.find(".no-item-wrapper"); // if cart has items and no item is present - no_of_cart_items > 0 && $no_item_element && $no_item_element.remove() && this.$cart_header.css('display', 'flex'); + no_of_cart_items > 0 && + $no_item_element && + $no_item_element.remove() && + this.$cart_header.css("display", "flex"); no_of_cart_items === 0 && !$no_item_element.length && this.make_no_items_placeholder(); } on_numpad_event($btn) { - const current_action = $btn.attr('data-button-value'); - const action_is_field_edit = ['qty', 'discount_percentage', 'rate'].includes(current_action); - const action_is_allowed = action_is_field_edit ? ( - (current_action == 'rate' && this.allow_rate_change) || - (current_action == 'discount_percentage' && this.allow_discount_change) || - (current_action == 'qty')) : true; + const current_action = $btn.attr("data-button-value"); + const action_is_field_edit = ["qty", "discount_percentage", "rate"].includes(current_action); + const action_is_allowed = action_is_field_edit + ? (current_action == "rate" && this.allow_rate_change) || + (current_action == "discount_percentage" && this.allow_discount_change) || + current_action == "qty" + : true; const action_is_pressed_twice = this.prev_action === current_action; const first_click_event = !this.prev_action; @@ -713,11 +737,11 @@ erpnext.PointOfSale.ItemCart = class { if (action_is_field_edit) { if (!action_is_allowed) { - const label = current_action == 'rate' ? 'Rate'.bold() : 'Discount'.bold(); - const message = __('Editing {0} is not allowed as per POS Profile settings', [label]); + const label = current_action == "rate" ? "Rate".bold() : "Discount".bold(); + const message = __("Editing {0} is not allowed as per POS Profile settings", [label]); frappe.show_alert({ - indicator: 'red', - message: message + indicator: "red", + message: message, }); frappe.utils.play_sound("error"); return; @@ -728,20 +752,22 @@ erpnext.PointOfSale.ItemCart = class { } else if (action_is_pressed_twice) { this.prev_action = undefined; } - this.numpad_value = ''; - - } else if (current_action === 'checkout') { + this.numpad_value = ""; + } else if (current_action === "checkout") { this.prev_action = undefined; this.toggle_item_highlight(); this.events.numpad_event(undefined, current_action); return; - } else if (current_action === 'remove') { + } else if (current_action === "remove") { this.prev_action = undefined; this.toggle_item_highlight(); this.events.numpad_event(undefined, current_action); return; } else { - this.numpad_value = current_action === 'delete' ? this.numpad_value.slice(0, -1) : this.numpad_value + current_action; + this.numpad_value = + current_action === "delete" + ? this.numpad_value.slice(0, -1) + : this.numpad_value + current_action; this.numpad_value = this.numpad_value || 0; } @@ -749,17 +775,17 @@ erpnext.PointOfSale.ItemCart = class { if (first_click_event_is_not_field_edit) { frappe.show_alert({ - indicator: 'red', - message: __('Please select a field to edit from numpad') + indicator: "red", + message: __("Please select a field to edit from numpad"), }); frappe.utils.play_sound("error"); return; } - if (flt(this.numpad_value) > 100 && this.prev_action === 'discount_percentage') { + if (flt(this.numpad_value) > 100 && this.prev_action === "discount_percentage") { frappe.show_alert({ - message: __('Discount cannot be greater than 100%'), - indicator: 'orange' + message: __("Discount cannot be greater than 100%"), + indicator: "orange", }); frappe.utils.play_sound("error"); this.numpad_value = current_action; @@ -770,48 +796,48 @@ erpnext.PointOfSale.ItemCart = class { } highlight_numpad_btn($btn, curr_action) { - const curr_action_is_highlighted = $btn.hasClass('highlighted-numpad-btn'); - const curr_action_is_action = ['qty', 'discount_percentage', 'rate', 'done'].includes(curr_action); + const curr_action_is_highlighted = $btn.hasClass("highlighted-numpad-btn"); + const curr_action_is_action = ["qty", "discount_percentage", "rate", "done"].includes(curr_action); if (!curr_action_is_highlighted) { - $btn.addClass('highlighted-numpad-btn'); + $btn.addClass("highlighted-numpad-btn"); } if (this.prev_action === curr_action && curr_action_is_highlighted) { // if Qty is pressed twice - $btn.removeClass('highlighted-numpad-btn'); + $btn.removeClass("highlighted-numpad-btn"); } if (this.prev_action && this.prev_action !== curr_action && curr_action_is_action) { // Order: Qty -> Rate then remove Qty highlight const prev_btn = $(`[data-button-value='${this.prev_action}']`); - prev_btn.removeClass('highlighted-numpad-btn'); + prev_btn.removeClass("highlighted-numpad-btn"); } - if (!curr_action_is_action || curr_action === 'done') { + if (!curr_action_is_action || curr_action === "done") { // if numbers are clicked setTimeout(() => { - $btn.removeClass('highlighted-numpad-btn'); + $btn.removeClass("highlighted-numpad-btn"); }, 200); } } toggle_numpad(show) { if (show) { - this.$totals_section.css('display', 'none'); - this.$numpad_section.css('display', 'flex'); + this.$totals_section.css("display", "none"); + this.$numpad_section.css("display", "flex"); } else { - this.$totals_section.css('display', 'flex'); - this.$numpad_section.css('display', 'none'); + this.$totals_section.css("display", "flex"); + this.$numpad_section.css("display", "none"); } this.reset_numpad(); } reset_numpad() { - this.numpad_value = ''; + this.numpad_value = ""; this.prev_action = undefined; - this.$numpad_section.find('.highlighted-numpad-btn').removeClass('highlighted-numpad-btn'); + this.$numpad_section.find(".highlighted-numpad-btn").removeClass("highlighted-numpad-btn"); } toggle_numpad_field_edit(fieldname) { - if (['qty', 'discount_percentage', 'rate'].includes(fieldname)) { + if (["qty", "discount_percentage", "rate"].includes(fieldname)) { this.$numpad_section.find(`[data-button-value="${fieldname}"]`).click(); } } @@ -820,12 +846,12 @@ erpnext.PointOfSale.ItemCart = class { if (show) { const { customer } = this.customer_info || {}; - this.$cart_container.css('display', 'none'); + this.$cart_container.css("display", "none"); this.$customer_section.css({ - 'height': '100%', - 'padding-top': '0px' + height: "100%", + "padding-top": "0px", }); - this.$customer_section.find('.customer-details').html( + this.$customer_section.find(".customer-details").html( `
      Contact Details
      @@ -854,12 +880,11 @@ erpnext.PointOfSale.ItemCart = class { this.render_customer_fields(); this.fetch_customer_transactions(); - } else { - this.$cart_container.css('display', 'flex'); + this.$cart_container.css("display", "flex"); this.$customer_section.css({ - 'height': '', - 'padding-top': '' + height: "", + "padding-top": "", }); this.update_customer_section(); @@ -867,100 +892,107 @@ erpnext.PointOfSale.ItemCart = class { } render_customer_fields() { - const $customer_form = this.$customer_section.find('.customer-fields-container'); + const $customer_form = this.$customer_section.find(".customer-fields-container"); - const dfs = [{ - fieldname: 'email_id', - label: __('Email'), - fieldtype: 'Data', - options: 'email', - placeholder: __("Enter customer's email") - },{ - fieldname: 'mobile_no', - label: __('Phone Number'), - fieldtype: 'Data', - placeholder: __("Enter customer's phone number") - },{ - fieldname: 'loyalty_program', - label: __('Loyalty Program'), - fieldtype: 'Link', - options: 'Loyalty Program', - placeholder: __("Select Loyalty Program") - },{ - fieldname: 'loyalty_points', - label: __('Loyalty Points'), - fieldtype: 'Data', - read_only: 1 - }]; + const dfs = [ + { + fieldname: "email_id", + label: __("Email"), + fieldtype: "Data", + options: "email", + placeholder: __("Enter customer's email"), + }, + { + fieldname: "mobile_no", + label: __("Phone Number"), + fieldtype: "Data", + placeholder: __("Enter customer's phone number"), + }, + { + fieldname: "loyalty_program", + label: __("Loyalty Program"), + fieldtype: "Link", + options: "Loyalty Program", + placeholder: __("Select Loyalty Program"), + }, + { + fieldname: "loyalty_points", + label: __("Loyalty Points"), + fieldtype: "Data", + read_only: 1, + }, + ]; const me = this; - dfs.forEach(df => { + dfs.forEach((df) => { this[`customer_${df.fieldname}_field`] = frappe.ui.form.make_control({ - df: { ...df, - onchange: handle_customer_field_change, - }, + df: { ...df, onchange: handle_customer_field_change }, parent: $customer_form.find(`.${df.fieldname}-field`), render_input: true, }); this[`customer_${df.fieldname}_field`].set_value(this.customer_info[df.fieldname]); - }) + }); function handle_customer_field_change() { const current_value = me.customer_info[this.df.fieldname]; const current_customer = me.customer_info.customer; - if (this.value && current_value != this.value && this.df.fieldname != 'loyalty_points') { + if (this.value && current_value != this.value && this.df.fieldname != "loyalty_points") { frappe.call({ - method: 'erpnext.selling.page.point_of_sale.point_of_sale.set_customer_info', + method: "erpnext.selling.page.point_of_sale.point_of_sale.set_customer_info", args: { fieldname: this.df.fieldname, customer: current_customer, - value: this.value + value: this.value, }, callback: (r) => { - if(!r.exc) { + if (!r.exc) { me.customer_info[this.df.fieldname] = this.value; frappe.show_alert({ message: __("Customer contact updated successfully."), - indicator: 'green' + indicator: "green", }); frappe.utils.play_sound("submit"); } - } + }, }); } } } fetch_customer_transactions() { - frappe.db.get_list('POS Invoice', { - filters: { customer: this.customer_info.customer, docstatus: 1 }, - fields: ['name', 'grand_total', 'status', 'posting_date', 'posting_time', 'currency'], - limit: 20 - }).then((res) => { - const transaction_container = this.$customer_section.find('.customer-transactions'); + frappe.db + .get_list("POS Invoice", { + filters: { customer: this.customer_info.customer, docstatus: 1 }, + fields: ["name", "grand_total", "status", "posting_date", "posting_time", "currency"], + limit: 20, + }) + .then((res) => { + const transaction_container = this.$customer_section.find(".customer-transactions"); - if (!res.length) { - transaction_container.html( - `
      No recent transactions found
      ` - ) - return; - } + if (!res.length) { + transaction_container.html( + `
      No recent transactions found
      ` + ); + return; + } - const elapsed_time = moment(res[0].posting_date+" "+res[0].posting_time).fromNow(); - this.$customer_section.find('.customer-desc').html(`Last transacted ${elapsed_time}`); + const elapsed_time = moment(res[0].posting_date + " " + res[0].posting_time).fromNow(); + this.$customer_section.find(".customer-desc").html(`Last transacted ${elapsed_time}`); - res.forEach(invoice => { - const posting_datetime = moment(invoice.posting_date+" "+invoice.posting_time).format("Do MMMM, h:mma"); - let indicator_color = { - 'Paid': 'green', - 'Draft': 'red', - 'Return': 'gray', - 'Consolidated': 'blue' - }; + res.forEach((invoice) => { + const posting_datetime = moment(invoice.posting_date + " " + invoice.posting_time).format( + "Do MMMM, h:mma" + ); + let indicator_color = { + Paid: "green", + Draft: "red", + Return: "gray", + Consolidated: "blue", + }; - transaction_container.append( - `
      + transaction_container.append( + `
      ${invoice.name}
      ${posting_datetime}
      @@ -977,17 +1009,17 @@ erpnext.PointOfSale.ItemCart = class {
      ` - ) + ); + }); }); - }); } attach_refresh_field_event(frm) { - $(frm.wrapper).off('refresh-fields'); - $(frm.wrapper).on('refresh-fields', () => { + $(frm.wrapper).off("refresh-fields"); + $(frm.wrapper).on("refresh-fields", () => { if (frm.doc.items.length) { - this.$cart_items_wrapper.html(''); - frm.doc.items.forEach(item => { + this.$cart_items_wrapper.html(""); + frm.doc.items.forEach((item) => { this.update_item_html(item); }); } @@ -1005,9 +1037,9 @@ erpnext.PointOfSale.ItemCart = class { this.update_customer_section(); }); - this.$cart_items_wrapper.html(''); + this.$cart_items_wrapper.html(""); if (frm.doc.items.length) { - frm.doc.items.forEach(item => { + frm.doc.items.forEach((item) => { this.update_item_html(item); }); } else { @@ -1017,19 +1049,18 @@ erpnext.PointOfSale.ItemCart = class { this.update_totals_section(frm); - if(frm.doc.docstatus === 1) { - this.$totals_section.find('.checkout-btn').css('display', 'none'); - this.$totals_section.find('.edit-cart-btn').css('display', 'none'); + if (frm.doc.docstatus === 1) { + this.$totals_section.find(".checkout-btn").css("display", "none"); + this.$totals_section.find(".edit-cart-btn").css("display", "none"); } else { - this.$totals_section.find('.checkout-btn').css('display', 'flex'); - this.$totals_section.find('.edit-cart-btn').css('display', 'none'); + this.$totals_section.find(".checkout-btn").css("display", "flex"); + this.$totals_section.find(".edit-cart-btn").css("display", "none"); } this.toggle_component(true); } toggle_component(show) { - show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none'); + show ? this.$component.css("display", "flex") : this.$component.css("display", "none"); } - -} +}; diff --git a/erpnext/selling/page/point_of_sale/pos_item_details.js b/erpnext/selling/page/point_of_sale/pos_item_details.js index b6e567c7cce..9646a04e400 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_details.js +++ b/erpnext/selling/page/point_of_sale/pos_item_details.js @@ -18,17 +18,15 @@ erpnext.PointOfSale.ItemDetails = class { } prepare_dom() { - this.wrapper.append( - `
      ` - ) + this.wrapper.append(`
      `); - this.$component = this.wrapper.find('.item-details-container'); + this.$component = this.wrapper.find(".item-details-container"); } init_child_components() { this.$component.html( `
      -
      ${__('Item Details')}
      +
      ${__("Item Details")}
      @@ -46,15 +44,15 @@ erpnext.PointOfSale.ItemDetails = class {
      ` - ) + ); - this.$item_name = this.$component.find('.item-name'); - this.$item_description = this.$component.find('.item-desc'); - this.$item_price = this.$component.find('.item-price'); - this.$item_image = this.$component.find('.item-image'); - this.$form_container = this.$component.find('.form-container'); - this.$dicount_section = this.$component.find('.discount-section'); - this.$serial_batch_container = this.$component.find('.serial-batch-container'); + this.$item_name = this.$component.find(".item-name"); + this.$item_description = this.$component.find(".item-desc"); + this.$item_price = this.$component.find(".item-price"); + this.$item_image = this.$component.find(".item-image"); + this.$form_container = this.$component.find(".form-container"); + this.$dicount_section = this.$component.find(".discount-section"); + this.$serial_batch_container = this.$component.find(".serial-batch-container"); } compare_with_current_item(item) { @@ -97,7 +95,7 @@ erpnext.PointOfSale.ItemDetails = class { validate_serial_batch_item() { const doc = this.events.get_frm().doc; - const item_row = doc.items.find(item => item.name === this.name); + const item_row = doc.items.find((item) => item.name === this.name); if (!item_row) return; @@ -108,7 +106,7 @@ erpnext.PointOfSale.ItemDetails = class { if ((serialized && no_bundle_selected) || (batched && no_bundle_selected)) { frappe.show_alert({ message: __("Item is removed since no serial / batch no selected."), - indicator: 'orange' + indicator: "orange", }); frappe.utils.play_sound("cancel"); return this.events.remove_item_from_cart(); @@ -120,7 +118,10 @@ erpnext.PointOfSale.ItemDetails = class { function get_description_html() { if (description) { - description = description.indexOf('...') === -1 && description.length > 140 ? description.substr(0, 139) + '...' : description; + description = + description.indexOf("...") === -1 && description.length > 140 + ? description.substr(0, 139) + "..." + : description; return description; } return ``; @@ -140,11 +141,10 @@ erpnext.PointOfSale.ItemDetails = class { } else { this.$item_image.html(`
      ${frappe.get_abbr(item_name)}
      `); } - } handle_broken_image($img) { - const item_abbr = $($img).attr('alt'); + const item_abbr = $($img).attr("alt"); $($img).replaceWith(`
      ${item_abbr}
      `); } @@ -153,36 +153,36 @@ erpnext.PointOfSale.ItemDetails = class { this.$dicount_section.html( `
      ${format_currency(item.price_list_rate, this.currency)}
      ${item.discount_percentage}% off
      ` - ) + ); this.$item_price.html(format_currency(item.rate, this.currency)); } else { - this.$dicount_section.html(``) + this.$dicount_section.html(``); } } render_form(item) { const fields_to_display = this.get_form_fields(item); - this.$form_container.html(''); + this.$form_container.html(""); fields_to_display.forEach((fieldname, idx) => { this.$form_container.append( `
      ` - ) + ); - const field_meta = this.item_meta.fields.find(df => df.fieldname === fieldname); - fieldname === 'discount_percentage' ? (field_meta.label = __('Discount (%)')) : ''; + const field_meta = this.item_meta.fields.find((df) => df.fieldname === fieldname); + fieldname === "discount_percentage" ? (field_meta.label = __("Discount (%)")) : ""; const me = this; this[`${fieldname}_control`] = frappe.ui.form.make_control({ df: { ...field_meta, - onchange: function() { + onchange: function () { me.events.form_updated(me.current_item, fieldname, this.value); - } + }, }, parent: this.$form_container.find(`.${fieldname}-control`), render_input: true, - }) + }); this[`${fieldname}_control`].set_value(item[fieldname]); }); @@ -192,28 +192,37 @@ erpnext.PointOfSale.ItemDetails = class { } get_form_fields(item) { - const fields = ['qty', 'uom', 'rate', 'conversion_factor', 'discount_percentage', 'warehouse', 'actual_qty', 'price_list_rate']; - if (item.has_serial_no) fields.push('serial_no'); - if (item.has_batch_no) fields.push('batch_no'); + const fields = [ + "qty", + "uom", + "rate", + "conversion_factor", + "discount_percentage", + "warehouse", + "actual_qty", + "price_list_rate", + ]; + if (item.has_serial_no) fields.push("serial_no"); + if (item.has_batch_no) fields.push("batch_no"); return fields; } make_auto_serial_selection_btn(item) { if (item.has_serial_no || item.has_batch_no) { - const label = item.has_serial_no ? __('Select Serial No') : __('Select Batch No'); + const label = item.has_serial_no ? __("Select Serial No") : __("Select Batch No"); this.$form_container.append( `
      ${label}
      ` ); - this.$form_container.find('.serial_no-control').find('textarea').css('height', '6rem'); + this.$form_container.find(".serial_no-control").find("textarea").css("height", "6rem"); } } bind_custom_control_change_event() { const me = this; if (this.rate_control) { - this.rate_control.df.onchange = function() { + this.rate_control.df.onchange = function () { if (this.value || flt(this.value) === 0) { - me.events.form_updated(me.current_item, 'rate', this.value).then(() => { + me.events.form_updated(me.current_item, "rate", this.value).then(() => { const item_row = frappe.get_doc(me.doctype, me.name); const doc = me.events.get_frm().doc; me.$item_price.html(format_currency(item_row.rate, doc.currency)); @@ -232,43 +241,48 @@ erpnext.PointOfSale.ItemDetails = class { if (this.warehouse_control) { this.warehouse_control.df.reqd = 1; - this.warehouse_control.df.onchange = function() { + this.warehouse_control.df.onchange = function () { if (this.value) { - me.events.form_updated(me.current_item, 'warehouse', this.value).then(() => { + me.events.form_updated(me.current_item, "warehouse", this.value).then(() => { me.item_stock_map = me.events.get_item_stock_map(); const available_qty = me.item_stock_map[me.item_row.item_code][this.value][0]; - const is_stock_item = Boolean(me.item_stock_map[me.item_row.item_code][this.value][1]); + const is_stock_item = Boolean( + me.item_stock_map[me.item_row.item_code][this.value][1] + ); if (available_qty === undefined) { me.events.get_available_stock(me.item_row.item_code, this.value).then(() => { // item stock map is updated now reset warehouse me.warehouse_control.set_value(this.value); - }) + }); } else if (available_qty === 0 && is_stock_item) { - me.warehouse_control.set_value(''); + me.warehouse_control.set_value(""); const bold_item_code = me.item_row.item_code.bold(); const bold_warehouse = this.value.bold(); frappe.throw( - __('Item Code: {0} is not available under warehouse {1}.', [bold_item_code, bold_warehouse]) + __("Item Code: {0} is not available under warehouse {1}.", [ + bold_item_code, + bold_warehouse, + ]) ); } me.actual_qty_control.set_value(available_qty); }); } - } + }; this.warehouse_control.df.get_query = () => { return { - filters: { company: this.events.get_frm().doc.company } - } + filters: { company: this.events.get_frm().doc.company }, + }; }; this.warehouse_control.refresh(); } if (this.serial_no_control) { this.serial_no_control.df.reqd = 1; - this.serial_no_control.df.onchange = async function() { - !me.current_item.batch_no && await me.auto_update_batch_no(); - me.events.form_updated(me.current_item, 'serial_no', this.value); - } + this.serial_no_control.df.onchange = async function () { + !me.current_item.batch_no && (await me.auto_update_batch_no()); + me.events.form_updated(me.current_item, "serial_no", this.value); + }; this.serial_no_control.refresh(); } @@ -276,25 +290,25 @@ erpnext.PointOfSale.ItemDetails = class { this.batch_no_control.df.reqd = 1; this.batch_no_control.df.get_query = () => { return { - query: 'erpnext.controllers.queries.get_batch_no', + query: "erpnext.controllers.queries.get_batch_no", filters: { item_code: me.item_row.item_code, warehouse: me.item_row.warehouse, - posting_date: me.events.get_frm().doc.posting_date - } - } + posting_date: me.events.get_frm().doc.posting_date, + }, + }; }; this.batch_no_control.refresh(); } if (this.uom_control) { - this.uom_control.df.onchange = function() { - me.events.form_updated(me.current_item, 'uom', this.value); + this.uom_control.df.onchange = function () { + me.events.form_updated(me.current_item, "uom", this.value); const item_row = frappe.get_doc(me.doctype, me.name); - me.conversion_factor_control.df.read_only = (item_row.stock_uom == this.value); + me.conversion_factor_control.df.read_only = item_row.stock_uom == this.value; me.conversion_factor_control.refresh(); - } + }; } frappe.model.on("POS Invoice Item", "*", (fieldname, value, item_row) => { @@ -310,13 +324,16 @@ erpnext.PointOfSale.ItemDetails = class { async auto_update_batch_no() { if (this.serial_no_control && this.batch_no_control) { - const selected_serial_nos = this.serial_no_control.get_value().split(`\n`).filter(s => s); + const selected_serial_nos = this.serial_no_control + .get_value() + .split(`\n`) + .filter((s) => s); if (!selected_serial_nos.length) return; // find batch nos of the selected serial no const serials_with_batch_no = await frappe.db.get_list("Serial No", { - filters: { 'name': ["in", selected_serial_nos]}, - fields: ["batch_no", "name"] + filters: { name: ["in", selected_serial_nos] }, + fields: ["batch_no", "name"], }); const batch_serial_map = serials_with_batch_no.reduce((acc, r) => { if (!acc[r.batch_no]) { @@ -329,10 +346,11 @@ erpnext.PointOfSale.ItemDetails = class { const batch_no = Object.keys(batch_serial_map)[0]; const batch_serial_nos = batch_serial_map[batch_no].join(`\n`); // eg. 10 selected serial no. -> 5 belongs to first batch other 5 belongs to second batch - const serial_nos_belongs_to_other_batch = selected_serial_nos.length !== batch_serial_map[batch_no].length; + const serial_nos_belongs_to_other_batch = + selected_serial_nos.length !== batch_serial_map[batch_no].length; const current_batch_no = this.batch_no_control.get_value(); - current_batch_no != batch_no && await this.batch_no_control.set_value(batch_no); + current_batch_no != batch_no && (await this.batch_no_control.set_value(batch_no)); if (serial_nos_belongs_to_other_batch) { this.serial_no_control.set_value(batch_serial_nos); @@ -348,13 +366,13 @@ erpnext.PointOfSale.ItemDetails = class { this.bind_auto_serial_fetch_event(); this.bind_fields_to_numpad_fields(); - this.$component.on('click', '.close-btn', () => { + this.$component.on("click", ".close-btn", () => { this.events.close_item_details(); }); } attach_shortcuts() { - this.wrapper.find('.close-btn').attr("title", "Esc"); + this.wrapper.find(".close-btn").attr("title", "Esc"); frappe.ui.keys.on("escape", () => { const item_details_visible = this.$component.is(":visible"); if (item_details_visible) { @@ -365,8 +383,8 @@ erpnext.PointOfSale.ItemDetails = class { bind_fields_to_numpad_fields() { const me = this; - this.$form_container.on('click', '.input-with-feedback', function() { - const fieldname = $(this).attr('data-fieldname'); + this.$form_container.on("click", ".input-with-feedback", function () { + const fieldname = $(this).attr("data-fieldname"); if (this.last_field_focused != fieldname) { me.events.item_field_focused(fieldname); this.last_field_focused = fieldname; @@ -375,7 +393,7 @@ erpnext.PointOfSale.ItemDetails = class { } bind_auto_serial_fetch_event() { - this.$form_container.on('click', '.auto-fetch-btn', () => { + this.$form_container.on("click", ".auto-fetch-btn", () => { frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", () => { let frm = this.events.get_frm(); let item_row = this.item_row; @@ -384,16 +402,16 @@ erpnext.PointOfSale.ItemDetails = class { new erpnext.SerialBatchPackageSelector(frm, item_row, (r) => { if (r) { frappe.model.set_value(item_row.doctype, item_row.name, { - "serial_and_batch_bundle": r.name, - "qty": Math.abs(r.total_qty) + serial_and_batch_bundle: r.name, + qty: Math.abs(r.total_qty), }); } }); }); - }) + }); } toggle_component(show) { - show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none'); + show ? this.$component.css("display", "flex") : this.$component.css("display", "none"); } -} +}; diff --git a/erpnext/selling/page/point_of_sale/pos_item_selector.js b/erpnext/selling/page/point_of_sale/pos_item_selector.js index ec67bdfd9dd..b5fa8849d60 100644 --- a/erpnext/selling/page/point_of_sale/pos_item_selector.js +++ b/erpnext/selling/page/point_of_sale/pos_item_selector.js @@ -1,4 +1,4 @@ -import onScan from 'onscan.js'; +import onScan from "onscan.js"; erpnext.PointOfSale.ItemSelector = class { // eslint-disable-next-line no-unused-vars @@ -24,7 +24,7 @@ erpnext.PointOfSale.ItemSelector = class { this.wrapper.append( `
      -
      ${__('All Items')}
      +
      ${__("All Items")}
      @@ -32,13 +32,13 @@ erpnext.PointOfSale.ItemSelector = class {
      ` ); - this.$component = this.wrapper.find('.items-selector'); - this.$items_container = this.$component.find('.items-container'); + this.$component = this.wrapper.find(".items-selector"); + this.$items_container = this.$component.find(".items-container"); } async load_items_data() { if (!this.item_group) { - const res = await frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name"); + const res = await frappe.db.get_value("Item Group", { lft: 1, is_group: 1 }, "name"); this.parent_item_group = res.message.name; } if (!this.price_list) { @@ -46,12 +46,12 @@ erpnext.PointOfSale.ItemSelector = class { this.price_list = res.message.selling_price_list; } - this.get_items({}).then(({message}) => { + this.get_items({}).then(({ message }) => { this.render_item_list(message.items); }); } - get_items({start = 0, page_length = 40, search_term=''}) { + get_items({ start = 0, page_length = 40, search_term = "" }) { const doc = this.events.get_frm().doc; const price_list = (doc && doc.selling_price_list) || this.price_list; let { item_group, pos_profile } = this; @@ -65,11 +65,10 @@ erpnext.PointOfSale.ItemSelector = class { }); } - render_item_list(items) { - this.$items_container.html(''); + this.$items_container.html(""); - items.forEach(item => { + items.forEach((item) => { const item_html = this.get_item_html(item); this.$items_container.append(item_html); }); @@ -84,15 +83,15 @@ erpnext.PointOfSale.ItemSelector = class { let qty_to_display = actual_qty; if (item.is_stock_item) { - indicator_color = (actual_qty > 10 ? "green" : actual_qty <= 0 ? "red" : "orange"); + indicator_color = actual_qty > 10 ? "green" : actual_qty <= 0 ? "red" : "orange"; if (Math.round(qty_to_display) > 999) { - qty_to_display = Math.round(qty_to_display)/1000; - qty_to_display = qty_to_display.toFixed(1) + 'K'; + qty_to_display = Math.round(qty_to_display) / 1000; + qty_to_display = qty_to_display.toFixed(1) + "K"; } } else { - indicator_color = ''; - qty_to_display = ''; + indicator_color = ""; + qty_to_display = ""; } function get_item_image_html() { @@ -115,8 +114,7 @@ erpnext.PointOfSale.ItemSelector = class { } } - return ( - `
      ${format_currency(price_list_rate, item.currency, precision) || 0} / ${uom}
      -
      ` - ); +
      `; } handle_broken_image($img) { - const item_abbr = $($img).attr('alt'); + const item_abbr = $($img).attr("alt"); $($img).parent().replaceWith(`
      ${item_abbr}
      `); } make_search_bar() { const me = this; const doc = me.events.get_frm().doc; - this.$component.find('.search-field').html(''); - this.$component.find('.item-group-field').html(''); + this.$component.find(".search-field").html(""); + this.$component.find(".item-group-field").html(""); this.search_field = frappe.ui.form.make_control({ df: { - label: __('Search'), - fieldtype: 'Data', - placeholder: __('Search by item code, serial number or barcode') + label: __("Search"), + fieldtype: "Data", + placeholder: __("Search by item code, serial number or barcode"), }, - parent: this.$component.find('.search-field'), + parent: this.$component.find(".search-field"), render_input: true, }); this.item_group_field = frappe.ui.form.make_control({ df: { - label: __('Item Group'), - fieldtype: 'Link', - options: 'Item Group', - placeholder: __('Select item group'), - onchange: function() { + label: __("Item Group"), + fieldtype: "Link", + options: "Item Group", + placeholder: __("Select item group"), + onchange: function () { me.item_group = this.value; !me.item_group && (me.item_group = me.parent_item_group); me.filter_items(); }, get_query: function () { return { - query: 'erpnext.selling.page.point_of_sale.point_of_sale.item_group_query', + query: "erpnext.selling.page.point_of_sale.point_of_sale.item_group_query", filters: { - pos_profile: doc ? doc.pos_profile : '' - } + pos_profile: doc ? doc.pos_profile : "", + }, }; }, }, - parent: this.$component.find('.item-group-field'), + parent: this.$component.find(".item-group-field"), render_input: true, }); this.search_field.toggle_label(false); @@ -184,18 +181,18 @@ erpnext.PointOfSale.ItemSelector = class { } attach_clear_btn() { - this.search_field.$wrapper.find('.control-input').append( + this.search_field.$wrapper.find(".control-input").append( ` - ${frappe.utils.icon('close', 'sm')} + ${frappe.utils.icon("close", "sm")} ` ); - this.$clear_search_btn = this.search_field.$wrapper.find('.link-btn'); + this.$clear_search_btn = this.search_field.$wrapper.find(".link-btn"); - this.$clear_search_btn.on('click', 'a', () => { - this.set_search_value(''); + this.$clear_search_btn.on("click", "a", () => { + this.set_search_value(""); this.search_field.set_focus(); }); } @@ -217,39 +214,43 @@ erpnext.PointOfSale.ItemSelector = class { case iCode >= 186 && iCode <= 194: // (; = , - . / `) case iCode >= 219 && iCode <= 222: // ([ \ ] ') case iCode == 32: // spacebar - if (oEvent.key !== undefined && oEvent.key !== '') { + if (oEvent.key !== undefined && oEvent.key !== "") { return oEvent.key; } var sDecoded = String.fromCharCode(iCode); switch (oEvent.shiftKey) { - case false: sDecoded = sDecoded.toLowerCase(); break; - case true: sDecoded = sDecoded.toUpperCase(); break; + case false: + sDecoded = sDecoded.toLowerCase(); + break; + case true: + sDecoded = sDecoded.toUpperCase(); + break; } return sDecoded; case iCode >= 96 && iCode <= 105: // numbers on numeric keypad return 0 + (iCode - 96); } - return ''; + return ""; }; onScan.attachTo(document, { onScan: (sScancode) => { - if (this.search_field && this.$component.is(':visible')) { + if (this.search_field && this.$component.is(":visible")) { this.search_field.set_focus(); this.set_search_value(sScancode); this.barcode_scanned = true; } - } + }, }); - this.$component.on('click', '.item-wrapper', function() { + this.$component.on("click", ".item-wrapper", function () { const $item = $(this); - const item_code = unescape($item.attr('data-item-code')); - let batch_no = unescape($item.attr('data-batch-no')); - let serial_no = unescape($item.attr('data-serial-no')); - let uom = unescape($item.attr('data-uom')); - let rate = unescape($item.attr('data-rate')); + const item_code = unescape($item.attr("data-item-code")); + let batch_no = unescape($item.attr("data-batch-no")); + let serial_no = unescape($item.attr("data-serial-no")); + let uom = unescape($item.attr("data-uom")); + let rate = unescape($item.attr("data-rate")); // escape(undefined) returns "undefined" then unescape returns "undefined" batch_no = batch_no === "undefined" ? undefined : batch_no; @@ -258,76 +259,72 @@ erpnext.PointOfSale.ItemSelector = class { rate = rate === "undefined" ? undefined : rate; me.events.item_selected({ - field: 'qty', + field: "qty", value: "+1", - item: { item_code, batch_no, serial_no, uom, rate } + item: { item_code, batch_no, serial_no, uom, rate }, }); me.search_field.set_focus(); }); - this.search_field.$input.on('input', (e) => { + this.search_field.$input.on("input", (e) => { clearTimeout(this.last_search); this.last_search = setTimeout(() => { const search_term = e.target.value; this.filter_items({ search_term }); }, 300); - this.$clear_search_btn.toggle( - Boolean(this.search_field.$input.val()) - ); + this.$clear_search_btn.toggle(Boolean(this.search_field.$input.val())); }); - this.search_field.$input.on('focus', () => { - this.$clear_search_btn.toggle( - Boolean(this.search_field.$input.val()) - ); + this.search_field.$input.on("focus", () => { + this.$clear_search_btn.toggle(Boolean(this.search_field.$input.val())); }); } attach_shortcuts() { - const ctrl_label = frappe.utils.is_mac() ? '⌘' : 'Ctrl'; + const ctrl_label = frappe.utils.is_mac() ? "⌘" : "Ctrl"; this.search_field.parent.attr("title", `${ctrl_label}+I`); frappe.ui.keys.add_shortcut({ shortcut: "ctrl+i", action: () => this.search_field.set_focus(), - condition: () => this.$component.is(':visible'), + condition: () => this.$component.is(":visible"), description: __("Focus on search input"), ignore_inputs: true, - page: cur_page.page.page + page: cur_page.page.page, }); this.item_group_field.parent.attr("title", `${ctrl_label}+G`); frappe.ui.keys.add_shortcut({ shortcut: "ctrl+g", action: () => this.item_group_field.set_focus(), - condition: () => this.$component.is(':visible'), + condition: () => this.$component.is(":visible"), description: __("Focus on Item Group filter"), ignore_inputs: true, - page: cur_page.page.page + page: cur_page.page.page, }); // for selecting the last filtered item on search frappe.ui.keys.on("enter", () => { - const selector_is_visible = this.$component.is(':visible'); + const selector_is_visible = this.$component.is(":visible"); if (!selector_is_visible || this.search_field.get_value() === "") return; if (this.items.length == 1) { this.$items_container.find(".item-wrapper").click(); frappe.utils.play_sound("submit"); - this.set_search_value(''); + this.set_search_value(""); } else if (this.items.length == 0 && this.barcode_scanned) { // only show alert of barcode is scanned and enter is pressed frappe.show_alert({ message: __("No items found. Scan barcode again."), - indicator: 'orange' + indicator: "orange", }); frappe.utils.play_sound("error"); this.barcode_scanned = false; - this.set_search_value(''); + this.set_search_value(""); } }); } - filter_items({ search_term='' }={}) { + filter_items({ search_term = "" } = {}) { if (search_term) { search_term = search_term.toLowerCase(); @@ -342,44 +339,47 @@ erpnext.PointOfSale.ItemSelector = class { } } - this.get_items({ search_term }) - .then(({ message }) => { - // eslint-disable-next-line no-unused-vars - const { items, serial_no, batch_no, barcode } = message; - if (search_term && !barcode) { - this.search_index[search_term] = items; - } - this.items = items; - this.render_item_list(items); - this.auto_add_item && this.items.length == 1 && this.add_filtered_item_to_cart(); - }); + this.get_items({ search_term }).then(({ message }) => { + // eslint-disable-next-line no-unused-vars + const { items, serial_no, batch_no, barcode } = message; + if (search_term && !barcode) { + this.search_index[search_term] = items; + } + this.items = items; + this.render_item_list(items); + this.auto_add_item && this.items.length == 1 && this.add_filtered_item_to_cart(); + }); } add_filtered_item_to_cart() { this.$items_container.find(".item-wrapper").click(); - this.set_search_value(''); + this.set_search_value(""); } resize_selector(minimize) { - minimize ? - this.$component.find('.filter-section').css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') : - this.$component.find('.filter-section').css('grid-template-columns', 'repeat(12, minmax(0, 1fr))'); + minimize + ? this.$component + .find(".filter-section") + .css("grid-template-columns", "repeat(1, minmax(0, 1fr))") + : this.$component + .find(".filter-section") + .css("grid-template-columns", "repeat(12, minmax(0, 1fr))"); - minimize ? - this.$component.find('.search-field').css('margin', 'var(--margin-sm) 0px') : - this.$component.find('.search-field').css('margin', '0px var(--margin-sm)'); + minimize + ? this.$component.find(".search-field").css("margin", "var(--margin-sm) 0px") + : this.$component.find(".search-field").css("margin", "0px var(--margin-sm)"); - minimize ? - this.$component.css('grid-column', 'span 2 / span 2') : - this.$component.css('grid-column', 'span 6 / span 6'); + minimize + ? this.$component.css("grid-column", "span 2 / span 2") + : this.$component.css("grid-column", "span 6 / span 6"); - minimize ? - this.$items_container.css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') : - this.$items_container.css('grid-template-columns', 'repeat(4, minmax(0, 1fr))'); + minimize + ? this.$items_container.css("grid-template-columns", "repeat(1, minmax(0, 1fr))") + : this.$items_container.css("grid-template-columns", "repeat(4, minmax(0, 1fr))"); } toggle_component(show) { - this.set_search_value(''); - this.$component.css('display', show ? 'flex': 'none'); + this.set_search_value(""); + this.$component.css("display", show ? "flex" : "none"); } }; diff --git a/erpnext/selling/page/point_of_sale/pos_number_pad.js b/erpnext/selling/page/point_of_sale/pos_number_pad.js index f27b0d55ef6..c77f206308d 100644 --- a/erpnext/selling/page/point_of_sale/pos_number_pad.js +++ b/erpnext/selling/page/point_of_sale/pos_number_pad.js @@ -20,28 +20,40 @@ erpnext.PointOfSale.NumberPad = class { function get_keys() { return keys.reduce((a, row, i) => { - return a + row.reduce((a2, number, j) => { - const class_to_append = css_classes && css_classes[i] ? css_classes[i][j] : ''; - const fieldname = fieldnames && fieldnames[number] ? - fieldnames[number] : typeof number === 'string' ? frappe.scrub(number) : number; + return ( + a + + row.reduce((a2, number, j) => { + const class_to_append = css_classes && css_classes[i] ? css_classes[i][j] : ""; + const fieldname = + fieldnames && fieldnames[number] + ? fieldnames[number] + : typeof number === "string" + ? frappe.scrub(number) + : number; - return a2 + `
      ${__(number)}
      `; - }, ''); - }, ''); + return ( + a2 + + `
      ${__( + number + )}
      ` + ); + }, "") + ); + }, ""); } this.wrapper.html( `
      ${get_keys()}
      ` - ) + ); } bind_events() { const me = this; - this.wrapper.on('click', '.numpad-btn', function() { + this.wrapper.on("click", ".numpad-btn", function () { const $btn = $(this); me.events.numpad_event($btn); }); } -} +}; diff --git a/erpnext/selling/page/point_of_sale/pos_past_order_list.js b/erpnext/selling/page/point_of_sale/pos_past_order_list.js index a0475c70d0d..c450d8a109a 100644 --- a/erpnext/selling/page/point_of_sale/pos_past_order_list.js +++ b/erpnext/selling/page/point_of_sale/pos_past_order_list.js @@ -16,7 +16,7 @@ erpnext.PointOfSale.PastOrderList = class { this.wrapper.append( `
      -
      ${__('Recent Orders')}
      +
      ${__("Recent Orders")}
      @@ -24,12 +24,12 @@ erpnext.PointOfSale.PastOrderList = class {
      ` ); - this.$component = this.wrapper.find('.past-order-list'); - this.$invoices_container = this.$component.find('.invoices-container'); + this.$component = this.wrapper.find(".past-order-list"); + this.$invoices_container = this.$component.find(".invoices-container"); } bind_events() { - this.search_field.$input.on('input', (e) => { + this.search_field.$input.on("input", (e) => { clearTimeout(this.last_search); this.last_search = setTimeout(() => { const search_term = e.target.value; @@ -37,8 +37,8 @@ erpnext.PointOfSale.PastOrderList = class { }, 300); }); const me = this; - this.$invoices_container.on('click', '.invoice-wrapper', function() { - const invoice_name = unescape($(this).attr('data-invoice-name')); + this.$invoices_container.on("click", ".invoice-wrapper", function () { + const invoice_name = unescape($(this).attr("data-invoice-name")); me.events.open_invoice_data(invoice_name); }); @@ -48,29 +48,29 @@ erpnext.PointOfSale.PastOrderList = class { const me = this; this.search_field = frappe.ui.form.make_control({ df: { - label: __('Search'), - fieldtype: 'Data', - placeholder: __('Search by invoice id or customer name') + label: __("Search"), + fieldtype: "Data", + placeholder: __("Search by invoice id or customer name"), }, - parent: this.$component.find('.search-field'), + parent: this.$component.find(".search-field"), render_input: true, }); this.status_field = frappe.ui.form.make_control({ df: { - label: __('Invoice Status'), - fieldtype: 'Select', + label: __("Invoice Status"), + fieldtype: "Select", options: `Draft\nPaid\nConsolidated\nReturn`, - placeholder: __('Filter by invoice status'), - onchange: function() { - if (me.$component.is(':visible')) me.refresh_list(); - } + placeholder: __("Filter by invoice status"), + onchange: function () { + if (me.$component.is(":visible")) me.refresh_list(); + }, }, - parent: this.$component.find('.status-field'), + parent: this.$component.find(".status-field"), render_input: true, }); this.search_field.toggle_label(false); this.status_field.toggle_label(false); - this.status_field.set_value('Draft'); + this.status_field.set_value("Draft"); } refresh_list() { @@ -79,7 +79,7 @@ erpnext.PointOfSale.PastOrderList = class { const search_term = this.search_field.get_value(); const status = this.status_field.get_value(); - this.$invoices_container.html(''); + this.$invoices_container.html(""); return frappe.call({ method: "erpnext.selling.page.point_of_sale.point_of_sale.get_past_order_list", @@ -87,18 +87,19 @@ erpnext.PointOfSale.PastOrderList = class { args: { search_term, status }, callback: (response) => { frappe.dom.unfreeze(); - response.message.forEach(invoice => { + response.message.forEach((invoice) => { const invoice_html = this.get_invoice_html(invoice); this.$invoices_container.append(invoice_html); }); - } + }, }); } get_invoice_html(invoice) { - const posting_datetime = moment(invoice.posting_date+" "+invoice.posting_time).format("Do MMMM, h:mma"); - return ( - `
      + const posting_datetime = moment(invoice.posting_date + " " + invoice.posting_time).format( + "Do MMMM, h:mma" + ); + return `
      ${invoice.name}
      @@ -113,11 +114,12 @@ erpnext.PointOfSale.PastOrderList = class {
      ${posting_datetime}
      -
      ` - ); +
      `; } toggle_component(show) { - show ? this.$component.css('display', 'flex') && this.refresh_list() : this.$component.css('display', 'none'); + show + ? this.$component.css("display", "flex") && this.refresh_list() + : this.$component.css("display", "none"); } }; diff --git a/erpnext/selling/page/point_of_sale/pos_past_order_summary.js b/erpnext/selling/page/point_of_sale/pos_past_order_summary.js index d341d23bd37..448dbcab43a 100644 --- a/erpnext/selling/page/point_of_sale/pos_past_order_summary.js +++ b/erpnext/selling/page/point_of_sale/pos_past_order_summary.js @@ -17,16 +17,16 @@ erpnext.PointOfSale.PastOrderSummary = class { this.wrapper.append( `
      - ${__('Select an invoice to load summary data')} + ${__("Select an invoice to load summary data")}
      -
      ${__('Items')}
      +
      ${__("Items")}
      -
      ${__('Totals')}
      +
      ${__("Totals")}
      -
      ${__('Payments')}
      +
      ${__("Payments")}
      @@ -34,55 +34,53 @@ erpnext.PointOfSale.PastOrderSummary = class {
      ` ); - this.$component = this.wrapper.find('.past-order-summary'); - this.$summary_wrapper = this.$component.find('.invoice-summary-wrapper'); - this.$summary_container = this.$component.find('.abs-container'); - this.$upper_section = this.$summary_container.find('.upper-section'); - this.$items_container = this.$summary_container.find('.items-container'); - this.$totals_container = this.$summary_container.find('.totals-container'); - this.$payment_container = this.$summary_container.find('.payments-container'); - this.$summary_btns = this.$summary_container.find('.summary-btns'); + this.$component = this.wrapper.find(".past-order-summary"); + this.$summary_wrapper = this.$component.find(".invoice-summary-wrapper"); + this.$summary_container = this.$component.find(".abs-container"); + this.$upper_section = this.$summary_container.find(".upper-section"); + this.$items_container = this.$summary_container.find(".items-container"); + this.$totals_container = this.$summary_container.find(".totals-container"); + this.$payment_container = this.$summary_container.find(".payments-container"); + this.$summary_btns = this.$summary_container.find(".summary-btns"); } init_email_print_dialog() { const email_dialog = new frappe.ui.Dialog({ - title: 'Email Receipt', + title: "Email Receipt", fields: [ - {fieldname: 'email_id', fieldtype: 'Data', options: 'Email', label: 'Email ID', reqd: 1}, - {fieldname:'content', fieldtype:'Small Text', label:'Message (if any)'} + { fieldname: "email_id", fieldtype: "Data", options: "Email", label: "Email ID", reqd: 1 }, + { fieldname: "content", fieldtype: "Small Text", label: "Message (if any)" }, ], primary_action: () => { this.send_email(); }, - primary_action_label: __('Send'), + primary_action_label: __("Send"), }); this.email_dialog = email_dialog; const print_dialog = new frappe.ui.Dialog({ - title: 'Print Receipt', - fields: [ - {fieldname: 'print', fieldtype: 'Data', label: 'Print Preview'} - ], + title: "Print Receipt", + fields: [{ fieldname: "print", fieldtype: "Data", label: "Print Preview" }], primary_action: () => { this.print_receipt(); }, - primary_action_label: __('Print'), + primary_action_label: __("Print"), }); this.print_dialog = print_dialog; } get_upper_section_html(doc) { const { status } = doc; - let indicator_color = ''; + let indicator_color = ""; - in_list(['Paid', 'Consolidated'], status) && (indicator_color = 'green'); - status === 'Draft' && (indicator_color = 'red'); - status === 'Return' && (indicator_color = 'grey'); + in_list(["Paid", "Consolidated"], status) && (indicator_color = "green"); + status === "Draft" && (indicator_color = "red"); + status === "Return" && (indicator_color = "grey"); return `
      ${doc.customer}
      ${this.customer_email}
      -
      ${__('Sold by')}: ${doc.owner}
      +
      ${__("Sold by")}: ${doc.owner}
      @@ -103,7 +101,10 @@ erpnext.PointOfSale.PastOrderSummary = class { return `(${item_data.discount_percentage}% off)
      ${format_currency(item_data.rate, doc.currency)}
      `; } else { - return `
      ${format_currency(item_data.price_list_rate || item_data.rate, doc.currency)}
      `; + return `
      ${format_currency( + item_data.price_list_rate || item_data.rate, + doc.currency + )}
      `; } } } @@ -121,31 +122,37 @@ erpnext.PointOfSale.PastOrderSummary = class { get_net_total_html(doc) { return `
      -
      ${__('Net Total')}
      +
      ${__("Net Total")}
      ${format_currency(doc.net_total, doc.currency)}
      `; } get_taxes_html(doc) { - if (!doc.taxes.length) return ''; + if (!doc.taxes.length) return ""; - let taxes_html = doc.taxes.map(t => { - // if tax rate is 0, don't print it. - const description = /[0-9]+/.test(t.description) ? t.description : ((t.rate != 0) ? `${t.description} @ ${t.rate}%`: t.description); - return ` + let taxes_html = doc.taxes + .map((t) => { + // if tax rate is 0, don't print it. + const description = /[0-9]+/.test(t.description) + ? t.description + : t.rate != 0 + ? `${t.description} @ ${t.rate}%` + : t.description; + return `
      ${description}
      ${format_currency(t.tax_amount_after_discount_amount, doc.currency)}
      `; - }).join(''); + }) + .join(""); return `
      ${taxes_html}
      `; } get_grand_total_html(doc) { return `
      -
      ${__('Grand Total')}
      +
      ${__("Grand Total")}
      ${format_currency(doc.grand_total, doc.currency)}
      `; } @@ -158,26 +165,26 @@ erpnext.PointOfSale.PastOrderSummary = class { } bind_events() { - this.$summary_container.on('click', '.return-btn', () => { + this.$summary_container.on("click", ".return-btn", () => { this.events.process_return(this.doc.name); this.toggle_component(false); - this.$component.find('.no-summary-placeholder').css('display', 'flex'); - this.$summary_wrapper.css('display', 'none'); + this.$component.find(".no-summary-placeholder").css("display", "flex"); + this.$summary_wrapper.css("display", "none"); }); - this.$summary_container.on('click', '.edit-btn', () => { + this.$summary_container.on("click", ".edit-btn", () => { this.events.edit_order(this.doc.name); this.toggle_component(false); - this.$component.find('.no-summary-placeholder').css('display', 'flex'); - this.$summary_wrapper.css('display', 'none'); + this.$component.find(".no-summary-placeholder").css("display", "flex"); + this.$summary_wrapper.css("display", "none"); }); - this.$summary_container.on('click', '.delete-btn', () => { + this.$summary_container.on("click", ".delete-btn", () => { this.events.delete_order(this.doc.name); this.show_summary_placeholder(); }); - this.$summary_container.on('click', '.delete-btn', () => { + this.$summary_container.on("click", ".delete-btn", () => { this.events.delete_order(this.doc.name); this.show_summary_placeholder(); // this.toggle_component(false); @@ -185,19 +192,19 @@ erpnext.PointOfSale.PastOrderSummary = class { // this.$summary_wrapper.addClass('d-none'); }); - this.$summary_container.on('click', '.new-btn', () => { + this.$summary_container.on("click", ".new-btn", () => { this.events.new_order(); this.toggle_component(false); - this.$component.find('.no-summary-placeholder').css('display', 'flex'); - this.$summary_wrapper.css('display', 'none'); + this.$component.find(".no-summary-placeholder").css("display", "flex"); + this.$summary_wrapper.css("display", "none"); }); - this.$summary_container.on('click', '.email-btn', () => { + this.$summary_container.on("click", ".email-btn", () => { this.email_dialog.fields_dict.email_id.set_value(this.customer_email); this.email_dialog.show(); }); - this.$summary_container.on('click', '.print-btn', () => { + this.$summary_container.on("click", ".print-btn", () => { this.print_receipt(); }); } @@ -214,29 +221,31 @@ erpnext.PointOfSale.PastOrderSummary = class { } attach_shortcuts() { - const ctrl_label = frappe.utils.is_mac() ? '⌘' : 'Ctrl'; - this.$summary_container.find('.print-btn').attr("title", `${ctrl_label}+P`); + const ctrl_label = frappe.utils.is_mac() ? "⌘" : "Ctrl"; + this.$summary_container.find(".print-btn").attr("title", `${ctrl_label}+P`); frappe.ui.keys.add_shortcut({ shortcut: "ctrl+p", - action: () => this.$summary_container.find('.print-btn').click(), - condition: () => this.$component.is(':visible') && this.$summary_container.find('.print-btn').is(":visible"), + action: () => this.$summary_container.find(".print-btn").click(), + condition: () => + this.$component.is(":visible") && this.$summary_container.find(".print-btn").is(":visible"), description: __("Print Receipt"), - page: cur_page.page.page + page: cur_page.page.page, }); - this.$summary_container.find('.new-btn').attr("title", `${ctrl_label}+Enter`); + this.$summary_container.find(".new-btn").attr("title", `${ctrl_label}+Enter`); frappe.ui.keys.on("ctrl+enter", () => { const summary_is_visible = this.$component.is(":visible"); - if (summary_is_visible && this.$summary_container.find('.new-btn').is(":visible")) { - this.$summary_container.find('.new-btn').click(); + if (summary_is_visible && this.$summary_container.find(".new-btn").is(":visible")) { + this.$summary_container.find(".new-btn").click(); } }); - this.$summary_container.find('.edit-btn').attr("title", `${ctrl_label}+E`); + this.$summary_container.find(".edit-btn").attr("title", `${ctrl_label}+E`); frappe.ui.keys.add_shortcut({ shortcut: "ctrl+e", - action: () => this.$summary_container.find('.edit-btn').click(), - condition: () => this.$component.is(':visible') && this.$summary_container.find('.edit-btn').is(":visible"), + action: () => this.$summary_container.find(".edit-btn").click(), + condition: () => + this.$component.is(":visible") && this.$summary_container.find(".edit-btn").is(":visible"), description: __("Edit Receipt"), - page: cur_page.page.page + page: cur_page.page.page, }); } @@ -251,43 +260,44 @@ erpnext.PointOfSale.PastOrderSummary = class { method: "frappe.core.doctype.communication.email.make", args: { recipients: recipients, - subject: __(frm.meta.name) + ': ' + doc.name, - content: content ? content : __(frm.meta.name) + ': ' + doc.name, + subject: __(frm.meta.name) + ": " + doc.name, + content: content ? content : __(frm.meta.name) + ": " + doc.name, doctype: doc.doctype, name: doc.name, send_email: 1, print_format, sender_full_name: frappe.user.full_name(), - _lang: doc.language + _lang: doc.language, }, - callback: r => { + callback: (r) => { if (!r.exc) { frappe.utils.play_sound("email"); if (r.message["emails_not_sent_to"]) { - frappe.msgprint(__( - "Email not sent to {0} (unsubscribed / disabled)", - [ frappe.utils.escape_html(r.message["emails_not_sent_to"]) ] - )); + frappe.msgprint( + __("Email not sent to {0} (unsubscribed / disabled)", [ + frappe.utils.escape_html(r.message["emails_not_sent_to"]), + ]) + ); } else { frappe.show_alert({ - message: __('Email sent successfully.'), - indicator: 'green' + message: __("Email sent successfully."), + indicator: "green", }); } this.email_dialog.hide(); } else { frappe.msgprint(__("There were errors while sending email. Please try again.")); } - } + }, }); } add_summary_btns(map) { - this.$summary_btns.html(''); - map.forEach(m => { + this.$summary_btns.html(""); + map.forEach((m) => { if (m.condition) { - m.visible_btns.forEach(b => { - const class_name = b.split(' ')[0].toLowerCase(); + m.visible_btns.forEach((b) => { + const class_name = b.split(" ")[0].toLowerCase(); const btn = __(b); this.$summary_btns.append( `
      ${btn}
      ` @@ -295,34 +305,40 @@ erpnext.PointOfSale.PastOrderSummary = class { }); } }); - this.$summary_btns.children().last().removeClass('mr-4'); + this.$summary_btns.children().last().removeClass("mr-4"); } toggle_summary_placeholder(show) { if (show) { - this.$summary_wrapper.css('display', 'none'); - this.$component.find('.no-summary-placeholder').css('display', 'flex'); + this.$summary_wrapper.css("display", "none"); + this.$component.find(".no-summary-placeholder").css("display", "flex"); } else { - this.$summary_wrapper.css('display', 'flex'); - this.$component.find('.no-summary-placeholder').css('display', 'none'); + this.$summary_wrapper.css("display", "flex"); + this.$component.find(".no-summary-placeholder").css("display", "none"); } } get_condition_btn_map(after_submission) { if (after_submission) - return [{ condition: true, visible_btns: ['Print Receipt', 'Email Receipt', 'New Order'] }]; + return [{ condition: true, visible_btns: ["Print Receipt", "Email Receipt", "New Order"] }]; return [ - { condition: this.doc.docstatus === 0, visible_btns: ['Edit Order', 'Delete Order'] }, - { condition: !this.doc.is_return && this.doc.docstatus === 1, visible_btns: ['Print Receipt', 'Email Receipt', 'Return']}, - { condition: this.doc.is_return && this.doc.docstatus === 1, visible_btns: ['Print Receipt', 'Email Receipt']} + { condition: this.doc.docstatus === 0, visible_btns: ["Edit Order", "Delete Order"] }, + { + condition: !this.doc.is_return && this.doc.docstatus === 1, + visible_btns: ["Print Receipt", "Email Receipt", "Return"], + }, + { + condition: this.doc.is_return && this.doc.docstatus === 1, + visible_btns: ["Print Receipt", "Email Receipt"], + }, ]; } - load_summary_of(doc, after_submission=false) { - after_submission ? - this.$component.css('grid-column', 'span 10 / span 10') : - this.$component.css('grid-column', 'span 6 / span 6'); + load_summary_of(doc, after_submission = false) { + after_submission + ? this.$component.css("grid-column", "span 10 / span 10") + : this.$component.css("grid-column", "span 6 / span 6"); this.toggle_summary_placeholder(false); @@ -342,16 +358,16 @@ erpnext.PointOfSale.PastOrderSummary = class { } attach_document_info(doc) { - frappe.db.get_value('Customer', this.doc.customer, 'email_id').then(({ message }) => { - this.customer_email = message.email_id || ''; + frappe.db.get_value("Customer", this.doc.customer, "email_id").then(({ message }) => { + this.customer_email = message.email_id || ""; const upper_section_dom = this.get_upper_section_html(doc); this.$upper_section.html(upper_section_dom); }); } attach_items_info(doc) { - this.$items_container.html(''); - doc.items.forEach(item => { + this.$items_container.html(""); + doc.items.forEach((item) => { const item_dom = this.get_item_html(doc, item); this.$items_container.append(item_dom); this.set_dynamic_rate_header_width(); @@ -362,8 +378,7 @@ erpnext.PointOfSale.PastOrderSummary = class { const rate_cols = Array.from(this.$items_container.find(".item-rate-disc")); this.$items_container.find(".item-rate-disc").css("width", ""); let max_width = rate_cols.reduce((max_width, elm) => { - if ($(elm).width() > max_width) - max_width = $(elm).width(); + if ($(elm).width() > max_width) max_width = $(elm).width(); return max_width; }, 0); @@ -374,8 +389,8 @@ erpnext.PointOfSale.PastOrderSummary = class { } attach_payments_info(doc) { - this.$payment_container.html(''); - doc.payments.forEach(p => { + this.$payment_container.html(""); + doc.payments.forEach((p) => { if (p.amount) { const payment_dom = this.get_payment_html(doc, p); this.$payment_container.append(payment_dom); @@ -383,7 +398,7 @@ erpnext.PointOfSale.PastOrderSummary = class { }); if (doc.redeem_loyalty_points && doc.loyalty_amount) { const payment_dom = this.get_payment_html(doc, { - mode_of_payment: 'Loyalty Points', + mode_of_payment: "Loyalty Points", amount: doc.loyalty_amount, }); this.$payment_container.append(payment_dom); @@ -391,7 +406,7 @@ erpnext.PointOfSale.PastOrderSummary = class { } attach_totals_info(doc) { - this.$totals_container.html(''); + this.$totals_container.html(""); const net_total_dom = this.get_net_total_html(doc); const taxes_dom = this.get_taxes_html(doc); @@ -404,6 +419,6 @@ erpnext.PointOfSale.PastOrderSummary = class { } toggle_component(show) { - show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none'); + show ? this.$component.css("display", "flex") : this.$component.css("display", "none"); } }; diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js index 588b6987ab6..cadbfa70415 100644 --- a/erpnext/selling/page/point_of_sale/pos_payment.js +++ b/erpnext/selling/page/point_of_sale/pos_payment.js @@ -12,17 +12,16 @@ erpnext.PointOfSale.Payment = class { this.initialize_numpad(); this.bind_events(); this.attach_shortcuts(); - } prepare_dom() { this.wrapper.append( `
      - +
      - +
      @@ -33,12 +32,12 @@ erpnext.PointOfSale.Payment = class {
      ${__("Complete Order")}
      ` ); - this.$component = this.wrapper.find('.payment-container'); - this.$payment_modes = this.$component.find('.payment-modes'); - this.$totals_section = this.$component.find('.totals-section'); - this.$totals = this.$component.find('.totals'); - this.$numpad = this.$component.find('.number-pad'); - this.$invoice_fields_section = this.$component.find('.fields-section'); + this.$component = this.wrapper.find(".payment-container"); + this.$payment_modes = this.$component.find(".payment-modes"); + this.$totals_section = this.$component.find(".totals-section"); + this.$totals = this.$component.find(".totals"); + this.$numpad = this.$component.find(".number-pad"); + this.$invoice_fields_section = this.$component.find(".fields-section"); } make_invoice_fields_control() { @@ -46,33 +45,33 @@ erpnext.PointOfSale.Payment = class { const fields = doc.invoice_fields; if (!fields.length) return; - this.$invoice_fields = this.$invoice_fields_section.find('.invoice-fields'); - this.$invoice_fields.html(''); + this.$invoice_fields = this.$invoice_fields_section.find(".invoice-fields"); + this.$invoice_fields.html(""); const frm = this.events.get_frm(); - fields.forEach(df => { + fields.forEach((df) => { this.$invoice_fields.append( `
      ` ); let df_events = { - onchange: function() { + onchange: function () { frm.set_value(this.df.fieldname, this.get_value()); - } + }, }; if (df.fieldtype == "Button") { df_events = { - click: function() { + click: function () { if (frm.script_manager.has_handlers(df.fieldname, frm.doc.doctype)) { frm.script_manager.trigger(df.fieldname, frm.doc.doctype, frm.doc.docname); } - } + }, }; } this[`${df.fieldname}_field`] = frappe.ui.form.make_control({ df: { ...df, - ...df_events + ...df_events, }, parent: this.$invoice_fields.find(`.${df.fieldname}-field`), render_input: true, @@ -87,34 +86,35 @@ erpnext.PointOfSale.Payment = class { this.number_pad = new erpnext.PointOfSale.NumberPad({ wrapper: this.$numpad, events: { - numpad_event: function($btn) { + numpad_event: function ($btn) { me.on_numpad_clicked($btn); - } + }, }, cols: 3, keys: [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ], - [ '.', 0, 'Delete' ] + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + [".", 0, "Delete"], ], }); - this.numpad_value = ''; + this.numpad_value = ""; } on_numpad_clicked($btn) { - const button_value = $btn.attr('data-button-value'); + const button_value = $btn.attr("data-button-value"); highlight_numpad_btn($btn); - this.numpad_value = button_value === 'delete' ? this.numpad_value.slice(0, -1) : this.numpad_value + button_value; + this.numpad_value = + button_value === "delete" ? this.numpad_value.slice(0, -1) : this.numpad_value + button_value; this.selected_mode.$input.get(0).focus(); this.selected_mode.set_value(this.numpad_value); function highlight_numpad_btn($btn) { - $btn.addClass('shadow-base-inner bg-selected'); + $btn.addClass("shadow-base-inner bg-selected"); setTimeout(() => { - $btn.removeClass('shadow-base-inner bg-selected'); + $btn.removeClass("shadow-base-inner bg-selected"); }, 100); } } @@ -122,36 +122,37 @@ erpnext.PointOfSale.Payment = class { bind_events() { const me = this; - this.$payment_modes.on('click', '.mode-of-payment', function(e) { + this.$payment_modes.on("click", ".mode-of-payment", function (e) { const mode_clicked = $(this); // if clicked element doesn't have .mode-of-payment class then return if (!$(e.target).is(mode_clicked)) return; - const scrollLeft = mode_clicked.offset().left - me.$payment_modes.offset().left + me.$payment_modes.scrollLeft(); + const scrollLeft = + mode_clicked.offset().left - me.$payment_modes.offset().left + me.$payment_modes.scrollLeft(); me.$payment_modes.animate({ scrollLeft }); - const mode = mode_clicked.attr('data-mode'); + const mode = mode_clicked.attr("data-mode"); // hide all control fields and shortcuts - $(`.mode-of-payment-control`).css('display', 'none'); - $(`.cash-shortcuts`).css('display', 'none'); - me.$payment_modes.find(`.pay-amount`).css('display', 'inline'); - me.$payment_modes.find(`.loyalty-amount-name`).css('display', 'none'); + $(`.mode-of-payment-control`).css("display", "none"); + $(`.cash-shortcuts`).css("display", "none"); + me.$payment_modes.find(`.pay-amount`).css("display", "inline"); + me.$payment_modes.find(`.loyalty-amount-name`).css("display", "none"); // remove highlight from all mode-of-payments - $('.mode-of-payment').removeClass('border-primary'); + $(".mode-of-payment").removeClass("border-primary"); - if (mode_clicked.hasClass('border-primary')) { + if (mode_clicked.hasClass("border-primary")) { // clicked one is selected then unselect it - mode_clicked.removeClass('border-primary'); - me.selected_mode = ''; + mode_clicked.removeClass("border-primary"); + me.selected_mode = ""; } else { // clicked one is not selected then select it - mode_clicked.addClass('border-primary'); - mode_clicked.find('.mode-of-payment-control').css('display', 'flex'); - mode_clicked.find('.cash-shortcuts').css('display', 'grid'); - me.$payment_modes.find(`.${mode}-amount`).css('display', 'none'); - me.$payment_modes.find(`.${mode}-name`).css('display', 'inline'); + mode_clicked.addClass("border-primary"); + mode_clicked.find(".mode-of-payment-control").css("display", "flex"); + mode_clicked.find(".cash-shortcuts").css("display", "grid"); + me.$payment_modes.find(`.${mode}-amount`).css("display", "none"); + me.$payment_modes.find(`.${mode}-name`).css("display", "inline"); me.selected_mode = me[`${mode}_control`]; me.selected_mode && me.selected_mode.$input.get(0).focus(); @@ -159,33 +160,33 @@ erpnext.PointOfSale.Payment = class { } }); - frappe.ui.form.on('POS Invoice', 'contact_mobile', (frm) => { + frappe.ui.form.on("POS Invoice", "contact_mobile", (frm) => { const contact = frm.doc.contact_mobile; const request_button = $(this.request_for_payment_field?.$input[0]); if (contact) { - request_button.removeClass('btn-default').addClass('btn-primary'); + request_button.removeClass("btn-default").addClass("btn-primary"); } else { - request_button.removeClass('btn-primary').addClass('btn-default'); + request_button.removeClass("btn-primary").addClass("btn-default"); } }); - frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => { + frappe.ui.form.on("POS Invoice", "coupon_code", (frm) => { if (frm.doc.coupon_code && !frm.applying_pos_coupon_code) { if (!frm.doc.ignore_pricing_rule) { frm.applying_pos_coupon_code = true; frappe.run_serially([ - () => frm.doc.ignore_pricing_rule=1, - () => frm.trigger('ignore_pricing_rule'), - () => frm.doc.ignore_pricing_rule=0, - () => frm.trigger('apply_pricing_rule'), + () => (frm.doc.ignore_pricing_rule = 1), + () => frm.trigger("ignore_pricing_rule"), + () => (frm.doc.ignore_pricing_rule = 0), + () => frm.trigger("apply_pricing_rule"), () => frm.save(), () => this.update_totals_section(frm.doc), - () => (frm.applying_pos_coupon_code = false) + () => (frm.applying_pos_coupon_code = false), ]); } else if (frm.doc.ignore_pricing_rule) { frappe.show_alert({ message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."), - indicator: "orange" + indicator: "orange", }); } } @@ -193,18 +194,20 @@ erpnext.PointOfSale.Payment = class { this.setup_listener_for_payments(); - this.$payment_modes.on('click', '.shortcut', function() { - const value = $(this).attr('data-value'); + this.$payment_modes.on("click", ".shortcut", function () { + const value = $(this).attr("data-value"); me.selected_mode.set_value(value); }); - this.$component.on('click', '.submit-order-btn', () => { + this.$component.on("click", ".submit-order-btn", () => { const doc = this.events.get_frm().doc; const paid_amount = doc.paid_amount; const items = doc.items; if (!items.length || (paid_amount == 0 && doc.additional_discount_percentage != 100)) { - const message = items.length ? __("You cannot submit the order without payment.") : __("You cannot submit empty order."); + const message = items.length + ? __("You cannot submit the order without payment.") + : __("You cannot submit empty order."); frappe.show_alert({ message, indicator: "orange" }); frappe.utils.play_sound("error"); return; @@ -213,17 +216,18 @@ erpnext.PointOfSale.Payment = class { this.events.submit_invoice(); }); - frappe.ui.form.on('POS Invoice', 'paid_amount', (frm) => { + frappe.ui.form.on("POS Invoice", "paid_amount", (frm) => { this.update_totals_section(frm.doc); // need to re calculate cash shortcuts after discount is applied - const is_cash_shortcuts_invisible = !this.$payment_modes.find('.cash-shortcuts').is(':visible'); + const is_cash_shortcuts_invisible = !this.$payment_modes.find(".cash-shortcuts").is(":visible"); this.attach_cash_shortcuts(frm.doc); - !is_cash_shortcuts_invisible && this.$payment_modes.find('.cash-shortcuts').css('display', 'grid'); + !is_cash_shortcuts_invisible && + this.$payment_modes.find(".cash-shortcuts").css("display", "grid"); this.render_payment_mode_dom(); }); - frappe.ui.form.on('POS Invoice', 'loyalty_amount', (frm) => { + frappe.ui.form.on("POS Invoice", "loyalty_amount", (frm) => { const formatted_currency = format_currency(frm.doc.loyalty_amount, frm.doc.currency); this.$payment_modes.find(`.loyalty-amount-amount`).html(formatted_currency); }); @@ -246,28 +250,36 @@ erpnext.PointOfSale.Payment = class { if (success) { title = __("Payment Received"); - const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total; + const grand_total = cint(frappe.sys_defaults.disable_rounded_total) + ? doc.grand_total + : doc.rounded_total; if (amount >= grand_total) { frappe.dom.unfreeze(); - message = __("Payment of {0} received successfully.", [format_currency(amount, doc.currency, 0)]); + message = __("Payment of {0} received successfully.", [ + format_currency(amount, doc.currency, 0), + ]); this.events.submit_invoice(); cur_frm.reload_doc(); - } else { - message = __("Payment of {0} received successfully. Waiting for other requests to complete...", [format_currency(amount, doc.currency, 0)]); + message = __( + "Payment of {0} received successfully. Waiting for other requests to complete...", + [format_currency(amount, doc.currency, 0)] + ); } } else if (failure_message) { message = failure_message; title = __("Payment Failed"); } - frappe.msgprint({ "message": message, "title": title }); + frappe.msgprint({ message: message, title: title }); }); } auto_set_remaining_amount() { const doc = this.events.get_frm().doc; - const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total; + const grand_total = cint(frappe.sys_defaults.disable_rounded_total) + ? doc.grand_total + : doc.rounded_total; const remaining_amount = grand_total - doc.paid_amount; const current_value = this.selected_mode ? this.selected_mode.get_value() : undefined; if (!current_value && remaining_amount > 0 && this.selected_mode) { @@ -276,13 +288,13 @@ erpnext.PointOfSale.Payment = class { } attach_shortcuts() { - const ctrl_label = frappe.utils.is_mac() ? '⌘' : 'Ctrl'; - this.$component.find('.submit-order-btn').attr("title", `${ctrl_label}+Enter`); + const ctrl_label = frappe.utils.is_mac() ? "⌘" : "Ctrl"; + this.$component.find(".submit-order-btn").attr("title", `${ctrl_label}+Enter`); frappe.ui.keys.on("ctrl+enter", () => { const payment_is_visible = this.$component.is(":visible"); const active_mode = this.$payment_modes.find(".border-primary"); if (payment_is_visible && active_mode.length) { - this.$component.find('.submit-order-btn').click(); + this.$component.find(".submit-order-btn").click(); } }); @@ -295,19 +307,24 @@ erpnext.PointOfSale.Payment = class { if (!active_mode) return; - const mode_of_payments = Array.from(this.$payment_modes.find(".mode-of-payment")).map(m => $(m).attr("data-mode")); + const mode_of_payments = Array.from(this.$payment_modes.find(".mode-of-payment")).map((m) => + $(m).attr("data-mode") + ); const mode_index = mode_of_payments.indexOf(active_mode); const next_mode_index = (mode_index + 1) % mode_of_payments.length; - const next_mode_to_be_clicked = this.$payment_modes.find(`.mode-of-payment[data-mode="${mode_of_payments[next_mode_index]}"]`); + const next_mode_to_be_clicked = this.$payment_modes.find( + `.mode-of-payment[data-mode="${mode_of_payments[next_mode_index]}"]` + ); if (payment_is_visible && mode_index != next_mode_index) { next_mode_to_be_clicked.click(); } }, - condition: () => this.$component.is(':visible') && this.$payment_modes.find(".border-primary").length, + condition: () => + this.$component.is(":visible") && this.$payment_modes.find(".border-primary").length, description: __("Switch Between Payment Modes"), ignore_inputs: true, - page: cur_page.page.page + page: cur_page.page.page, }); } @@ -341,20 +358,20 @@ erpnext.PointOfSale.Payment = class { } toggle_remarks_control() { - if (this.$remarks.find('.frappe-control').length) { - this.$remarks.html('+ Add Remark'); + if (this.$remarks.find(".frappe-control").length) { + this.$remarks.html("+ Add Remark"); } else { - this.$remarks.html(''); + this.$remarks.html(""); this[`remark_control`] = frappe.ui.form.make_control({ df: { - label: __('Remark'), - fieldtype: 'Data', - onchange: function() {} + label: __("Remark"), + fieldtype: "Data", + onchange: function () {}, }, parent: this.$totals_section.find(`.remarks`), render_input: true, }); - this[`remark_control`].set_value(''); + this[`remark_control`].set_value(""); } } @@ -363,14 +380,15 @@ erpnext.PointOfSale.Payment = class { const payments = doc.payments; const currency = doc.currency; - this.$payment_modes.html(`${ - payments.map((p, i) => { - const mode = p.mode_of_payment.replace(/ +/g, "_").toLowerCase(); - const payment_type = p.type; - const margin = i % 2 === 0 ? 'pr-2' : 'pl-2'; - const amount = p.amount > 0 ? format_currency(p.amount, currency) : ''; + this.$payment_modes.html( + `${payments + .map((p, i) => { + const mode = p.mode_of_payment.replace(/ +/g, "_").toLowerCase(); + const payment_type = p.type; + const margin = i % 2 === 0 ? "pr-2" : "pl-2"; + const amount = p.amount > 0 ? format_currency(p.amount, currency) : ""; - return (` + return `
      ${p.mode_of_payment} @@ -378,29 +396,30 @@ erpnext.PointOfSale.Payment = class {
      - `); - }).join('') - }`); + `; + }) + .join("")}` + ); - payments.forEach(p => { + payments.forEach((p) => { const mode = p.mode_of_payment.replace(/ +/g, "_").toLowerCase(); const me = this; this[`${mode}_control`] = frappe.ui.form.make_control({ df: { label: p.mode_of_payment, - fieldtype: 'Currency', - placeholder: __('Enter {0} amount.', [__(p.mode_of_payment)]), - onchange: function() { - const current_value = frappe.model.get_value(p.doctype, p.name, 'amount'); + fieldtype: "Currency", + placeholder: __("Enter {0} amount.", [__(p.mode_of_payment)]), + onchange: function () { + const current_value = frappe.model.get_value(p.doctype, p.name, "amount"); if (current_value != this.value) { frappe.model - .set_value(p.doctype, p.name, 'amount', flt(this.value)) - .then(() => me.update_totals_section()) + .set_value(p.doctype, p.name, "amount", flt(this.value)) + .then(() => me.update_totals_section()); const formatted_currency = format_currency(this.value, currency); me.$payment_modes.find(`.${mode}-amount`).html(formatted_currency); } - } + }, }, parent: this.$payment_modes.find(`.${mode}.mode-of-payment-control`), render_input: true, @@ -417,7 +436,7 @@ erpnext.PointOfSale.Payment = class { focus_on_default_mop() { const doc = this.events.get_frm().doc; const payments = doc.payments; - payments.forEach(p => { + payments.forEach((p) => { const mode = p.mode_of_payment.replace(/ +/g, "_").toLowerCase(); if (p.default) { setTimeout(() => { @@ -428,17 +447,23 @@ erpnext.PointOfSale.Payment = class { } attach_cash_shortcuts(doc) { - const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total; + const grand_total = cint(frappe.sys_defaults.disable_rounded_total) + ? doc.grand_total + : doc.rounded_total; const currency = doc.currency; const shortcuts = this.get_cash_shortcuts(flt(grand_total)); - this.$payment_modes.find('.cash-shortcuts').remove(); - let shortcuts_html = shortcuts.map(s => { - return `
      ${format_currency(s, currency, 0)}
      `; - }).join(''); + this.$payment_modes.find(".cash-shortcuts").remove(); + let shortcuts_html = shortcuts + .map((s) => { + return `
      ${format_currency(s, currency, 0)}
      `; + }) + .join(""); - this.$payment_modes.find('[data-payment-type="Cash"]').find('.mode-of-payment-control') + this.$payment_modes + .find('[data-payment-type="Cash"]') + .find(".mode-of-payment-control") .after(`
      ${shortcuts_html}
      `); } @@ -446,10 +471,10 @@ erpnext.PointOfSale.Payment = class { let steps = [1, 5, 10]; const digits = String(Math.round(grand_total)).length; - steps = steps.map(x => x * (10 ** (digits - 2))); + steps = steps.map((x) => x * 10 ** (digits - 2)); const get_nearest = (amount, x) => { - let nearest_x = Math.ceil((amount / x)) * x; + let nearest_x = Math.ceil(amount / x) * x; return nearest_x === amount ? nearest_x + x : nearest_x; }; @@ -474,13 +499,16 @@ erpnext.PointOfSale.Payment = class { description = __("You don't have enough points to redeem."); read_only = true; } else { - max_redeemable_amount = flt(flt(loyalty_points) * flt(conversion_factor), precision("loyalty_amount", doc)); + max_redeemable_amount = flt( + flt(loyalty_points) * flt(conversion_factor), + precision("loyalty_amount", doc) + ); description = __("You can redeem upto {0}.", [format_currency(max_redeemable_amount)]); read_only = false; } - const margin = this.$payment_modes.children().length % 2 === 0 ? 'pr-2' : 'pl-2'; - const amount = doc.loyalty_amount > 0 ? format_currency(doc.loyalty_amount, doc.currency) : ''; + const margin = this.$payment_modes.children().length % 2 === 0 ? "pr-2" : "pl-2"; + const amount = doc.loyalty_amount > 0 ? format_currency(doc.loyalty_amount, doc.currency) : ""; this.$payment_modes.append( `
      @@ -492,35 +520,47 @@ erpnext.PointOfSale.Payment = class {
      ` ); - this['loyalty-amount_control'] = frappe.ui.form.make_control({ + this["loyalty-amount_control"] = frappe.ui.form.make_control({ df: { label: __("Redeem Loyalty Points"), - fieldtype: 'Currency', + fieldtype: "Currency", placeholder: __("Enter amount to be redeemed."), - options: 'company:currency', + options: "company:currency", read_only, - onchange: async function() { + onchange: async function () { if (!loyalty_points) return; if (this.value > max_redeemable_amount) { frappe.show_alert({ - message: __("You cannot redeem more than {0}.", [format_currency(max_redeemable_amount)]), - indicator: "red" + message: __("You cannot redeem more than {0}.", [ + format_currency(max_redeemable_amount), + ]), + indicator: "red", }); frappe.utils.play_sound("submit"); - me['loyalty-amount_control'].set_value(0); + me["loyalty-amount_control"].set_value(0); return; } const redeem_loyalty_points = this.value > 0 ? 1 : 0; - await frappe.model.set_value(doc.doctype, doc.name, 'redeem_loyalty_points', redeem_loyalty_points); - frappe.model.set_value(doc.doctype, doc.name, 'loyalty_points', parseInt(this.value / conversion_factor)); + await frappe.model.set_value( + doc.doctype, + doc.name, + "redeem_loyalty_points", + redeem_loyalty_points + ); + frappe.model.set_value( + doc.doctype, + doc.name, + "loyalty_points", + parseInt(this.value / conversion_factor) + ); }, - description + description, }, parent: this.$payment_modes.find(`.loyalty-amount.mode-of-payment-control`), render_input: true, }); - this['loyalty-amount_control'].toggle_label(false); + this["loyalty-amount_control"].toggle_label(false); // this.render_add_payment_method_dom(); } @@ -538,20 +578,22 @@ erpnext.PointOfSale.Payment = class { update_totals_section(doc) { if (!doc) doc = this.events.get_frm().doc; const paid_amount = doc.paid_amount; - const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total; + const grand_total = cint(frappe.sys_defaults.disable_rounded_total) + ? doc.grand_total + : doc.rounded_total; const remaining = grand_total - doc.paid_amount; const change = doc.change_amount || remaining <= 0 ? -1 * remaining : undefined; const currency = doc.currency; - const label = change ? __('Change') : __('To Be Paid'); + const label = change ? __("Change") : __("To Be Paid"); this.$totals.html( `
      -
      ${__('Grand Total')}
      +
      ${__("Grand Total")}
      ${format_currency(grand_total, currency)}
      -
      ${__('Paid Amount')}
      +
      ${__("Paid Amount")}
      ${format_currency(paid_amount, currency)}
      @@ -563,6 +605,6 @@ erpnext.PointOfSale.Payment = class { } toggle_component(show) { - show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none'); + show ? this.$component.css("display", "flex") : this.$component.css("display", "none"); } }; diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.js b/erpnext/selling/page/sales_funnel/sales_funnel.js index a0a1222eb3f..1d52597c6aa 100644 --- a/erpnext/selling/page/sales_funnel/sales_funnel.js +++ b/erpnext/selling/page/sales_funnel/sales_funnel.js @@ -1,23 +1,23 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.pages['sales-funnel'].on_page_load = function(wrapper) { +frappe.pages["sales-funnel"].on_page_load = function (wrapper) { frappe.ui.make_app_page({ parent: wrapper, - title: __('Sales Funnel'), - single_column: true + title: __("Sales Funnel"), + single_column: true, }); wrapper.sales_funnel = new erpnext.SalesFunnel(wrapper); frappe.breadcrumbs.add("Selling"); -} +}; erpnext.SalesFunnel = class SalesFunnel { constructor(wrapper) { var me = this; // 0 setTimeout hack - this gives time for canvas to get width and height - setTimeout(function() { + setTimeout(function () { me.setup(wrapper); me.get_data(); }, 0); @@ -26,50 +26,65 @@ erpnext.SalesFunnel = class SalesFunnel { setup(wrapper) { var me = this; - this.company_field = wrapper.page.add_field({"fieldtype": "Link", "fieldname": "company", "options": "Company", - "label": __("Company"), "reqd": 1, "default": frappe.defaults.get_user_default('company'), - change: function() { - me.company = this.value || frappe.defaults.get_user_default('company'); + (this.company_field = wrapper.page.add_field({ + fieldtype: "Link", + fieldname: "company", + options: "Company", + label: __("Company"), + reqd: 1, + default: frappe.defaults.get_user_default("company"), + change: function () { + me.company = this.value || frappe.defaults.get_user_default("company"); me.get_data(); - } - }), + }, + })), + (this.elements = { + layout: $(wrapper).find(".layout-main"), + from_date: wrapper.page.add_date(__("From Date")), + to_date: wrapper.page.add_date(__("To Date")), + chart: wrapper.page.add_select(__("Chart"), [ + { value: "sales_funnel", label: __("Sales Funnel") }, + { value: "sales_pipeline", label: __("Sales Pipeline") }, + { value: "opp_by_lead_source", label: __("Opportunities by lead source") }, + ]), + refresh_btn: wrapper.page.set_primary_action( + __("Refresh"), + function () { + me.get_data(); + }, + "fa fa-refresh" + ), + }); - this.elements = { - layout: $(wrapper).find(".layout-main"), - from_date: wrapper.page.add_date(__("From Date")), - to_date: wrapper.page.add_date(__("To Date")), - chart: wrapper.page.add_select(__("Chart"), [{value: 'sales_funnel', label:__("Sales Funnel")}, - {value: 'sales_pipeline', label:__("Sales Pipeline")}, - {value: 'opp_by_lead_source', label:__("Opportunities by lead source")}]), - refresh_btn: wrapper.page.set_primary_action(__("Refresh"), - function() { me.get_data(); }, "fa fa-refresh"), - }; - - this.elements.no_data = $('
      ' + __("No Data") + '
      ') + this.elements.no_data = $('
      ' + __("No Data") + "
      ") .toggle(false) .appendTo(this.elements.layout); - this.elements.funnel_wrapper = $('
      ') - .appendTo(this.elements.layout); + this.elements.funnel_wrapper = $('
      ').appendTo( + this.elements.layout + ); - this.company = frappe.defaults.get_user_default('company'); + this.company = frappe.defaults.get_user_default("company"); this.options = { from_date: frappe.datetime.add_months(frappe.datetime.get_today(), -1), to_date: frappe.datetime.get_today(), - chart: 'sales_funnel' + chart: "sales_funnel", }; // set defaults and bind on change - $.each(this.options, function(k, v) { - if (['from_date', 'to_date'].includes(k)) { + $.each(this.options, function (k, v) { + if (["from_date", "to_date"].includes(k)) { me.elements[k].val(frappe.datetime.str_to_user(v)); } else { me.elements[k].val(v); } - me.elements[k].on("change", function() { - if (['from_date', 'to_date'].includes(k)) { - me.options[k] = frappe.datetime.user_to_str($(this).val()) != 'Invalid date' ? frappe.datetime.user_to_str($(this).val()) : frappe.datetime.get_today(); + me.elements[k].on("change", function () { + if (["from_date", "to_date"].includes(k)) { + me.options[k] = + frappe.datetime.user_to_str($(this).val()) != "Invalid date" + ? frappe.datetime.user_to_str($(this).val()) + : frappe.datetime.get_today(); } else { me.options.chart = $(this).val(); } @@ -78,12 +93,12 @@ erpnext.SalesFunnel = class SalesFunnel { }); // bind refresh - this.elements.refresh_btn.on("click", function() { + this.elements.refresh_btn.on("click", function () { me.get_data(this); }); // bind resize - $(window).resize(function() { + $(window).resize(function () { me.render(); }); } @@ -95,39 +110,39 @@ erpnext.SalesFunnel = class SalesFunnel { } const method_map = { - "sales_funnel": "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data", - "opp_by_lead_source": "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source", - "sales_pipeline": "erpnext.selling.page.sales_funnel.sales_funnel.get_pipeline_data" + sales_funnel: "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data", + opp_by_lead_source: "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source", + sales_pipeline: "erpnext.selling.page.sales_funnel.sales_funnel.get_pipeline_data", }; frappe.call({ method: method_map[this.options.chart], args: { from_date: this.options.from_date, to_date: this.options.to_date, - company: this.company + company: this.company, }, btn: btn, - callback: function(r) { - if(!r.exc) { + callback: function (r) { + if (!r.exc) { me.options.data = r.message; - if (me.options.data=='empty') { + if (me.options.data == "empty") { const $parent = me.elements.funnel_wrapper; - $parent.html(__('No data for this period')); + $parent.html(__("No data for this period")); } else { me.render(); } } - } + }, }); } render() { let me = this; - if (me.options.chart == 'sales_funnel'){ + if (me.options.chart == "sales_funnel") { me.render_funnel(); - } else if (me.options.chart == 'opp_by_lead_source'){ + } else if (me.options.chart == "opp_by_lead_source") { me.render_chart(__("Sales Opportunities by Source")); - } else if (me.options.chart == 'sales_pipeline'){ + } else if (me.options.chart == "sales_pipeline") { me.render_chart(__("Sales Pipeline by Stage")); } } @@ -143,12 +158,12 @@ erpnext.SalesFunnel = class SalesFunnel { y = 0, y_old = 0.0; - if(this.options.total_value === 0) { + if (this.options.total_value === 0) { this.elements.no_data.toggle(true); return; } - this.options.data.forEach(function(d) { + this.options.data.forEach(function (d) { context.fillStyle = d.color; context.strokeStyle = d.color; me.draw_triangle(x_start, x_mid, x_end, y, me.options.height); @@ -175,21 +190,22 @@ erpnext.SalesFunnel = class SalesFunnel { this.elements.no_data.toggle(false); // calculate width and height options - this.options.width = $(this.elements.funnel_wrapper).width() * 2.0 / 3.0; + this.options.width = ($(this.elements.funnel_wrapper).width() * 2.0) / 3.0; this.options.height = (Math.sqrt(3) * this.options.width) / 2.0; // calculate total weightage // as height decreases, area decreases by the square of the reduction // hence, compensating by squaring the index value - this.options.total_weightage = this.options.data.reduce( - function(prev, curr, i) { return prev + Math.pow(i+1, 2) * curr.value; }, 0.0); + this.options.total_weightage = this.options.data.reduce(function (prev, curr, i) { + return prev + Math.pow(i + 1, 2) * curr.value; + }, 0.0); // calculate height for each data - $.each(this.options.data, function(i, d) { - d.height = me.options.height * d.value * Math.pow(i+1, 2) / me.options.total_weightage; + $.each(this.options.data, function (i, d) { + d.height = (me.options.height * d.value * Math.pow(i + 1, 2)) / me.options.total_weightage; }); - this.elements.canvas = $('') + this.elements.canvas = $("") .appendTo(this.elements.funnel_wrapper.empty()) .attr("width", $(this.elements.funnel_wrapper).width()) .attr("height", this.options.height); @@ -211,7 +227,7 @@ erpnext.SalesFunnel = class SalesFunnel { draw_legend(x_mid, y_mid, width, height, title) { var context = this.elements.context; - if(y_mid == 0) { + if (y_mid == 0) { y_mid = 7; } @@ -246,13 +262,13 @@ erpnext.SalesFunnel = class SalesFunnel { title: title, height: 400, data: chart_data, - type: 'bar', + type: "bar", barOptions: { - stacked: 1 + stacked: 1, }, tooltipOptions: { - formatTooltipY: d => format_currency(d, currency), - } + formatTooltipY: (d) => format_currency(d, currency), + }, }); } }; diff --git a/erpnext/selling/report/address_and_contacts/address_and_contacts.js b/erpnext/selling/report/address_and_contacts/address_and_contacts.js index f81d1c10390..c19ed7d0091 100644 --- a/erpnext/selling/report/address_and_contacts/address_and_contacts.js +++ b/erpnext/selling/report/address_and_contacts/address_and_contacts.js @@ -1,34 +1,33 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Address And Contacts"] = { - "filters": [ + filters: [ { - "reqd": 1, - "fieldname":"party_type", - "label": __("Party Type"), - "fieldtype": "Link", - "options": "DocType", - "get_query": function() { + reqd: 1, + fieldname: "party_type", + label: __("Party Type"), + fieldtype: "Link", + options: "DocType", + get_query: function () { return { - "filters": { - "name": ["in","Customer,Supplier,Sales Partner,Lead"], - } - } - } + filters: { + name: ["in", "Customer,Supplier,Sales Partner,Lead"], + }, + }; + }, }, { - "fieldname":"party_name", - "label": __("Party Name"), - "fieldtype": "Dynamic Link", - "get_options": function() { - let party_type = frappe.query_report.get_filter_value('party_type'); - if(!party_type) { + fieldname: "party_name", + label: __("Party Name"), + fieldtype: "Dynamic Link", + get_options: function () { + let party_type = frappe.query_report.get_filter_value("party_type"); + if (!party_type) { frappe.throw(__("Please select Party Type first")); } return party_type; - } - } - ] -} + }, + }, + ], +}; diff --git a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.js b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.js index 1e83acdeb18..a9ee0cbf067 100644 --- a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.js +++ b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.js @@ -2,7 +2,5 @@ // For license information, please see license.txt frappe.query_reports["Available Stock for Packing Items"] = { - "filters": [ - - ] -} + filters: [], +}; diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.js b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.js index 744b5d982b5..745550b57c6 100644 --- a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.js +++ b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.js @@ -2,43 +2,43 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Customer Acquisition and Loyalty"] = { - "filters": [ + filters: [ { - "fieldname": "view_type", - "label": __("View Type"), - "fieldtype": "Select", - "options": ["Monthly", "Territory Wise"], - "default": "Monthly", - "reqd": 1 + fieldname: "view_type", + label: __("View Type"), + fieldtype: "Select", + options: ["Monthly", "Territory Wise"], + default: "Monthly", + reqd: 1, }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], - "reqd": 1 + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], + reqd: 1, }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2], - "reqd": 1 - } + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2], + reqd: 1, + }, ], - 'formatter': function(value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (data && data.bold) { value = value.bold(); } return value; - } -} + }, +}; diff --git a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js index 3a99eb0891d..9902abedfa3 100644 --- a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js +++ b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js @@ -2,20 +2,20 @@ // For license information, please see license.txt frappe.query_reports["Customer Credit Balance"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname":"customer", - "label": __("Customer"), - "fieldtype": "Link", - "options": "Customer" - } - ] -} + fieldname: "customer", + label: __("Customer"), + fieldtype: "Link", + options: "Customer", + }, + ], +}; diff --git a/erpnext/selling/report/customer_wise_item_price/customer_wise_item_price.js b/erpnext/selling/report/customer_wise_item_price/customer_wise_item_price.js index 2aac3436c07..02c71252ed3 100644 --- a/erpnext/selling/report/customer_wise_item_price/customer_wise_item_price.js +++ b/erpnext/selling/report/customer_wise_item_price/customer_wise_item_price.js @@ -1,27 +1,26 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Customer-wise Item Price"] = { - "filters": [ + filters: [ { - "label": __("Customer"), - "fieldname": "customer", - "fieldtype": "Link", - "options": "Customer", - "reqd": 1 + label: __("Customer"), + fieldname: "customer", + fieldtype: "Link", + options: "Customer", + reqd: 1, }, { - "label": __("Item"), - "fieldname": "item", - "fieldtype": "Link", - "options": "Item", - "get_query": () => { + label: __("Item"), + fieldname: "item", + fieldtype: "Link", + options: "Item", + get_query: () => { return { query: "erpnext.controllers.queries.item_query", - filters: { 'is_sales_item': 1 } - } - } - } - ] -} + filters: { is_sales_item: 1 }, + }; + }, + }, + ], +}; diff --git a/erpnext/selling/report/inactive_customers/inactive_customers.js b/erpnext/selling/report/inactive_customers/inactive_customers.js index 804d17e2b0b..a191d564fee 100644 --- a/erpnext/selling/report/inactive_customers/inactive_customers.js +++ b/erpnext/selling/report/inactive_customers/inactive_customers.js @@ -2,19 +2,19 @@ // For license information, please see license.txt frappe.query_reports["Inactive Customers"] = { - "filters": [ + filters: [ { - "fieldname":"days_since_last_order", - "label": __("Days Since Last Order"), - "fieldtype": "Int", - "default": 60 + fieldname: "days_since_last_order", + label: __("Days Since Last Order"), + fieldtype: "Int", + default: 60, }, { - "fieldname":"doctype", - "label": __("Doctype"), - "fieldtype": "Select", - "default": "Sales Order", - "options": "Sales Order\nSales Invoice" - } - ] -} + fieldname: "doctype", + label: __("Doctype"), + fieldtype: "Select", + default: "Sales Order", + options: "Sales Order\nSales Invoice", + }, + ], +}; diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js index f63d02ec84b..2b4b8e714ed 100644 --- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js +++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.js @@ -1,57 +1,56 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Item-wise Sales History"] = { - "filters": [ + filters: [ { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { - fieldname:"from_date", + fieldname: "from_date", reqd: 1, label: __("From Date"), fieldtype: "Date", default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - fieldname:"to_date", + fieldname: "to_date", reqd: 1, default: frappe.datetime.get_today(), label: __("To Date"), fieldtype: "Date", }, { - fieldname:"item_group", + fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", - options: "Item Group" + options: "Item Group", }, { - fieldname:"item_code", + fieldname: "item_code", label: __("Item"), fieldtype: "Link", options: "Item", get_query: () => { return { - query: "erpnext.controllers.queries.item_query" - } - } + query: "erpnext.controllers.queries.item_query", + }; + }, }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", - options: "Customer" - } + options: "Customer", + }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); let format_fields = ["delivered_quantity", "billed_amount"]; @@ -59,5 +58,5 @@ frappe.query_reports["Item-wise Sales History"] = { value = "" + value + ""; } return value; - } + }, }; diff --git a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js index 0203a054f99..99ef5e40f3b 100644 --- a/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js +++ b/erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.js @@ -1,144 +1,138 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - function get_filters() { let filters = [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"period_start_date", - "label": __("Start Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1) + fieldname: "period_start_date", + label: __("Start Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - "fieldname":"period_end_date", - "label": __("End Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.get_today() + fieldname: "period_end_date", + label: __("End Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.get_today(), }, { - "fieldname":"customer_group", - "label": __("Customer Group"), - "fieldtype": "Link", - "width": 100, - "options": "Customer Group", + fieldname: "customer_group", + label: __("Customer Group"), + fieldtype: "Link", + width: 100, + options: "Customer Group", }, { - "fieldname":"customer", - "label": __("Customer"), - "fieldtype": "Link", - "width": 100, - "options": "Customer", - "get_query": () => { - var customer_group = frappe.query_report.get_filter_value('customer_group'); - return{ - "query": "erpnext.selling.report.payment_terms_status_for_sales_order.payment_terms_status_for_sales_order.get_customers_or_items", - "filters": [ - ['Customer', 'disabled', '=', '0'], - ['Customer Group','name', '=', customer_group] - ] - } - } + fieldname: "customer", + label: __("Customer"), + fieldtype: "Link", + width: 100, + options: "Customer", + get_query: () => { + var customer_group = frappe.query_report.get_filter_value("customer_group"); + return { + query: "erpnext.selling.report.payment_terms_status_for_sales_order.payment_terms_status_for_sales_order.get_customers_or_items", + filters: [ + ["Customer", "disabled", "=", "0"], + ["Customer Group", "name", "=", customer_group], + ], + }; + }, }, { - "fieldname":"item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "width": 100, - "options": "Item Group", - + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + width: 100, + options: "Item Group", }, { - "fieldname":"item", - "label": __("Item"), - "fieldtype": "Link", - "width": 100, - "options": "Item", - "get_query": () => { - var item_group = frappe.query_report.get_filter_value('item_group'); - return{ - "query": "erpnext.selling.report.payment_terms_status_for_sales_order.payment_terms_status_for_sales_order.get_customers_or_items", - "filters": [ - ['Item', 'disabled', '=', '0'], - ['Item Group','name', '=', item_group] - ] - } - } + fieldname: "item", + label: __("Item"), + fieldtype: "Link", + width: 100, + options: "Item", + get_query: () => { + var item_group = frappe.query_report.get_filter_value("item_group"); + return { + query: "erpnext.selling.report.payment_terms_status_for_sales_order.payment_terms_status_for_sales_order.get_customers_or_items", + filters: [ + ["Item", "disabled", "=", "0"], + ["Item Group", "name", "=", item_group], + ], + }; + }, }, { - "fieldname":"from_due_date", - "label": __("From Due Date"), - "fieldtype": "Date", + fieldname: "from_due_date", + label: __("From Due Date"), + fieldtype: "Date", }, { - "fieldname":"to_due_date", - "label": __("To Due Date"), - "fieldtype": "Date", + fieldname: "to_due_date", + label: __("To Due Date"), + fieldtype: "Date", }, { - "fieldname":"status", - "label": __("Status"), - "fieldtype": "MultiSelectList", - "width": 100, - get_data: function(txt) { - let status = ["Overdue", "Unpaid", "Completed", "Partly Paid"] - let options = [] - for (let option of status){ + fieldname: "status", + label: __("Status"), + fieldtype: "MultiSelectList", + width: 100, + get_data: function (txt) { + let status = ["Overdue", "Unpaid", "Completed", "Partly Paid"]; + let options = []; + for (let option of status) { options.push({ - "value": option, - "label": __(option), - "description": "" - }) + value: option, + label: __(option), + description: "", + }); } - return options - } + return options; + }, }, { - "fieldname":"only_immediate_upcoming_term", - "label": __("Show only the Immediate Upcoming Term"), - "fieldtype": "Check", + fieldname: "only_immediate_upcoming_term", + label: __("Show only the Immediate Upcoming Term"), + fieldtype: "Check", }, - ] + ]; return filters; } frappe.query_reports["Payment Terms Status for Sales Order"] = { - "filters": get_filters(), - "formatter": function(value, row, column, data, default_formatter){ - if(column.fieldname == 'invoices' && value) { - let invoices = value.split(','); + filters: get_filters(), + formatter: function (value, row, column, data, default_formatter) { + if (column.fieldname == "invoices" && value) { + let invoices = value.split(","); const invoice_formatter = (prev_value, curr_value) => { - if(prev_value != "") { + if (prev_value != "") { return prev_value + ", " + default_formatter(curr_value, row, column, data); - } - else { + } else { return default_formatter(curr_value, row, column, data); } - } - return invoices.reduce(invoice_formatter, "") - } - else if (column.fieldname == 'paid_amount' && value){ + }; + return invoices.reduce(invoice_formatter, ""); + } else if (column.fieldname == "paid_amount" && value) { let formatted_value = default_formatter(value, row, column, data); - if(value > 0) { - formatted_value = "" + formatted_value + "" + if (value > 0) { + formatted_value = "" + formatted_value + ""; } return formatted_value; - } - else if (column.fieldname == 'status' && value == 'Completed'){ + } else if (column.fieldname == "status" && value == "Completed") { return "" + default_formatter(value, row, column, data) + ""; } return default_formatter(value, row, column, data); }, - }; diff --git a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.js b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.js index 204205949e9..76d04b03f9b 100644 --- a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.js +++ b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.js @@ -1,6 +1,4 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - -frappe.query_reports["Pending SO Items For Purchase Request"] = { -} +frappe.query_reports["Pending SO Items For Purchase Request"] = {}; diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.js b/erpnext/selling/report/quotation_trends/quotation_trends.js index 97a19315ec3..8ffeda47b64 100644 --- a/erpnext/selling/report/quotation_trends/quotation_trends.js +++ b/erpnext/selling/report/quotation_trends/quotation_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { +frappe.require("assets/erpnext/js/sales_trends_filters.js", function () { frappe.query_reports["Quotation Trends"] = { - filters: erpnext.get_sales_trends_filters() - } + filters: erpnext.get_sales_trends_filters(), + }; }); diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js index abe4f011364..a01103afb96 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.js +++ b/erpnext/selling/report/sales_analytics/sales_analytics.js @@ -1,49 +1,56 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Analytics"] = { - "filters": [ + filters: [ { fieldname: "tree_type", label: __("Tree Type"), fieldtype: "Select", - options: ["Customer Group", "Customer", "Item Group", "Item", "Territory", "Order Type", "Project"], + options: [ + "Customer Group", + "Customer", + "Item Group", + "Item", + "Territory", + "Order Type", + "Project", + ], default: "Customer", - reqd: 1 + reqd: 1, }, { fieldname: "doc_type", label: __("based_on"), fieldtype: "Select", - options: ["Sales Order","Delivery Note","Sales Invoice"], + options: ["Sales Order", "Delivery Note", "Sales Invoice"], default: "Sales Invoice", - reqd: 1 + reqd: 1, }, { fieldname: "value_quantity", label: __("Value Or Qty"), fieldtype: "Select", options: [ - { "value": "Value", "label": __("Value") }, - { "value": "Quantity", "label": __("Quantity") }, + { value: "Value", label: __("Value") }, + { value: "Quantity", label: __("Quantity") }, ], default: "Value", - reqd: 1 + reqd: 1, }, { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2], - reqd: 1 + reqd: 1, }, { fieldname: "company", @@ -51,21 +58,21 @@ frappe.query_reports["Sales Analytics"] = { fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { fieldname: "range", label: __("Range"), fieldtype: "Select", options: [ - { "value": "Weekly", "label": __("Weekly") }, - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Weekly", label: __("Weekly") }, + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Yearly", label: __("Yearly") }, ], default: "Monthly", - reqd: 1 - } + reqd: 1, + }, ], get_datatable_options(options) { return Object.assign(options, { @@ -73,32 +80,26 @@ frappe.query_reports["Sales Analytics"] = { events: { onCheckRow: function (data) { if (!data) return; - const data_doctype = $( - data[2].html - )[0].attributes.getNamedItem("data-doctype").value; + const data_doctype = $(data[2].html)[0].attributes.getNamedItem("data-doctype").value; const tree_type = frappe.query_report.filters[0].value; if (data_doctype != tree_type) return; const row_name = data[2].content; const raw_data = frappe.query_report.chart.data; const new_datasets = raw_data.datasets; - const element_found = new_datasets.some( - (element, index, array) => { - if (element.name == row_name) { - array.splice(index, 1); - return true; - } - return false; + const element_found = new_datasets.some((element, index, array) => { + if (element.name == row_name) { + array.splice(index, 1); + return true; } - ); + return false; + }); const slice_at = { Customer: 4, Item: 5 }[tree_type] || 3; if (!element_found) { new_datasets.push({ name: row_name, - values: data - .slice(slice_at, data.length - 1) - .map(column => column.content), + values: data.slice(slice_at, data.length - 1).map((column) => column.content), }); } @@ -106,7 +107,9 @@ frappe.query_reports["Sales Analytics"] = { labels: raw_data.labels, datasets: new_datasets, }; - const new_options = Object.assign({}, frappe.query_report.chart_options, {data: new_data}); + const new_options = Object.assign({}, frappe.query_report.chart_options, { + data: new_data, + }); frappe.query_report.render_chart(new_options); frappe.query_report.raw_chart_data = new_data; diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js index fc685e0fe96..2b6e1434525 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.js @@ -1,82 +1,81 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Order Analysis"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "width": "80", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_default("company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + width: "80", + options: "Company", + reqd: 1, + default: frappe.defaults.get_default("company"), }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.get_today(), }, { - "fieldname": "sales_order", - "label": __("Sales Order"), - "fieldtype": "MultiSelectList", - "width": "80", - "options": "Sales Order", - "get_data": function(txt) { + fieldname: "sales_order", + label: __("Sales Order"), + fieldtype: "MultiSelectList", + width: "80", + options: "Sales Order", + get_data: function (txt) { return frappe.db.get_link_options("Sales Order", txt); }, - "get_query": () =>{ + get_query: () => { return { - filters: { "docstatus": 1 } - } - } + filters: { docstatus: 1 }, + }; + }, }, { - "fieldname": "warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse" + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", }, { - "fieldname": "status", - "label": __("Status"), - "fieldtype": "MultiSelectList", - "width": "80", - get_data: function(txt) { - let status = ["To Pay", "To Bill", "To Deliver", "To Deliver and Bill", "Completed"] - let options = [] - for (let option of status){ + fieldname: "status", + label: __("Status"), + fieldtype: "MultiSelectList", + width: "80", + get_data: function (txt) { + let status = ["To Pay", "To Bill", "To Deliver", "To Deliver and Bill", "Completed"]; + let options = []; + for (let option of status) { options.push({ - "value": option, - "label": __(option), - "description": "" - }) + value: option, + label: __(option), + description: "", + }); } - return options - } + return options; + }, }, { - "fieldname": "group_by_so", - "label": __("Group by Sales Order"), - "fieldtype": "Check", - "default": 0 - } + fieldname: "group_by_so", + label: __("Group by Sales Order"), + fieldtype: "Check", + default: 0, + }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); let format_fields = ["delivered_qty", "billed_amount"]; @@ -88,5 +87,5 @@ frappe.query_reports["Sales Order Analysis"] = { value = "" + value + ""; } return value; - } + }, }; 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 b22ea8fa2ca..fe38804ed45 100644 --- a/erpnext/selling/report/sales_order_trends/sales_order_trends.js +++ b/erpnext/selling/report/sales_order_trends/sales_order_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { +frappe.require("assets/erpnext/js/sales_trends_filters.js", function () { frappe.query_reports["Sales Order Trends"] = { - filters: erpnext.get_sales_trends_filters() - } + filters: erpnext.get_sales_trends_filters(), + }; }); diff --git a/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js index f08780ae724..4a1ebabbccf 100644 --- a/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js +++ b/erpnext/selling/report/sales_partner_commission_summary/sales_partner_commission_summary.js @@ -1,22 +1,20 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Partner Commission Summary"] = { - "filters": [ - + filters: [ { fieldname: "sales_partner", label: __("Sales Partner"), fieldtype: "Link", - options: "Sales Partner" + options: "Sales Partner", }, { fieldname: "doctype", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "from_date", @@ -25,30 +23,29 @@ frappe.query_reports["Sales Partner Commission Summary"] = { default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.get_today() + default: frappe.datetime.get_today(), }, { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"territory", + fieldname: "territory", label: __("Territory"), fieldtype: "Link", options: "Territory", }, - - ] -} + ], +}; diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js index 93aad54fa07..6809b38c7ed 100644 --- a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js +++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/sales_partner_target_variance_based_on_item_group.js @@ -1,63 +1,60 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Partner Target Variance based on Item Group"] = { - "filters": [ + filters: [ { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { fieldname: "fiscal_year", label: __("Fiscal Year"), fieldtype: "Link", options: "Fiscal Year", - default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()) + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()), }, { fieldname: "doctype", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "period", label: __("Period"), fieldtype: "Select", options: [ - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Half-Yearly", "label": __("Half-Yearly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Half-Yearly", label: __("Half-Yearly") }, + { value: "Yearly", label: __("Yearly") }, ], - default: "Monthly" + default: "Monthly", }, { fieldname: "target_on", label: __("Target On"), fieldtype: "Select", options: "Quantity\nAmount", - default: "Quantity" + default: "Quantity", }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); - if (column.fieldname.includes('variance')) { - + if (column.fieldname.includes("variance")) { if (data[column.fieldname] < 0) { value = "" + value + ""; - } - else if (data[column.fieldname] > 0) { + } else if (data[column.fieldname] > 0) { value = "" + value + ""; } } return value; - } -} + }, +}; diff --git a/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js index e443ab39f6a..b7bca8ae5fa 100644 --- a/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js +++ b/erpnext/selling/report/sales_partner_transaction_summary/sales_partner_transaction_summary.js @@ -1,21 +1,20 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Partner Transaction Summary"] = { - "filters": [ + filters: [ { fieldname: "sales_partner", label: __("Sales Partner"), fieldtype: "Link", - options: "Sales Partner" + options: "Sales Partner", }, { fieldname: "doctype", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "from_date", @@ -24,48 +23,48 @@ frappe.query_reports["Sales Partner Transaction Summary"] = { default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.get_today() + default: frappe.datetime.get_today(), }, { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { - fieldname:"item_group", + fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", options: "Item Group", }, { - fieldname:"brand", + fieldname: "brand", label: __("Brand"), fieldtype: "Link", options: "Brand", }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"territory", + fieldname: "territory", label: __("Territory"), fieldtype: "Link", options: "Territory", }, { - fieldname:"show_return_entries", + fieldname: "show_return_entries", label: __("Show Return Entries"), fieldtype: "Check", default: 0, }, - ] -} + ], +}; diff --git a/erpnext/selling/report/sales_person_commission_summary/sales_person_commission_summary.js b/erpnext/selling/report/sales_person_commission_summary/sales_person_commission_summary.js index 9ed0b00187b..b197a9a5657 100644 --- a/erpnext/selling/report/sales_person_commission_summary/sales_person_commission_summary.js +++ b/erpnext/selling/report/sales_person_commission_summary/sales_person_commission_summary.js @@ -1,22 +1,20 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Person Commission Summary"] = { - "filters": [ - + filters: [ { fieldname: "sales_person", label: __("Sales Person"), fieldtype: "Link", - options: "Sales Person" + options: "Sales Person", }, { fieldname: "doc_type", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "from_date", @@ -25,30 +23,29 @@ frappe.query_reports["Sales Person Commission Summary"] = { default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.get_today() + default: frappe.datetime.get_today(), }, { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"territory", + fieldname: "territory", label: __("Territory"), fieldtype: "Link", options: "Territory", }, - - ] -} + ], +}; diff --git a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js index 8ee86dcb050..f9e8cc6ea5b 100644 --- a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js +++ b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/sales_person_target_variance_based_on_item_group.js @@ -1,15 +1,14 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Sales Person Target Variance Based On Item Group"] = { - "filters": [ + filters: [ { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { fieldname: "fiscal_year", @@ -23,41 +22,39 @@ frappe.query_reports["Sales Person Target Variance Based On Item Group"] = { label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "period", label: __("Period"), fieldtype: "Select", options: [ - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Half-Yearly", "label": __("Half-Yearly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Half-Yearly", label: __("Half-Yearly") }, + { value: "Yearly", label: __("Yearly") }, ], - default: "Monthly" + default: "Monthly", }, { fieldname: "target_on", label: __("Target On"), fieldtype: "Select", options: "Quantity\nAmount", - default: "Quantity" + default: "Quantity", }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); - if (column.fieldname.includes('variance')) { - + if (column.fieldname.includes("variance")) { if (data[column.fieldname] < 0) { value = "" + value + ""; - } - else if (data[column.fieldname] > 0) { + } else if (data[column.fieldname] > 0) { value = "" + value + ""; } } return value; - } -} + }, +}; 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 80c7b5f59d7..828e9e74f23 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 @@ -2,19 +2,19 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Sales Person-wise Transaction Summary"] = { - "filters": [ + filters: [ { fieldname: "sales_person", label: __("Sales Person"), fieldtype: "Link", - options: "Sales Person" + options: "Sales Person", }, { fieldname: "doc_type", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "from_date", @@ -23,48 +23,48 @@ frappe.query_reports["Sales Person-wise Transaction Summary"] = { default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.datetime.get_today() + default: frappe.datetime.get_today(), }, { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { - fieldname:"item_group", + fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", options: "Item Group", }, { - fieldname:"brand", + fieldname: "brand", label: __("Brand"), fieldtype: "Link", options: "Brand", }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"territory", + fieldname: "territory", label: __("Territory"), fieldtype: "Link", options: "Territory", }, { - fieldname:"show_return_entries", + fieldname: "show_return_entries", label: __("Show Return Entries"), fieldtype: "Check", default: 0, }, - ] -} + ], +}; diff --git a/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js index 50ac4da4450..a9e343276d2 100644 --- a/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js +++ b/erpnext/selling/report/territory_target_variance_based_on_item_group/territory_target_variance_based_on_item_group.js @@ -1,63 +1,60 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Territory Target Variance Based On Item Group"] = { - "filters": [ + filters: [ { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { fieldname: "fiscal_year", label: __("Fiscal Year"), fieldtype: "Link", options: "Fiscal Year", - default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()) + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()), }, { fieldname: "doctype", label: __("Document Type"), fieldtype: "Select", options: "Sales Order\nDelivery Note\nSales Invoice", - default: "Sales Order" + default: "Sales Order", }, { fieldname: "period", label: __("Period"), fieldtype: "Select", options: [ - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Half-Yearly", "label": __("Half-Yearly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Half-Yearly", label: __("Half-Yearly") }, + { value: "Yearly", label: __("Yearly") }, ], - default: "Monthly" + default: "Monthly", }, { fieldname: "target_on", label: __("Target On"), fieldtype: "Select", options: "Quantity\nAmount", - default: "Quantity" + default: "Quantity", }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); - if (column.fieldname.includes('variance')) { - + if (column.fieldname.includes("variance")) { if (data[column.fieldname] < 0) { value = "" + value + ""; - } - else if (data[column.fieldname] > 0) { + } else if (data[column.fieldname] > 0) { value = "" + value + ""; } } return value; - } -} + }, +}; diff --git a/erpnext/selling/report/territory_wise_sales/territory_wise_sales.js b/erpnext/selling/report/territory_wise_sales/territory_wise_sales.js index c755a75d827..409b7c76057 100644 --- a/erpnext/selling/report/territory_wise_sales/territory_wise_sales.js +++ b/erpnext/selling/report/territory_wise_sales/territory_wise_sales.js @@ -1,22 +1,23 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - - frappe.query_reports["Territory-wise Sales"] = { - "breadcrumb":"Selling", - "filters": [ + breadcrumb: "Selling", + filters: [ { - fieldname:"transaction_date", + fieldname: "transaction_date", label: __("Transaction Date"), fieldtype: "DateRange", - default: [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()], + default: [ + frappe.datetime.add_months(frappe.datetime.get_today(), -1), + frappe.datetime.get_today(), + ], }, { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", - } - ] + }, + ], }; diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.js b/erpnext/setup/doctype/authorization_rule/authorization_rule.js index f00ed3ecd0d..0004119ce97 100644 --- a/erpnext/setup/doctype/authorization_rule/authorization_rule.js +++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.js @@ -2,17 +2,17 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Authorization Rule", { - refresh: function(frm) { + refresh: function (frm) { frm.events.set_master_type(frm); }, - set_master_type: function(frm) { - if(frm.doc.based_on==="Customerwise Discount") { + set_master_type: function (frm) { + if (frm.doc.based_on === "Customerwise Discount") { unhide_field("master_name"); frm.set_value("customer_or_item", "Customer"); - } else if(frm.doc.based_on==="Itemwise Discount") { + } else if (frm.doc.based_on === "Itemwise Discount") { unhide_field("master_name"); frm.set_value("customer_or_item", "Item"); - } else if(frm.doc.based_on==="Item Group wise Discount") { + } else if (frm.doc.based_on === "Item Group wise Discount") { unhide_field("master_name"); frm.set_value("customer_or_item", "Item Group"); } else { @@ -21,84 +21,74 @@ frappe.ui.form.on("Authorization Rule", { hide_field("master_name"); } }, - based_on: function(frm) { + based_on: function (frm) { frm.events.set_master_type(frm); - if (frm.doc.based_on === 'Not Applicable') { + if (frm.doc.based_on === "Not Applicable") { frm.set_value("value", 0); - hide_field('value'); + hide_field("value"); } else { - unhide_field('value'); + unhide_field("value"); } }, - transaction: function(frm) { - unhide_field(['system_role', 'system_user', 'value', 'based_on']); - hide_field(['to_emp', 'to_designation']); - } -}) - + transaction: function (frm) { + unhide_field(["system_role", "system_user", "value", "based_on"]); + hide_field(["to_emp", "to_designation"]); + }, +}); // Settings Module -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - if (doc.based_on == 'Not Applicable') - hide_field('value'); - else - unhide_field('value'); +cur_frm.cscript.refresh = function (doc, cdt, cdn) { + if (doc.based_on == "Not Applicable") hide_field("value"); + else unhide_field("value"); - unhide_field(['system_role', 'system_user', 'value']); - hide_field(['to_emp', 'to_designation']); -} + unhide_field(["system_role", "system_user", "value"]); + hide_field(["to_emp", "to_designation"]); +}; -cur_frm.fields_dict.system_user.get_query = function(doc, cdt, cdn) { - return { query:"frappe.core.doctype.user.user.user_query" } -} +cur_frm.fields_dict.system_user.get_query = function (doc, cdt, cdn) { + return { query: "frappe.core.doctype.user.user.user_query" }; +}; -cur_frm.fields_dict.approving_user.get_query = function(doc, cdt, cdn) { - return { query:"frappe.core.doctype.user.user.user_query" } -} +cur_frm.fields_dict.approving_user.get_query = function (doc, cdt, cdn) { + return { query: "frappe.core.doctype.user.user.user_query" }; +}; -cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query; +cur_frm.fields_dict["approving_role"].get_query = cur_frm.fields_dict["system_role"].get_query; // System Role Trigger // ----------------------- -cur_frm.fields_dict['system_role'].get_query = function(doc) { +cur_frm.fields_dict["system_role"].get_query = function (doc) { return { - filters:[ - ['Role', 'name', 'not in', 'Administrator, Guest, All'] - ] - } -} - + filters: [["Role", "name", "not in", "Administrator, Guest, All"]], + }; +}; // Master Name Trigger // -------------------- -cur_frm.fields_dict['master_name'].get_query = function(doc) { - if (doc.based_on == 'Customerwise Discount') +cur_frm.fields_dict["master_name"].get_query = function (doc) { + if (doc.based_on == "Customerwise Discount") return { doctype: "Customer", - filters:[ - ['Customer', 'docstatus', '!=', 2] - ] - } - else if (doc.based_on == 'Itemwise Discount') + filters: [["Customer", "docstatus", "!=", 2]], + }; + else if (doc.based_on == "Itemwise Discount") return { doctype: "Item", - query: "erpnext.controllers.queries.item_query" - } - else if (doc.based_on==="Item Group wise Discount") + query: "erpnext.controllers.queries.item_query", + }; + else if (doc.based_on === "Item Group wise Discount") return { doctype: "Item Group", filters: { - "is_group": 0 - } - } + is_group: 0, + }, + }; else return { - filters: [ - ['Item', 'name', '=', 'cheating done to avoid null'] - ] - } -} + filters: [["Item", "name", "=", "cheating done to avoid null"]], + }; +}; -cur_frm.fields_dict.to_emp.get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.employee_query" } -} +cur_frm.fields_dict.to_emp.get_query = function (doc, cdt, cdn) { + return { query: "erpnext.controllers.queries.employee_query" }; +}; diff --git a/erpnext/setup/doctype/branch/branch.js b/erpnext/setup/doctype/branch/branch.js index c8a0afced8d..6e17c781931 100644 --- a/erpnext/setup/doctype/branch/branch.js +++ b/erpnext/setup/doctype/branch/branch.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Branch', { - refresh: function(frm) { - - } +frappe.ui.form.on("Branch", { + refresh: function (frm) {}, }); diff --git a/erpnext/setup/doctype/brand/brand.js b/erpnext/setup/doctype/brand/brand.js index 0abb71a3629..5d16d734e0f 100644 --- a/erpnext/setup/doctype/brand/brand.js +++ b/erpnext/setup/doctype/brand/brand.js @@ -1,71 +1,99 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Brand', { +frappe.ui.form.on("Brand", { setup: (frm) => { - frm.fields_dict["brand_defaults"].grid.get_field("default_warehouse").get_query = function(doc, cdt, cdn) { + frm.fields_dict["brand_defaults"].grid.get_field("default_warehouse").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { - filters: { company: row.company } - } - } - - frm.fields_dict["brand_defaults"].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) { - const row = locals[cdt][cdn]; - return { - filters: { - 'report_type': 'Profit and Loss', - 'company': row.company, - "is_group": 0 - } + filters: { company: row.company }, }; - } + }; - frm.fields_dict["brand_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["brand_defaults"].grid.get_field("default_discount_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + report_type: "Profit and Loss", + company: row.company, + is_group: 0, + }, + }; + }; - frm.fields_dict["brand_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) { + frm.fields_dict["brand_defaults"].grid.get_field("buying_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { + const row = locals[cdt][cdn]; + return { + filters: { + is_group: 0, + company: row.company, + }, + }; + }; + + frm.fields_dict["brand_defaults"].grid.get_field("expense_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { query: "erpnext.controllers.queries.get_expense_account", - filters: { company: row.company } - } - } - - frm.fields_dict["brand_defaults"].grid.get_field("default_provisional_account").get_query = function(doc, cdt, cdn) { - const row = locals[cdt][cdn]; - return { - filters: { - "company": row.company, - "root_type": ["in", ["Liability", "Asset"]], - "is_group": 0 - } + filters: { company: row.company }, }; - } + }; - frm.fields_dict["brand_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["brand_defaults"].grid.get_field("default_provisional_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + company: row.company, + root_type: ["in", ["Liability", "Asset"]], + is_group: 0, + }, + }; + }; - frm.fields_dict["brand_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) { + frm.fields_dict["brand_defaults"].grid.get_field("selling_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { + const row = locals[cdt][cdn]; + return { + filters: { + is_group: 0, + company: row.company, + }, + }; + }; + + frm.fields_dict["brand_defaults"].grid.get_field("income_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { query: "erpnext.controllers.queries.get_income_account", - filters: { company: row.company } - } - } - } -}); \ No newline at end of file + filters: { company: row.company }, + }; + }; + }, +}); diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 340a917ffa7..39170053838 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -4,119 +4,146 @@ frappe.provide("erpnext.company"); frappe.ui.form.on("Company", { - onload: function(frm) { + onload: function (frm) { if (frm.doc.__islocal && frm.doc.parent_company) { - frappe.db.get_value('Company', frm.doc.parent_company, 'is_group', (r) => { + frappe.db.get_value("Company", frm.doc.parent_company, "is_group", (r) => { if (!r.is_group) { - frm.set_value('parent_company', ''); + frm.set_value("parent_company", ""); } }); } - frm.call('check_if_transactions_exist').then(r => { - frm.toggle_enable("default_currency", (!r.message)); + frm.call("check_if_transactions_exist").then((r) => { + frm.toggle_enable("default_currency", !r.message); }); }, - setup: function(frm) { + setup: function (frm) { frm.__rename_queue = "long"; erpnext.company.setup_queries(frm); - frm.set_query("parent_company", function() { + frm.set_query("parent_company", function () { return { - filters: {"is_group": 1} - } + filters: { is_group: 1 }, + }; }); - frm.set_query("default_selling_terms", function() { + frm.set_query("default_selling_terms", function () { return { filters: { selling: 1 } }; }); - frm.set_query("default_buying_terms", function() { + frm.set_query("default_buying_terms", function () { return { filters: { buying: 1 } }; }); - frm.set_query("default_in_transit_warehouse", function() { + frm.set_query("default_in_transit_warehouse", function () { return { - filters:{ - 'warehouse_type' : 'Transit', - 'is_group': 0, - 'company': frm.doc.company_name - } + filters: { + warehouse_type: "Transit", + is_group: 0, + company: frm.doc.company_name, + }, }; }); }, - company_name: function(frm) { - if(frm.doc.__islocal) { + company_name: function (frm) { + if (frm.doc.__islocal) { // add missing " " arg in split method let parts = frm.doc.company_name.split(" "); let abbr = $.map(parts, function (p) { - return p? p.substr(0, 1) : null; + return p ? p.substr(0, 1) : null; }).join(""); frm.set_value("abbr", abbr); } }, - parent_company: function(frm) { + parent_company: function (frm) { var bool = frm.doc.parent_company ? true : false; - frm.set_value('create_chart_of_accounts_based_on', bool ? "Existing Company" : ""); - frm.set_value('existing_company', bool ? frm.doc.parent_company : ""); + frm.set_value("create_chart_of_accounts_based_on", bool ? "Existing Company" : ""); + frm.set_value("existing_company", bool ? frm.doc.parent_company : ""); disbale_coa_fields(frm, bool); }, - date_of_commencement: function(frm) { - if(frm.doc.date_of_commencement { + .then((r) => { frappe.model.set_value(cdt, cdn, "address", r.name); }) - .catch(err => { + .catch((err) => { console.log(err); }); - } + }, }); diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js index c2c2710b025..c0a887e4b11 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.js +++ b/erpnext/setup/doctype/email_digest/email_digest.js @@ -2,30 +2,30 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Email Digest", { - refresh: function(frm) { + refresh: function (frm) { if (!frm.is_new()) { - frm.add_custom_button(__('View Now'), function() { + frm.add_custom_button(__("View Now"), function () { frappe.call({ - method: 'erpnext.setup.doctype.email_digest.email_digest.get_digest_msg', + method: "erpnext.setup.doctype.email_digest.email_digest.get_digest_msg", args: { - name: frm.doc.name + name: frm.doc.name, }, - callback: function(r) { + callback: function (r) { let d = new frappe.ui.Dialog({ - title: __('Email Digest: {0}', [frm.doc.name]), - width: 800 + title: __("Email Digest: {0}", [frm.doc.name]), + width: 800, }); $(d.body).html(r.message); d.show(); - } + }, }); }); - frm.add_custom_button(__('Send Now'), function() { - return frm.call('send', null, () => { - frappe.show_alert({ message: __("Message Sent"), indicator: 'green'}); + frm.add_custom_button(__("Send Now"), function () { + return frm.call("send", null, () => { + frappe.show_alert({ message: __("Message Sent"), indicator: "green" }); }); }); } - } + }, }); diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js index efc3fd1d33d..d165d429f44 100755 --- a/erpnext/setup/doctype/employee/employee.js +++ b/erpnext/setup/doctype/employee/employee.js @@ -4,14 +4,15 @@ frappe.provide("erpnext.setup"); erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.form.Controller { setup() { - this.frm.fields_dict.user_id.get_query = function(doc, cdt, cdn) { + this.frm.fields_dict.user_id.get_query = function (doc, cdt, cdn) { return { query: "frappe.core.doctype.user.user.user_query", - filters: {ignore_user_type: 1} - } - } - this.frm.fields_dict.reports_to.get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.employee_query"} } + filters: { ignore_user_type: 1 }, + }; + }; + this.frm.fields_dict.reports_to.get_query = function (doc, cdt, cdn) { + return { query: "erpnext.controllers.queries.employee_query" }; + }; } refresh() { @@ -20,58 +21,59 @@ erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.fo salutation() { if (this.frm.doc.salutation) { - this.frm.set_value("gender", { - "Mr": "Male", - "Ms": "Female" - }[this.frm.doc.salutation]); + this.frm.set_value( + "gender", + { + Mr: "Male", + Ms: "Female", + }[this.frm.doc.salutation] + ); } } - }; frappe.ui.form.on("Employee", { onload: function (frm) { - frm.set_query("department", function() { + frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); }, - prefered_contact_email: function(frm) { + prefered_contact_email: function (frm) { frm.events.update_contact(frm); }, - personal_email: function(frm) { + personal_email: function (frm) { frm.events.update_contact(frm); }, - company_email: function(frm) { + company_email: function (frm) { frm.events.update_contact(frm); }, - user_id: function(frm) { + user_id: function (frm) { frm.events.update_contact(frm); }, - update_contact: function(frm) { - var prefered_email_fieldname = frappe.model.scrub(frm.doc.prefered_contact_email) || 'user_id'; - frm.set_value("prefered_email", - frm.fields_dict[prefered_email_fieldname].value); + update_contact: function (frm) { + var prefered_email_fieldname = frappe.model.scrub(frm.doc.prefered_contact_email) || "user_id"; + frm.set_value("prefered_email", frm.fields_dict[prefered_email_fieldname].value); }, - status: function(frm) { + status: function (frm) { return frm.call({ method: "deactivate_sales_person", args: { employee: frm.doc.employee, - status: frm.doc.status - } + status: frm.doc.status, + }, }); }, - create_user: function(frm) { + create_user: function (frm) { if (!frm.doc.prefered_email) { frappe.throw(__("Please enter Preferred Contact Email")); } @@ -79,46 +81,53 @@ frappe.ui.form.on("Employee", { method: "erpnext.setup.doctype.employee.employee.create_user", args: { employee: frm.doc.name, - email: frm.doc.prefered_email + email: frm.doc.prefered_email, }, freeze: true, freeze_message: __("Creating User..."), callback: function (r) { frm.reload_doc(); - } + }, }); - } + }, }); cur_frm.cscript = new erpnext.setup.EmployeeController({ - frm: cur_frm + frm: cur_frm, }); - -frappe.tour['Employee'] = [ +frappe.tour["Employee"] = [ { fieldname: "first_name", title: "First Name", - description: __("Enter First and Last name of Employee, based on Which Full Name will be updated. IN transactions, it will be Full Name which will be fetched.") + description: __( + "Enter First and Last name of Employee, based on Which Full Name will be updated. IN transactions, it will be Full Name which will be fetched." + ), }, { fieldname: "company", title: "Company", - description: __("Select a Company this Employee belongs to.") + description: __("Select a Company this Employee belongs to."), }, { fieldname: "date_of_birth", title: "Date of Birth", - description: __("Select Date of Birth. This will validate Employees age and prevent hiring of under-age staff.") + description: __( + "Select Date of Birth. This will validate Employees age and prevent hiring of under-age staff." + ), }, { fieldname: "date_of_joining", title: "Date of Joining", - description: __("Select Date of joining. It will have impact on the first salary calculation, Leave allocation on pro-rata bases.") + description: __( + "Select Date of joining. It will have impact on the first salary calculation, Leave allocation on pro-rata bases." + ), }, { fieldname: "reports_to", title: "Reports To", - description: __("Here, you can select a senior of this Employee. Based on this, Organization Chart will be populated.") + description: __( + "Here, you can select a senior of this Employee. Based on this, Organization Chart will be populated." + ), }, ]; diff --git a/erpnext/setup/doctype/employee/employee_list.js b/erpnext/setup/doctype/employee/employee_list.js index d37e1496ca3..0c97b626954 100644 --- a/erpnext/setup/doctype/employee/employee_list.js +++ b/erpnext/setup/doctype/employee/employee_list.js @@ -1,9 +1,9 @@ -frappe.listview_settings['Employee'] = { - add_fields: ["status", "branch", "department", "designation","image"], - filters: [["status","=", "Active"]], - get_indicator: function(doc) { +frappe.listview_settings["Employee"] = { + add_fields: ["status", "branch", "department", "designation", "image"], + filters: [["status", "=", "Active"]], + get_indicator: function (doc) { var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status]; - indicator[1] = {"Active": "green", "Inactive": "red", "Left": "gray", "Suspended": "orange"}[doc.status]; + indicator[1] = { Active: "green", Inactive: "red", Left: "gray", Suspended: "orange" }[doc.status]; return indicator; - } + }, }; diff --git a/erpnext/setup/doctype/employee/employee_tree.js b/erpnext/setup/doctype/employee/employee_tree.js index 8f52cff8c2c..26a89719d7f 100644 --- a/erpnext/setup/doctype/employee/employee_tree.js +++ b/erpnext/setup/doctype/employee/employee_tree.js @@ -1,13 +1,13 @@ -frappe.treeview_settings['Employee'] = { +frappe.treeview_settings["Employee"] = { get_tree_nodes: "erpnext.setup.doctype.employee.employee.get_children", filters: [ { fieldname: "company", - fieldtype:"Select", - options: ['All Companies'].concat(erpnext.utils.get_tree_options("company")), + fieldtype: "Select", + options: ["All Companies"].concat(erpnext.utils.get_tree_options("company")), label: __("Company"), - default: erpnext.utils.get_tree_default("company") - } + default: erpnext.utils.get_tree_default("company"), + }, ], breadcrumb: "Hr", disable_add_node: true, @@ -15,22 +15,22 @@ frappe.treeview_settings['Employee'] = { toolbar: [ { toggle_btn: true }, { - label:__("Edit"), - condition: function(node) { + label: __("Edit"), + condition: function (node) { return !node.is_root; }, - click: function(node) { + click: function (node) { frappe.set_route("Form", "Employee", node.data.value); - } - } + }, + }, ], menu_items: [ { label: __("New Employee"), - action: function() { + action: function () { frappe.new_doc("Employee", true); }, - condition: 'frappe.boot.user.can_create.indexOf("Employee") !== -1' - } + condition: 'frappe.boot.user.can_create.indexOf("Employee") !== -1', + }, ], }; diff --git a/erpnext/setup/doctype/employee_group/employee_group.js b/erpnext/setup/doctype/employee_group/employee_group.js index 3db57181f8a..0ffa877ee7e 100644 --- a/erpnext/setup/doctype/employee_group/employee_group.js +++ b/erpnext/setup/doctype/employee_group/employee_group.js @@ -1,6 +1,4 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Group', { - -}); +frappe.ui.form.on("Employee Group", {}); diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.js b/erpnext/setup/doctype/global_defaults/global_defaults.js index 942dd5989ea..20ac6dafde5 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.js +++ b/erpnext/setup/doctype/global_defaults/global_defaults.js @@ -1,14 +1,14 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Global Defaults', { - onload: function(frm) { - frm.trigger('get_distance_uoms'); +frappe.ui.form.on("Global Defaults", { + onload: function (frm) { + frm.trigger("get_distance_uoms"); }, - validate: function(frm) { - frm.call('get_defaults', null, r => { + validate: function (frm) { + frm.call("get_defaults", null, (r) => { frappe.sys_defaults = r.message; - }) + }); }, get_distance_uoms: function (frm) { let units = []; @@ -17,16 +17,16 @@ frappe.ui.form.on('Global Defaults', { method: "frappe.client.get_list", args: { doctype: "UOM Conversion Factor", - filters: { "category": __("Length") }, + filters: { category: __("Length") }, fields: ["to_uom"], - limit_page_length: 500 + limit_page_length: 500, }, callback: function (r) { - r.message.forEach(row => units.push(row.to_uom)); - } + r.message.forEach((row) => units.push(row.to_uom)); + }, }); frm.set_query("default_distance_unit", function () { - return { filters: { "name": ["IN", units] } }; + return { filters: { name: ["IN", units] } }; }); - } + }, }); diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.js b/erpnext/setup/doctype/holiday_list/holiday_list.js index 90d9f1b6f50..1f95a73c242 100644 --- a/erpnext/setup/doctype/holiday_list/holiday_list.js +++ b/erpnext/setup/doctype/holiday_list/holiday_list.js @@ -2,12 +2,12 @@ // For license information, please see license.txt frappe.ui.form.on("Holiday List", { - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.holidays) { frm.set_value("total_holidays", frm.doc.holidays.length); } - frm.call("get_supported_countries").then(r => { + frm.call("get_supported_countries").then((r) => { frm.subdivisions_by_country = r.message.subdivisions_by_country; frm.fields_dict.country.set_data( r.message.countries.sort((a, b) => a.label.localeCompare(b.label)) @@ -18,20 +18,20 @@ frappe.ui.form.on("Holiday List", { } }); }, - from_date: function(frm) { + from_date: function (frm) { if (frm.doc.from_date && !frm.doc.to_date) { var a_year_from_start = frappe.datetime.add_months(frm.doc.from_date, 12); frm.set_value("to_date", frappe.datetime.add_days(a_year_from_start, -1)); } }, - country: function(frm) { + country: function (frm) { frm.set_value("subdivision", ""); if (frm.doc.country) { frm.trigger("set_subdivisions"); } }, - set_subdivisions: function(frm) { + set_subdivisions: function (frm) { const subdivisions = [...frm.subdivisions_by_country[frm.doc.country]]; if (subdivisions && subdivisions.length > 0) { frm.fields_dict.subdivision.set_data(subdivisions); @@ -67,11 +67,15 @@ frappe.tour["Holiday List"] = [ { fieldname: "get_weekly_off_dates", title: "Add Holidays", - description: __("Click on Add to Holidays. This will populate the holidays table with all the dates that fall on the selected weekly off. Repeat the process for populating the dates for all your weekly holidays"), + description: __( + "Click on Add to Holidays. This will populate the holidays table with all the dates that fall on the selected weekly off. Repeat the process for populating the dates for all your weekly holidays" + ), }, { fieldname: "holidays", title: "Holidays", - description: __("Here, your weekly offs are pre-populated based on the previous selections. You can add more rows to also add public and national holidays individually.") + description: __( + "Here, your weekly offs are pre-populated based on the previous selections. You can add more rows to also add public and national holidays individually." + ), }, ]; diff --git a/erpnext/setup/doctype/holiday_list/holiday_list_calendar.js b/erpnext/setup/doctype/holiday_list/holiday_list_calendar.js index bb6d8315467..ff830881c92 100644 --- a/erpnext/setup/doctype/holiday_list/holiday_list_calendar.js +++ b/erpnext/setup/doctype/holiday_list/holiday_list_calendar.js @@ -3,20 +3,20 @@ frappe.views.calendar["Holiday List"] = { field_map: { - "start": "holiday_date", - "end": "holiday_date", - "id": "name", - "title": "description", - "allDay": "allDay" + start: "holiday_date", + end: "holiday_date", + id: "name", + title: "description", + allDay: "allDay", }, order_by: `from_date`, get_events_method: "erpnext.setup.doctype.holiday_list.holiday_list.get_events", filters: [ { - 'fieldtype': 'Link', - 'fieldname': 'holiday_list', - 'options': 'Holiday List', - 'label': __('Holiday List') - } - ] -} + fieldtype: "Link", + fieldname: "holiday_list", + options: "Holiday List", + label: __("Holiday List"), + }, + ], +}; diff --git a/erpnext/setup/doctype/item_group/item_group.js b/erpnext/setup/doctype/item_group/item_group.js index d6eb11f73d9..6835be17ab7 100644 --- a/erpnext/setup/doctype/item_group/item_group.js +++ b/erpnext/setup/doctype/item_group/item_group.js @@ -2,85 +2,102 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Item Group", { - onload: function(frm) { + onload: function (frm) { frm.list_route = "Tree/Item Group"; //get query select item group - frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) { - return{ - filters:[ - ['Item Group', 'is_group', '=', 1], - ['Item Group', 'name', '!=', doc.item_group_name] - ] - } - } - frm.fields_dict['item_group_defaults'].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) { - const row = locals[cdt][cdn]; + frm.fields_dict["parent_item_group"].get_query = function (doc, cdt, cdn) { return { - filters: { - 'report_type': 'Profit and Loss', - 'company': row.company, - "is_group": 0 - } + filters: [ + ["Item Group", "is_group", "=", 1], + ["Item Group", "name", "!=", doc.item_group_name], + ], }; - } - frm.fields_dict["item_group_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) { + }; + frm.fields_dict["item_group_defaults"].grid.get_field("default_discount_account").get_query = + function (doc, cdt, cdn) { + const row = locals[cdt][cdn]; + return { + filters: { + report_type: "Profit and Loss", + company: row.company, + is_group: 0, + }, + }; + }; + frm.fields_dict["item_group_defaults"].grid.get_field("expense_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { query: "erpnext.controllers.queries.get_expense_account", - filters: { company: row.company } - } - } - frm.fields_dict["item_group_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) { + filters: { company: row.company }, + }; + }; + frm.fields_dict["item_group_defaults"].grid.get_field("income_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { query: "erpnext.controllers.queries.get_income_account", - filters: { company: row.company } - } - } + filters: { company: row.company }, + }; + }; - frm.fields_dict["item_group_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_group_defaults"].grid.get_field("buying_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + is_group: 0, + company: row.company, + }, + }; + }; - frm.fields_dict["item_group_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_group_defaults"].grid.get_field("selling_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + is_group: 0, + company: row.company, + }, + }; + }; }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("set_root_readonly"); - frm.add_custom_button(__("Item Group Tree"), function() { + frm.add_custom_button(__("Item Group Tree"), function () { frappe.set_route("Tree", "Item Group"); }); - if(!frm.is_new()) { - frm.add_custom_button(__("Items"), function() { - frappe.set_route("List", "Item", {"item_group": frm.doc.name}); + if (!frm.is_new()) { + frm.add_custom_button(__("Items"), function () { + frappe.set_route("List", "Item", { item_group: frm.doc.name }); }); } }, - set_root_readonly: function(frm) { + set_root_readonly: function (frm) { // read-only for root item group frm.set_intro(""); - if(!frm.doc.parent_item_group && !frm.doc.__islocal) { + if (!frm.doc.parent_item_group && !frm.doc.__islocal) { frm.set_read_only(); frm.set_intro(__("This is a root item group and cannot be edited."), true); } }, - page_name: frappe.utils.warn_page_name_change + page_name: frappe.utils.warn_page_name_change, }); diff --git a/erpnext/setup/doctype/item_group/item_group_tree.js b/erpnext/setup/doctype/item_group/item_group_tree.js index b2628f4f4f8..a7c2b6360cf 100644 --- a/erpnext/setup/doctype/item_group/item_group_tree.js +++ b/erpnext/setup/doctype/item_group/item_group_tree.js @@ -1,3 +1,3 @@ frappe.treeview_settings["Item Group"] = { - ignore_fields:["parent_item_group"] -} + ignore_fields: ["parent_item_group"], +}; diff --git a/erpnext/setup/doctype/party_type/party_type.js b/erpnext/setup/doctype/party_type/party_type.js index 7a96dc55ee9..9bbfd7d8832 100644 --- a/erpnext/setup/doctype/party_type/party_type.js +++ b/erpnext/setup/doctype/party_type/party_type.js @@ -1,15 +1,15 @@ // Copyright (c) 2016, Frappe Technologies and contributors // For license information, please see license.txt -frappe.ui.form.on('Party Type', { - setup: function(frm) { - frm.fields_dict["party_type"].get_query = function(frm) { +frappe.ui.form.on("Party Type", { + setup: function (frm) { + frm.fields_dict["party_type"].get_query = function (frm) { return { filters: { - "istable": 0, - "is_submittable": 0 - } - } - } - } + istable: 0, + is_submittable: 0, + }, + }; + }; + }, }); diff --git a/erpnext/setup/doctype/print_heading/print_heading.js b/erpnext/setup/doctype/print_heading/print_heading.js index 3680906057f..273e30fd197 100644 --- a/erpnext/setup/doctype/print_heading/print_heading.js +++ b/erpnext/setup/doctype/print_heading/print_heading.js @@ -1,13 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - - //--------- ONLOAD ------------- -cur_frm.cscript.onload = function(doc, cdt, cdn) { +cur_frm.cscript.onload = function (doc, cdt, cdn) {}; -} - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - -} +cur_frm.cscript.refresh = function (doc, cdt, cdn) {}; diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.js b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.js index 3680906057f..273e30fd197 100644 --- a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.js +++ b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.js @@ -1,13 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - - //--------- ONLOAD ------------- -cur_frm.cscript.onload = function(doc, cdt, cdn) { +cur_frm.cscript.onload = function (doc, cdt, cdn) {}; -} - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - -} +cur_frm.cscript.refresh = function (doc, cdt, cdn) {}; diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index f9e37705604..f6b3dd2d7f5 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -1,32 +1,31 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Sales Partner', { - refresh: function(frm) { - if(frm.doc.__islocal){ - hide_field(['address_html', 'contact_html', 'address_contacts']); +frappe.ui.form.on("Sales Partner", { + refresh: function (frm) { + if (frm.doc.__islocal) { + hide_field(["address_html", "contact_html", "address_contacts"]); frappe.contacts.clear_address_and_contact(frm); - } - else{ - unhide_field(['address_html', 'contact_html', 'address_contacts']); + } else { + unhide_field(["address_html", "contact_html", "address_contacts"]); frappe.contacts.render_address_and_contact(frm); } }, - setup: function(frm) { - frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){ + setup: function (frm) { + frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) { var row = locals[cdt][cdn]; return { filters: { - 'fiscal_year': row.fiscal_year - } - } + fiscal_year: row.fiscal_year, + }, + }; }; }, - referral_code:function(frm){ + referral_code: function (frm) { if (frm.doc.referral_code) { - frm.doc.referral_code=frm.doc.referral_code.toUpperCase(); - frm.refresh_field('referral_code'); + frm.doc.referral_code = frm.doc.referral_code.toUpperCase(); + frm.refresh_field("referral_code"); } - } + }, }); diff --git a/erpnext/setup/doctype/sales_person/sales_person.js b/erpnext/setup/doctype/sales_person/sales_person.js index f0d9aa87bce..127bdac6e13 100644 --- a/erpnext/setup/doctype/sales_person/sales_person.js +++ b/erpnext/setup/doctype/sales_person/sales_person.js @@ -1,56 +1,65 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Sales Person', { - refresh: function(frm) { - if(frm.doc.__onload && frm.doc.__onload.dashboard_info) { +frappe.ui.form.on("Sales Person", { + refresh: function (frm) { + if (frm.doc.__onload && frm.doc.__onload.dashboard_info) { let info = frm.doc.__onload.dashboard_info; - frm.dashboard.add_indicator(__('Total Contribution Amount Against Orders: {0}', - [format_currency(info.allocated_amount_against_order, info.currency)]), 'blue'); + frm.dashboard.add_indicator( + __("Total Contribution Amount Against Orders: {0}", [ + format_currency(info.allocated_amount_against_order, info.currency), + ]), + "blue" + ); - frm.dashboard.add_indicator(__('Total Contribution Amount Against Invoices: {0}', - [format_currency(info.allocated_amount_against_invoice, info.currency)]), 'blue'); + frm.dashboard.add_indicator( + __("Total Contribution Amount Against Invoices: {0}", [ + format_currency(info.allocated_amount_against_invoice, info.currency), + ]), + "blue" + ); } frm.trigger("set_root_readonly"); }, - setup: function(frm) { - frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){ + setup: function (frm) { + frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) { var row = locals[cdt][cdn]; return { filters: { - 'fiscal_year': row.fiscal_year - } - } + fiscal_year: row.fiscal_year, + }, + }; }; frm.make_methods = { - 'Sales Order': () => frappe.new_doc("Sales Order") - .then(() => frm.add_child("sales_team", {"sales_person": frm.doc.name})) - } + "Sales Order": () => + frappe + .new_doc("Sales Order") + .then(() => frm.add_child("sales_team", { sales_person: frm.doc.name })), + }; }, - set_root_readonly: function(frm) { + set_root_readonly: function (frm) { // read-only for root - if(!frm.doc.parent_sales_person && !frm.doc.__islocal) { + if (!frm.doc.parent_sales_person && !frm.doc.__islocal) { frm.set_read_only(); frm.set_intro(__("This is a root sales person and cannot be edited.")); } else { frm.set_intro(null); } - } + }, }); - //get query select sales person -cur_frm.fields_dict['parent_sales_person'].get_query = function(doc, cdt, cdn) { - return{ +cur_frm.fields_dict["parent_sales_person"].get_query = function (doc, cdt, cdn) { + return { filters: [ - ['Sales Person', 'is_group', '=', 1], - ['Sales Person', 'name', '!=', doc.sales_person_name] - ] - } -} + ["Sales Person", "is_group", "=", 1], + ["Sales Person", "name", "!=", doc.sales_person_name], + ], + }; +}; -cur_frm.fields_dict.employee.get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.employee_query" } -} +cur_frm.fields_dict.employee.get_query = function (doc, cdt, cdn) { + return { query: "erpnext.controllers.queries.employee_query" }; +}; diff --git a/erpnext/setup/doctype/sales_person/sales_person_tree.js b/erpnext/setup/doctype/sales_person/sales_person_tree.js index 00056fde869..0fcd592aea3 100644 --- a/erpnext/setup/doctype/sales_person/sales_person_tree.js +++ b/erpnext/setup/doctype/sales_person/sales_person_tree.js @@ -1,12 +1,18 @@ - frappe.treeview_settings["Sales Person"] = { fields: [ - {fieldtype:'Data', fieldname: 'sales_person_name', - label:__('New Sales Person Name'), reqd:true}, - {fieldtype:'Link', fieldname:'employee', - label:__('Employee'), options:'Employee', - description: __("Please enter Employee Id of this sales person")}, - {fieldtype:'Check', fieldname:'is_group', label:__('Group Node'), - description: __("Further nodes can be only created under 'Group' type nodes")} + { fieldtype: "Data", fieldname: "sales_person_name", label: __("New Sales Person Name"), reqd: true }, + { + fieldtype: "Link", + fieldname: "employee", + label: __("Employee"), + options: "Employee", + description: __("Please enter Employee Id of this sales person"), + }, + { + fieldtype: "Check", + fieldname: "is_group", + label: __("Group Node"), + description: __("Further nodes can be only created under 'Group' type nodes"), + }, ], -} +}; diff --git a/erpnext/setup/doctype/supplier_group/supplier_group.js b/erpnext/setup/doctype/supplier_group/supplier_group.js index c697a99cb47..d720b3bd50a 100644 --- a/erpnext/setup/doctype/supplier_group/supplier_group.js +++ b/erpnext/setup/doctype/supplier_group/supplier_group.js @@ -2,48 +2,48 @@ // For license information, please see license.txt frappe.ui.form.on("Supplier Group", { - setup: function(frm){ - frm.set_query('parent_supplier_group', function (doc) { + setup: function (frm) { + frm.set_query("parent_supplier_group", function (doc) { return { filters: { - 'is_group': 1, - 'name': ['!=', cur_frm.doc.supplier_group_name] - } - } + is_group: 1, + name: ["!=", cur_frm.doc.supplier_group_name], + }, + }; }); - frm.set_query('account', 'accounts', function (doc, cdt, cdn) { + frm.set_query("account", "accounts", function (doc, cdt, cdn) { return { filters: { - 'root_type': 'Liability', - 'account_type': 'Payable', - 'company': locals[cdt][cdn].company, - "is_group": 0 - } - } + root_type: "Liability", + account_type: "Payable", + company: locals[cdt][cdn].company, + is_group: 0, + }, + }; }); - frm.set_query('advance_account', 'accounts', function (doc, cdt, cdn) { + frm.set_query("advance_account", "accounts", function (doc, cdt, cdn) { return { filters: { - "root_type": 'Asset', - "account_type": "Payable", - "company": locals[cdt][cdn].company, - "is_group": 0 - } - } + root_type: "Asset", + account_type: "Payable", + company: locals[cdt][cdn].company, + is_group: 0, + }, + }; }); }, - refresh: function(frm) { + refresh: function (frm) { frm.set_intro(frm.doc.__islocal ? "" : __("There is nothing to edit.")); frm.trigger("set_root_readonly"); }, - set_root_readonly: function(frm) { - if(!frm.doc.parent_supplier_group && !frm.doc.__islocal) { + set_root_readonly: function (frm) { + if (!frm.doc.parent_supplier_group && !frm.doc.__islocal) { frm.trigger("set_read_only"); frm.set_intro(__("This is a root supplier group and cannot be edited.")); } else { frm.set_intro(null); } - } + }, }); diff --git a/erpnext/setup/doctype/supplier_group/supplier_group_tree.js b/erpnext/setup/doctype/supplier_group/supplier_group_tree.js index 728793eb25f..9210dc1f002 100644 --- a/erpnext/setup/doctype/supplier_group/supplier_group_tree.js +++ b/erpnext/setup/doctype/supplier_group/supplier_group_tree.js @@ -1,4 +1,4 @@ frappe.treeview_settings["Supplier Group"] = { breadcrumbs: "Buying", - ignore_fields:["parent_supplier_group"] + ignore_fields: ["parent_supplier_group"], }; diff --git a/erpnext/setup/doctype/territory/territory.js b/erpnext/setup/doctype/territory/territory.js index e11d20b7bf6..62fab458da4 100644 --- a/erpnext/setup/doctype/territory/territory.js +++ b/erpnext/setup/doctype/territory/territory.js @@ -2,37 +2,36 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Territory", { - setup: function(frm) { - frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){ + setup: function (frm) { + frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) { var row = locals[cdt][cdn]; return { filters: { - 'fiscal_year': row.fiscal_year - } - } + fiscal_year: row.fiscal_year, + }, + }; }; }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("set_root_readonly"); }, - set_root_readonly: function(frm) { + set_root_readonly: function (frm) { // read-only for root territory - if(!frm.doc.parent_territory && !frm.doc.__islocal) { + if (!frm.doc.parent_territory && !frm.doc.__islocal) { frm.set_read_only(); frm.set_intro(__("This is a root territory and cannot be edited.")); } else { frm.set_intro(null); } - } - + }, }); //get query select territory -cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) { - return{ - filters:[ - ['Territory', 'is_group', '=', 1], - ['Territory', 'name', '!=', doc.territory_name] - ] - } -} +cur_frm.fields_dict["parent_territory"].get_query = function (doc, cdt, cdn) { + return { + filters: [ + ["Territory", "is_group", "=", 1], + ["Territory", "name", "!=", doc.territory_name], + ], + }; +}; diff --git a/erpnext/setup/doctype/territory/territory_tree.js b/erpnext/setup/doctype/territory/territory_tree.js index dadeeef09e9..4892b8c45fc 100644 --- a/erpnext/setup/doctype/territory/territory_tree.js +++ b/erpnext/setup/doctype/territory/territory_tree.js @@ -1,3 +1,3 @@ frappe.treeview_settings["Territory"] = { - ignore_fields:["parent_territory"] -} + ignore_fields: ["parent_territory"], +}; diff --git a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.js b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.js index a7b0709b3da..527c753d6a9 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.js +++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record.js @@ -1,39 +1,38 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Transaction Deletion Record', { - onload: function(frm) { +frappe.ui.form.on("Transaction Deletion Record", { + onload: function (frm) { if (frm.doc.docstatus == 0) { let doctypes_to_be_ignored_array; frappe.call({ - method: 'erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.get_doctypes_to_be_ignored', - callback: function(r) { + method: "erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.get_doctypes_to_be_ignored", + callback: function (r) { doctypes_to_be_ignored_array = r.message; populate_doctypes_to_be_ignored(doctypes_to_be_ignored_array, frm); - frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false); - frm.refresh_field('doctypes_to_be_ignored'); - } + frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false); + frm.refresh_field("doctypes_to_be_ignored"); + }, }); } - frm.get_field('doctypes_to_be_ignored').grid.cannot_add_rows = true; - frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false); - frm.refresh_field('doctypes_to_be_ignored'); + frm.get_field("doctypes_to_be_ignored").grid.cannot_add_rows = true; + frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false); + frm.refresh_field("doctypes_to_be_ignored"); }, - refresh: function(frm) { - frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false); - frm.refresh_field('doctypes_to_be_ignored'); - } - + refresh: function (frm) { + frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false); + frm.refresh_field("doctypes_to_be_ignored"); + }, }); function populate_doctypes_to_be_ignored(doctypes_to_be_ignored_array, frm) { if (frm.doc.doctypes_to_be_ignored.length === 0) { var i; for (i = 0; i < doctypes_to_be_ignored_array.length; i++) { - frm.add_child('doctypes_to_be_ignored', { - doctype_name: doctypes_to_be_ignored_array[i] + frm.add_child("doctypes_to_be_ignored", { + doctype_name: doctypes_to_be_ignored_array[i], }); } } diff --git a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record_list.js b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record_list.js index c238f18abad..08a35df2c17 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record_list.js +++ b/erpnext/setup/doctype/transaction_deletion_record/transaction_deletion_record_list.js @@ -1,12 +1,12 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.listview_settings['Transaction Deletion Record'] = { - get_indicator: function(doc) { +frappe.listview_settings["Transaction Deletion Record"] = { + get_indicator: function (doc) { if (doc.docstatus == 0) { return [__("Draft"), "red"]; } else { return [__("Completed"), "green"]; } - } + }, }; diff --git a/erpnext/setup/doctype/uom/uom.js b/erpnext/setup/doctype/uom/uom.js index 3680906057f..273e30fd197 100644 --- a/erpnext/setup/doctype/uom/uom.js +++ b/erpnext/setup/doctype/uom/uom.js @@ -1,13 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - - //--------- ONLOAD ------------- -cur_frm.cscript.onload = function(doc, cdt, cdn) { +cur_frm.cscript.onload = function (doc, cdt, cdn) {}; -} - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - -} +cur_frm.cscript.refresh = function (doc, cdt, cdn) {}; diff --git a/erpnext/setup/doctype/uom_conversion_factor/uom_conversion_factor.js b/erpnext/setup/doctype/uom_conversion_factor/uom_conversion_factor.js index e734d83500f..e975729dca7 100644 --- a/erpnext/setup/doctype/uom_conversion_factor/uom_conversion_factor.js +++ b/erpnext/setup/doctype/uom_conversion_factor/uom_conversion_factor.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('UOM Conversion Factor', { - refresh: function() { - - } +frappe.ui.form.on("UOM Conversion Factor", { + refresh: function () {}, }); diff --git a/erpnext/setup/doctype/vehicle/vehicle.js b/erpnext/setup/doctype/vehicle/vehicle.js index f12c4346852..9d598a9883b 100644 --- a/erpnext/setup/doctype/vehicle/vehicle.js +++ b/erpnext/setup/doctype/vehicle/vehicle.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Vehicle', { - refresh: function(frm) { - - } +frappe.ui.form.on("Vehicle", { + refresh: function (frm) {}, }); diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index e02abb48e5c..36a51056bb4 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -1,4 +1,4 @@ -frappe.provide('erpnext.stock'); +frappe.provide("erpnext.stock"); erpnext.stock.ItemDashboard = class ItemDashboard { constructor(opts) { @@ -9,46 +9,51 @@ erpnext.stock.ItemDashboard = class ItemDashboard { var me = this; this.start = 0; if (!this.sort_by) { - this.sort_by = 'projected_qty'; - this.sort_order = 'asc'; + this.sort_by = "projected_qty"; + this.sort_order = "asc"; } - this.content = $(frappe.render_template('item_dashboard')).appendTo(this.parent); - this.result = this.content.find('.result'); + this.content = $(frappe.render_template("item_dashboard")).appendTo(this.parent); + this.result = this.content.find(".result"); - this.content.on('click', '.btn-move', function () { + this.content.on("click", ".btn-move", function () { handle_move_add($(this), "Move"); }); - this.content.on('click', '.btn-add', function () { + this.content.on("click", ".btn-add", function () { handle_move_add($(this), "Add"); }); - this.content.on('click', '.btn-edit', function () { - let item = unescape($(this).attr('data-item')); - let warehouse = unescape($(this).attr('data-warehouse')); - let company = unescape($(this).attr('data-company')); - frappe.db.get_value('Putaway Rule', { - 'item_code': item, - 'warehouse': warehouse, - 'company': company - }, 'name', (r) => { - frappe.set_route("Form", "Putaway Rule", r.name); - }); + this.content.on("click", ".btn-edit", function () { + let item = unescape($(this).attr("data-item")); + let warehouse = unescape($(this).attr("data-warehouse")); + let company = unescape($(this).attr("data-company")); + frappe.db.get_value( + "Putaway Rule", + { + item_code: item, + warehouse: warehouse, + company: company, + }, + "name", + (r) => { + frappe.set_route("Form", "Putaway Rule", r.name); + } + ); }); function handle_move_add(element, action) { - let item = unescape(element.attr('data-item')); - let warehouse = unescape(element.attr('data-warehouse')); - let actual_qty = unescape(element.attr('data-actual_qty')); - let disable_quick_entry = Number(unescape(element.attr('data-disable_quick_entry'))); + let item = unescape(element.attr("data-item")); + let warehouse = unescape(element.attr("data-warehouse")); + let actual_qty = unescape(element.attr("data-actual_qty")); + let disable_quick_entry = Number(unescape(element.attr("data-disable_quick_entry"))); let entry_type = action === "Move" ? "Material Transfer" : "Material Receipt"; if (disable_quick_entry) { open_stock_entry(item, warehouse, entry_type); } else { if (action === "Add") { - let rate = unescape($(this).attr('data-rate')); + let rate = unescape($(this).attr("data-rate")); erpnext.stock.move_item(item, null, warehouse, actual_qty, rate, function () { me.refresh(); }); @@ -61,35 +66,33 @@ erpnext.stock.ItemDashboard = class ItemDashboard { } function open_stock_entry(item, warehouse, entry_type) { - frappe.model.with_doctype('Stock Entry', function () { - var doc = frappe.model.get_new_doc('Stock Entry'); + frappe.model.with_doctype("Stock Entry", function () { + var doc = frappe.model.get_new_doc("Stock Entry"); if (entry_type) { doc.stock_entry_type = entry_type; } - var row = frappe.model.add_child(doc, 'items'); + var row = frappe.model.add_child(doc, "items"); row.item_code = item; if (entry_type === "Material Transfer") { row.s_warehouse = warehouse; - } - else { + } else { row.t_warehouse = warehouse; } - frappe.set_route('Form', doc.doctype, doc.name); + frappe.set_route("Form", doc.doctype, doc.name); }); } // more - this.content.find('.btn-more').on('click', function () { + this.content.find(".btn-more").on("click", function () { me.start += me.page_length; me.refresh(); }); - } refresh() { - if(this.before_refresh) { + if (this.before_refresh) { this.before_refresh(); } @@ -101,7 +104,7 @@ erpnext.stock.ItemDashboard = class ItemDashboard { company: this.company, start: this.start, sort_by: this.sort_by, - sort_order: this.sort_order + sort_order: this.sort_order, }; var me = this; @@ -110,14 +113,14 @@ erpnext.stock.ItemDashboard = class ItemDashboard { args: args, callback: function (r) { me.render(r.message); - if(me.after_refresh) { + if (me.after_refresh) { me.after_refresh(); } - } + }, }); } render(data) { - if (this.start===0) { + if (this.start === 0) { this.max_count = 0; this.result.empty(); } @@ -130,22 +133,22 @@ erpnext.stock.ItemDashboard = class ItemDashboard { } // show more button - if (data && data.length === (this.page_length + 1)) { - this.content.find('.more').removeClass('hidden'); + if (data && data.length === this.page_length + 1) { + this.content.find(".more").removeClass("hidden"); // remove the last element data.splice(-1); } else { - this.content.find('.more').addClass('hidden'); + this.content.find(".more").addClass("hidden"); } // If not any stock in any warehouses provide a message to end user if (context.data.length > 0) { - this.content.find('.result').css('text-align', 'unset'); + this.content.find(".result").css("text-align", "unset"); $(frappe.render_template(this.template, context)).appendTo(this.result); } else { var message = __("No Stock Available Currently"); - this.content.find('.result').css('text-align', 'center'); + this.content.find(".result").css("text-align", "center"); $(`
      ${message}
      `).appendTo(this.result); @@ -153,19 +156,23 @@ erpnext.stock.ItemDashboard = class ItemDashboard { } get_item_dashboard_data(data, max_count, show_item) { - if(!max_count) max_count = 0; - if(!data) data = []; + if (!max_count) max_count = 0; + if (!data) data = []; data.forEach(function (d) { - d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production + d.reserved_qty_for_sub_contract; + d.actual_or_pending = + d.projected_qty + + d.reserved_qty + + d.reserved_qty_for_production + + d.reserved_qty_for_sub_contract; d.pending_qty = 0; - d.total_reserved = d.reserved_qty + d.reserved_qty_for_production + d.reserved_qty_for_sub_contract; + d.total_reserved = + d.reserved_qty + d.reserved_qty_for_production + d.reserved_qty_for_sub_contract; if (d.actual_or_pending > d.actual_qty) { d.pending_qty = d.actual_or_pending - d.actual_qty; } - max_count = Math.max(d.actual_or_pending, d.actual_qty, - d.total_reserved, max_count); + max_count = Math.max(d.actual_or_pending, d.actual_qty, d.total_reserved, max_count); }); let can_write = 0; @@ -177,7 +184,7 @@ erpnext.stock.ItemDashboard = class ItemDashboard { data: data, max_count: max_count, can_write: can_write, - show_item: show_item || false + show_item: show_item || false, }; } @@ -202,73 +209,74 @@ erpnext.stock.ItemDashboard = class ItemDashboard { erpnext.stock.move_item = function (item, source, target, actual_qty, rate, callback) { var dialog = new frappe.ui.Dialog({ - title: target ? __('Add Item') : __('Move Item'), - fields: [{ - fieldname: 'item_code', - label: __('Item'), - fieldtype: 'Link', - options: 'Item', - read_only: 1 - }, - { - fieldname: 'source', - label: __('Source Warehouse'), - fieldtype: 'Link', - options: 'Warehouse', - read_only: 1 - }, - { - fieldname: 'target', - label: __('Target Warehouse'), - fieldtype: 'Link', - options: 'Warehouse', - reqd: 1, - get_query() { - return { - filters: { - is_group: 0 - } - } - } - }, - { - fieldname: 'qty', - label: __('Quantity'), - reqd: 1, - fieldtype: 'Float', - description: __('Available {0}', [actual_qty]) - }, - { - fieldname: 'rate', - label: __('Rate'), - fieldtype: 'Currency', - hidden: 1 - }, + title: target ? __("Add Item") : __("Move Item"), + fields: [ + { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", + read_only: 1, + }, + { + fieldname: "source", + label: __("Source Warehouse"), + fieldtype: "Link", + options: "Warehouse", + read_only: 1, + }, + { + fieldname: "target", + label: __("Target Warehouse"), + fieldtype: "Link", + options: "Warehouse", + reqd: 1, + get_query() { + return { + filters: { + is_group: 0, + }, + }; + }, + }, + { + fieldname: "qty", + label: __("Quantity"), + reqd: 1, + fieldtype: "Float", + description: __("Available {0}", [actual_qty]), + }, + { + fieldname: "rate", + label: __("Rate"), + fieldtype: "Currency", + hidden: 1, + }, ], }); dialog.show(); - dialog.get_field('item_code').set_input(item); + dialog.get_field("item_code").set_input(item); if (source) { - dialog.get_field('source').set_input(source); + dialog.get_field("source").set_input(source); } else { - dialog.get_field('source').df.hidden = 1; - dialog.get_field('source').refresh(); + dialog.get_field("source").df.hidden = 1; + dialog.get_field("source").refresh(); } if (rate) { - dialog.get_field('rate').set_value(rate); - dialog.get_field('rate').df.hidden = 0; - dialog.get_field('rate').refresh(); + dialog.get_field("rate").set_value(rate); + dialog.get_field("rate").df.hidden = 0; + dialog.get_field("rate").refresh(); } if (target) { - dialog.get_field('target').df.read_only = 1; - dialog.get_field('target').value = target; - dialog.get_field('target').refresh(); + dialog.get_field("target").df.read_only = 1; + dialog.get_field("target").value = target; + dialog.get_field("target").refresh(); } - dialog.set_primary_action(__('Create Stock Entry'), function () { + dialog.set_primary_action(__("Create Stock Entry"), function () { if (source && (dialog.get_value("qty") == 0 || dialog.get_value("qty") > actual_qty)) { frappe.msgprint(__("Quantity must be greater than zero, and less or equal to {0}", [actual_qty])); return; @@ -279,20 +287,20 @@ erpnext.stock.move_item = function (item, source, target, actual_qty, rate, call return; } - frappe.model.with_doctype('Stock Entry', function () { - let doc = frappe.model.get_new_doc('Stock Entry'); - doc.from_warehouse = dialog.get_value('source'); - doc.to_warehouse = dialog.get_value('target'); + frappe.model.with_doctype("Stock Entry", function () { + let doc = frappe.model.get_new_doc("Stock Entry"); + doc.from_warehouse = dialog.get_value("source"); + doc.to_warehouse = dialog.get_value("target"); doc.stock_entry_type = doc.from_warehouse ? "Material Transfer" : "Material Receipt"; - let row = frappe.model.add_child(doc, 'items'); - row.item_code = dialog.get_value('item_code'); - row.s_warehouse = dialog.get_value('source'); - row.t_warehouse = dialog.get_value('target'); - row.qty = dialog.get_value('qty'); + let row = frappe.model.add_child(doc, "items"); + row.item_code = dialog.get_value("item_code"); + row.s_warehouse = dialog.get_value("source"); + row.t_warehouse = dialog.get_value("target"); + row.qty = dialog.get_value("qty"); row.conversion_factor = 1; - row.transfer_qty = dialog.get_value('qty'); - row.basic_rate = dialog.get_value('rate'); - frappe.set_route('Form', doc.doctype, doc.name); + row.transfer_qty = dialog.get_value("qty"); + row.basic_rate = dialog.get_value("rate"); + frappe.set_route("Form", doc.doctype, doc.name); }); }); }; diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js index 2b9d46e4ab0..a550174d656 100644 --- a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js +++ b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js @@ -1,4 +1,4 @@ -frappe.provide('frappe.dashboards.chart_sources'); +frappe.provide("frappe.dashboards.chart_sources"); frappe.dashboards.chart_sources["Warehouse wise Stock Value"] = { method: "erpnext.stock.dashboard_chart_source.warehouse_wise_stock_value.warehouse_wise_stock_value.get", @@ -8,7 +8,7 @@ frappe.dashboards.chart_sources["Warehouse wise Stock Value"] = { label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") - } - ] + default: frappe.defaults.get_user_default("Company"), + }, + ], }; diff --git a/erpnext/stock/doctype/batch/batch.js b/erpnext/stock/doctype/batch/batch.js index f4a935aa90d..3719c96c6e7 100644 --- a/erpnext/stock/doctype/batch/batch.js +++ b/erpnext/stock/doctype/batch/batch.js @@ -1,62 +1,72 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on('Batch', { +frappe.ui.form.on("Batch", { setup: (frm) => { - frm.fields_dict['item'].get_query = function(doc, cdt, cdn) { + frm.fields_dict["item"].get_query = function (doc, cdt, cdn) { return { query: "erpnext.controllers.queries.item_query", - filters:{ - 'is_stock_item': 1, - 'has_batch_no': 1 - } - } - } + filters: { + is_stock_item: 1, + has_batch_no: 1, + }, + }; + }; }, refresh: (frm) => { - if(!frm.is_new()) { + if (!frm.is_new()) { frm.add_custom_button(__("View Ledger"), () => { frappe.route_options = { - batch_no: frm.doc.name + batch_no: frm.doc.name, }; frappe.set_route("query-report", "Stock Ledger"); }); - frm.trigger('make_dashboard'); + frm.trigger("make_dashboard"); } }, item: (frm) => { // frappe.db.get_value('Item', {name: frm.doc.item}, 'has_expiry_date', (r) => { // frm.toggle_reqd('expiry_date', r.has_expiry_date); // }); - frappe.db.get_value('Item', {name: frm.doc.item}, ['shelf_life_in_days', 'has_expiry_date'], (r) => { - if (r.has_expiry_date && r.shelf_life_in_days) { - // Calculate expiry date based on shelf_life_in_days - frm.set_value('expiry_date', frappe.datetime.add_days(frm.doc.manufacturing_date, r.shelf_life_in_days)); - }else if(r.has_expiry_date){ - frm.toggle_reqd('expiry_date', r.has_expiry_date); + frappe.db.get_value( + "Item", + { name: frm.doc.item }, + ["shelf_life_in_days", "has_expiry_date"], + (r) => { + if (r.has_expiry_date && r.shelf_life_in_days) { + // Calculate expiry date based on shelf_life_in_days + frm.set_value( + "expiry_date", + frappe.datetime.add_days(frm.doc.manufacturing_date, r.shelf_life_in_days) + ); + } else if (r.has_expiry_date) { + frm.toggle_reqd("expiry_date", r.has_expiry_date); + } } - }) + ); }, make_dashboard: (frm) => { - if(!frm.is_new()) { + if (!frm.is_new()) { frappe.call({ - method: 'erpnext.stock.doctype.batch.batch.get_batch_qty', - args: {batch_no: frm.doc.name, item_code: frm.doc.item}, + method: "erpnext.stock.doctype.batch.batch.get_batch_qty", + args: { batch_no: frm.doc.name, item_code: frm.doc.item }, callback: (r) => { - if(!r.message) { + if (!r.message) { return; } - const section = frm.dashboard.add_section('', __("Stock Levels")); + const section = frm.dashboard.add_section("", __("Stock Levels")); // sort by qty - r.message.sort(function(a, b) { a.qty > b.qty ? 1 : -1 }); + r.message.sort(function (a, b) { + a.qty > b.qty ? 1 : -1; + }); - const rows = $('
      ').appendTo(section); + const rows = $("
      ").appendTo(section); // show - (r.message || []).forEach(function(d) { - if(d.qty > 0) { + (r.message || []).forEach(function (d) { + if (d.qty > 0) { $(`
      ${d.warehouse}
      ${d.qty}
      @@ -64,98 +74,110 @@ frappe.ui.form.on('Batch', { + ${__("Move")} + ${__("Split")}
      `).appendTo(rows); } }); // move - ask for target warehouse and make stock entry - rows.find('.btn-move').on('click', function() { + rows.find(".btn-move").on("click", function () { const $btn = $(this); const fields = [ { - fieldname: 'to_warehouse', - label: __('To Warehouse'), - fieldtype: 'Link', - options: 'Warehouse' - } + fieldname: "to_warehouse", + label: __("To Warehouse"), + fieldtype: "Link", + options: "Warehouse", + }, ]; frappe.prompt( fields, (data) => { frappe.call({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry_utils.make_stock_entry', + 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'), + qty: $btn.attr("data-qty"), + from_warehouse: $btn.attr("data-warehouse"), to_warehouse: data.to_warehouse, source_document: frm.doc.reference_name, - reference_doctype: frm.doc.reference_doctype + reference_doctype: frm.doc.reference_doctype, }, callback: (r) => { - frappe.show_alert(__('Stock Entry {0} created', - ['' + r.message.name+ ''])); + frappe.show_alert( + __("Stock Entry {0} created", [ + '' + + r.message.name + + "", + ]) + ); frm.refresh(); }, }); }, - __('Select Target Warehouse'), - __('Move') + __("Select Target Warehouse"), + __("Move") ); }); // split - ask for new qty and batch ID (optional) // and make stock entry via batch.batch_split - rows.find('.btn-split').on('click', function() { + rows.find(".btn-split").on("click", function () { const $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.xcall( - 'erpnext.stock.doctype.batch.batch.split_batch', + frappe.prompt( + [ { - 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 - } - ).then(() => frm.reload_doc()); - }, - __('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 + .xcall("erpnext.stock.doctype.batch.batch.split_batch", { + 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, + }) + .then(() => frm.reload_doc()); + }, + __("Split Batch"), + __("Split") ); - }) + }); frm.dashboard.show(); - } + }, }); } - } -}) + }, +}); -frappe.ui.form.on('Batch', 'manufacturing_date', function (frm){ - frappe.db.get_value('Item', {name: frm.doc.item}, ['shelf_life_in_days', 'has_expiry_date'], (r) => { +frappe.ui.form.on("Batch", "manufacturing_date", function (frm) { + frappe.db.get_value("Item", { name: frm.doc.item }, ["shelf_life_in_days", "has_expiry_date"], (r) => { if (r.has_expiry_date && r.shelf_life_in_days) { // Calculate expiry date based on shelf_life_in_days - frm.set_value('expiry_date', frappe.datetime.add_days(frm.doc.manufacturing_date, r.shelf_life_in_days)); + frm.set_value( + "expiry_date", + frappe.datetime.add_days(frm.doc.manufacturing_date, r.shelf_life_in_days) + ); } - }) -}) + }); +}); diff --git a/erpnext/stock/doctype/batch/batch_list.js b/erpnext/stock/doctype/batch/batch_list.js index f1a0643cfde..2060d6e8763 100644 --- a/erpnext/stock/doctype/batch/batch_list.js +++ b/erpnext/stock/doctype/batch/batch_list.js @@ -1,14 +1,21 @@ -frappe.listview_settings['Batch'] = { +frappe.listview_settings["Batch"] = { add_fields: ["item", "expiry_date", "batch_qty", "disabled"], get_indicator: (doc) => { if (doc.disabled) { return [__("Disabled"), "gray", "disabled,=,1"]; } else if (!doc.batch_qty) { return [__("Empty"), "gray", "batch_qty,=,0|disabled,=,0"]; - } else if (doc.expiry_date && frappe.datetime.get_diff(doc.expiry_date, frappe.datetime.nowdate()) <= 0) { - return [__("Expired"), "red", "expiry_date,not in,|expiry_date,<=,Today|batch_qty,>,0|disabled,=,0"] + } else if ( + doc.expiry_date && + frappe.datetime.get_diff(doc.expiry_date, frappe.datetime.nowdate()) <= 0 + ) { + return [ + __("Expired"), + "red", + "expiry_date,not in,|expiry_date,<=,Today|batch_qty,>,0|disabled,=,0", + ]; } else { return [__("Active"), "green", "batch_qty,>,0|disabled,=,0"]; } - } + }, }; diff --git a/erpnext/stock/doctype/bin/bin.js b/erpnext/stock/doctype/bin/bin.js index 40411b68b48..02ff8b62396 100644 --- a/erpnext/stock/doctype/bin/bin.js +++ b/erpnext/stock/doctype/bin/bin.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Bin', { - refresh: function(frm) { - - } +frappe.ui.form.on("Bin", { + refresh: function (frm) {}, }); diff --git a/erpnext/stock/doctype/closing_stock_balance/closing_stock_balance.js b/erpnext/stock/doctype/closing_stock_balance/closing_stock_balance.js index 5c807a80a04..0f0221fa562 100644 --- a/erpnext/stock/doctype/closing_stock_balance/closing_stock_balance.js +++ b/erpnext/stock/doctype/closing_stock_balance/closing_stock_balance.js @@ -16,9 +16,9 @@ frappe.ui.form.on("Closing Stock Balance", { freeze: true, callback: () => { frm.reload_doc(); - } - }) - }) + }, + }); + }); } }, @@ -31,9 +31,9 @@ frappe.ui.form.on("Closing Stock Balance", { freeze: true, callback: () => { frm.reload_doc(); - } - }) - }) + }, + }); + }); } - } + }, }); diff --git a/erpnext/stock/doctype/customs_tariff_number/customs_tariff_number.js b/erpnext/stock/doctype/customs_tariff_number/customs_tariff_number.js index a39414c8363..bb60ee7e368 100644 --- a/erpnext/stock/doctype/customs_tariff_number/customs_tariff_number.js +++ b/erpnext/stock/doctype/customs_tariff_number/customs_tariff_number.js @@ -1,8 +1,6 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Customs Tariff Number', { - refresh: function(frm) { - - } +frappe.ui.form.on("Customs Tariff Number", { + refresh: function (frm) {}, }); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 14aedca39eb..c04d5c188a0 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.add_fetch('customer', 'tax_id', 'tax_id'); +cur_frm.add_fetch("customer", "tax_id", "tax_id"); frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock.delivery_note"); @@ -11,138 +11,148 @@ erpnext.accounts.taxes.setup_tax_filters("Sales Taxes and Charges"); erpnext.accounts.taxes.setup_tax_validations("Delivery Note"); erpnext.sales_common.setup_selling_controller(); - frappe.ui.form.on("Delivery Note", { - setup: function(frm) { - frm.custom_make_buttons = { - 'Packing Slip': 'Packing Slip', - 'Installation Note': 'Installation Note', - 'Sales Invoice': 'Sales Invoice', - 'Stock Entry': 'Return', - 'Shipment': 'Shipment' - }, - frm.set_indicator_formatter('item_code', - function(doc) { - return (doc.docstatus==1 || doc.qty<=doc.actual_qty) ? "green" : "orange" - }) + setup: function (frm) { + (frm.custom_make_buttons = { + "Packing Slip": "Packing Slip", + "Installation Note": "Installation Note", + "Sales Invoice": "Sales Invoice", + "Stock Entry": "Return", + Shipment: "Shipment", + }), + frm.set_indicator_formatter("item_code", function (doc) { + return doc.docstatus == 1 || doc.qty <= doc.actual_qty ? "green" : "orange"; + }); - erpnext.queries.setup_queries(frm, "Warehouse", function() { + erpnext.queries.setup_queries(frm, "Warehouse", function () { return erpnext.queries.warehouse(frm.doc); }); erpnext.queries.setup_warehouse_query(frm); - frm.set_query('transporter', function() { + frm.set_query("transporter", function () { return { filters: { - 'is_transporter': 1 - } - } + is_transporter: 1, + }, + }; }); - frm.set_query('driver', function(doc) { + frm.set_query("driver", function (doc) { return { filters: { - 'transporter': doc.transporter - } - } + transporter: doc.transporter, + }, + }; }); - - frm.set_query('expense_account', 'items', function(doc, cdt, cdn) { + frm.set_query("expense_account", "items", function (doc, cdt, cdn) { if (erpnext.is_perpetual_inventory_enabled(doc.company)) { return { filters: { - "report_type": "Profit and Loss", - "company": doc.company, - "is_group": 0 - } - } + report_type: "Profit and Loss", + company: doc.company, + is_group: 0, + }, + }; } }); - frm.set_query('cost_center', 'items', function(doc, cdt, cdn) { + frm.set_query("cost_center", "items", function (doc, cdt, cdn) { if (erpnext.is_perpetual_inventory_enabled(doc.company)) { return { filters: { - 'company': doc.company, - "is_group": 0 - } - } + company: doc.company, + is_group: 0, + }, + }; } }); - frm.set_df_property('packed_items', 'cannot_add_rows', true); - frm.set_df_property('packed_items', 'cannot_delete_rows', true); + frm.set_df_property("packed_items", "cannot_add_rows", true); + frm.set_df_property("packed_items", "cannot_delete_rows", true); }, - print_without_amount: function(frm) { + print_without_amount: function (frm) { erpnext.stock.delivery_note.set_print_hide(frm.doc); }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) { - frm.add_custom_button(__('Credit Note'), function() { - frappe.model.open_mapped_doc({ - method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", - frm: cur_frm, - }) - }, __('Create')); - frm.page.set_inner_btn_group_as_primary(__('Create')); + frm.add_custom_button( + __("Credit Note"), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", + frm: cur_frm, + }); + }, + __("Create") + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } if (frm.doc.docstatus == 1 && !frm.doc.inter_company_reference) { let internal = frm.doc.is_internal_customer; if (internal) { - let button_label = (frm.doc.company === frm.doc.represents_company) ? "Internal Purchase Receipt" : - "Inter Company Purchase Receipt"; + let button_label = + frm.doc.company === frm.doc.represents_company + ? "Internal Purchase Receipt" + : "Inter Company Purchase Receipt"; - frm.add_custom_button(__(button_label), function() { - frappe.model.open_mapped_doc({ - method: 'erpnext.stock.doctype.delivery_note.delivery_note.make_inter_company_purchase_receipt', - frm: frm, - }); - }, __('Create')); + frm.add_custom_button( + __(button_label), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_inter_company_purchase_receipt", + frm: frm, + }); + }, + __("Create") + ); } } - } + }, }); frappe.ui.form.on("Delivery Note Item", { - expense_account: function(frm, dt, dn) { + expense_account: function (frm, dt, dn) { var d = locals[dt][dn]; - frm.update_in_all_rows('items', 'expense_account', d.expense_account); + frm.update_in_all_rows("items", "expense_account", d.expense_account); }, - cost_center: function(frm, dt, dn) { + cost_center: function (frm, dt, dn) { var d = locals[dt][dn]; - frm.update_in_all_rows('items', 'cost_center', d.cost_center); - } + frm.update_in_all_rows("items", "cost_center", d.cost_center); + }, }); -erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpnext.selling.SellingController { +erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends ( + erpnext.selling.SellingController +) { setup(doc) { this.setup_posting_date_time_check(); super.setup(doc); this.frm.make_methods = { - 'Delivery Trip': this.make_delivery_trip, + "Delivery Trip": this.make_delivery_trip, }; } refresh(doc, dt, dn) { var me = this; super.refresh(); - if ((!doc.is_return) && (doc.status!="Closed" || this.frm.is_new())) { - if (this.frm.doc.docstatus===0) { - this.frm.add_custom_button(__('Sales Order'), - function() { + if (!doc.is_return && (doc.status != "Closed" || this.frm.is_new())) { + if (this.frm.doc.docstatus === 0) { + this.frm.add_custom_button( + __("Sales Order"), + function () { if (!me.frm.doc.customer) { frappe.throw({ title: __("Mandatory"), - message: __("Please Select a Customer") + message: __("Please Select a Customer"), }); } erpnext.utils.map_current_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note", args: { - for_reserved_stock: 1 + for_reserved_stock: 1, }, source_doctype: "Sales Order", target: me.frm, @@ -155,45 +165,71 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn per_delivered: ["<", 99.99], company: me.frm.doc.company, project: me.frm.doc.project || undefined, - } - }) - }, __("Get Items From")); + }, + }); + }, + __("Get Items From") + ); } } - if (!doc.is_return && doc.status!="Closed") { - if(doc.docstatus == 1) { - this.frm.add_custom_button(__('Shipment'), function() { - me.make_shipment() }, __('Create')); + if (!doc.is_return && doc.status != "Closed") { + if (doc.docstatus == 1) { + this.frm.add_custom_button( + __("Shipment"), + function () { + me.make_shipment(); + }, + __("Create") + ); } - if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) - this.frm.add_custom_button(__('Installation Note'), function() { - me.make_installation_note() }, __('Create')); + if (flt(doc.per_installed, 2) < 100 && doc.docstatus == 1) + this.frm.add_custom_button( + __("Installation Note"), + function () { + me.make_installation_note(); + }, + __("Create") + ); - if (doc.docstatus==1) { - this.frm.add_custom_button(__('Sales Return'), function() { - me.make_sales_return() }, __('Create')); + if (doc.docstatus == 1) { + this.frm.add_custom_button( + __("Sales Return"), + function () { + me.make_sales_return(); + }, + __("Create") + ); } - if (doc.docstatus==1) { - this.frm.add_custom_button(__('Delivery Trip'), function() { - me.make_delivery_trip() }, __('Create')); + if (doc.docstatus == 1) { + this.frm.add_custom_button( + __("Delivery Trip"), + function () { + me.make_delivery_trip(); + }, + __("Create") + ); } - if(doc.docstatus==0 && !doc.__islocal) { + if (doc.docstatus == 0 && !doc.__islocal) { if (doc.__onload && doc.__onload.has_unpacked_items) { - this.frm.add_custom_button(__('Packing Slip'), function() { - frappe.model.open_mapped_doc({ - method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip", - frm: me.frm - }) }, __('Create') + this.frm.add_custom_button( + __("Packing Slip"), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip", + frm: me.frm, + }); + }, + __("Create") ); } } - if (!doc.__islocal && doc.docstatus==1) { - this.frm.page.set_inner_btn_group_as_primary(__('Create')); + if (!doc.__islocal && doc.docstatus == 1) { + this.frm.page.set_inner_btn_group_as_primary(__("Create")); } } @@ -206,27 +242,42 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn this.show_general_ledger(); } if (this.frm.has_perm("submit") && doc.status !== "Closed") { - me.frm.add_custom_button(__("Close"), function() { me.close_delivery_note() }, - __("Status")) + me.frm.add_custom_button( + __("Close"), + function () { + me.close_delivery_note(); + }, + __("Status") + ); } } - if(doc.docstatus==1 && !doc.is_return && doc.status!="Closed" && flt(doc.per_billed) < 100) { + if (doc.docstatus == 1 && !doc.is_return && doc.status != "Closed" && flt(doc.per_billed) < 100) { // show Make Invoice button only if Delivery Note is not created from Sales Invoice var from_sales_invoice = false; - from_sales_invoice = me.frm.doc.items.some(function(item) { + from_sales_invoice = me.frm.doc.items.some(function (item) { return item.against_sales_invoice ? true : false; }); - if(!from_sales_invoice) { - this.frm.add_custom_button(__('Sales Invoice'), function() { me.make_sales_invoice() }, - __('Create')); + if (!from_sales_invoice) { + this.frm.add_custom_button( + __("Sales Invoice"), + function () { + me.make_sales_invoice(); + }, + __("Create") + ); } } - if(doc.docstatus==1 && doc.status === "Closed" && this.frm.has_perm("submit")) { - this.frm.add_custom_button(__('Reopen'), function() { me.reopen_delivery_note() }, - __("Status")) + if (doc.docstatus == 1 && doc.status === "Closed" && this.frm.has_perm("submit")) { + this.frm.add_custom_button( + __("Reopen"), + function () { + me.reopen_delivery_note(); + }, + __("Status") + ); } erpnext.stock.delivery_note.set_print_hide(doc, dt, dn); } @@ -234,36 +285,36 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn make_shipment() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_shipment", - frm: this.frm - }) + frm: this.frm, + }); } make_sales_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", - frm: this.frm - }) + frm: this.frm, + }); } make_installation_note() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note", - frm: this.frm + frm: this.frm, }); } make_sales_return() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_return", - frm: this.frm - }) + frm: this.frm, + }); } make_delivery_trip() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", - frm: cur_frm - }) + frm: cur_frm, + }); } tc_name() { @@ -278,96 +329,91 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn erpnext.setup_serial_or_batch_no(); } - close_delivery_note(doc){ - this.update_status("Closed") + close_delivery_note(doc) { + this.update_status("Closed"); } reopen_delivery_note() { - this.update_status("Submitted") + this.update_status("Submitted"); } update_status(status) { var me = this; frappe.ui.form.is_saving = true; frappe.call({ - method:"erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status", - args: {docname: me.frm.doc.name, status: status}, - callback: function(r){ - if(!r.exc) - me.frm.reload_doc(); + method: "erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status", + args: { docname: me.frm.doc.name, status: status }, + callback: function (r) { + if (!r.exc) me.frm.reload_doc(); }, - always: function(){ + always: function () { frappe.ui.form.is_saving = false; - } - }) + }, + }); } }; -extend_cscript(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({ frm: cur_frm })); -frappe.ui.form.on('Delivery Note', { - setup: function(frm) { - if(frm.doc.company) { +frappe.ui.form.on("Delivery Note", { + setup: function (frm) { + if (frm.doc.company) { frm.trigger("unhide_account_head"); } }, - company: function(frm) { + company: function (frm) { frm.trigger("unhide_account_head"); erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); }, - unhide_account_head: function(frm) { + unhide_account_head: function (frm) { // unhide expense_account and cost_center if perpetual inventory is enabled in the company - var aii_enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company) + var aii_enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company); frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled); - } -}) + }, +}); - -erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){ - var dn_fields = frappe.meta.docfield_map['Delivery Note']; - var dn_item_fields = frappe.meta.docfield_map['Delivery Note Item']; +erpnext.stock.delivery_note.set_print_hide = function (doc, cdt, cdn) { + var dn_fields = frappe.meta.docfield_map["Delivery Note"]; + var dn_item_fields = frappe.meta.docfield_map["Delivery Note Item"]; var dn_fields_copy = dn_fields; var dn_item_fields_copy = dn_item_fields; if (doc.print_without_amount) { - dn_fields['currency'].print_hide = 1; - dn_item_fields['rate'].print_hide = 1; - dn_item_fields['discount_percentage'].print_hide = 1; - dn_item_fields['price_list_rate'].print_hide = 1; - dn_item_fields['amount'].print_hide = 1; - dn_item_fields['discount_amount'].print_hide = 1; - dn_fields['taxes'].print_hide = 1; + dn_fields["currency"].print_hide = 1; + dn_item_fields["rate"].print_hide = 1; + dn_item_fields["discount_percentage"].print_hide = 1; + dn_item_fields["price_list_rate"].print_hide = 1; + dn_item_fields["amount"].print_hide = 1; + dn_item_fields["discount_amount"].print_hide = 1; + dn_fields["taxes"].print_hide = 1; } else { - if (dn_fields_copy['currency'].print_hide != 1) - dn_fields['currency'].print_hide = 0; - if (dn_item_fields_copy['rate'].print_hide != 1) - dn_item_fields['rate'].print_hide = 0; - if (dn_item_fields_copy['amount'].print_hide != 1) - dn_item_fields['amount'].print_hide = 0; - if (dn_item_fields_copy['discount_amount'].print_hide != 1) - dn_item_fields['discount_amount'].print_hide = 0; - if (dn_fields_copy['taxes'].print_hide != 1) - dn_fields['taxes'].print_hide = 0; + if (dn_fields_copy["currency"].print_hide != 1) dn_fields["currency"].print_hide = 0; + if (dn_item_fields_copy["rate"].print_hide != 1) dn_item_fields["rate"].print_hide = 0; + if (dn_item_fields_copy["amount"].print_hide != 1) dn_item_fields["amount"].print_hide = 0; + if (dn_item_fields_copy["discount_amount"].print_hide != 1) + dn_item_fields["discount_amount"].print_hide = 0; + if (dn_fields_copy["taxes"].print_hide != 1) dn_fields["taxes"].print_hide = 0; } -} +}; - -frappe.tour['Delivery Note'] = [ +frappe.tour["Delivery Note"] = [ { fieldname: "customer", title: __("Customer"), - description: __("This field is used to set the 'Customer'.") + description: __("This field is used to set the 'Customer'."), }, { fieldname: "items", title: __("Items"), - description: __("This table is used to set details about the 'Item', 'Qty', 'Basic Rate', etc.") + " " + - __("Different 'Source Warehouse' and 'Target Warehouse' can be set for each row.") + description: + __("This table is used to set details about the 'Item', 'Qty', 'Basic Rate', etc.") + + " " + + __("Different 'Source Warehouse' and 'Target Warehouse' can be set for each row."), }, { fieldname: "set_posting_time", title: __("Edit Posting Date and Time"), - description: __("This option can be checked to edit the 'Posting Date' and 'Posting Time' fields.") - } -] + description: __("This option can be checked to edit the 'Posting Date' and 'Posting Time' fields."), + }, +]; diff --git a/erpnext/stock/doctype/delivery_note/delivery_note_list.js b/erpnext/stock/doctype/delivery_note/delivery_note_list.js index 51a899b6991..c6b98c4134c 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note_list.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note_list.js @@ -1,8 +1,18 @@ -frappe.listview_settings['Delivery Note'] = { - add_fields: ["customer", "customer_name", "base_grand_total", "per_installed", "per_billed", - "transporter_name", "grand_total", "is_return", "status", "currency"], - get_indicator: function(doc) { - if(cint(doc.is_return)==1) { +frappe.listview_settings["Delivery Note"] = { + add_fields: [ + "customer", + "customer_name", + "base_grand_total", + "per_installed", + "per_billed", + "transporter_name", + "grand_total", + "is_return", + "status", + "currency", + ], + get_indicator: function (doc) { + if (cint(doc.is_return) == 1) { return [__("Return"), "gray", "is_return,=,Yes"]; } else if (doc.status === "Closed") { return [__("Closed"), "green", "status,=,Closed"]; @@ -26,44 +36,43 @@ frappe.listview_settings['Delivery Note'] = { } } - frappe.new_doc("Delivery Trip") - .then(() => { - // Empty out the child table before inserting new ones - cur_frm.set_value("delivery_stops", []); + frappe.new_doc("Delivery Trip").then(() => { + // Empty out the child table before inserting new ones + cur_frm.set_value("delivery_stops", []); - // We don't want to use `map_current_doc` since it brings up - // the dialog to select more items. We just want the mapper - // function to be called. - frappe.call({ - type: "POST", - method: "frappe.model.mapper.map_docs", - args: { - "method": "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", - "source_names": docnames, - "target_doc": cur_frm.doc - }, - callback: function (r) { - if (!r.exc) { - frappe.model.sync(r.message); - cur_frm.dirty(); - cur_frm.refresh(); - } + // We don't want to use `map_current_doc` since it brings up + // the dialog to select more items. We just want the mapper + // function to be called. + frappe.call({ + type: "POST", + method: "frappe.model.mapper.map_docs", + args: { + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", + source_names: docnames, + target_doc: cur_frm.doc, + }, + callback: function (r) { + if (!r.exc) { + frappe.model.sync(r.message); + cur_frm.dirty(); + cur_frm.refresh(); } - }); - }) + }, + }); + }); } }; // doclist.page.add_actions_menu_item(__('Create Delivery Trip'), action, false); - doclist.page.add_action_item(__('Create Delivery Trip'), action); + doclist.page.add_action_item(__("Create Delivery Trip"), action); - doclist.page.add_action_item(__("Sales Invoice"), ()=>{ + doclist.page.add_action_item(__("Sales Invoice"), () => { erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Sales Invoice"); }); - doclist.page.add_action_item(__("Packaging Slip From Delivery Note"), ()=>{ + doclist.page.add_action_item(__("Packaging Slip From Delivery Note"), () => { erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Packing Slip"); }); - } -} + }, +}; diff --git a/erpnext/stock/doctype/delivery_settings/delivery_settings.js b/erpnext/stock/doctype/delivery_settings/delivery_settings.js index 03aa1922ff5..4328158e6d9 100644 --- a/erpnext/stock/doctype/delivery_settings/delivery_settings.js +++ b/erpnext/stock/doctype/delivery_settings/delivery_settings.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Delivery Settings', { - refresh: function(frm) { - - } +frappe.ui.form.on("Delivery Settings", { + refresh: function (frm) {}, }); diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.js b/erpnext/stock/doctype/delivery_trip/delivery_trip.js index 158bd0cac1e..4f8649c0bfa 100755 --- a/erpnext/stock/doctype/delivery_trip/delivery_trip.js +++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.js @@ -1,15 +1,15 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Delivery Trip', { +frappe.ui.form.on("Delivery Trip", { setup: function (frm) { - frm.set_indicator_formatter('customer', (stop) => (stop.visited) ? "green" : "orange"); + frm.set_indicator_formatter("customer", (stop) => (stop.visited ? "green" : "orange")); frm.set_query("driver", function () { return { filters: { - "status": "Active" - } + status: "Active", + }, }; }); @@ -17,58 +17,71 @@ frappe.ui.form.on('Delivery Trip', { var row = locals[cdt][cdn]; if (row.customer) { return { - query: 'frappe.contacts.doctype.address.address.address_query', + query: "frappe.contacts.doctype.address.address.address_query", filters: { link_doctype: "Customer", - link_name: row.customer - } + link_name: row.customer, + }, }; } - }) + }); frm.set_query("contact", "delivery_stops", function (doc, cdt, cdn) { var row = locals[cdt][cdn]; if (row.customer) { return { - query: 'frappe.contacts.doctype.contact.contact.contact_query', + query: "frappe.contacts.doctype.contact.contact.contact_query", filters: { link_doctype: "Customer", - link_name: row.customer - } + link_name: row.customer, + }, }; } - }) + }); }, refresh: function (frm) { if (frm.doc.docstatus == 1 && frm.doc.delivery_stops.length > 0) { frm.add_custom_button(__("Notify Customers via Email"), function () { - frm.trigger('notify_customers'); + frm.trigger("notify_customers"); }); } if (frm.doc.docstatus === 0) { - frm.add_custom_button(__('Delivery Note'), () => { - erpnext.utils.map_current_doc({ - method: "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", - source_doctype: "Delivery Note", - target: frm, - date_field: "posting_date", - setters: { - company: frm.doc.company, - }, - get_query_filters: { - docstatus: 1, - company: frm.doc.company, - } - }) - }, __("Get stops from")); - } - frm.add_custom_button(__("Delivery Notes"), function () { - frappe.set_route("List", "Delivery Note", - {'name': ["in", frm.doc.delivery_stops.map((stop) => {return stop.delivery_note;})]} + frm.add_custom_button( + __("Delivery Note"), + () => { + erpnext.utils.map_current_doc({ + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_delivery_trip", + source_doctype: "Delivery Note", + target: frm, + date_field: "posting_date", + setters: { + company: frm.doc.company, + }, + get_query_filters: { + docstatus: 1, + company: frm.doc.company, + }, + }); + }, + __("Get stops from") ); - }, __("View")); + } + frm.add_custom_button( + __("Delivery Notes"), + function () { + frappe.set_route("List", "Delivery Note", { + name: [ + "in", + frm.doc.delivery_stops.map((stop) => { + return stop.delivery_note; + }), + ], + }); + }, + __("View") + ); }, calculate_arrival_time: function (frm) { @@ -77,13 +90,17 @@ frappe.ui.form.on('Delivery Trip', { } frappe.show_alert({ message: "Calculating Arrival Times", - indicator: 'orange' - }); - frm.call("process_route", { - optimize: false, - }, () => { - frm.reload_doc(); + indicator: "orange", }); + frm.call( + "process_route", + { + optimize: false, + }, + () => { + frm.reload_doc(); + } + ); }, driver: function (frm) { @@ -91,11 +108,11 @@ frappe.ui.form.on('Delivery Trip', { frappe.call({ method: "erpnext.stock.doctype.delivery_trip.delivery_trip.get_driver_email", args: { - driver: frm.doc.driver + driver: frm.doc.driver, }, callback: (data) => { frm.set_value("driver_email", data.message.email); - } + }, }); } }, @@ -106,23 +123,27 @@ frappe.ui.form.on('Delivery Trip', { } frappe.show_alert({ message: "Optimizing Route", - indicator: 'orange' - }); - frm.call("process_route", { - optimize: true, - }, () => { - frm.reload_doc(); + indicator: "orange", }); + frm.call( + "process_route", + { + optimize: true, + }, + () => { + frm.reload_doc(); + } + ); }, notify_customers: function (frm) { $.each(frm.doc.delivery_stops || [], function (i, delivery_stop) { if (!delivery_stop.delivery_note) { frappe.msgprint({ - "message": __("No Delivery Note selected for Customer {}", [delivery_stop.customer]), - "title": __("Warning"), - "indicator": "orange", - "alert": 1 + message: __("No Delivery Note selected for Customer {}", [delivery_stop.customer]), + title: __("Warning"), + indicator: "orange", + alert: 1, }); } }); @@ -135,48 +156,45 @@ frappe.ui.form.on('Delivery Trip', { frappe.call({ method: "erpnext.stock.doctype.delivery_trip.delivery_trip.notify_customers", args: { - "delivery_trip": frm.doc.name + delivery_trip: frm.doc.name, }, callback: function (r) { if (!r.exc) { frm.doc.email_notification_sent = true; - frm.refresh_field('email_notification_sent'); + frm.refresh_field("email_notification_sent"); } - } + }, }); }); } }); - } + }, }); -frappe.ui.form.on('Delivery Stop', { +frappe.ui.form.on("Delivery Stop", { customer: function (frm, cdt, cdn) { var row = locals[cdt][cdn]; if (row.customer) { frappe.call({ method: "erpnext.stock.doctype.delivery_trip.delivery_trip.get_contact_and_address", - args: { "name": row.customer }, + args: { name: row.customer }, callback: function (r) { if (r.message) { if (r.message["shipping_address"]) { frappe.model.set_value(cdt, cdn, "address", r.message["shipping_address"].parent); - } - else { - frappe.model.set_value(cdt, cdn, "address", ''); + } else { + frappe.model.set_value(cdt, cdn, "address", ""); } if (r.message["contact_person"]) { frappe.model.set_value(cdt, cdn, "contact", r.message["contact_person"].parent); + } else { + frappe.model.set_value(cdt, cdn, "contact", ""); } - else { - frappe.model.set_value(cdt, cdn, "contact", ''); - } + } else { + frappe.model.set_value(cdt, cdn, "address", ""); + frappe.model.set_value(cdt, cdn, "contact", ""); } - else { - frappe.model.set_value(cdt, cdn, "address", ''); - frappe.model.set_value(cdt, cdn, "contact", ''); - } - } + }, }); } }, @@ -186,12 +204,12 @@ frappe.ui.form.on('Delivery Stop', { if (row.address) { frappe.call({ method: "frappe.contacts.doctype.address.address.get_address_display", - args: { "address_dict": row.address }, + args: { address_dict: row.address }, callback: function (r) { if (r.message) { frappe.model.set_value(cdt, cdn, "customer_address", r.message); } - } + }, }); } else { frappe.model.set_value(cdt, cdn, "customer_address", ""); @@ -203,15 +221,15 @@ frappe.ui.form.on('Delivery Stop', { if (row.contact) { frappe.call({ method: "erpnext.stock.doctype.delivery_trip.delivery_trip.get_contact_display", - args: { "contact": row.contact }, + args: { contact: row.contact }, callback: function (r) { if (r.message) { frappe.model.set_value(cdt, cdn, "customer_contact", r.message); } - } + }, }); } else { frappe.model.set_value(cdt, cdn, "customer_contact", ""); } - } + }, }); diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip_list.js b/erpnext/stock/doctype/delivery_trip/delivery_trip_list.js index 1d198b733fb..230107caadb 100644 --- a/erpnext/stock/doctype/delivery_trip/delivery_trip_list.js +++ b/erpnext/stock/doctype/delivery_trip/delivery_trip_list.js @@ -1,4 +1,4 @@ -frappe.listview_settings['Delivery Trip'] = { +frappe.listview_settings["Delivery Trip"] = { add_fields: ["status"], get_indicator: function (doc) { if (in_list(["Cancelled", "Draft"], doc.status)) { @@ -8,5 +8,5 @@ frappe.listview_settings['Delivery Trip'] = { } else if (doc.status === "Completed") { return [__(doc.status), "green", "status,=," + doc.status]; } - } + }, }; diff --git a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js index 35d1c02719c..c819d17b1e7 100644 --- a/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js +++ b/erpnext/stock/doctype/inventory_dimension/inventory_dimension.js @@ -1,43 +1,59 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Inventory Dimension', { +frappe.ui.form.on("Inventory Dimension", { setup(frm) { - frm.trigger('set_query_on_fields'); + frm.trigger("set_query_on_fields"); }, set_query_on_fields(frm) { - frm.set_query('reference_document', () => { + frm.set_query("reference_document", () => { let invalid_doctypes = frappe.model.core_doctypes_list; - invalid_doctypes.push('Batch', 'Serial No', 'Warehouse', 'Item', 'Inventory Dimension', - 'Accounting Dimension', 'Accounting Dimension Filter'); + invalid_doctypes.push( + "Batch", + "Serial No", + "Warehouse", + "Item", + "Inventory Dimension", + "Accounting Dimension", + "Accounting Dimension Filter" + ); return { filters: { - 'istable': 0, - 'issingle': 0, - 'name': ['not in', invalid_doctypes] - } + istable: 0, + issingle: 0, + name: ["not in", invalid_doctypes], + }, }; }); - frm.set_query('document_type', () => { + frm.set_query("document_type", () => { return { - query: 'erpnext.stock.doctype.inventory_dimension.inventory_dimension.get_inventory_documents', + query: "erpnext.stock.doctype.inventory_dimension.inventory_dimension.get_inventory_documents", }; }); }, onload(frm) { - frm.trigger('render_traget_field'); + frm.trigger("render_traget_field"); frm.trigger("set_parent_fields"); }, refresh(frm) { - if (frm.doc.__onload && frm.doc.__onload.has_stock_ledger - && frm.doc.__onload.has_stock_ledger.length) { - let allow_to_edit_fields = ['disabled', 'fetch_from_parent', - 'type_of_transaction', 'condition', 'mandatory_depends_on', 'validate_negative_stock']; + if ( + frm.doc.__onload && + frm.doc.__onload.has_stock_ledger && + frm.doc.__onload.has_stock_ledger.length + ) { + let allow_to_edit_fields = [ + "disabled", + "fetch_from_parent", + "type_of_transaction", + "condition", + "mandatory_depends_on", + "validate_negative_stock", + ]; frm.fields.forEach((field) => { if (!in_list(allow_to_edit_fields, field.df.fieldname)) { @@ -47,8 +63,8 @@ frappe.ui.form.on('Inventory Dimension', { } if (!frm.is_new()) { - frm.add_custom_button(__('Delete Dimension'), () => { - frm.trigger('delete_dimension'); + frm.add_custom_button(__("Delete Dimension"), () => { + frm.trigger("delete_dimension"); }); } }, @@ -62,39 +78,38 @@ frappe.ui.form.on('Inventory Dimension', { frm.set_df_property("fetch_from_parent", "options", frm.doc.reference_document); } else if (frm.doc.document_type && frm.doc.istable) { frappe.call({ - method: 'erpnext.stock.doctype.inventory_dimension.inventory_dimension.get_parent_fields', + method: "erpnext.stock.doctype.inventory_dimension.inventory_dimension.get_parent_fields", args: { child_doctype: frm.doc.document_type, - dimension_name: frm.doc.reference_document + dimension_name: frm.doc.reference_document, }, callback: (r) => { if (r.message && r.message.length) { - frm.set_df_property("fetch_from_parent", "options", - [""].concat(r.message)); + frm.set_df_property("fetch_from_parent", "options", [""].concat(r.message)); } else { frm.set_df_property("fetch_from_parent", "hidden", 1); } - } + }, }); } }, delete_dimension(frm) { - let msg = (` + let msg = ` Custom fields related to this dimension will be deleted on deletion of dimension.
      Do you want to delete {0} dimension? - `); + `; frappe.confirm(__(msg, [frm.doc.name.bold()]), () => { frappe.call({ - method: 'erpnext.stock.doctype.inventory_dimension.inventory_dimension.delete_dimension', + method: "erpnext.stock.doctype.inventory_dimension.inventory_dimension.delete_dimension", args: { - dimension: frm.doc.name + dimension: frm.doc.name, + }, + callback: function () { + frappe.set_route("List", "Inventory Dimension"); }, - callback: function() { - frappe.set_route('List', 'Inventory Dimension'); - } }); }); - } + }, }); diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index b964c843a72..7a38024872e 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -3,48 +3,47 @@ frappe.provide("erpnext.item"); -const SALES_DOCTYPES = ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice']; -const PURCHASE_DOCTYPES = ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']; +const SALES_DOCTYPES = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]; +const PURCHASE_DOCTYPES = ["Purchase Order", "Purchase Receipt", "Purchase Invoice"]; frappe.ui.form.on("Item", { - setup: function(frm) { - frm.add_fetch('attribute', 'numeric_values', 'numeric_values'); - frm.add_fetch('attribute', 'from_range', 'from_range'); - frm.add_fetch('attribute', 'to_range', 'to_range'); - frm.add_fetch('attribute', 'increment', 'increment'); - frm.add_fetch('tax_type', 'tax_rate', 'tax_rate'); + setup: function (frm) { + frm.add_fetch("attribute", "numeric_values", "numeric_values"); + frm.add_fetch("attribute", "from_range", "from_range"); + frm.add_fetch("attribute", "to_range", "to_range"); + frm.add_fetch("attribute", "increment", "increment"); + frm.add_fetch("tax_type", "tax_rate", "tax_rate"); frm.make_methods = { - 'Sales Order': () => { + "Sales Order": () => { open_form(frm, "Sales Order", "Sales Order Item", "items"); }, - 'Delivery Note': () => { + "Delivery Note": () => { open_form(frm, "Delivery Note", "Delivery Note Item", "items"); }, - 'Sales Invoice': () => { + "Sales Invoice": () => { open_form(frm, "Sales Invoice", "Sales Invoice Item", "items"); }, - 'Purchase Order': () => { + "Purchase Order": () => { open_form(frm, "Purchase Order", "Purchase Order Item", "items"); }, - 'Purchase Receipt': () => { + "Purchase Receipt": () => { open_form(frm, "Purchase Receipt", "Purchase Receipt Item", "items"); }, - 'Purchase Invoice': () => { + "Purchase Invoice": () => { open_form(frm, "Purchase Invoice", "Purchase Invoice Item", "items"); }, - 'Material Request': () => { + "Material Request": () => { open_form(frm, "Material Request", "Material Request Item", "items"); }, - 'Stock Entry': () => { + "Stock Entry": () => { open_form(frm, "Stock Entry", "Stock Entry Detail", "items"); }, }; - }, - onload: function(frm) { + onload: function (frm) { erpnext.item.setup_queries(frm); - if (frm.doc.variant_of){ + if (frm.doc.variant_of) { frm.fields_dict["attributes"].grid.set_column_disp("attribute_value", true); } @@ -53,73 +52,117 @@ frappe.ui.form.on("Item", { } }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.is_stock_item) { - frm.add_custom_button(__("Stock Balance"), function() { - frappe.route_options = { - "item_code": frm.doc.name - } - frappe.set_route("query-report", "Stock Balance"); - }, __("View")); - frm.add_custom_button(__("Stock Ledger"), function() { - frappe.route_options = { - "item_code": frm.doc.name - } - frappe.set_route("query-report", "Stock Ledger"); - }, __("View")); - frm.add_custom_button(__("Stock Projected Qty"), function() { - frappe.route_options = { - "item_code": frm.doc.name - } - frappe.set_route("query-report", "Stock Projected Qty"); - }, __("View")); + frm.add_custom_button( + __("Stock Balance"), + function () { + frappe.route_options = { + item_code: frm.doc.name, + }; + frappe.set_route("query-report", "Stock Balance"); + }, + __("View") + ); + frm.add_custom_button( + __("Stock Ledger"), + function () { + frappe.route_options = { + item_code: frm.doc.name, + }; + frappe.set_route("query-report", "Stock Ledger"); + }, + __("View") + ); + frm.add_custom_button( + __("Stock Projected Qty"), + function () { + frappe.route_options = { + item_code: frm.doc.name, + }; + frappe.set_route("query-report", "Stock Projected Qty"); + }, + __("View") + ); } - if (frm.doc.is_fixed_asset) { - frm.trigger('is_fixed_asset'); - frm.trigger('auto_create_assets'); + frm.trigger("is_fixed_asset"); + frm.trigger("auto_create_assets"); } // clear intro frm.set_intro(); if (frm.doc.has_variants) { - frm.set_intro(__("This Item is a Template and cannot be used in transactions. Item attributes will be copied over into the variants unless 'No Copy' is set"), true); + frm.set_intro( + __( + "This Item is a Template and cannot be used in transactions. Item attributes will be copied over into the variants unless 'No Copy' is set" + ), + true + ); - frm.add_custom_button(__("Show Variants"), function() { - frappe.set_route("List", "Item", {"variant_of": frm.doc.name}); - }, __("View")); + frm.add_custom_button( + __("Show Variants"), + function () { + frappe.set_route("List", "Item", { variant_of: frm.doc.name }); + }, + __("View") + ); - frm.add_custom_button(__("Item Variant Settings"), function() { - frappe.set_route("Form", "Item Variant Settings"); - }, __("View")); + frm.add_custom_button( + __("Item Variant Settings"), + function () { + frappe.set_route("Form", "Item Variant Settings"); + }, + __("View") + ); - frm.add_custom_button(__("Variant Details Report"), function() { - frappe.set_route("query-report", "Item Variant Details", {"item": frm.doc.name}); - }, __("View")); + frm.add_custom_button( + __("Variant Details Report"), + function () { + frappe.set_route("query-report", "Item Variant Details", { item: frm.doc.name }); + }, + __("View") + ); - if(frm.doc.variant_based_on==="Item Attribute") { - frm.add_custom_button(__("Single Variant"), function() { - erpnext.item.show_single_variant_dialog(frm); - }, __('Create')); - frm.add_custom_button(__("Multiple Variants"), function() { - erpnext.item.show_multiple_variants_dialog(frm); - }, __('Create')); + if (frm.doc.variant_based_on === "Item Attribute") { + frm.add_custom_button( + __("Single Variant"), + function () { + erpnext.item.show_single_variant_dialog(frm); + }, + __("Create") + ); + frm.add_custom_button( + __("Multiple Variants"), + function () { + erpnext.item.show_multiple_variants_dialog(frm); + }, + __("Create") + ); } else { - frm.add_custom_button(__("Variant"), function() { - erpnext.item.show_modal_for_manufacturers(frm); - }, __('Create')); + frm.add_custom_button( + __("Variant"), + function () { + erpnext.item.show_modal_for_manufacturers(frm); + }, + __("Create") + ); } // frm.page.set_inner_btn_group_as_primary(__('Create')); } if (frm.doc.variant_of) { - frm.set_intro(__('This Item is a Variant of {0} (Template).', - [`${frm.doc.variant_of}`]), true); + frm.set_intro( + __("This Item is a Variant of {0} (Template).", [ + `${frm.doc.variant_of}`, + ]), + true + ); } - if (frappe.defaults.get_default("item_naming_by")!="Naming Series" || frm.doc.variant_of) { + if (frappe.defaults.get_default("item_naming_by") != "Naming Series" || frm.doc.variant_of) { frm.toggle_display("naming_series", false); } else { erpnext.toggle_naming_series(); @@ -132,341 +175,374 @@ frappe.ui.form.on("Item", { erpnext.item.make_dashboard(frm); } - frm.add_custom_button(__('Duplicate'), function() { + frm.add_custom_button(__("Duplicate"), function () { var new_item = frappe.model.copy_doc(frm.doc); // Duplicate item could have different name, causing "copy paste" error. - if (new_item.item_name===new_item.item_code) { + if (new_item.item_name === new_item.item_code) { new_item.item_name = null; } - if (new_item.item_code===new_item.description || new_item.item_code===new_item.description) { + if (new_item.item_code === new_item.description || new_item.item_code === new_item.description) { new_item.description = null; } - frappe.set_route('Form', 'Item', new_item.name); + frappe.set_route("Form", "Item", new_item.name); }); - const stock_exists = (frm.doc.__onload - && frm.doc.__onload.stock_exists) ? 1 : 0; + const stock_exists = frm.doc.__onload && frm.doc.__onload.stock_exists ? 1 : 0; - ['is_stock_item', 'has_serial_no', 'has_batch_no', 'has_variants'].forEach((fieldname) => { - frm.set_df_property(fieldname, 'read_only', stock_exists); + ["is_stock_item", "has_serial_no", "has_batch_no", "has_variants"].forEach((fieldname) => { + frm.set_df_property(fieldname, "read_only", stock_exists); }); - frm.toggle_reqd('customer', frm.doc.is_customer_provided_item ? 1:0); + frm.toggle_reqd("customer", frm.doc.is_customer_provided_item ? 1 : 0); }, - validate: function(frm){ + validate: function (frm) { erpnext.item.weight_to_validate(frm); }, - image: function() { + image: function () { refresh_field("image_view"); }, - is_customer_provided_item: function(frm) { - frm.toggle_reqd('customer', frm.doc.is_customer_provided_item ? 1:0); + is_customer_provided_item: function (frm) { + frm.toggle_reqd("customer", frm.doc.is_customer_provided_item ? 1 : 0); }, - is_fixed_asset: function(frm) { + is_fixed_asset: function (frm) { // set serial no to false & toggles its visibility - frm.set_value('has_serial_no', 0); - frm.set_value('has_batch_no', 0); - frm.toggle_enable(['has_serial_no', 'serial_no_series'], !frm.doc.is_fixed_asset); + frm.set_value("has_serial_no", 0); + frm.set_value("has_batch_no", 0); + frm.toggle_enable(["has_serial_no", "serial_no_series"], !frm.doc.is_fixed_asset); frappe.call({ method: "erpnext.stock.doctype.item.item.get_asset_naming_series", - callback: function(r) { + callback: function (r) { frm.set_value("is_stock_item", frm.doc.is_fixed_asset ? 0 : 1); frm.events.set_asset_naming_series(frm, r.message); - } + }, }); - frm.trigger('auto_create_assets'); + frm.trigger("auto_create_assets"); }, - set_asset_naming_series: function(frm, asset_naming_series) { + set_asset_naming_series: function (frm, asset_naming_series) { if ((frm.doc.__onload && frm.doc.__onload.asset_naming_series) || asset_naming_series) { - let naming_series = (frm.doc.__onload && frm.doc.__onload.asset_naming_series) || asset_naming_series; + let naming_series = + (frm.doc.__onload && frm.doc.__onload.asset_naming_series) || asset_naming_series; frm.set_df_property("asset_naming_series", "options", naming_series); } }, - auto_create_assets: function(frm) { - frm.toggle_reqd(['asset_naming_series'], frm.doc.auto_create_assets); - frm.toggle_display(['asset_naming_series'], frm.doc.auto_create_assets); + auto_create_assets: function (frm) { + frm.toggle_reqd(["asset_naming_series"], frm.doc.auto_create_assets); + frm.toggle_display(["asset_naming_series"], frm.doc.auto_create_assets); }, page_name: frappe.utils.warn_page_name_change, - item_code: function(frm) { - if(!frm.doc.item_name) - frm.set_value("item_name", frm.doc.item_code); + item_code: function (frm) { + if (!frm.doc.item_name) frm.set_value("item_name", frm.doc.item_code); }, - is_stock_item: function(frm) { - if(!frm.doc.is_stock_item) { + is_stock_item: function (frm) { + if (!frm.doc.is_stock_item) { frm.set_value("has_batch_no", 0); frm.set_value("create_new_batch", 0); frm.set_value("has_serial_no", 0); } }, - has_variants: function(frm) { + has_variants: function (frm) { erpnext.item.toggle_attributes(frm); - } + }, }); -frappe.ui.form.on('Item Reorder', { - reorder_levels_add: function(frm, cdt, cdn) { +frappe.ui.form.on("Item Reorder", { + reorder_levels_add: function (frm, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); - var type = frm.doc.default_material_request_type - row.material_request_type = (type == 'Material Transfer')? 'Transfer' : type; - } -}) - -frappe.ui.form.on('Item Customer Detail', { - customer_items_add: function(frm, cdt, cdn) { - frappe.model.set_value(cdt, cdn, 'customer_group', ""); + var type = frm.doc.default_material_request_type; + row.material_request_type = type == "Material Transfer" ? "Transfer" : type; }, - customer_name: function(frm, cdt, cdn) { +}); + +frappe.ui.form.on("Item Customer Detail", { + customer_items_add: function (frm, cdt, cdn) { + frappe.model.set_value(cdt, cdn, "customer_group", ""); + }, + customer_name: function (frm, cdt, cdn) { set_customer_group(frm, cdt, cdn); }, - customer_group: function(frm, cdt, cdn) { - if(set_customer_group(frm, cdt, cdn)){ + customer_group: function (frm, cdt, cdn) { + if (set_customer_group(frm, cdt, cdn)) { frappe.msgprint(__("Changing Customer Group for the selected Customer is not allowed.")); } - } + }, }); -var set_customer_group = function(frm, cdt, cdn) { +var set_customer_group = function (frm, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); if (!row.customer_name) { return false; } - frappe.model.with_doc("Customer", row.customer_name, function() { + frappe.model.with_doc("Customer", row.customer_name, function () { var customer = frappe.model.get_doc("Customer", row.customer_name); row.customer_group = customer.customer_group; refresh_field("customer_group", cdn, "customer_items"); }); return true; -} +}; $.extend(erpnext.item, { - setup_queries: function(frm) { - frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) { + setup_queries: function (frm) { + frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { query: "erpnext.controllers.queries.get_expense_account", - filters: { company: row.company } - } - } - - frm.fields_dict["item_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) { - const row = locals[cdt][cdn]; - return { - query: "erpnext.controllers.queries.get_income_account", - filters: { company: row.company } - } - } - - frm.fields_dict["item_defaults"].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) { - const row = locals[cdt][cdn]; - return { - filters: { - 'report_type': 'Profit and Loss', - 'company': row.company, - "is_group": 0 - } + filters: { company: row.company }, }; }; - frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_defaults"].grid.get_field("income_account").get_query = function ( + doc, + cdt, + cdn + ) { + const row = locals[cdt][cdn]; + return { + query: "erpnext.controllers.queries.get_income_account", + filters: { company: row.company }, + }; + }; + + frm.fields_dict["item_defaults"].grid.get_field("default_discount_account").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + report_type: "Profit and Loss", + company: row.company, + is_group: 0, + }, + }; + }; - frm.fields_dict["item_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + is_group: 0, + company: row.company, + }, + }; + }; + frm.fields_dict["item_defaults"].grid.get_field("selling_cost_center").get_query = function ( + doc, + cdt, + cdn + ) { + const row = locals[cdt][cdn]; + return { + filters: { + is_group: 0, + company: row.company, + }, + }; + }; - frm.fields_dict['taxes'].grid.get_field("tax_type").get_query = function(doc, cdt, cdn) { + frm.fields_dict["taxes"].grid.get_field("tax_type").get_query = function (doc, cdt, cdn) { return { filters: [ - ['Account', 'account_type', 'in', - 'Tax, Chargeable, Income Account, Expense Account'], - ['Account', 'docstatus', '!=', 2] - ] - } - } + ["Account", "account_type", "in", "Tax, Chargeable, Income Account, Expense Account"], + ["Account", "docstatus", "!=", 2], + ], + }; + }; - frm.fields_dict['item_group'].get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_group"].get_query = function (doc, cdt, cdn) { return { - filters: [ - ['Item Group', 'docstatus', '!=', 2] - ] - } - } + filters: [["Item Group", "docstatus", "!=", 2]], + }; + }; - frm.fields_dict["item_defaults"].grid.get_field("deferred_revenue_account").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_defaults"].grid.get_field("deferred_revenue_account").get_query = function ( + doc, + cdt, + cdn + ) { return { filters: { - "company": locals[cdt][cdn].company, - 'root_type': 'Liability', - "is_group": 0 - } - } - } + company: locals[cdt][cdn].company, + root_type: "Liability", + is_group: 0, + }, + }; + }; - frm.fields_dict["item_defaults"].grid.get_field("deferred_expense_account").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_defaults"].grid.get_field("deferred_expense_account").get_query = function ( + doc, + cdt, + cdn + ) { return { filters: { - "company": locals[cdt][cdn].company, - 'root_type': 'Asset', - "is_group": 0 - } - } - } + company: locals[cdt][cdn].company, + root_type: "Asset", + is_group: 0, + }, + }; + }; - frm.fields_dict.customer_items.grid.get_field("customer_name").get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.customer_query" } - } + frm.fields_dict.customer_items.grid.get_field("customer_name").get_query = function (doc, cdt, cdn) { + return { query: "erpnext.controllers.queries.customer_query" }; + }; - frm.fields_dict.supplier_items.grid.get_field("supplier").get_query = function(doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.supplier_query" } - } + frm.fields_dict.supplier_items.grid.get_field("supplier").get_query = function (doc, cdt, cdn) { + return { query: "erpnext.controllers.queries.supplier_query" }; + }; - frm.fields_dict["item_defaults"].grid.get_field("default_warehouse").get_query = function(doc, cdt, cdn) { + frm.fields_dict["item_defaults"].grid.get_field("default_warehouse").get_query = function ( + doc, + cdt, + cdn + ) { const row = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": row.company - } - } - } + is_group: 0, + company: row.company, + }, + }; + }; - frm.fields_dict.reorder_levels.grid.get_field("warehouse_group").get_query = function(doc, cdt, cdn) { + frm.fields_dict.reorder_levels.grid.get_field("warehouse_group").get_query = function ( + doc, + cdt, + cdn + ) { return { - filters: { "is_group": 1 } - } - } + filters: { is_group: 1 }, + }; + }; - frm.fields_dict.reorder_levels.grid.get_field("warehouse").get_query = function(doc, cdt, cdn) { + frm.fields_dict.reorder_levels.grid.get_field("warehouse").get_query = function (doc, cdt, cdn) { var d = locals[cdt][cdn]; var filters = { - "is_group": 0 - } + is_group: 0, + }; if (d.parent_warehouse) { - filters.extend({"parent_warehouse": d.warehouse_group}) + filters.extend({ parent_warehouse: d.warehouse_group }); } return { - filters: filters - } - } + filters: filters, + }; + }; - frm.set_query('default_provisional_account', 'item_defaults', (doc, cdt, cdn) => { + frm.set_query("default_provisional_account", "item_defaults", (doc, cdt, cdn) => { let row = locals[cdt][cdn]; return { filters: { - "company": row.company, - "root_type": ["in", ["Liability", "Asset"]], - "is_group": 0 - } + company: row.company, + root_type: ["in", ["Liability", "Asset"]], + is_group: 0, + }, }; }); - }, - make_dashboard: function(frm) { - if(frm.doc.__islocal) - return; + make_dashboard: function (frm) { + if (frm.doc.__islocal) return; // Show Stock Levels only if is_stock_item if (frm.doc.is_stock_item) { - frappe.require('item-dashboard.bundle.js', function() { - const section = frm.dashboard.add_section('', __("Stock Levels")); + frappe.require("item-dashboard.bundle.js", function () { + const section = frm.dashboard.add_section("", __("Stock Levels")); erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({ parent: section, item_code: frm.doc.name, page_length: 20, - method: 'erpnext.stock.dashboard.item_dashboard.get_data', - template: 'item_dashboard_list' + method: "erpnext.stock.dashboard.item_dashboard.get_data", + template: "item_dashboard_list", }); erpnext.item.item_dashboard.refresh(); }); } }, - edit_prices_button: function(frm) { - frm.add_custom_button(__("Add / Edit Prices"), function() { - frappe.set_route("List", "Item Price", {"item_code": frm.doc.name}); - }, __("Actions")); + edit_prices_button: function (frm) { + frm.add_custom_button( + __("Add / Edit Prices"), + function () { + frappe.set_route("List", "Item Price", { item_code: frm.doc.name }); + }, + __("Actions") + ); }, - weight_to_validate: function(frm) { + weight_to_validate: function (frm) { if (frm.doc.weight_per_unit && !frm.doc.weight_uom) { frappe.msgprint({ message: __("Please mention 'Weight UOM' along with Weight."), - title: __("Note") + title: __("Note"), }); } }, - show_modal_for_manufacturers: function(frm) { + show_modal_for_manufacturers: function (frm) { var dialog = new frappe.ui.Dialog({ fields: [ { - fieldtype: 'Link', - fieldname: 'manufacturer', - options: 'Manufacturer', - label: 'Manufacturer', + fieldtype: "Link", + fieldname: "manufacturer", + options: "Manufacturer", + label: "Manufacturer", reqd: 1, }, { - fieldtype: 'Data', - label: 'Manufacturer Part Number', - fieldname: 'manufacturer_part_no' + fieldtype: "Data", + label: "Manufacturer Part Number", + fieldname: "manufacturer_part_no", }, - ] + ], }); - dialog.set_primary_action(__('Create'), function() { + dialog.set_primary_action(__("Create"), function () { var data = dialog.get_values(); - if(!data) return; + if (!data) return; // call the server to make the variant data.template = frm.doc.name; frappe.call({ method: "erpnext.controllers.item_variant.get_variant", args: data, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); dialog.hide(); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); - }) + }); dialog.show(); }, - show_multiple_variants_dialog: function(frm) { + show_multiple_variants_dialog: function (frm) { var me = this; let promises = []; @@ -475,27 +551,26 @@ $.extend(erpnext.item, { function make_fields_from_attribute_values(attr_dict) { let fields = []; Object.keys(attr_dict).forEach((name, i) => { - if(i % 3 === 0){ - fields.push({fieldtype: 'Section Break'}); + if (i % 3 === 0) { + fields.push({ fieldtype: "Section Break" }); } - fields.push({fieldtype: 'Column Break', label: name}); - attr_dict[name].forEach(value => { + fields.push({ fieldtype: "Column Break", label: name }); + attr_dict[name].forEach((value) => { fields.push({ - fieldtype: 'Check', + fieldtype: "Check", label: value, fieldname: value, default: 0, - onchange: function() { + onchange: function () { let selected_attributes = get_selected_attributes(); let lengths = []; - Object.keys(selected_attributes).map(key => { + Object.keys(selected_attributes).map((key) => { lengths.push(selected_attributes[key].length); }); - if(lengths.includes(0)) { - me.multiple_variant_dialog.get_primary_btn().html(__('Create Variants')); + if (lengths.includes(0)) { + me.multiple_variant_dialog.get_primary_btn().html(__("Create Variants")); me.multiple_variant_dialog.disable_primary_action(); } else { - let no_of_combinations = lengths.reduce((a, b) => a * b, 1); let msg; if (no_of_combinations === 1) { @@ -506,7 +581,7 @@ $.extend(erpnext.item, { me.multiple_variant_dialog.get_primary_btn().html(msg); me.multiple_variant_dialog.enable_primary_action(); } - } + }, }); }); }); @@ -523,38 +598,40 @@ $.extend(erpnext.item, { options: ``, - } - ].concat(fields) + }, + ].concat(fields), }); - me.multiple_variant_dialog.set_primary_action(__('Create Variants'), () => { + me.multiple_variant_dialog.set_primary_action(__("Create Variants"), () => { let selected_attributes = get_selected_attributes(); me.multiple_variant_dialog.hide(); frappe.call({ method: "erpnext.controllers.item_variant.enqueue_multiple_variant_creation", args: { - "item": frm.doc.name, - "args": selected_attributes + item: frm.doc.name, + args: selected_attributes, }, - callback: function(r) { - if (r.message==='queued') { + callback: function (r) { + if (r.message === "queued") { frappe.show_alert({ message: __("Variant creation has been queued."), - indicator: 'orange' + indicator: "orange", }); } else { frappe.show_alert({ message: __("{0} variants created.", [r.message]), - indicator: 'green' + indicator: "green", }); } - } + }, }); }); - $($(me.multiple_variant_dialog.$wrapper.find('.form-column')) - .find('.frappe-control')).css('margin-bottom', '0px'); + $($(me.multiple_variant_dialog.$wrapper.find(".form-column")).find(".frappe-control")).css( + "margin-bottom", + "0px" + ); me.multiple_variant_dialog.disable_primary_action(); me.multiple_variant_dialog.clear(); @@ -563,14 +640,14 @@ $.extend(erpnext.item, { function get_selected_attributes() { let selected_attributes = {}; - me.multiple_variant_dialog.$wrapper.find('.form-column').each((i, col) => { - if(i===0) return; - let attribute_name = $(col).find('.column-label').html().trim(); + me.multiple_variant_dialog.$wrapper.find(".form-column").each((i, col) => { + if (i === 0) return; + let attribute_name = $(col).find(".column-label").html().trim(); selected_attributes[attribute_name] = []; - let checked_opts = $(col).find('.checkbox input'); + let checked_opts = $(col).find(".checkbox input"); checked_opts.each((i, opt) => { - if($(opt).is(':checked')) { - selected_attributes[attribute_name].push($(opt).attr('data-fieldname')); + if ($(opt).is(":checked")) { + selected_attributes[attribute_name].push($(opt).attr("data-fieldname")); } }); }); @@ -578,30 +655,32 @@ $.extend(erpnext.item, { return selected_attributes; } - frm.doc.attributes.forEach(function(d) { - let p = new Promise(resolve => { - if(!d.numeric_values) { - frappe.call({ - method: "frappe.client.get_list", - args: { - doctype: "Item Attribute Value", - filters: [ - ["parent","=", d.attribute] - ], - fields: ["attribute_value"], - limit_page_length: 0, - parent: "Item Attribute", - order_by: "idx" - } - }).then((r) => { - if(r.message) { - attr_val_fields[d.attribute] = r.message.map(function(d) { return d.attribute_value; }); - resolve(); - } - }); + frm.doc.attributes.forEach(function (d) { + let p = new Promise((resolve) => { + if (!d.numeric_values) { + frappe + .call({ + method: "frappe.client.get_list", + args: { + doctype: "Item Attribute Value", + filters: [["parent", "=", d.attribute]], + fields: ["attribute_value"], + limit_page_length: 0, + parent: "Item Attribute", + order_by: "idx", + }, + }) + .then((r) => { + if (r.message) { + attr_val_fields[d.attribute] = r.message.map(function (d) { + return d.attribute_value; + }); + resolve(); + } + }); } else { let values = []; - for(var i = d.from_range; i <= d.to_range; i = flt(i + d.increment, 6)) { + for (var i = d.from_range; i <= d.to_range; i = flt(i + d.increment, 6)) { values.push(i); } attr_val_fields[d.attribute] = values; @@ -610,66 +689,74 @@ $.extend(erpnext.item, { }); promises.push(p); - }, this); Promise.all(promises).then(() => { let fields = make_fields_from_attribute_values(attr_val_fields); make_and_show_dialog(fields); - }) - + }); }, - show_single_variant_dialog: function(frm) { - var fields = [] + show_single_variant_dialog: function (frm) { + var fields = []; - for(var i=0;i< frm.doc.attributes.length;i++){ + for (var i = 0; i < frm.doc.attributes.length; i++) { var fieldtype, desc; var row = frm.doc.attributes[i]; - if (row.numeric_values){ + if (row.numeric_values) { fieldtype = "Float"; - desc = "Min Value: "+ row.from_range +" , Max Value: "+ row.to_range +", in Increments of: "+ row.increment - } - else { + desc = + "Min Value: " + + row.from_range + + " , Max Value: " + + row.to_range + + ", in Increments of: " + + row.increment; + } else { fieldtype = "Data"; - desc = "" + desc = ""; } fields = fields.concat({ - "label": row.attribute, - "fieldname": row.attribute, - "fieldtype": fieldtype, - "reqd": 0, - "description": desc - }) + label: row.attribute, + fieldname: row.attribute, + fieldtype: fieldtype, + reqd: 0, + description: desc, + }); } var d = new frappe.ui.Dialog({ - title: __('Create Variant'), - fields: fields + title: __("Create Variant"), + fields: fields, }); - d.set_primary_action(__('Create'), function() { + d.set_primary_action(__("Create"), function () { var args = d.get_values(); - if(!args) return; + if (!args) return; frappe.call({ method: "erpnext.controllers.item_variant.get_variant", btn: d.get_primary_btn(), args: { - "template": frm.doc.name, - "args": d.get_values() + template: frm.doc.name, + args: d.get_values(), }, - callback: function(r) { + callback: function (r) { // returns variant item if (r.message) { var variant = r.message; - frappe.msgprint_dialog = frappe.msgprint(__("Item Variant {0} already exists with same attributes", - [repl('%(item)s', { - item_encoded: encodeURIComponent(variant), - item: variant - })] - )); + frappe.msgprint_dialog = frappe.msgprint( + __("Item Variant {0} already exists with same attributes", [ + repl( + '%(item)s', + { + item_encoded: encodeURIComponent(variant), + item: variant, + } + ), + ]) + ); frappe.msgprint_dialog.hide_on_page_refresh = true; - frappe.msgprint_dialog.$wrapper.find(".variant-click").on("click", function() { + frappe.msgprint_dialog.$wrapper.find(".variant-click").on("click", function () { d.hide(); }); } else { @@ -677,24 +764,23 @@ $.extend(erpnext.item, { frappe.call({ method: "erpnext.controllers.item_variant.create_variant", args: { - "item": frm.doc.name, - "args": d.get_values() + item: frm.doc.name, + args: d.get_values(), }, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); } - } + }, }); }); d.show(); - $.each(d.fields_dict, function(i, field) { - - if(field.df.fieldtype !== "Data") { + $.each(d.fields_dict, function (i, field) { + if (field.df.fieldtype !== "Data") { return; } @@ -710,26 +796,28 @@ $.extend(erpnext.item, { input.field = field; field.$input - .on('input', function(e) { + .on("input", function (e) { var term = e.target.value; frappe.call({ method: "erpnext.stock.doctype.item.item.get_item_attribute", args: { parent: i, - attribute_value: term + attribute_value: term, }, - callback: function(r) { + callback: function (r) { if (r.message) { - e.target.awesomplete.list = r.message.map(function(d) { return d.attribute_value; }); + e.target.awesomplete.list = r.message.map(function (d) { + return d.attribute_value; + }); } - } + }, }); }) - .on('focus', function(e) { - $(e.target).val('').trigger('input'); + .on("focus", function (e) { + $(e.target).val("").trigger("input"); }) .on("awesomplete-open", () => { - let modal = field.$input.parents('.modal-dialog')[0]; + let modal = field.$input.parents(".modal-dialog")[0]; if (modal) { $(modal).removeClass("modal-dialog-scrollable"); } @@ -737,14 +825,13 @@ $.extend(erpnext.item, { }); }, - toggle_attributes: function(frm) { - if((frm.doc.has_variants || frm.doc.variant_of) - && frm.doc.variant_based_on==='Item Attribute') { + toggle_attributes: function (frm) { + if ((frm.doc.has_variants || frm.doc.variant_of) && frm.doc.variant_based_on === "Item Attribute") { frm.toggle_display("attributes", true); var grid = frm.fields_dict.attributes.grid; - if(frm.doc.variant_of) { + if (frm.doc.variant_of) { // variant // value column is displayed but not editable @@ -768,78 +855,87 @@ $.extend(erpnext.item, { // enable the grid so you can add more attributes grid.toggle_enable("attribute", true); } - } else { // nothing to do with attributes, hide it frm.toggle_display("attributes", false); } frm.layout.refresh_sections(); - } + }, }); frappe.ui.form.on("UOM Conversion Detail", { - uom: function(frm, cdt, cdn) { + uom: function (frm, cdt, cdn) { var row = locals[cdt][cdn]; if (row.uom) { frappe.call({ method: "erpnext.stock.doctype.item.item.get_uom_conv_factor", args: { - "uom": row.uom, - "stock_uom": frm.doc.stock_uom + uom: row.uom, + stock_uom: frm.doc.stock_uom, }, - callback: function(r) { + callback: function (r) { if (!r.exc && r.message) { frappe.model.set_value(cdt, cdn, "conversion_factor", r.message); } - } + }, }); } - } + }, }); -frappe.tour['Item'] = [ +frappe.tour["Item"] = [ { fieldname: "item_code", title: "Item Code", - description: __("Enter an Item Code, the name will be auto-filled the same as Item Code on clicking inside the Item Name field.") + description: __( + "Enter an Item Code, the name will be auto-filled the same as Item Code on clicking inside the Item Name field." + ), }, { fieldname: "item_group", title: "Item Group", - description: __("Select an Item Group.") + description: __("Select an Item Group."), }, { fieldname: "is_stock_item", title: "Maintain Stock", - description: __("If you are maintaining stock of this Item in your Inventory, ERPNext will make a stock ledger entry for each transaction of this item.") + description: __( + "If you are maintaining stock of this Item in your Inventory, ERPNext will make a stock ledger entry for each transaction of this item." + ), }, { fieldname: "include_item_in_manufacturing", title: "Include Item in Manufacturing", - description: __("This is for raw material Items that'll be used to create finished goods. If the Item is an additional service like 'washing' that'll be used in the BOM, keep this unchecked.") + description: __( + "This is for raw material Items that'll be used to create finished goods. If the Item is an additional service like 'washing' that'll be used in the BOM, keep this unchecked." + ), }, { fieldname: "opening_stock", title: "Opening Stock", - description: __("Enter the opening stock units.") + description: __("Enter the opening stock units."), }, { fieldname: "valuation_rate", title: "Valuation Rate", - description: __("There are two options to maintain valuation of stock. FIFO (first in - first out) and Moving Average. To understand this topic in detail please visit Item Valuation, FIFO and Moving Average.") + description: __( + "There are two options to maintain valuation of stock. FIFO (first in - first out) and Moving Average. To understand this topic in detail please visit Item Valuation, FIFO and Moving Average." + ), }, { fieldname: "standard_rate", title: "Standard Selling Rate", - description: __("When creating an Item, entering a value for this field will automatically create an Item Price at the backend.") + description: __( + "When creating an Item, entering a value for this field will automatically create an Item Price at the backend." + ), }, { fieldname: "item_defaults", title: "Item Defaults", - description: __("In this section, you can define Company-wide transaction-related defaults for this Item. Eg. Default Warehouse, Default Price List, Supplier, etc.") - } - - + description: __( + "In this section, you can define Company-wide transaction-related defaults for this Item. Eg. Default Warehouse, Default Price List, Supplier, etc." + ), + }, ]; function open_form(frm, doctype, child_doctype, parentfield) { @@ -866,7 +962,7 @@ function open_form(frm, doctype, child_doctype, parentfield) { () => { frappe.flags.ignore_company_party_validation = true; frappe.model.trigger("item_code", frm.doc.name, new_child_doc); - } - ]) + }, + ]); }); } diff --git a/erpnext/stock/doctype/item/item_list.js b/erpnext/stock/doctype/item/item_list.js index 67dc86c89b8..e8d886a9c24 100644 --- a/erpnext/stock/doctype/item/item_list.js +++ b/erpnext/stock/doctype/item/item_list.js @@ -1,9 +1,17 @@ -frappe.listview_settings['Item'] = { - add_fields: ["item_name", "stock_uom", "item_group", "image", - "has_variants", "end_of_life", "disabled", "variant_of"], +frappe.listview_settings["Item"] = { + add_fields: [ + "item_name", + "stock_uom", + "item_group", + "image", + "has_variants", + "end_of_life", + "disabled", + "variant_of", + ], filters: [["disabled", "=", "0"]], - get_indicator: function(doc) { + get_indicator: function (doc) { if (doc.disabled) { return [__("Disabled"), "grey", "disabled,=,Yes"]; } else if (doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) { @@ -17,23 +25,22 @@ frappe.listview_settings['Item'] = { reports: [ { - name: 'Stock Summary', - route: '/app/stock-balance' + name: "Stock Summary", + route: "/app/stock-balance", }, { - name: 'Stock Ledger', - report_type: 'Script Report' + name: "Stock Ledger", + report_type: "Script Report", }, { - name: 'Stock Balance', - report_type: 'Script Report' + name: "Stock Balance", + report_type: "Script Report", }, { - name: 'Stock Projected Qty', - report_type: 'Script Report' - } - - ] + name: "Stock Projected Qty", + report_type: "Script Report", + }, + ], }; frappe.help.youtube_id["Item"] = "qXaEwld4_Ps"; diff --git a/erpnext/stock/doctype/item_alternative/item_alternative.js b/erpnext/stock/doctype/item_alternative/item_alternative.js index ef0a88b9c81..e384e576bd2 100644 --- a/erpnext/stock/doctype/item_alternative/item_alternative.js +++ b/erpnext/stock/doctype/item_alternative/item_alternative.js @@ -1,14 +1,14 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Item Alternative', { - setup: function(frm) { +frappe.ui.form.on("Item Alternative", { + setup: function (frm) { frm.fields_dict.item_code.get_query = () => { return { filters: { - 'allow_alternative_item': 1 - } + allow_alternative_item: 1, + }, }; }; - } + }, }); diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.js b/erpnext/stock/doctype/item_attribute/item_attribute.js index f253e22327f..22c7978ac3c 100644 --- a/erpnext/stock/doctype/item_attribute/item_attribute.js +++ b/erpnext/stock/doctype/item_attribute/item_attribute.js @@ -1,6 +1,4 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Item Attribute', { - -}); +frappe.ui.form.on("Item Attribute", {}); diff --git a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.js b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.js index a4df923f039..21803720f1f 100644 --- a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.js +++ b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Item Manufacturer', { +frappe.ui.form.on("Item Manufacturer", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/doctype/item_price/item_price.js b/erpnext/stock/doctype/item_price/item_price.js index 8a4b4eef0ae..a5599e340a6 100644 --- a/erpnext/stock/doctype/item_price/item_price.js +++ b/erpnext/stock/doctype/item_price/item_price.js @@ -3,11 +3,11 @@ frappe.ui.form.on("Item Price", { setup(frm) { - frm.set_query("item_code", function() { + frm.set_query("item_code", function () { return { filters: { - "has_variants": 0 - } + has_variants: 0, + }, }; }); }, @@ -23,15 +23,18 @@ frappe.ui.form.on("Item Price", { frm.add_fetch("item_code", "description", "item_description"); frm.add_fetch("item_code", "stock_uom", "uom"); - frm.set_df_property("bulk_import_help", "options", - '' + __("Import in Bulk") + ''); + frm.set_df_property( + "bulk_import_help", + "options", + '' + __("Import in Bulk") + "" + ); - frm.set_query('batch_no', function() { + frm.set_query("batch_no", function () { return { filters: { - 'item': frm.doc.item_code - } + item: frm.doc.item_code, + }, }; }); - } + }, }); diff --git a/erpnext/stock/doctype/item_price/item_price_list.js b/erpnext/stock/doctype/item_price/item_price_list.js index 48158393f67..94c232e2e65 100644 --- a/erpnext/stock/doctype/item_price/item_price_list.js +++ b/erpnext/stock/doctype/item_price/item_price_list.js @@ -1,3 +1,3 @@ -frappe.listview_settings['Item Price'] = { +frappe.listview_settings["Item Price"] = { hide_name_column: true, }; diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js index 457e48fdaf9..d906b85a031 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js @@ -1,24 +1,39 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Item Variant Settings', { - refresh: function(frm) { +frappe.ui.form.on("Item Variant Settings", { + refresh: function (frm) { const allow_fields = []; - const existing_fields = frm.doc.fields.map(row => row.field_name); - const exclude_fields = [...existing_fields, "naming_series", "item_code", "item_name", - "published_in_website", "standard_rate", "opening_stock", "image", - "variant_of", "valuation_rate", "barcodes", "has_variants", "attributes"]; + const existing_fields = frm.doc.fields.map((row) => row.field_name); + const exclude_fields = [ + ...existing_fields, + "naming_series", + "item_code", + "item_name", + "published_in_website", + "standard_rate", + "opening_stock", + "image", + "variant_of", + "valuation_rate", + "barcodes", + "has_variants", + "attributes", + ]; - const exclude_field_types = ['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only']; + const exclude_field_types = ["HTML", "Section Break", "Column Break", "Button", "Read Only"]; - frappe.model.with_doctype('Item', () => { + frappe.model.with_doctype("Item", () => { const field_label_map = {}; - frappe.get_meta('Item').fields.forEach(d => { + frappe.get_meta("Item").fields.forEach((d) => { field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`; - if (!in_list(exclude_field_types, d.fieldtype) - && !d.no_copy && !in_list(exclude_fields, d.fieldname)) { + if ( + !in_list(exclude_field_types, d.fieldtype) && + !d.no_copy && + !in_list(exclude_fields, d.fieldname) + ) { allow_fields.push({ label: field_label_map[d.fieldname], value: d.fieldname, @@ -33,9 +48,7 @@ frappe.ui.form.on('Item Variant Settings', { }); } - frm.fields_dict.fields.grid.update_docfield_property( - 'field_name', 'options', allow_fields - ); + frm.fields_dict.fields.grid.update_docfield_property("field_name", "options", allow_fields); }); - } + }, }); 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 8215efcad39..0ecb9f2600e 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js +++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js @@ -7,24 +7,27 @@ erpnext.landed_cost_taxes_and_charges.setup_triggers("Landed Cost Voucher"); erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock.StockController { setup() { var me = this; - this.frm.fields_dict.purchase_receipts.grid.get_field('receipt_document').get_query = - function (doc, cdt, cdn) { - var d = locals[cdt][cdn] + this.frm.fields_dict.purchase_receipts.grid.get_field("receipt_document").get_query = function ( + doc, + cdt, + cdn + ) { + var d = locals[cdt][cdn]; - var filters = [ - [d.receipt_document_type, 'docstatus', '=', '1'], - [d.receipt_document_type, 'company', '=', me.frm.doc.company], - ] + var filters = [ + [d.receipt_document_type, "docstatus", "=", "1"], + [d.receipt_document_type, "company", "=", me.frm.doc.company], + ]; - if (d.receipt_document_type == "Purchase Invoice") { - filters.push(["Purchase Invoice", "update_stock", "=", "1"]) - } + if (d.receipt_document_type == "Purchase Invoice") { + filters.push(["Purchase Invoice", "update_stock", "=", "1"]); + } - if (!me.frm.doc.company) frappe.msgprint(__("Please enter company first")); - return { - filters: filters - } + if (!me.frm.doc.company) frappe.msgprint(__("Please enter company first")); + return { + filters: filters, }; + }; this.frm.add_fetch("receipt_document", "supplier", "supplier"); this.frm.add_fetch("receipt_document", "posting_date", "posting_date"); @@ -32,8 +35,7 @@ erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock. } refresh() { - var help_content = - `

      + var help_content = `

      @@ -70,15 +72,15 @@ erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock. get_items_from_purchase_receipts() { var me = this; - if(!this.frm.doc.purchase_receipts.length) { + if (!this.frm.doc.purchase_receipts.length) { frappe.msgprint(__("Please enter Purchase Receipt first")); } else { return this.frm.call({ doc: me.frm.doc, method: "get_items_from_purchase_receipts", - callback: function(r, rt) { + callback: function (r, rt) { me.set_applicable_charges_for_item(); - } + }, }); } } @@ -90,7 +92,7 @@ erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock. set_total_taxes_and_charges() { var total_taxes_and_charges = 0.0; - $.each(this.frm.doc.taxes || [], function(i, d) { + $.each(this.frm.doc.taxes || [], function (i, d) { total_taxes_and_charges += flt(d.base_amount); }); this.frm.set_value("total_taxes_and_charges", total_taxes_and_charges); @@ -99,47 +101,52 @@ erpnext.stock.LandedCostVoucher = class LandedCostVoucher extends erpnext.stock. set_applicable_charges_for_item() { var me = this; - if(this.frm.doc.taxes.length) { + if (this.frm.doc.taxes.length) { var total_item_cost = 0.0; var based_on = this.frm.doc.distribute_charges_based_on.toLowerCase(); - if (based_on != 'distribute manually') { - $.each(this.frm.doc.items || [], function(i, d) { - total_item_cost += flt(d[based_on]) + if (based_on != "distribute manually") { + $.each(this.frm.doc.items || [], function (i, d) { + total_item_cost += flt(d[based_on]); }); var total_charges = 0.0; - $.each(this.frm.doc.items || [], function(i, item) { - item.applicable_charges = flt(item[based_on]) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost) - item.applicable_charges = flt(item.applicable_charges, precision("applicable_charges", item)) - total_charges += item.applicable_charges + $.each(this.frm.doc.items || [], function (i, item) { + item.applicable_charges = + (flt(item[based_on]) * flt(me.frm.doc.total_taxes_and_charges)) / + flt(total_item_cost); + item.applicable_charges = flt( + item.applicable_charges, + precision("applicable_charges", item) + ); + total_charges += item.applicable_charges; }); - if (total_charges != this.frm.doc.total_taxes_and_charges){ - var diff = this.frm.doc.total_taxes_and_charges - flt(total_charges) - this.frm.doc.items.slice(-1)[0].applicable_charges += diff + if (total_charges != this.frm.doc.total_taxes_and_charges) { + var diff = this.frm.doc.total_taxes_and_charges - flt(total_charges); + this.frm.doc.items.slice(-1)[0].applicable_charges += diff; } refresh_field("items"); } } } - distribute_charges_based_on (frm) { + distribute_charges_based_on(frm) { this.set_applicable_charges_for_item(); } items_remove() { - this.trigger('set_applicable_charges_for_item'); + this.trigger("set_applicable_charges_for_item"); } }; cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher); -frappe.ui.form.on('Landed Cost Taxes and Charges', { - expense_account: function(frm, cdt, cdn) { +frappe.ui.form.on("Landed Cost Taxes and Charges", { + expense_account: function (frm, cdt, cdn) { frm.events.set_account_currency(frm, cdt, cdn); }, - amount: function(frm, cdt, cdn) { + amount: function (frm, cdt, cdn) { frm.events.set_base_amount(frm, cdt, cdn); - } + }, }); diff --git a/erpnext/stock/doctype/manufacturer/manufacturer.js b/erpnext/stock/doctype/manufacturer/manufacturer.js index 5b4990f08be..e316543ce07 100644 --- a/erpnext/stock/doctype/manufacturer/manufacturer.js +++ b/erpnext/stock/doctype/manufacturer/manufacturer.js @@ -1,15 +1,14 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Manufacturer', { - refresh: function(frm) { +frappe.ui.form.on("Manufacturer", { + refresh: function (frm) { if (frm.doc.__islocal) { - hide_field(['address_html','contact_html']); + hide_field(["address_html", "contact_html"]); frappe.contacts.clear_address_and_contact(frm); - } - else { - unhide_field(['address_html','contact_html']); + } else { + unhide_field(["address_html", "contact_html"]); frappe.contacts.render_address_and_contact(frm); } - } + }, }); diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index a913e2845a8..f04acc85ed5 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -5,181 +5,212 @@ frappe.provide("erpnext.accounts.dimensions"); erpnext.buying.setup_buying_controller(); -frappe.ui.form.on('Material Request', { - setup: function(frm) { +frappe.ui.form.on("Material Request", { + setup: function (frm) { frm.custom_make_buttons = { - 'Stock Entry': 'Issue Material', - 'Pick List': 'Pick List', - 'Purchase Order': 'Purchase Order', - 'Request for Quotation': 'Request for Quotation', - 'Supplier Quotation': 'Supplier Quotation', - 'Work Order': 'Work Order', - 'Purchase Receipt': 'Purchase Receipt' + "Stock Entry": "Issue Material", + "Pick List": "Pick List", + "Purchase Order": "Purchase Order", + "Request for Quotation": "Request for Quotation", + "Supplier Quotation": "Supplier Quotation", + "Work Order": "Work Order", + "Purchase Receipt": "Purchase Receipt", }; // formatter for material request item - frm.set_indicator_formatter('item_code', - function(doc) { return (doc.stock_qty<=doc.ordered_qty) ? "green" : "orange"; }); + frm.set_indicator_formatter("item_code", function (doc) { + return doc.stock_qty <= doc.ordered_qty ? "green" : "orange"; + }); - frm.set_query("item_code", "items", function() { + frm.set_query("item_code", "items", function () { return { - query: "erpnext.controllers.queries.item_query" + query: "erpnext.controllers.queries.item_query", }; }); - frm.set_query("from_warehouse", "items", function(doc) { + frm.set_query("from_warehouse", "items", function (doc) { return { - filters: {'company': doc.company} + filters: { company: doc.company }, }; }); - frm.set_query("bom_no", "items", function(doc, cdt, cdn) { + frm.set_query("bom_no", "items", function (doc, cdt, cdn) { var row = locals[cdt][cdn]; return { filters: { - "item": row.item_code - } - } + item: row.item_code, + }, + }; }); }, - onload: function(frm) { + onload: function (frm) { // add item, if previous view was item erpnext.utils.add_item(frm); // set schedule_date set_schedule_date(frm); - frm.set_query("warehouse", "items", function(doc) { + frm.set_query("warehouse", "items", function (doc) { return { - filters: {'company': doc.company} + filters: { company: doc.company }, }; }); - frm.set_query("set_warehouse", function(doc){ + frm.set_query("set_warehouse", function (doc) { return { - filters: {'company': doc.company} + filters: { company: doc.company }, }; }); - frm.set_query("set_from_warehouse", function(doc){ + frm.set_query("set_from_warehouse", function (doc) { return { - filters: {'company': doc.company} + filters: { company: doc.company }, }; }); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); }, - company: function(frm) { + company: function (frm) { erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); }, - onload_post_render: function(frm) { + onload_post_render: function (frm) { frm.get_field("items").grid.set_multiple_add("item_code", "qty"); }, - refresh: function(frm) { + refresh: function (frm) { frm.events.make_custom_buttons(frm); - frm.toggle_reqd('customer', frm.doc.material_request_type=="Customer Provided"); + frm.toggle_reqd("customer", frm.doc.material_request_type == "Customer Provided"); }, - set_from_warehouse: function(frm) { - if (frm.doc.material_request_type == "Material Transfer" - && frm.doc.set_from_warehouse) { - frm.doc.items.forEach(d => { - frappe.model.set_value(d.doctype, d.name, - "from_warehouse", frm.doc.set_from_warehouse); - }) + set_from_warehouse: function (frm) { + if (frm.doc.material_request_type == "Material Transfer" && frm.doc.set_from_warehouse) { + frm.doc.items.forEach((d) => { + frappe.model.set_value(d.doctype, d.name, "from_warehouse", frm.doc.set_from_warehouse); + }); } }, - make_custom_buttons: function(frm) { - if (frm.doc.docstatus==0) { - frm.add_custom_button(__("Bill of Materials"), - () => frm.events.get_items_from_bom(frm), __("Get Items From")); + make_custom_buttons: function (frm) { + if (frm.doc.docstatus == 0) { + frm.add_custom_button( + __("Bill of Materials"), + () => frm.events.get_items_from_bom(frm), + __("Get Items From") + ); } - if (frm.doc.docstatus == 1 && frm.doc.status != 'Stopped') { + if (frm.doc.docstatus == 1 && frm.doc.status != "Stopped") { let precision = frappe.defaults.get_default("float_precision"); if (flt(frm.doc.per_received, precision) < 100) { - frm.add_custom_button(__('Stop'), - () => frm.events.update_status(frm, 'Stopped')); + frm.add_custom_button(__("Stop"), () => frm.events.update_status(frm, "Stopped")); } if (flt(frm.doc.per_ordered, precision) < 100) { let add_create_pick_list_button = () => { - frm.add_custom_button(__('Pick List'), - () => frm.events.create_pick_list(frm), __('Create')); - } + frm.add_custom_button( + __("Pick List"), + () => frm.events.create_pick_list(frm), + __("Create") + ); + }; if (frm.doc.material_request_type === "Material Transfer") { add_create_pick_list_button(); - frm.add_custom_button(__("Material Transfer"), - () => frm.events.make_stock_entry(frm), __('Create')); + frm.add_custom_button( + __("Material Transfer"), + () => frm.events.make_stock_entry(frm), + __("Create") + ); - frm.add_custom_button(__("Material Transfer (In Transit)"), - () => frm.events.make_in_transit_stock_entry(frm), __('Create')); + frm.add_custom_button( + __("Material Transfer (In Transit)"), + () => frm.events.make_in_transit_stock_entry(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Material Issue") { - frm.add_custom_button(__("Issue Material"), - () => frm.events.make_stock_entry(frm), __('Create')); + frm.add_custom_button( + __("Issue Material"), + () => frm.events.make_stock_entry(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Customer Provided") { - frm.add_custom_button(__("Material Receipt"), - () => frm.events.make_stock_entry(frm), __('Create')); + frm.add_custom_button( + __("Material Receipt"), + () => frm.events.make_stock_entry(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Purchase") { - frm.add_custom_button(__('Purchase Order'), - () => frm.events.make_purchase_order(frm), __('Create')); + frm.add_custom_button( + __("Purchase Order"), + () => frm.events.make_purchase_order(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Purchase") { - frm.add_custom_button(__("Request for Quotation"), - () => frm.events.make_request_for_quotation(frm), __('Create')); + frm.add_custom_button( + __("Request for Quotation"), + () => frm.events.make_request_for_quotation(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Purchase") { - frm.add_custom_button(__("Supplier Quotation"), - () => frm.events.make_supplier_quotation(frm), __('Create')); + frm.add_custom_button( + __("Supplier Quotation"), + () => frm.events.make_supplier_quotation(frm), + __("Create") + ); } if (frm.doc.material_request_type === "Manufacture") { - frm.add_custom_button(__("Work Order"), - () => frm.events.raise_work_orders(frm), __('Create')); + frm.add_custom_button( + __("Work Order"), + () => frm.events.raise_work_orders(frm), + __("Create") + ); } - frm.page.set_inner_btn_group_as_primary(__('Create')); + frm.page.set_inner_btn_group_as_primary(__("Create")); } } - if (frm.doc.docstatus===0) { - frm.add_custom_button(__('Sales Order'), () => frm.events.get_items_from_sales_order(frm), - __("Get Items From")); + if (frm.doc.docstatus === 0) { + frm.add_custom_button( + __("Sales Order"), + () => frm.events.get_items_from_sales_order(frm), + __("Get Items From") + ); } - if (frm.doc.docstatus == 1 && frm.doc.status == 'Stopped') { - frm.add_custom_button(__('Re-open'), () => frm.events.update_status(frm, 'Submitted')); + if (frm.doc.docstatus == 1 && frm.doc.status == "Stopped") { + frm.add_custom_button(__("Re-open"), () => frm.events.update_status(frm, "Submitted")); } }, - update_status: function(frm, stop_status) { + update_status: function (frm, stop_status) { frappe.call({ - method: 'erpnext.stock.doctype.material_request.material_request.update_status', + method: "erpnext.stock.doctype.material_request.material_request.update_status", args: { name: frm.doc.name, status: stop_status }, callback(r) { if (!r.exc) { frm.reload_doc(); } - } + }, }); }, - get_items_from_sales_order: function(frm) { + get_items_from_sales_order: function (frm) { erpnext.utils.map_current_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request", source_doctype: "Sales Order", @@ -192,13 +223,15 @@ frappe.ui.form.on('Material Request', { docstatus: 1, status: ["not in", ["Closed", "On Hold"]], per_delivered: ["<", 99.99], - company: frm.doc.company - } + company: frm.doc.company, + }, }); }, - get_item_data: function(frm, item, overwrite_warehouse=false) { - if (item && !item.item_code) { return; } + get_item_data: function (frm, item, overwrite_warehouse = false) { + if (item && !item.item_code) { + return; + } frappe.call({ method: "erpnext.stock.get_item_details.get_item_details", @@ -208,8 +241,8 @@ frappe.ui.form.on('Material Request', { from_warehouse: item.from_warehouse, warehouse: item.warehouse, doctype: frm.doc.doctype, - buying_price_list: frappe.defaults.get_default('buying_price_list'), - currency: frappe.defaults.get_default('Currency'), + buying_price_list: frappe.defaults.get_default("buying_price_list"), + currency: frappe.defaults.get_default("Currency"), name: frm.doc.name, qty: item.qty || 1, stock_qty: item.stock_qty, @@ -222,15 +255,25 @@ frappe.ui.form.on('Material Request', { conversion_factor: item.conversion_factor, project: item.project, }, - overwrite_warehouse: overwrite_warehouse + overwrite_warehouse: overwrite_warehouse, }, - callback: function(r) { + callback: function (r) { const d = item; - const allow_to_change_fields = ['actual_qty', 'projected_qty', 'min_order_qty', 'item_name', 'description', 'stock_uom', 'uom', 'conversion_factor', 'stock_qty']; + const allow_to_change_fields = [ + "actual_qty", + "projected_qty", + "min_order_qty", + "item_name", + "description", + "stock_uom", + "uom", + "conversion_factor", + "stock_qty", + ]; - if(!r.exc) { - $.each(r.message, function(key, value) { - if(!d[key] || allow_to_change_fields.includes(key)) { + if (!r.exc) { + $.each(r.message, function (key, value) { + if (!d[key] || allow_to_change_fields.includes(key)) { d[key] = value; } }); @@ -243,39 +286,53 @@ frappe.ui.form.on('Material Request', { refresh_field("items"); } - } + }, }); }, - get_items_from_bom: function(frm) { + get_items_from_bom: function (frm) { var d = new frappe.ui.Dialog({ title: __("Get Items from BOM"), fields: [ - {"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"), - options:"BOM", reqd: 1, get_query: function() { - return {filters: { docstatus:1, "is_active": 1 }}; - }}, - {"fieldname":"warehouse", "fieldtype":"Link", "label":__("For Warehouse"), - options:"Warehouse", reqd: 1}, - {"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"), - reqd: 1, "default": 1}, - {"fieldname":"fetch_exploded", "fieldtype":"Check", - "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1} + { + fieldname: "bom", + fieldtype: "Link", + label: __("BOM"), + options: "BOM", + reqd: 1, + get_query: function () { + return { filters: { docstatus: 1, is_active: 1 } }; + }, + }, + { + fieldname: "warehouse", + fieldtype: "Link", + label: __("For Warehouse"), + options: "Warehouse", + reqd: 1, + }, + { fieldname: "qty", fieldtype: "Float", label: __("Quantity"), reqd: 1, default: 1 }, + { + fieldname: "fetch_exploded", + fieldtype: "Check", + label: __("Fetch exploded BOM (including sub-assemblies)"), + default: 1, + }, ], - primary_action_label: 'Get Items', + primary_action_label: "Get Items", primary_action(values) { - if(!values) return; + if (!values) return; values["company"] = frm.doc.company; - if(!frm.doc.company) frappe.throw(__("Company field is required")); + if (!frm.doc.company) frappe.throw(__("Company field is required")); frappe.call({ method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items", args: values, - callback: function(r) { + callback: function (r) { if (!r.message) { frappe.throw(__("BOM does not contain any stock item")); } else { erpnext.utils.remove_empty_first_row(frm, "items"); - $.each(r.message, function(i, item) { + $.each(r.message, function (i, item) { var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items"); d.item_code = item.item_code; d.item_name = item.item_name; @@ -290,61 +347,63 @@ frappe.ui.form.on('Material Request', { } d.hide(); refresh_field("items"); - } + }, }); - } + }, }); d.show(); }, - make_purchase_order: function(frm) { + make_purchase_order: function (frm) { frappe.prompt( { - label: __('For Default Supplier (Optional)'), - fieldname:'default_supplier', - fieldtype: 'Link', - options: 'Supplier', - description: __('Select a Supplier from the Default Suppliers of the items below. On selection, a Purchase Order will be made against items belonging to the selected Supplier only.'), + label: __("For Default Supplier (Optional)"), + fieldname: "default_supplier", + fieldtype: "Link", + options: "Supplier", + description: __( + "Select a Supplier from the Default Suppliers of the items below. On selection, a Purchase Order will be made against items belonging to the selected Supplier only." + ), get_query: () => { - return{ + return { query: "erpnext.stock.doctype.material_request.material_request.get_default_supplier_query", - filters: {'doc': frm.doc.name} - } - } + filters: { doc: frm.doc.name }, + }; + }, }, (values) => { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order", frm: frm, args: { default_supplier: values.default_supplier }, - run_link_triggers: true + run_link_triggers: true, }); }, - __('Enter Supplier'), - __('Create') - ) + __("Enter Supplier"), + __("Create") + ); }, - make_request_for_quotation: function(frm) { + make_request_for_quotation: function (frm) { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.material_request.material_request.make_request_for_quotation", frm: frm, - run_link_triggers: true + run_link_triggers: true, }); }, - make_supplier_quotation: function(frm) { + make_supplier_quotation: function (frm) { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.material_request.material_request.make_supplier_quotation", - frm: frm + frm: frm, }); }, - make_stock_entry: function(frm) { + make_stock_entry: function (frm) { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry", - frm: frm + frm: frm, }); }, @@ -352,71 +411,70 @@ frappe.ui.form.on('Material Request', { frappe.prompt( [ { - label: __('In Transit Warehouse'), - fieldname: 'in_transit_warehouse', - fieldtype: 'Link', - options: 'Warehouse', + label: __("In Transit Warehouse"), + fieldname: "in_transit_warehouse", + fieldtype: "Link", + options: "Warehouse", reqd: 1, get_query: () => { - return{ + return { filters: { - 'company': frm.doc.company, - 'is_group': 0, - 'warehouse_type': 'Transit' - } - } - } - } + company: frm.doc.company, + is_group: 0, + warehouse_type: "Transit", + }, + }; + }, + }, ], (values) => { frappe.call({ method: "erpnext.stock.doctype.material_request.material_request.make_in_transit_stock_entry", args: { source_name: frm.doc.name, - in_transit_warehouse: values.in_transit_warehouse + in_transit_warehouse: values.in_transit_warehouse, }, - callback: function(r) { + callback: function (r) { if (r.message) { let doc = frappe.model.sync(r.message); - frappe.set_route('Form', doc[0].doctype, doc[0].name); + frappe.set_route("Form", doc[0].doctype, doc[0].name); } - } - }) + }, + }); }, - __('In Transit Transfer'), + __("In Transit Transfer"), __("Create Stock Entry") - ) + ); }, create_pick_list: (frm) => { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.material_request.material_request.create_pick_list", - frm: frm + frm: frm, }); }, - raise_work_orders: function(frm) { + raise_work_orders: function (frm) { frappe.call({ - method:"erpnext.stock.doctype.material_request.material_request.raise_work_orders", + method: "erpnext.stock.doctype.material_request.material_request.raise_work_orders", args: { - "material_request": frm.doc.name + material_request: frm.doc.name, }, freeze: true, - callback: function(r) { - if(r.message.length) { + callback: function (r) { + if (r.message.length) { frm.reload_doc(); } - } + }, }); }, - material_request_type: function(frm) { - frm.toggle_reqd('customer', frm.doc.material_request_type=="Customer Provided"); + material_request_type: function (frm) { + frm.toggle_reqd("customer", frm.doc.material_request_type == "Customer Provided"); - if (frm.doc.material_request_type !== 'Material Transfer' && frm.doc.set_from_warehouse) { - frm.set_value('set_from_warehouse', ''); + if (frm.doc.material_request_type !== "Material Transfer" && frm.doc.set_from_warehouse) { + frm.set_value("set_from_warehouse", ""); } }, - }); frappe.ui.form.on("Material Request Item", { @@ -428,12 +486,12 @@ frappe.ui.form.on("Material Request Item", { frm.events.get_item_data(frm, item, false); }, - from_warehouse: function(frm, doctype, name) { + from_warehouse: function (frm, doctype, name) { const item = locals[doctype][name]; frm.events.get_item_data(frm, item, false); }, - warehouse: function(frm, doctype, name) { + warehouse: function (frm, doctype, name) { const item = locals[doctype][name]; frm.events.get_item_data(frm, item, false); }, @@ -445,18 +503,18 @@ frappe.ui.form.on("Material Request Item", { refresh_field("amount", item.name, item.parentfield); }, - item_code: function(frm, doctype, name) { + item_code: function (frm, doctype, name) { const item = locals[doctype][name]; item.rate = 0; - item.uom = ''; + item.uom = ""; set_schedule_date(frm); frm.events.get_item_data(frm, item, true); }, - schedule_date: function(frm, cdt, cdn) { + schedule_date: function (frm, cdt, cdn) { var row = locals[cdt][cdn]; if (row.schedule_date) { - if(!frm.doc.schedule_date) { + if (!frm.doc.schedule_date) { erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "items", "schedule_date"); } else { set_schedule_date(frm); @@ -464,13 +522,15 @@ frappe.ui.form.on("Material Request Item", { } }, - conversion_factor: function(frm, doctype, name) { + conversion_factor: function (frm, doctype, name) { const item = locals[doctype][name]; frm.events.get_item_data(frm, item, false); }, }); -erpnext.buying.MaterialRequestController = class MaterialRequestController extends erpnext.buying.BuyingController { +erpnext.buying.MaterialRequestController = class MaterialRequestController extends ( + erpnext.buying.BuyingController +) { tc_name() { this.get_terms(); } @@ -492,32 +552,32 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten } onload() { - this.frm.set_query("item_code", "items", function(doc, cdt, cdn) { + this.frm.set_query("item_code", "items", function (doc, cdt, cdn) { if (doc.material_request_type == "Customer Provided") { - return{ + return { query: "erpnext.controllers.queries.item_query", - filters:{ - 'customer': doc.customer, - 'is_stock_item':1 - } - } + filters: { + customer: doc.customer, + is_stock_item: 1, + }, + }; } else if (doc.material_request_type == "Purchase") { - return{ + return { query: "erpnext.controllers.queries.item_query", - filters: {'is_purchase_item': 1} - } + filters: { is_purchase_item: 1 }, + }; } else { - return{ + return { query: "erpnext.controllers.queries.item_query", - filters: {'is_stock_item': 1} - } + filters: { is_stock_item: 1 }, + }; } }); } items_add(doc, cdt, cdn) { var row = frappe.get_doc(cdt, cdn); - if(doc.schedule_date) { + if (doc.schedule_date) { row.schedule_date = doc.schedule_date; refresh_field("schedule_date", cdn, "items"); } else { @@ -542,10 +602,16 @@ erpnext.buying.MaterialRequestController = class MaterialRequestController exten }; // for backward compatibility: combine new and previous states -extend_cscript(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.buying.MaterialRequestController({ frm: cur_frm })); function set_schedule_date(frm) { - if(frm.doc.schedule_date){ - erpnext.utils.copy_value_in_all_rows(frm.doc, frm.doc.doctype, frm.doc.name, "items", "schedule_date"); + if (frm.doc.schedule_date) { + erpnext.utils.copy_value_in_all_rows( + frm.doc, + frm.doc.doctype, + frm.doc.name, + "items", + "schedule_date" + ); } } diff --git a/erpnext/stock/doctype/material_request/material_request_list.js b/erpnext/stock/doctype/material_request/material_request_list.js index c85bd715f2d..8a8cfd47b81 100644 --- a/erpnext/stock/doctype/material_request/material_request_list.js +++ b/erpnext/stock/doctype/material_request/material_request_list.js @@ -1,8 +1,8 @@ -frappe.listview_settings['Material Request'] = { +frappe.listview_settings["Material Request"] = { add_fields: ["material_request_type", "status", "per_ordered", "per_received", "transfer_status"], - get_indicator: function(doc) { + get_indicator: function (doc) { var precision = frappe.defaults.get_default("float_precision"); - if (doc.status=="Stopped") { + if (doc.status == "Stopped") { return [__("Stopped"), "red", "status,=,Stopped"]; } else if (doc.transfer_status && doc.docstatus != 2) { if (doc.transfer_status == "Not Started") { @@ -12,12 +12,16 @@ frappe.listview_settings['Material Request'] = { } else if (doc.transfer_status == "Completed") { return [__("Completed"), "green"]; } - } else if (doc.docstatus==1 && flt(doc.per_ordered, precision) == 0) { + } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) == 0) { return [__("Pending"), "orange", "per_ordered,=,0"]; - } else if (doc.docstatus==1 && flt(doc.per_ordered, precision) < 100) { + } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) < 100) { return [__("Partially ordered"), "yellow", "per_ordered,<,100"]; - } else if (doc.docstatus==1 && flt(doc.per_ordered, precision) == 100) { - if (doc.material_request_type == "Purchase" && flt(doc.per_received, precision) < 100 && flt(doc.per_received, precision) > 0) { + } else if (doc.docstatus == 1 && flt(doc.per_ordered, precision) == 100) { + if ( + doc.material_request_type == "Purchase" && + flt(doc.per_received, precision) < 100 && + flt(doc.per_received, precision) > 0 + ) { return [__("Partially Received"), "yellow", "per_received,<,100"]; } else if (doc.material_request_type == "Purchase" && flt(doc.per_received, precision) == 100) { return [__("Received"), "green", "per_received,=,100"]; @@ -33,5 +37,5 @@ frappe.listview_settings['Material Request'] = { return [__("Manufactured"), "green", "per_ordered,=,100"]; } } - } + }, }; diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index 95e5ea309f8..682631f1b74 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -1,45 +1,45 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Packing Slip', { - setup: (frm) => { - frm.set_query('delivery_note', () => { - return { - filters: { - docstatus: 0, - } - } - }); +frappe.ui.form.on("Packing Slip", { + setup: (frm) => { + frm.set_query("delivery_note", () => { + return { + filters: { + docstatus: 0, + }, + }; + }); - frm.set_query('item_code', 'items', (doc, cdt, cdn) => { - if (!doc.delivery_note) { - frappe.throw(__('Please select a Delivery Note')); - } else { - let d = locals[cdt][cdn]; - return { - query: 'erpnext.stock.doctype.packing_slip.packing_slip.item_details', - filters: { - delivery_note: doc.delivery_note, - } - } - } - }); + frm.set_query("item_code", "items", (doc, cdt, cdn) => { + if (!doc.delivery_note) { + frappe.throw(__("Please select a Delivery Note")); + } else { + let d = locals[cdt][cdn]; + return { + query: "erpnext.stock.doctype.packing_slip.packing_slip.item_details", + filters: { + delivery_note: doc.delivery_note, + }, + }; + } + }); }, refresh: (frm) => { - frm.toggle_display('misc_details', frm.doc.amended_from); + frm.toggle_display("misc_details", frm.doc.amended_from); }, delivery_note: (frm) => { - frm.set_value('items', null); + frm.set_value("items", null); if (frm.doc.delivery_note) { erpnext.utils.map_current_doc({ - method: 'erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip', + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip", source_name: frm.doc.delivery_note, target_doc: frm, freeze: true, - freeze_message: __('Creating Packing Slip ...'), + freeze_message: __("Creating Packing Slip ..."), }); } }, diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js index 3a5daa1bb73..43519e76467 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -1,54 +1,55 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Pick List', { +frappe.ui.form.on("Pick List", { setup: (frm) => { frm.ignore_doctypes_on_cancel_all = ["Serial and Batch Bundle"]; - frm.set_indicator_formatter('item_code', - function(doc) { return (doc.stock_qty === 0) ? "red" : "green"; }); + frm.set_indicator_formatter("item_code", function (doc) { + return doc.stock_qty === 0 ? "red" : "green"; + }); frm.custom_make_buttons = { - 'Delivery Note': 'Delivery Note', - 'Stock Entry': 'Stock Entry', + "Delivery Note": "Delivery Note", + "Stock Entry": "Stock Entry", }; - frm.set_query('parent_warehouse', () => { + frm.set_query("parent_warehouse", () => { return { filters: { - 'company': frm.doc.company - } + company: frm.doc.company, + }, }; }); - frm.set_query('work_order', () => { + frm.set_query("work_order", () => { return { - query: 'erpnext.stock.doctype.pick_list.pick_list.get_pending_work_orders', + query: "erpnext.stock.doctype.pick_list.pick_list.get_pending_work_orders", filters: { - 'company': frm.doc.company - } + company: frm.doc.company, + }, }; }); - frm.set_query('material_request', () => { + frm.set_query("material_request", () => { return { filters: { - 'material_request_type': ['=', frm.doc.purpose] - } + material_request_type: ["=", frm.doc.purpose], + }, }; }); - frm.set_query('item_code', 'locations', () => { - return erpnext.queries.item({ "is_stock_item": 1 }); + frm.set_query("item_code", "locations", () => { + return erpnext.queries.item({ is_stock_item: 1 }); }); - frm.set_query('batch_no', 'locations', (frm, cdt, cdn) => { + frm.set_query("batch_no", "locations", (frm, cdt, cdn) => { const row = locals[cdt][cdn]; return { - query: 'erpnext.controllers.queries.get_batch_no', + query: "erpnext.controllers.queries.get_batch_no", filters: { item_code: row.item_code, - warehouse: row.warehouse + warehouse: row.warehouse, }, }; }); @@ -57,29 +58,29 @@ frappe.ui.form.on('Pick List', { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ["in", [doc.name, ""]], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); }, - set_item_locations:(frm, save) => { + set_item_locations: (frm, save) => { if (!(frm.doc.locations && frm.doc.locations.length)) { - frappe.msgprint(__('Add items in the Item Locations table')); + frappe.msgprint(__("Add items in the Item Locations table")); } else { frappe.call({ method: "set_item_locations", doc: frm.doc, args: { - "save": save, + save: save, }, freeze: 1, freeze_message: __("Setting Item Locations..."), callback(r) { refresh_field("locations"); - } + }, }); } }, @@ -88,142 +89,173 @@ frappe.ui.form.on('Pick List', { frm.events.set_item_locations(frm, false); }, refresh: (frm) => { - frm.trigger('add_get_items_button'); + frm.trigger("add_get_items_button"); if (frm.doc.docstatus === 1) { - frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.target_document_exists', { - 'pick_list_name': frm.doc.name, - 'purpose': frm.doc.purpose - }).then(target_document_exists => { - frm.set_df_property("locations", "allow_on_submit", target_document_exists ? 0 : 1); + frappe + .xcall("erpnext.stock.doctype.pick_list.pick_list.target_document_exists", { + pick_list_name: frm.doc.name, + purpose: frm.doc.purpose, + }) + .then((target_document_exists) => { + frm.set_df_property("locations", "allow_on_submit", target_document_exists ? 0 : 1); - if (target_document_exists) return; + if (target_document_exists) return; - frm.add_custom_button(__('Update Current Stock'), () => frm.trigger('update_pick_list_stock')); + frm.add_custom_button(__("Update Current Stock"), () => + frm.trigger("update_pick_list_stock") + ); - if (frm.doc.purpose === 'Delivery') { - frm.add_custom_button(__('Delivery Note'), () => frm.trigger('create_delivery_note'), __('Create')); - } else { - frm.add_custom_button(__('Stock Entry'), () => frm.trigger('create_stock_entry'), __('Create')); - } - }); + if (frm.doc.purpose === "Delivery") { + frm.add_custom_button( + __("Delivery Note"), + () => frm.trigger("create_delivery_note"), + __("Create") + ); + } else { + frm.add_custom_button( + __("Stock Entry"), + () => frm.trigger("create_stock_entry"), + __("Create") + ); + } + }); - if (frm.doc.purpose === 'Delivery' && frm.doc.status === 'Open') { + if (frm.doc.purpose === "Delivery" && frm.doc.status === "Open") { if (frm.doc.__onload && frm.doc.__onload.has_unreserved_stock) { - frm.add_custom_button(__('Reserve'), () => frm.events.create_stock_reservation_entries(frm), __('Stock Reservation')); + frm.add_custom_button( + __("Reserve"), + () => frm.events.create_stock_reservation_entries(frm), + __("Stock Reservation") + ); } if (frm.doc.__onload && frm.doc.__onload.has_reserved_stock) { - frm.add_custom_button(__('Unreserve'), () => { - frappe.confirm( - __('The reserved stock will be released. Are you certain you wish to proceed?'), - () => frm.events.cancel_stock_reservation_entries(frm) - ) - }, __('Stock Reservation')); - frm.add_custom_button(__('Reserved Stock'), () => frm.events.show_reserved_stock(frm), __('Stock Reservation')); + frm.add_custom_button( + __("Unreserve"), + () => { + frappe.confirm( + __( + "The reserved stock will be released. Are you certain you wish to proceed?" + ), + () => frm.events.cancel_stock_reservation_entries(frm) + ); + }, + __("Stock Reservation") + ); + frm.add_custom_button( + __("Reserved Stock"), + () => frm.events.show_reserved_stock(frm), + __("Stock Reservation") + ); } } } - let sbb_field = frm.get_docfield('locations', 'serial_and_batch_bundle'); + let sbb_field = frm.get_docfield("locations", "serial_and_batch_bundle"); if (sbb_field) { sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'warehouse': row.doc.warehouse, - 'voucher_type': frm.doc.doctype, - } + item_code: row.doc.item_code, + warehouse: row.doc.warehouse, + voucher_type: frm.doc.doctype, + }; }; } }, work_order: (frm) => { - frappe.db.get_value('Work Order', - frm.doc.work_order, - ['qty', 'material_transferred_for_manufacturing'] - ).then(data => { - let qty_data = data.message; - let max = qty_data.qty - qty_data.material_transferred_for_manufacturing; - frappe.prompt({ - fieldtype: 'Float', - label: __('Qty of Finished Goods Item'), - fieldname: 'qty', - description: __('Max: {0}', [max]), - default: max - }, (data) => { - frm.set_value('for_qty', data.qty); - if (data.qty > max) { - frappe.msgprint(__('Quantity must not be more than {0}', [max])); - return; - } - frm.clear_table('locations'); - erpnext.utils.map_current_doc({ - method: 'erpnext.manufacturing.doctype.work_order.work_order.create_pick_list', - target: frm, - source_name: frm.doc.work_order - }); - }, __('Select Quantity'), __('Get Items')); - }); + frappe.db + .get_value("Work Order", frm.doc.work_order, ["qty", "material_transferred_for_manufacturing"]) + .then((data) => { + let qty_data = data.message; + let max = qty_data.qty - qty_data.material_transferred_for_manufacturing; + frappe.prompt( + { + fieldtype: "Float", + label: __("Qty of Finished Goods Item"), + fieldname: "qty", + description: __("Max: {0}", [max]), + default: max, + }, + (data) => { + frm.set_value("for_qty", data.qty); + if (data.qty > max) { + frappe.msgprint(__("Quantity must not be more than {0}", [max])); + return; + } + frm.clear_table("locations"); + erpnext.utils.map_current_doc({ + method: "erpnext.manufacturing.doctype.work_order.work_order.create_pick_list", + target: frm, + source_name: frm.doc.work_order, + }); + }, + __("Select Quantity"), + __("Get Items") + ); + }); }, material_request: (frm) => { erpnext.utils.map_current_doc({ - method: 'erpnext.stock.doctype.material_request.material_request.create_pick_list', + method: "erpnext.stock.doctype.material_request.material_request.create_pick_list", target: frm, - source_name: frm.doc.material_request + source_name: frm.doc.material_request, }); }, purpose: (frm) => { - frm.clear_table('locations'); - frm.trigger('add_get_items_button'); + frm.clear_table("locations"); + frm.trigger("add_get_items_button"); }, create_delivery_note: (frm) => { frappe.model.open_mapped_doc({ - method: 'erpnext.stock.doctype.pick_list.pick_list.create_delivery_note', - frm: frm + method: "erpnext.stock.doctype.pick_list.pick_list.create_delivery_note", + frm: frm, }); - }, create_stock_entry: (frm) => { - frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', { - 'pick_list': frm.doc, - }).then(stock_entry => { - frappe.model.sync(stock_entry); - frappe.set_route("Form", 'Stock Entry', stock_entry.name); - }); + frappe + .xcall("erpnext.stock.doctype.pick_list.pick_list.create_stock_entry", { + pick_list: frm.doc, + }) + .then((stock_entry) => { + frappe.model.sync(stock_entry); + frappe.set_route("Form", "Stock Entry", stock_entry.name); + }); }, update_pick_list_stock: (frm) => { frm.events.set_item_locations(frm, true); }, add_get_items_button: (frm) => { let purpose = frm.doc.purpose; - if (purpose != 'Delivery' || frm.doc.docstatus !== 0) return; + if (purpose != "Delivery" || frm.doc.docstatus !== 0) return; let get_query_filters = { docstatus: 1, - per_delivered: ['<', 100], - status: ['!=', ''], - customer: frm.doc.customer + per_delivered: ["<", 100], + status: ["!=", ""], + customer: frm.doc.customer, }; - frm.get_items_btn = frm.add_custom_button(__('Get Items'), () => { + frm.get_items_btn = frm.add_custom_button(__("Get Items"), () => { erpnext.utils.map_current_doc({ - method: 'erpnext.selling.doctype.sales_order.sales_order.create_pick_list', - source_doctype: 'Sales Order', + method: "erpnext.selling.doctype.sales_order.sales_order.create_pick_list", + source_doctype: "Sales Order", target: frm, setters: { company: frm.doc.company, - customer: frm.doc.customer + customer: frm.doc.customer, }, - date_field: 'transaction_date', - get_query_filters: get_query_filters + date_field: "transaction_date", + get_query_filters: get_query_filters, }); }); }, scan_barcode: (frm) => { const opts = { frm, - items_table_name: 'locations', - qty_field: 'picked_qty', - max_qty_field: 'qty', + items_table_name: "locations", + qty_field: "picked_qty", + max_qty_field: "qty", dont_allow_new_row: true, prompt_qty: frm.doc.prompt_qty, - serial_no_field: "not_supported", // doesn't make sense for picklist without a separate field. + serial_no_field: "not_supported", // doesn't make sense for picklist without a separate field. }; const barcode_scanner = new erpnext.utils.BarcodeScanner(opts); barcode_scanner.process_scan(); @@ -233,14 +265,14 @@ frappe.ui.form.on('Pick List', { doc: frm.doc, method: "create_stock_reservation_entries", args: { - notify: true + notify: true, }, freeze: true, freeze_message: __("Reserving Stock..."), callback: (r) => { frm.doc.__onload.has_unreserved_stock = false; frm.reload_doc(); - } + }, }); }, cancel_stock_reservation_entries: (frm) => { @@ -248,40 +280,42 @@ frappe.ui.form.on('Pick List', { doc: frm.doc, method: "cancel_stock_reservation_entries", args: { - notify: true + notify: true, }, freeze: true, - freeze_message: __('Unreserving Stock...'), + freeze_message: __("Unreserving Stock..."), callback: (r) => { frm.doc.__onload.has_reserved_stock = false; frm.reload_doc(); - } + }, }); }, show_reserved_stock(frm) { // Get the latest modified date from the locations table. - var to_date = moment(new Date(Math.max(...frm.doc.locations.map(e => new Date(e.modified))))).format('YYYY-MM-DD'); + var to_date = moment( + new Date(Math.max(...frm.doc.locations.map((e) => new Date(e.modified)))) + ).format("YYYY-MM-DD"); frappe.route_options = { company: frm.doc.company, - from_date: moment(frm.doc.creation).format('YYYY-MM-DD'), + from_date: moment(frm.doc.creation).format("YYYY-MM-DD"), to_date: to_date, voucher_type: "Sales Order", from_voucher_type: "Pick List", from_voucher_no: frm.doc.name, - } + }; frappe.set_route("query-report", "Reserved Stock"); - } + }, }); -frappe.ui.form.on('Pick List Item', { +frappe.ui.form.on("Pick List Item", { item_code: (frm, cdt, cdn) => { let row = frappe.get_doc(cdt, cdn); if (row.item_code) { - get_item_details(row.item_code).then(data => { - frappe.model.set_value(cdt, cdn, 'uom', data.stock_uom); - frappe.model.set_value(cdt, cdn, 'stock_uom', data.stock_uom); - frappe.model.set_value(cdt, cdn, 'conversion_factor', 1); + get_item_details(row.item_code).then((data) => { + frappe.model.set_value(cdt, cdn, "uom", data.stock_uom); + frappe.model.set_value(cdt, cdn, "stock_uom", data.stock_uom); + frappe.model.set_value(cdt, cdn, "conversion_factor", 1); }); } }, @@ -289,64 +323,62 @@ frappe.ui.form.on('Pick List Item', { uom: (frm, cdt, cdn) => { let row = frappe.get_doc(cdt, cdn); if (row.uom) { - get_item_details(row.item_code, row.uom).then(data => { - frappe.model.set_value(cdt, cdn, 'conversion_factor', data.conversion_factor); + get_item_details(row.item_code, row.uom).then((data) => { + frappe.model.set_value(cdt, cdn, "conversion_factor", data.conversion_factor); }); } }, qty: (frm, cdt, cdn) => { let row = frappe.get_doc(cdt, cdn); - frappe.model.set_value(cdt, cdn, 'stock_qty', row.qty * row.conversion_factor); + frappe.model.set_value(cdt, cdn, "stock_qty", row.qty * row.conversion_factor); }, conversion_factor: (frm, cdt, cdn) => { let row = frappe.get_doc(cdt, cdn); - frappe.model.set_value(cdt, cdn, 'stock_qty', row.qty * row.conversion_factor); + frappe.model.set_value(cdt, cdn, "stock_qty", row.qty * row.conversion_factor); }, pick_serial_and_batch(frm, cdt, cdn) { let item = locals[cdt][cdn]; let path = "assets/erpnext/js/utils/serial_no_batch_selector.js"; - frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]) - .then((r) => { - if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { - item.has_serial_no = r.message.has_serial_no; - item.has_batch_no = r.message.has_batch_no; - item.type_of_transaction = item.qty > 0 ? "Outward":"Inward"; + frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]).then((r) => { + if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { + item.has_serial_no = r.message.has_serial_no; + item.has_batch_no = r.message.has_batch_no; + item.type_of_transaction = item.qty > 0 ? "Outward" : "Inward"; - item.title = item.has_serial_no ? - __("Select Serial No") : __("Select Batch No"); + item.title = item.has_serial_no ? __("Select Serial No") : __("Select Batch No"); - if (item.has_serial_no && item.has_batch_no) { - item.title = __("Select Serial and Batch"); - } - - frappe.require(path, function() { - new erpnext.SerialBatchPackageSelector( - frm, item, (r) => { - if (r) { - let qty = Math.abs(r.total_qty); - frappe.model.set_value(item.doctype, item.name, { - "serial_and_batch_bundle": r.name, - "use_serial_batch_fields": 0, - "qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item)) - }); - } - } - ); - }); + if (item.has_serial_no && item.has_batch_no) { + item.title = __("Select Serial and Batch"); } - }); - } + + frappe.require(path, function () { + new erpnext.SerialBatchPackageSelector(frm, item, (r) => { + if (r) { + let qty = Math.abs(r.total_qty); + frappe.model.set_value(item.doctype, item.name, { + serial_and_batch_bundle: r.name, + use_serial_batch_fields: 0, + qty: + qty / + flt(item.conversion_factor || 1, precision("conversion_factor", item)), + }); + } + }); + }); + } + }); + }, }); -function get_item_details(item_code, uom=null) { +function get_item_details(item_code, uom = null) { if (item_code) { - return frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.get_item_details', { + return frappe.xcall("erpnext.stock.doctype.pick_list.pick_list.get_item_details", { item_code, - uom + uom, }); } } diff --git a/erpnext/stock/doctype/pick_list/pick_list_list.js b/erpnext/stock/doctype/pick_list/pick_list_list.js index ad88b0a682f..9cdbfe18720 100644 --- a/erpnext/stock/doctype/pick_list/pick_list_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list_list.js @@ -1,14 +1,14 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.listview_settings['Pick List'] = { +frappe.listview_settings["Pick List"] = { get_indicator: function (doc) { const status_colors = { - "Draft": "grey", - "Open": "orange", - "Completed": "green", - "Cancelled": "red", + Draft: "grey", + Open: "orange", + Completed: "green", + Cancelled: "red", }; return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; }, -}; \ No newline at end of file +}; diff --git a/erpnext/stock/doctype/price_list/price_list.js b/erpnext/stock/doctype/price_list/price_list.js index 9291498e863..85a3a391187 100644 --- a/erpnext/stock/doctype/price_list/price_list.js +++ b/erpnext/stock/doctype/price_list/price_list.js @@ -2,13 +2,17 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Price List", { - refresh: function(frm) { + refresh: function (frm) { let me = this; - frm.add_custom_button(__("Add / Edit Prices"), function() { - frappe.route_options = { - "price_list": frm.doc.name - }; - frappe.set_route("Report", "Item Price"); - }, "fa fa-money"); - } + frm.add_custom_button( + __("Add / Edit Prices"), + function () { + frappe.route_options = { + price_list: frm.doc.name, + }; + frappe.set_route("Report", "Item Price"); + }, + "fa fa-money" + ); + }, }); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 2cbccb0774c..997cdd0e56f 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -10,12 +10,12 @@ erpnext.buying.setup_buying_controller(); frappe.ui.form.on("Purchase Receipt", { setup: (frm) => { frm.make_methods = { - 'Landed Cost Voucher': () => { - let lcv = frappe.model.get_new_doc('Landed Cost Voucher'); + "Landed Cost Voucher": () => { + let lcv = frappe.model.get_new_doc("Landed Cost Voucher"); lcv.company = frm.doc.company; - let lcv_receipt = frappe.model.get_new_doc('Landed Cost Purchase Receipt'); - lcv_receipt.receipt_document_type = 'Purchase Receipt'; + let lcv_receipt = frappe.model.get_new_doc("Landed Cost Purchase Receipt"); + lcv_receipt.receipt_document_type = "Purchase Receipt"; lcv_receipt.receipt_document = frm.doc.name; lcv_receipt.supplier = frm.doc.supplier; lcv_receipt.grand_total = frm.doc.grand_total; @@ -23,69 +23,77 @@ frappe.ui.form.on("Purchase Receipt", { frappe.set_route("Form", lcv.doctype, lcv.name); }, - } - - frm.custom_make_buttons = { - 'Stock Entry': 'Return', - 'Purchase Invoice': 'Purchase Invoice' }; - frm.set_query("expense_account", "items", function() { + frm.custom_make_buttons = { + "Stock Entry": "Return", + "Purchase Invoice": "Purchase Invoice", + }; + + frm.set_query("expense_account", "items", function () { return { query: "erpnext.controllers.queries.get_expense_account", - filters: {'company': frm.doc.company } - } + filters: { company: frm.doc.company }, + }; }); - frm.set_query("wip_composite_asset", "items", function() { + frm.set_query("wip_composite_asset", "items", function () { return { - filters: {'is_composite_asset': 1, 'docstatus': 0 } - } + filters: { is_composite_asset: 1, docstatus: 0 }, + }; }); - frm.set_query("taxes_and_charges", function() { + frm.set_query("taxes_and_charges", function () { return { - filters: {'company': frm.doc.company } - } + filters: { company: frm.doc.company }, + }; }); - frm.set_query("subcontracting_receipt", function() { + frm.set_query("subcontracting_receipt", function () { return { filters: { - 'docstatus': 1, - 'supplier': frm.doc.supplier, - } - } + docstatus: 1, + supplier: frm.doc.supplier, + }, + }; }); }, - onload: function(frm) { - erpnext.queries.setup_queries(frm, "Warehouse", function() { + onload: function (frm) { + erpnext.queries.setup_queries(frm, "Warehouse", function () { return erpnext.queries.warehouse(frm.doc); }); }, - refresh: function(frm) { - if(frm.doc.company) { + refresh: function (frm) { + if (frm.doc.company) { frm.trigger("toggle_display_account_head"); } if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) { - frm.add_custom_button(__('Debit Note'), function() { - frappe.model.open_mapped_doc({ - method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", - frm: cur_frm, - }) - }, __('Create')); - frm.page.set_inner_btn_group_as_primary(__('Create')); + frm.add_custom_button( + __("Debit Note"), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", + frm: cur_frm, + }); + }, + __("Create") + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } if (frm.doc.docstatus === 1 && frm.doc.is_internal_supplier && !frm.doc.inter_company_reference) { - frm.add_custom_button(__('Delivery Note'), function() { - frappe.model.open_mapped_doc({ - method: 'erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_inter_company_delivery_note', - frm: cur_frm, - }) - }, __('Create')); + frm.add_custom_button( + __("Delivery Note"), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_inter_company_delivery_note", + frm: cur_frm, + }); + }, + __("Create") + ); } if (frm.doc.docstatus === 0) { @@ -94,7 +102,9 @@ frappe.ui.form.on("Purchase Receipt", { if (value) { frm.doc.items.forEach((item) => { frm.fields_dict.items.grid.update_docfield_property( - "rate", "read_only", (item.purchase_order && item.purchase_order_item) + "rate", + "read_only", + item.purchase_order && item.purchase_order_item ); }); } @@ -105,58 +115,68 @@ frappe.ui.form.on("Purchase Receipt", { frm.events.add_custom_buttons(frm); }, - add_custom_buttons: function(frm) { + add_custom_buttons: function (frm) { if (frm.doc.docstatus == 0) { - frm.add_custom_button(__('Purchase Invoice'), function () { - if (!frm.doc.supplier) { - frappe.throw({ - title: __("Mandatory"), - message: __("Please Select a Supplier") - }); - } - erpnext.utils.map_current_doc({ - method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_purchase_receipt", - source_doctype: "Purchase Invoice", - target: frm, - setters: { - supplier: frm.doc.supplier, - }, - get_query_filters: { - docstatus: 1, - per_received: ["<", 100], - company: frm.doc.company + frm.add_custom_button( + __("Purchase Invoice"), + function () { + if (!frm.doc.supplier) { + frappe.throw({ + title: __("Mandatory"), + message: __("Please Select a Supplier"), + }); } - }) - }, __("Get Items From")); + erpnext.utils.map_current_doc({ + method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_purchase_receipt", + source_doctype: "Purchase Invoice", + target: frm, + setters: { + supplier: frm.doc.supplier, + }, + get_query_filters: { + docstatus: 1, + per_received: ["<", 100], + company: frm.doc.company, + }, + }); + }, + __("Get Items From") + ); } }, - company: function(frm) { + company: function (frm) { frm.trigger("toggle_display_account_head"); erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); }, subcontracting_receipt: (frm) => { - if (frm.doc.is_subcontracted === 1 && frm.doc.is_old_subcontracting_flow === 0 && frm.doc.subcontracting_receipt) { - frm.set_value('items', null); + if ( + frm.doc.is_subcontracted === 1 && + frm.doc.is_old_subcontracting_flow === 0 && + frm.doc.subcontracting_receipt + ) { + frm.set_value("items", null); erpnext.utils.map_current_doc({ - method: 'erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_purchase_receipt', + method: "erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_purchase_receipt", source_name: frm.doc.subcontracting_receipt, target_doc: frm, freeze: true, - freeze_message: __('Mapping Purchase Receipt ...'), + freeze_message: __("Mapping Purchase Receipt ..."), }); } }, - toggle_display_account_head: function(frm) { - var enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company) + toggle_display_account_head: function (frm) { + var enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company); frm.fields_dict["items"].grid.set_column_disp(["cost_center"], enabled); - } + }, }); -erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extends erpnext.buying.BuyingController { +erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extends ( + erpnext.buying.BuyingController +) { setup(doc) { this.setup_posting_date_time_check(); super.setup(doc); @@ -169,34 +189,43 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend erpnext.accounts.ledger_preview.show_accounting_ledger_preview(this.frm); erpnext.accounts.ledger_preview.show_stock_ledger_preview(this.frm); - if(this.frm.doc.docstatus > 0) { + if (this.frm.doc.docstatus > 0) { this.show_stock_ledger(); //removed for temporary this.show_general_ledger(); - this.frm.add_custom_button(__('Asset'), function() { - frappe.route_options = { - purchase_receipt: me.frm.doc.name, - }; - frappe.set_route("List", "Asset"); - }, __("View")); + this.frm.add_custom_button( + __("Asset"), + function () { + frappe.route_options = { + purchase_receipt: me.frm.doc.name, + }; + frappe.set_route("List", "Asset"); + }, + __("View") + ); - this.frm.add_custom_button(__('Asset Movement'), function() { - frappe.route_options = { - reference_name: me.frm.doc.name, - }; - frappe.set_route("List", "Asset Movement"); - }, __("View")); + this.frm.add_custom_button( + __("Asset Movement"), + function () { + frappe.route_options = { + reference_name: me.frm.doc.name, + }; + frappe.set_route("List", "Asset Movement"); + }, + __("View") + ); } - if(!this.frm.doc.is_return && this.frm.doc.status!="Closed") { + if (!this.frm.doc.is_return && this.frm.doc.status != "Closed") { if (this.frm.doc.docstatus == 0) { - this.frm.add_custom_button(__('Purchase Order'), + this.frm.add_custom_button( + __("Purchase Order"), function () { if (!me.frm.doc.supplier) { frappe.throw({ title: __("Mandatory"), - message: __("Please Select a Supplier") + message: __("Please Select a Supplier"), }); } erpnext.utils.map_current_doc({ @@ -205,39 +234,52 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend target: me.frm, setters: { supplier: me.frm.doc.supplier, - schedule_date: undefined + schedule_date: undefined, }, get_query_filters: { docstatus: 1, status: ["not in", ["Closed", "On Hold"]], per_received: ["<", 99.99], - company: me.frm.doc.company - } - }) - }, __("Get Items From")); + company: me.frm.doc.company, + }, + }); + }, + __("Get Items From") + ); } - if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") { + if (this.frm.doc.docstatus == 1 && this.frm.doc.status != "Closed") { if (this.frm.has_perm("submit")) { - cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt, __("Status")) + cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt, __("Status")); } - cur_frm.add_custom_button(__('Purchase Return'), this.make_purchase_return, __('Create')); + cur_frm.add_custom_button(__("Purchase Return"), this.make_purchase_return, __("Create")); - cur_frm.add_custom_button(__('Make Stock Entry'), cur_frm.cscript['Make Stock Entry'], __('Create')); + cur_frm.add_custom_button( + __("Make Stock Entry"), + cur_frm.cscript["Make Stock Entry"], + __("Create") + ); - if(flt(this.frm.doc.per_billed) < 100) { - cur_frm.add_custom_button(__('Purchase Invoice'), this.make_purchase_invoice, __('Create')); + if (flt(this.frm.doc.per_billed) < 100) { + cur_frm.add_custom_button( + __("Purchase Invoice"), + this.make_purchase_invoice, + __("Create") + ); } - cur_frm.add_custom_button(__('Retention Stock Entry'), this.make_retention_stock_entry, __('Create')); + cur_frm.add_custom_button( + __("Retention Stock Entry"), + this.make_retention_stock_entry, + __("Create") + ); - cur_frm.page.set_inner_btn_group_as_primary(__('Create')); + cur_frm.page.set_inner_btn_group_as_primary(__("Create")); } } - - if(this.frm.doc.docstatus==1 && this.frm.doc.status === "Closed" && this.frm.has_perm("submit")) { - cur_frm.add_custom_button(__('Reopen'), this.reopen_purchase_receipt, __("Status")) + if (this.frm.doc.docstatus == 1 && this.frm.doc.status === "Closed" && this.frm.has_perm("submit")) { + cur_frm.add_custom_button(__("Reopen"), this.reopen_purchase_receipt, __("Status")); } this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_old_subcontracting_flow); @@ -246,8 +288,8 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend make_purchase_invoice() { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", - frm: cur_frm - }) + frm: cur_frm, + }); } make_purchase_return() { @@ -257,34 +299,39 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend if (item.rejected_qty > 0) { return true; } - }) + }); if (has_rejected_items && has_rejected_items.length > 0) { - frappe.prompt([ - { - label: __("Return Qty from Rejected Warehouse"), - fieldtype: "Check", - fieldname: "return_for_rejected_warehouse", - default: 1 + frappe.prompt( + [ + { + label: __("Return Qty from Rejected Warehouse"), + fieldtype: "Check", + fieldname: "return_for_rejected_warehouse", + default: 1, + }, + ], + function (values) { + if (values.return_for_rejected_warehouse) { + frappe.call({ + method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_return_against_rejected_warehouse", + args: { + source_name: cur_frm.doc.name, + }, + callback: function (r) { + if (r.message) { + frappe.model.sync(r.message); + frappe.set_route("Form", r.message.doctype, r.message.name); + } + }, + }); + } else { + cur_frm.cscript._make_purchase_return(); + } }, - ], function(values){ - if (values.return_for_rejected_warehouse) { - frappe.call({ - method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_return_against_rejected_warehouse", - args: { - source_name: cur_frm.doc.name - }, - callback: function(r) { - if(r.message) { - frappe.model.sync(r.message); - frappe.set_route("Form", r.message.doctype, r.message.name); - } - } - }) - } else { - cur_frm.cscript._make_purchase_return(); - } - }, __("Return Qty"), __("Make Return Entry")); + __("Return Qty"), + __("Make Return Entry") + ); } else { cur_frm.cscript._make_purchase_return(); } @@ -301,76 +348,71 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend make_retention_stock_entry() { frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.move_sample_to_retention_warehouse", - args:{ - "company": cur_frm.doc.company, - "items": cur_frm.doc.items + args: { + company: cur_frm.doc.company, + items: cur_frm.doc.items, }, callback: function (r) { if (r.message) { var doc = frappe.model.sync(r.message)[0]; frappe.set_route("Form", doc.doctype, doc.name); + } else { + frappe.msgprint( + __("Purchase Receipt doesn't have any Item for which Retain Sample is enabled.") + ); } - else { - frappe.msgprint(__("Purchase Receipt doesn't have any Item for which Retain Sample is enabled.")); - } - } + }, }); } apply_putaway_rule() { if (this.frm.doc.apply_putaway_rule) erpnext.apply_putaway_rule(this.frm); } - }; // for backward compatibility: combine new and previous states -extend_cscript(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({ frm: cur_frm })); -cur_frm.cscript.update_status = function(status) { +cur_frm.cscript.update_status = function (status) { frappe.ui.form.is_saving = true; frappe.call({ - method:"erpnext.stock.doctype.purchase_receipt.purchase_receipt.update_purchase_receipt_status", - args: {docname: cur_frm.doc.name, status: status}, - callback: function(r){ - if(!r.exc) - cur_frm.reload_doc(); + method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.update_purchase_receipt_status", + args: { docname: cur_frm.doc.name, status: status }, + callback: function (r) { + if (!r.exc) cur_frm.reload_doc(); }, - always: function(){ + always: function () { frappe.ui.form.is_saving = false; - } - }) -} + }, + }); +}; -cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) { +cur_frm.fields_dict["items"].grid.get_field("project").get_query = function (doc, cdt, cdn) { + return { + filters: [["Project", "status", "not in", "Completed, Cancelled"]], + }; +}; + +cur_frm.fields_dict["select_print_heading"].get_query = function (doc, cdt, cdn) { + return { + filters: [["Print Heading", "docstatus", "!=", "2"]], + }; +}; + +cur_frm.fields_dict["items"].grid.get_field("bom").get_query = function (doc, cdt, cdn) { + var d = locals[cdt][cdn]; return { filters: [ - ['Project', 'status', 'not in', 'Completed, Cancelled'] - ] - } -} - -cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { - return { - filters: [ - ['Print Heading', 'docstatus', '!=', '2'] - ] - } -} - -cur_frm.fields_dict['items'].grid.get_field('bom').get_query = function(doc, cdt, cdn) { - var d = locals[cdt][cdn] - return { - filters: [ - ['BOM', 'item', '=', d.item_code], - ['BOM', 'is_active', '=', '1'], - ['BOM', 'docstatus', '=', '1'] - ] - } -} + ["BOM", "item", "=", d.item_code], + ["BOM", "is_active", "=", "1"], + ["BOM", "docstatus", "=", "1"], + ], + }; +}; frappe.provide("erpnext.buying"); -frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) { +frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function (frm) { if (frm.doc.is_old_subcontracting_flow) { erpnext.buying.get_default_bom(frm); } @@ -378,53 +420,53 @@ frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) { frm.toggle_reqd("supplier_warehouse", frm.doc.is_old_subcontracting_flow); }); -frappe.ui.form.on('Purchase Receipt Item', { - item_code: function(frm, cdt, cdn) { +frappe.ui.form.on("Purchase Receipt Item", { + item_code: function (frm, cdt, cdn) { var d = locals[cdt][cdn]; - frappe.db.get_value('Item', {name: d.item_code}, 'sample_quantity', (r) => { + frappe.db.get_value("Item", { name: d.item_code }, "sample_quantity", (r) => { frappe.model.set_value(cdt, cdn, "sample_quantity", r.sample_quantity); validate_sample_quantity(frm, cdt, cdn); }); }, - qty: function(frm, cdt, cdn) { + qty: function (frm, cdt, cdn) { validate_sample_quantity(frm, cdt, cdn); }, - sample_quantity: function(frm, cdt, cdn) { + sample_quantity: function (frm, cdt, cdn) { validate_sample_quantity(frm, cdt, cdn); }, - batch_no: function(frm, cdt, cdn) { + batch_no: function (frm, cdt, cdn) { validate_sample_quantity(frm, cdt, cdn); }, }); -cur_frm.cscript._make_purchase_return = function() { +cur_frm.cscript._make_purchase_return = function () { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_return", - frm: cur_frm + frm: cur_frm, }); -} +}; -cur_frm.cscript['Make Stock Entry'] = function() { +cur_frm.cscript["Make Stock Entry"] = function () { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_stock_entry", frm: cur_frm, - }) -} + }); +}; -var validate_sample_quantity = function(frm, cdt, cdn) { +var validate_sample_quantity = function (frm, cdt, cdn) { var d = locals[cdt][cdn]; if (d.sample_quantity && d.qty) { frappe.call({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry.validate_sample_quantity', + method: "erpnext.stock.doctype.stock_entry.stock_entry.validate_sample_quantity", args: { batch_no: d.batch_no, item_code: d.item_code, sample_quantity: d.sample_quantity, - qty: d.qty + qty: d.qty, }, callback: (r) => { frappe.model.set_value(cdt, cdn, "sample_quantity", r.message); - } + }, }); } }; diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js index f19f1ff61ee..fc4aabdaa18 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js @@ -1,8 +1,17 @@ -frappe.listview_settings['Purchase Receipt'] = { - add_fields: ["supplier", "supplier_name", "base_grand_total", "is_subcontracted", - "transporter_name", "is_return", "status", "per_billed", "currency"], - get_indicator: function(doc) { - if(cint(doc.is_return)==1) { +frappe.listview_settings["Purchase Receipt"] = { + add_fields: [ + "supplier", + "supplier_name", + "base_grand_total", + "is_subcontracted", + "transporter_name", + "is_return", + "status", + "per_billed", + "currency", + ], + get_indicator: function (doc) { + if (cint(doc.is_return) == 1) { return [__("Return"), "gray", "is_return,=,Yes"]; } else if (doc.status === "Closed") { return [__("Closed"), "green", "status,=,Closed"]; @@ -17,11 +26,9 @@ frappe.listview_settings['Purchase Receipt'] = { } }, - onload: function(listview) { - - listview.page.add_action_item(__("Purchase Invoice"), ()=>{ + onload: function (listview) { + listview.page.add_action_item(__("Purchase Invoice"), () => { erpnext.bulk_transaction_processing.create(listview, "Purchase Receipt", "Purchase Invoice"); }); - } - + }, }; diff --git a/erpnext/stock/doctype/putaway_rule/putaway_rule.js b/erpnext/stock/doctype/putaway_rule/putaway_rule.js index e0569206ef9..351be16d7cb 100644 --- a/erpnext/stock/doctype/putaway_rule/putaway_rule.js +++ b/erpnext/stock/doctype/putaway_rule/putaway_rule.js @@ -1,41 +1,41 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Putaway Rule', { - setup: function(frm) { - frm.set_query("warehouse", function() { +frappe.ui.form.on("Putaway Rule", { + setup: function (frm) { + frm.set_query("warehouse", function () { return { - "filters": { - "company": frm.doc.company, - "is_group": 0 - } + filters: { + company: frm.doc.company, + is_group: 0, + }, }; }); }, - uom: function(frm) { + uom: function (frm) { if (frm.doc.item_code && frm.doc.uom) { return frm.call({ method: "erpnext.stock.get_item_details.get_conversion_factor", args: { item_code: frm.doc.item_code, - uom: frm.doc.uom + uom: frm.doc.uom, }, - callback: function(r) { + callback: function (r) { if (!r.exc) { let stock_capacity = flt(frm.doc.capacity) * flt(r.message.conversion_factor); - frm.set_value('conversion_factor', r.message.conversion_factor); - frm.set_value('stock_capacity', stock_capacity); + frm.set_value("conversion_factor", r.message.conversion_factor); + frm.set_value("stock_capacity", stock_capacity); } - } + }, }); } }, - capacity: function(frm) { + capacity: function (frm) { let stock_capacity = flt(frm.doc.capacity) * flt(frm.doc.conversion_factor); - frm.set_value('stock_capacity', stock_capacity); - } + frm.set_value("stock_capacity", stock_capacity); + }, // refresh: function(frm) { diff --git a/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js b/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js index 753569c8812..0b8c9ec9086 100644 --- a/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js +++ b/erpnext/stock/doctype/putaway_rule/putaway_rule_list.js @@ -1,4 +1,4 @@ -frappe.listview_settings['Putaway Rule'] = { +frappe.listview_settings["Putaway Rule"] = { add_fields: ["disable"], get_indicator: (doc) => { if (doc.disable) { @@ -10,8 +10,8 @@ frappe.listview_settings['Putaway Rule'] = { reports: [ { - name: 'Warehouse Capacity Summary', - route: '/app/warehouse-capacity-summary' - } - ] + name: "Warehouse Capacity Summary", + route: "/app/warehouse-capacity-summary", + }, + ], }; diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.js b/erpnext/stock/doctype/quality_inspection/quality_inspection.js index 05fa2324dd4..fc487514a2c 100644 --- a/erpnext/stock/doctype/quality_inspection/quality_inspection.js +++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.js @@ -4,88 +4,85 @@ cur_frm.cscript.refresh = cur_frm.cscript.inspection_type; frappe.ui.form.on("Quality Inspection", { - - setup: function(frm) { - frm.set_query("reference_name", function() { + setup: function (frm) { + frm.set_query("reference_name", function () { return { filters: { - "docstatus": ["!=", 2], - } - } + docstatus: ["!=", 2], + }, + }; }); - frm.set_query("batch_no", function() { + frm.set_query("batch_no", function () { return { filters: { - "item": frm.doc.item_code - } + item: frm.doc.item_code, + }, }; }); // Serial No based on item_code - frm.set_query("item_serial_no", function() { + frm.set_query("item_serial_no", function () { let filters = {}; if (frm.doc.item_code) { filters = { - 'item_code': frm.doc.item_code + item_code: frm.doc.item_code, }; } return { filters: filters }; }); // item code based on GRN/DN - frm.set_query("item_code", function(doc) { + frm.set_query("item_code", function (doc) { let doctype = doc.reference_type; if (doc.reference_type !== "Job Card") { - doctype = (doc.reference_type == "Stock Entry") ? - "Stock Entry Detail" : doc.reference_type + " Item"; + doctype = + doc.reference_type == "Stock Entry" ? "Stock Entry Detail" : doc.reference_type + " Item"; } if (doc.reference_type && doc.reference_name) { let filters = { - "from": doctype, - "inspection_type": doc.inspection_type + from: doctype, + inspection_type: doc.inspection_type, }; - if (doc.reference_type == doctype) - filters["reference_name"] = doc.reference_name; - else - filters["parent"] = doc.reference_name; + if (doc.reference_type == doctype) filters["reference_name"] = doc.reference_name; + else filters["parent"] = doc.reference_name; return { query: "erpnext.stock.doctype.quality_inspection.quality_inspection.item_query", - filters: filters + filters: filters, }; } }); }, - refresh: function(frm) { + refresh: function (frm) { // Ignore cancellation of reference doctype on cancel all. frm.ignore_doctypes_on_cancel_all = [frm.doc.reference_type]; }, - item_code: function(frm) { + item_code: function (frm) { if (frm.doc.item_code && !frm.doc.quality_inspection_template) { return frm.call({ method: "get_quality_inspection_template", doc: frm.doc, - callback: function() { - refresh_field(['quality_inspection_template', 'readings']); - } + callback: function () { + refresh_field(["quality_inspection_template", "readings"]); + }, }); } }, - quality_inspection_template: function(frm) { + quality_inspection_template: function (frm) { if (frm.doc.quality_inspection_template) { return frm.call({ method: "get_item_specification_details", doc: frm.doc, - callback: function() { - refresh_field('readings'); - } + callback: function () { + refresh_field("readings"); + }, }); } }, diff --git a/erpnext/stock/doctype/quality_inspection_parameter/quality_inspection_parameter.js b/erpnext/stock/doctype/quality_inspection_parameter/quality_inspection_parameter.js index 47c7e11d237..ecf84c91506 100644 --- a/erpnext/stock/doctype/quality_inspection_parameter/quality_inspection_parameter.js +++ b/erpnext/stock/doctype/quality_inspection_parameter/quality_inspection_parameter.js @@ -1,8 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Inspection Parameter', { +frappe.ui.form.on("Quality Inspection Parameter", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/doctype/quality_inspection_parameter_group/quality_inspection_parameter_group.js b/erpnext/stock/doctype/quality_inspection_parameter_group/quality_inspection_parameter_group.js index 8716a298716..796ab89d2b5 100644 --- a/erpnext/stock/doctype/quality_inspection_parameter_group/quality_inspection_parameter_group.js +++ b/erpnext/stock/doctype/quality_inspection_parameter_group/quality_inspection_parameter_group.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Inspection Parameter Group', { +frappe.ui.form.on("Quality Inspection Parameter Group", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/doctype/quality_inspection_template/quality_inspection_template.js b/erpnext/stock/doctype/quality_inspection_template/quality_inspection_template.js index fa57a3dcc34..053809d5fe0 100644 --- a/erpnext/stock/doctype/quality_inspection_template/quality_inspection_template.js +++ b/erpnext/stock/doctype/quality_inspection_template/quality_inspection_template.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quality Inspection Template', { - refresh: function() { - - } +frappe.ui.form.on("Quality Inspection Template", { + refresh: function () {}, }); diff --git a/erpnext/stock/doctype/quick_stock_balance/quick_stock_balance.js b/erpnext/stock/doctype/quick_stock_balance/quick_stock_balance.js index f261fd99790..5cfd1f5843a 100644 --- a/erpnext/stock/doctype/quick_stock_balance/quick_stock_balance.js +++ b/erpnext/stock/doctype/quick_stock_balance/quick_stock_balance.js @@ -1,91 +1,90 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Quick Stock Balance', { - +frappe.ui.form.on("Quick Stock Balance", { setup: (frm) => { - frm.set_query('item', () => { + frm.set_query("item", () => { if (!(frm.doc.warehouse && frm.doc.date)) { - frm.trigger('check_warehouse_and_date'); + frm.trigger("check_warehouse_and_date"); } }); }, make_custom_stock_report_button: (frm) => { if (frm.doc.item) { - frm.add_custom_button(__('Stock Balance Report'), () => { - frappe.set_route('query-report', 'Stock Balance', - { 'item_code': frm.doc.item, 'warehouse': frm.doc.warehouse }); + frm.add_custom_button(__("Stock Balance Report"), () => { + frappe.set_route("query-report", "Stock Balance", { + item_code: frm.doc.item, + warehouse: frm.doc.warehouse, + }); }); } }, refresh: (frm) => { frm.disable_save(); - frm.trigger('make_custom_stock_report_button'); + frm.trigger("make_custom_stock_report_button"); }, check_warehouse_and_date: (frm) => { - frappe.msgprint(__('Please enter Warehouse and Date')); - frm.doc.item = ''; + frappe.msgprint(__("Please enter Warehouse and Date")); + frm.doc.item = ""; frm.refresh(); }, warehouse: (frm) => { if (frm.doc.item || frm.doc.item_barcode) { - frm.trigger('get_stock_and_item_details'); + frm.trigger("get_stock_and_item_details"); } }, date: (frm) => { if (frm.doc.item || frm.doc.item_barcode) { - frm.trigger('get_stock_and_item_details'); + frm.trigger("get_stock_and_item_details"); } }, item: (frm) => { - frappe.flags.last_updated_element = 'item'; - frm.trigger('get_stock_and_item_details'); - frm.trigger('make_custom_stock_report_button'); + frappe.flags.last_updated_element = "item"; + frm.trigger("get_stock_and_item_details"); + frm.trigger("make_custom_stock_report_button"); }, item_barcode: (frm) => { - frappe.flags.last_updated_element = 'item_barcode'; - frm.trigger('get_stock_and_item_details'); - frm.trigger('make_custom_stock_report_button'); + frappe.flags.last_updated_element = "item_barcode"; + frm.trigger("get_stock_and_item_details"); + frm.trigger("make_custom_stock_report_button"); }, get_stock_and_item_details: (frm) => { if (!(frm.doc.warehouse && frm.doc.date)) { - frm.trigger('check_warehouse_and_date'); - } - else if (frm.doc.item || frm.doc.item_barcode) { + frm.trigger("check_warehouse_and_date"); + } else if (frm.doc.item || frm.doc.item_barcode) { let filters = { warehouse: frm.doc.warehouse, date: frm.doc.date, }; - if (frappe.flags.last_updated_element === 'item') { - filters = { ...filters, ...{ item: frm.doc.item }}; - } - else { - filters = { ...filters, ...{ barcode: frm.doc.item_barcode }}; + if (frappe.flags.last_updated_element === "item") { + filters = { ...filters, ...{ item: frm.doc.item } }; + } else { + filters = { ...filters, ...{ barcode: frm.doc.item_barcode } }; } frappe.call({ - method: 'erpnext.stock.doctype.quick_stock_balance.quick_stock_balance.get_stock_item_details', + method: "erpnext.stock.doctype.quick_stock_balance.quick_stock_balance.get_stock_item_details", args: filters, callback: (r) => { if (r.message) { - let fields = ['item', 'qty', 'value', 'image']; - if (!r.message['barcodes'].includes(frm.doc.item_barcode)) { - frm.doc.item_barcode = ''; + let fields = ["item", "qty", "value", "image"]; + if (!r.message["barcodes"].includes(frm.doc.item_barcode)) { + frm.doc.item_barcode = ""; frm.refresh(); } fields.forEach(function (field) { frm.set_value(field, r.message[field]); }); } - } + }, }); } - } + }, }); diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js index 40748ce3f5c..f0506ab6930 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js @@ -1,22 +1,32 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Repost Item Valuation', { - setup: function(frm) { +frappe.ui.form.on("Repost Item Valuation", { + setup: function (frm) { frm.set_query("warehouse", () => { let filters = { - 'is_group': 0 + is_group: 0, }; - if (frm.doc.company) filters['company'] = frm.doc.company; - return {filters: filters}; + if (frm.doc.company) filters["company"] = frm.doc.company; + return { filters: filters }; }); frm.set_query("voucher_type", () => { return { filters: { - name: ['in', ['Purchase Receipt', 'Purchase Invoice', 'Delivery Note', - 'Sales Invoice', 'Stock Entry', 'Stock Reconciliation', 'Subcontracting Receipt']] - } + name: [ + "in", + [ + "Purchase Receipt", + "Purchase Invoice", + "Delivery Note", + "Sales Invoice", + "Stock Entry", + "Stock Reconciliation", + "Subcontracting Receipt", + ], + ], + }, }; }); @@ -25,74 +35,74 @@ frappe.ui.form.on('Repost Item Valuation', { return { filters: { company: frm.doc.company, - docstatus: 1 - } + docstatus: 1, + }, }; }); } - frm.trigger('setup_realtime_progress'); + frm.trigger("setup_realtime_progress"); }, - based_on: function(frm) { + based_on: function (frm) { var fields_to_reset = []; - if (frm.doc.based_on == 'Transaction') { - fields_to_reset = ['item_code', 'warehouse']; - } else if (frm.doc.based_on == 'Item and Warehouse') { - fields_to_reset = ['voucher_type', 'voucher_no']; + if (frm.doc.based_on == "Transaction") { + fields_to_reset = ["item_code", "warehouse"]; + } else if (frm.doc.based_on == "Item and Warehouse") { + fields_to_reset = ["voucher_type", "voucher_no"]; } if (fields_to_reset) { - fields_to_reset.forEach(field => { + fields_to_reset.forEach((field) => { frm.set_value(field, undefined); }); } }, - setup_realtime_progress: function(frm) { - frappe.realtime.on('item_reposting_progress', data => { + setup_realtime_progress: function (frm) { + frappe.realtime.on("item_reposting_progress", (data) => { if (frm.doc.name !== data.name) { return; } - if (frm.doc.status == 'In Progress') { + if (frm.doc.status == "In Progress") { frm.doc.current_index = data.current_index; frm.doc.items_to_be_repost = data.items_to_be_repost; frm.doc.total_reposting_count = data.total_reposting_count; frm.dashboard.reset(); - frm.trigger('show_reposting_progress'); + frm.trigger("show_reposting_progress"); } }); }, - refresh: function(frm) { - if (frm.doc.status == "Failed" && frm.doc.docstatus==1) { - frm.add_custom_button(__('Restart'), function () { + refresh: function (frm) { + if (frm.doc.status == "Failed" && frm.doc.docstatus == 1) { + frm.add_custom_button(__("Restart"), function () { frm.trigger("restart_reposting"); }).addClass("btn-primary"); } - frm.trigger('show_reposting_progress'); + frm.trigger("show_reposting_progress"); - if (frm.doc.status === 'Queued' && frm.doc.docstatus === 1) { - frm.trigger('execute_reposting'); + if (frm.doc.status === "Queued" && frm.doc.docstatus === 1) { + frm.trigger("execute_reposting"); } }, execute_reposting(frm) { frm.add_custom_button(__("Start Reposting"), () => { frappe.call({ - method: 'erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.execute_repost_item_valuation', - callback: function() { - frappe.msgprint(__('Reposting has been started in the background.')); - } + method: "erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.execute_repost_item_valuation", + callback: function () { + frappe.msgprint(__("Reposting has been started in the background.")); + }, }); }); }, - show_reposting_progress: function(frm) { + show_reposting_progress: function (frm) { var bars = []; let total_count = frm.doc.items_to_be_repost ? JSON.parse(frm.doc.items_to_be_repost).length : 0; @@ -101,27 +111,27 @@ frappe.ui.form.on('Repost Item Valuation', { total_count = frm.doc.total_reposting_count; } - let progress = flt(cint(frm.doc.current_index) / total_count * 100, 2) || 0.5; - var title = __('Reposting Completed {0}%', [progress]); + let progress = flt((cint(frm.doc.current_index) / total_count) * 100, 2) || 0.5; + var title = __("Reposting Completed {0}%", [progress]); bars.push({ - 'title': title, - 'width': progress + '%', - 'progress_class': 'progress-bar-success' + title: title, + width: progress + "%", + progress_class: "progress-bar-success", }); - frm.dashboard.add_progress(__('Reposting Progress'), bars); + frm.dashboard.add_progress(__("Reposting Progress"), bars); }, - restart_reposting: function(frm) { + restart_reposting: function (frm) { frappe.call({ method: "restart_reposting", doc: frm.doc, - callback: function(r) { + callback: function (r) { if (!r.exc) { frm.refresh(); } - } + }, }); - } + }, }); diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index 1f7bb4d245a..21f0784df75 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -1,24 +1,24 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Serial and Batch Bundle', { +frappe.ui.form.on("Serial and Batch Bundle", { setup(frm) { - frm.trigger('set_queries'); + frm.trigger("set_queries"); }, refresh(frm) { - frm.trigger('toggle_fields'); - frm.trigger('prepare_serial_batch_prompt'); + frm.trigger("toggle_fields"); + frm.trigger("prepare_serial_batch_prompt"); }, item_code(frm) { frm.clear_custom_buttons(); - frm.trigger('prepare_serial_batch_prompt'); + frm.trigger("prepare_serial_batch_prompt"); }, type_of_transaction(frm) { frm.clear_custom_buttons(); - frm.trigger('prepare_serial_batch_prompt'); + frm.trigger("prepare_serial_batch_prompt"); }, warehouse(frm) { @@ -28,74 +28,77 @@ frappe.ui.form.on('Serial and Batch Bundle', { doc: frm.doc, callback(r) { refresh_field("entries"); - } - }) + }, + }); } }, has_serial_no(frm) { - frm.trigger('toggle_fields'); + frm.trigger("toggle_fields"); }, has_batch_no(frm) { - frm.trigger('toggle_fields'); + frm.trigger("toggle_fields"); }, prepare_serial_batch_prompt(frm) { - if (frm.doc.docstatus === 0 && frm.doc.item_code - && frm.doc.type_of_transaction === "Inward") { - let label = frm.doc?.has_serial_no === 1 - ? __('Serial Nos') : __('Batch Nos'); + if (frm.doc.docstatus === 0 && frm.doc.item_code && frm.doc.type_of_transaction === "Inward") { + let label = frm.doc?.has_serial_no === 1 ? __("Serial Nos") : __("Batch Nos"); if (frm.doc?.has_serial_no === 1 && frm.doc?.has_batch_no === 1) { - label = __('Serial and Batch Nos'); + label = __("Serial and Batch Nos"); } let fields = frm.events.get_prompt_fields(frm); frm.add_custom_button(__("Make " + label), () => { - frappe.prompt(fields, (data) => { - frm.events.add_serial_batch(frm, data); - }, "Add " + label, "Make " + label); + frappe.prompt( + fields, + (data) => { + frm.events.add_serial_batch(frm, data); + }, + "Add " + label, + "Make " + label + ); }); } }, get_prompt_fields(frm) { let attach_field = { - "label": __("Attach CSV File"), - "fieldname": "csv_file", - "fieldtype": "Attach" - } + label: __("Attach CSV File"), + fieldname: "csv_file", + fieldtype: "Attach", + }; if (!frm.doc.has_batch_no) { - attach_field.depends_on = "eval:doc.using_csv_file === 1" + attach_field.depends_on = "eval:doc.using_csv_file === 1"; } let fields = [ { - "label": __("Import Using CSV file"), - "fieldname": "using_csv_file", - "default": 1, - "fieldtype": "Check", + label: __("Import Using CSV file"), + fieldname: "using_csv_file", + default: 1, + fieldtype: "Check", }, attach_field, { - "fieldtype": "Section Break", - } - ] + fieldtype: "Section Break", + }, + ]; if (frm.doc.has_serial_no) { fields.push({ - "label": "Serial Nos", - "fieldname": "serial_nos", - "fieldtype": "Small Text", - "depends_on": "eval:doc.using_csv_file === 0" - }) + label: "Serial Nos", + fieldname: "serial_nos", + fieldtype: "Small Text", + depends_on: "eval:doc.using_csv_file === 0", + }); } if (frm.doc.has_batch_no) { - fields = attach_field + fields = attach_field; } return fields; @@ -108,11 +111,11 @@ frappe.ui.form.on('Serial and Batch Bundle', { method: "add_serial_batch", doc: frm.doc, args: { - "data": prompt_data, + data: prompt_data, }, callback(r) { refresh_field("entries"); - } + }, }); }, @@ -128,120 +131,119 @@ frappe.ui.form.on('Serial and Batch Bundle', { toggle_fields(frm) { if (frm.doc.has_serial_no) { - frm.doc.entries.forEach(row => { + frm.doc.entries.forEach((row) => { if (Math.abs(row.qty) !== 1) { frappe.model.set_value(row.doctype, row.name, "qty", 1); } - }) + }); } frm.fields_dict.entries.grid.update_docfield_property( - 'serial_no', 'read_only', !frm.doc.has_serial_no + "serial_no", + "read_only", + !frm.doc.has_serial_no ); - frm.fields_dict.entries.grid.update_docfield_property( - 'batch_no', 'read_only', !frm.doc.has_batch_no - ); + frm.fields_dict.entries.grid.update_docfield_property("batch_no", "read_only", !frm.doc.has_batch_no); - frm.fields_dict.entries.grid.update_docfield_property( - 'qty', 'read_only', frm.doc.has_serial_no - ); + frm.fields_dict.entries.grid.update_docfield_property("qty", "read_only", frm.doc.has_serial_no); }, set_queries(frm) { - frm.set_query('item_code', () => { + frm.set_query("item_code", () => { return { - query: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.item_query', + query: "erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.item_query", }; }); - frm.set_query('voucher_type', () => { + frm.set_query("voucher_type", () => { return { filters: { - 'istable': 0, - 'issingle': 0, - 'is_submittable': 1, - 'name': ['in', [ - "Asset Capitalization", - "Asset Repair", - "Delivery Note", - "Installation Note", - "Job Card", - "Maintenance Schedule", - "POS Invoice", - "Pick List", - "Purchase Invoice", - "Purchase Receipt", - "Quotation", - "Sales Invoice", - "Stock Entry", - "Stock Reconciliation", - "Subcontracting Receipt", - ]], - } + istable: 0, + issingle: 0, + is_submittable: 1, + name: [ + "in", + [ + "Asset Capitalization", + "Asset Repair", + "Delivery Note", + "Installation Note", + "Job Card", + "Maintenance Schedule", + "POS Invoice", + "Pick List", + "Purchase Invoice", + "Purchase Receipt", + "Quotation", + "Sales Invoice", + "Stock Entry", + "Stock Reconciliation", + "Subcontracting Receipt", + ], + ], + }, }; }); - frm.set_query('voucher_no', () => { + frm.set_query("voucher_no", () => { return { filters: { - 'docstatus': ["!=", 2], - } + docstatus: ["!=", 2], + }, }; }); - frm.set_query('warehouse', () => { + frm.set_query("warehouse", () => { return { filters: { - 'is_group': 0, - 'company': frm.doc.company, - } + is_group: 0, + company: frm.doc.company, + }, }; }); - frm.set_query('serial_no', 'entries', () => { + frm.set_query("serial_no", "entries", () => { return { filters: { item_code: frm.doc.item_code, - } + }, }; }); - frm.set_query('batch_no', 'entries', (doc) => { - - if (doc.type_of_transaction ==="Outward") { + frm.set_query("batch_no", "entries", (doc) => { + if (doc.type_of_transaction === "Outward") { return { - query : "erpnext.controllers.queries.get_batch_no", + query: "erpnext.controllers.queries.get_batch_no", filters: { item_code: doc.item_code, warehouse: doc.warehouse, - } - } + }, + }; } else { return { filters: { item: doc.item_code, disabled: 0, - } + }, }; } }); - frm.set_query('warehouse', 'entries', () => { + frm.set_query("warehouse", "entries", () => { return { filters: { company: frm.doc.company, - } + }, }; }); - } + }, }); - frappe.ui.form.on("Serial and Batch Entry", { entries_add(frm, cdt, cdn) { if (frm.doc.warehouse) { - frappe.model.set_value(cdt, cdn, 'warehouse', frm.doc.warehouse); + frappe.model.set_value(cdt, cdn, "warehouse", frm.doc.warehouse); } }, -}) \ No newline at end of file +}); diff --git a/erpnext/stock/doctype/serial_no/serial_no.js b/erpnext/stock/doctype/serial_no/serial_no.js index 1cb9fd1800e..338ed61bfc5 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.js +++ b/erpnext/stock/doctype/serial_no/serial_no.js @@ -1,39 +1,38 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.add_fetch("customer", "customer_name", "customer_name") -cur_frm.add_fetch("supplier", "supplier_name", "supplier_name") +cur_frm.add_fetch("customer", "customer_name", "customer_name"); +cur_frm.add_fetch("supplier", "supplier_name", "supplier_name"); -cur_frm.add_fetch("item_code", "item_name", "item_name") -cur_frm.add_fetch("item_code", "description", "description") -cur_frm.add_fetch("item_code", "item_group", "item_group") -cur_frm.add_fetch("item_code", "brand", "brand") +cur_frm.add_fetch("item_code", "item_name", "item_name"); +cur_frm.add_fetch("item_code", "description", "description"); +cur_frm.add_fetch("item_code", "item_group", "item_group"); +cur_frm.add_fetch("item_code", "brand", "brand"); -cur_frm.cscript.onload = function() { - cur_frm.set_query("item_code", function() { - return erpnext.queries.item({"is_stock_item": 1, "has_serial_no": 1}) +cur_frm.cscript.onload = function () { + cur_frm.set_query("item_code", function () { + return erpnext.queries.item({ is_stock_item: 1, has_serial_no: 1 }); }); }; -frappe.ui.form.on("Serial No", "refresh", function(frm) { +frappe.ui.form.on("Serial No", "refresh", function (frm) { frm.toggle_enable("item_code", frm.doc.__islocal); }); - frappe.ui.form.on("Serial No", { refresh(frm) { - frm.trigger("view_ledgers") + frm.trigger("view_ledgers"); }, view_ledgers(frm) { frm.add_custom_button(__("View Ledgers"), () => { frappe.route_options = { - "item_code": frm.doc.item_code, - "serial_no": frm.doc.name, - "posting_date": frappe.datetime.now_date(), - "posting_time": frappe.datetime.now_time() + item_code: frm.doc.item_code, + serial_no: frm.doc.name, + posting_date: frappe.datetime.now_date(), + posting_time: frappe.datetime.now_time(), }; frappe.set_route("query-report", "Serial No Ledger"); - }).addClass('btn-primary'); - } -}) \ No newline at end of file + }).addClass("btn-primary"); + }, +}); diff --git a/erpnext/stock/doctype/shipment/shipment.js b/erpnext/stock/doctype/shipment/shipment.js index 13a17a25913..8843d383531 100644 --- a/erpnext/stock/doctype/shipment/shipment.js +++ b/erpnext/stock/doctype/shipment/shipment.js @@ -1,34 +1,44 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Shipment', { - address_query: function(frm, link_doctype, link_name, is_your_company_address) { +frappe.ui.form.on("Shipment", { + address_query: function (frm, link_doctype, link_name, is_your_company_address) { return { - query: 'frappe.contacts.doctype.address.address.address_query', + query: "frappe.contacts.doctype.address.address.address_query", filters: { link_doctype: link_doctype, link_name: link_name, - is_your_company_address: is_your_company_address - } + is_your_company_address: is_your_company_address, + }, }; }, - contact_query: function(frm, link_doctype, link_name) { + contact_query: function (frm, link_doctype, link_name) { return { - query: 'frappe.contacts.doctype.contact.contact.contact_query', + query: "frappe.contacts.doctype.contact.contact.contact_query", filters: { link_doctype: link_doctype, - link_name: link_name - } + link_name: link_name, + }, }; }, - onload: function(frm) { + onload: function (frm) { frm.set_query("delivery_address_name", () => { let delivery_to = `delivery_${frappe.model.scrub(frm.doc.delivery_to_type)}`; - return frm.events.address_query(frm, frm.doc.delivery_to_type, frm.doc[delivery_to], frm.doc.delivery_to_type === 'Company' ? 1 : 0); + return frm.events.address_query( + frm, + frm.doc.delivery_to_type, + frm.doc[delivery_to], + frm.doc.delivery_to_type === "Company" ? 1 : 0 + ); }); frm.set_query("pickup_address_name", () => { let pickup_from = `pickup_${frappe.model.scrub(frm.doc.pickup_from_type)}`; - return frm.events.address_query(frm, frm.doc.pickup_from_type, frm.doc[pickup_from], frm.doc.pickup_from_type === 'Company' ? 1 : 0); + return frm.events.address_query( + frm, + frm.doc.pickup_from_type, + frm.doc[pickup_from], + frm.doc.pickup_from_type === "Company" ? 1 : 0 + ); }); frm.set_query("delivery_contact_name", () => { let delivery_to = `delivery_${frappe.model.scrub(frm.doc.delivery_to_type)}`; @@ -38,8 +48,8 @@ frappe.ui.form.on('Shipment', { let pickup_from = `pickup_${frappe.model.scrub(frm.doc.pickup_from_type)}`; return frm.events.contact_query(frm, frm.doc.pickup_from_type, frm.doc[pickup_from]); }); - frm.set_query("delivery_note", "shipment_delivery_note", function() { - let customer = ''; + frm.set_query("delivery_note", "shipment_delivery_note", function () { + let customer = ""; if (frm.doc.delivery_to_type == "Customer") { customer = frm.doc.delivery_customer; } @@ -51,305 +61,329 @@ frappe.ui.form.on('Shipment', { filters: { customer: customer, docstatus: 1, - status: ["not in", ["Cancelled"]] - } + status: ["not in", ["Cancelled"]], + }, }; } }); }, - refresh: function() { - $('div[data-fieldname=pickup_address] > div > .clearfix').hide(); - $('div[data-fieldname=pickup_contact] > div > .clearfix').hide(); - $('div[data-fieldname=delivery_address] > div > .clearfix').hide(); - $('div[data-fieldname=delivery_contact] > div > .clearfix').hide(); + refresh: function () { + $("div[data-fieldname=pickup_address] > div > .clearfix").hide(); + $("div[data-fieldname=pickup_contact] > div > .clearfix").hide(); + $("div[data-fieldname=delivery_address] > div > .clearfix").hide(); + $("div[data-fieldname=delivery_contact] > div > .clearfix").hide(); }, - before_save: function(frm) { + before_save: function (frm) { let delivery_to = `delivery_${frappe.model.scrub(frm.doc.delivery_to_type)}`; frm.set_value("delivery_to", frm.doc[delivery_to]); let pickup_from = `pickup_${frappe.model.scrub(frm.doc.pickup_from_type)}`; frm.set_value("pickup", frm.doc[pickup_from]); }, - set_pickup_company_address: function(frm) { - frappe.db.get_value('Address', { - address_title: frm.doc.pickup_company, - is_your_company_address: 1 - }, 'name', (r) => { - frm.set_value("pickup_address_name", r.name); - }); + set_pickup_company_address: function (frm) { + frappe.db.get_value( + "Address", + { + address_title: frm.doc.pickup_company, + is_your_company_address: 1, + }, + "name", + (r) => { + frm.set_value("pickup_address_name", r.name); + } + ); }, - set_delivery_company_address: function(frm) { - frappe.db.get_value('Address', { - address_title: frm.doc.delivery_company, - is_your_company_address: 1 - }, 'name', (r) => { - frm.set_value("delivery_address_name", r.name); - }); + set_delivery_company_address: function (frm) { + frappe.db.get_value( + "Address", + { + address_title: frm.doc.delivery_company, + is_your_company_address: 1, + }, + "name", + (r) => { + frm.set_value("delivery_address_name", r.name); + } + ); }, - pickup_from_type: function(frm) { - if (frm.doc.pickup_from_type == 'Company') { - frm.set_value("pickup_company", frappe.defaults.get_default('company')); - frm.set_value("pickup_customer", ''); - frm.set_value("pickup_supplier", ''); + pickup_from_type: function (frm) { + if (frm.doc.pickup_from_type == "Company") { + frm.set_value("pickup_company", frappe.defaults.get_default("company")); + frm.set_value("pickup_customer", ""); + frm.set_value("pickup_supplier", ""); } else { - frm.trigger('clear_pickup_fields'); + frm.trigger("clear_pickup_fields"); } - if (frm.doc.pickup_from_type == 'Customer') { - frm.set_value("pickup_company", ''); - frm.set_value("pickup_supplier", ''); + if (frm.doc.pickup_from_type == "Customer") { + frm.set_value("pickup_company", ""); + frm.set_value("pickup_supplier", ""); } - if (frm.doc.pickup_from_type == 'Supplier') { - frm.set_value("pickup_customer", ''); - frm.set_value("pickup_company", ''); + if (frm.doc.pickup_from_type == "Supplier") { + frm.set_value("pickup_customer", ""); + frm.set_value("pickup_company", ""); } }, - delivery_to_type: function(frm) { - if (frm.doc.delivery_to_type == 'Company') { - frm.set_value("delivery_company", frappe.defaults.get_default('company')); - frm.set_value("delivery_customer", ''); - frm.set_value("delivery_supplier", ''); + delivery_to_type: function (frm) { + if (frm.doc.delivery_to_type == "Company") { + frm.set_value("delivery_company", frappe.defaults.get_default("company")); + frm.set_value("delivery_customer", ""); + frm.set_value("delivery_supplier", ""); } else { - frm.trigger('clear_delivery_fields'); + frm.trigger("clear_delivery_fields"); } - if (frm.doc.delivery_to_type == 'Customer') { - frm.set_value("delivery_company", ''); - frm.set_value("delivery_supplier", ''); + if (frm.doc.delivery_to_type == "Customer") { + frm.set_value("delivery_company", ""); + frm.set_value("delivery_supplier", ""); } - if (frm.doc.delivery_to_type == 'Supplier') { - frm.set_value("delivery_customer", ''); - frm.set_value("delivery_company", ''); + if (frm.doc.delivery_to_type == "Supplier") { + frm.set_value("delivery_customer", ""); + frm.set_value("delivery_company", ""); frm.toggle_display("shipment_delivery_note", false); } else { frm.toggle_display("shipment_delivery_note", true); } }, - delivery_address_name: function(frm) { - if (frm.doc.delivery_to_type == 'Company') { - erpnext.utils.get_address_display(frm, 'delivery_address_name', 'delivery_address', true); + delivery_address_name: function (frm) { + if (frm.doc.delivery_to_type == "Company") { + erpnext.utils.get_address_display(frm, "delivery_address_name", "delivery_address", true); } else { - erpnext.utils.get_address_display(frm, 'delivery_address_name', 'delivery_address', false); + erpnext.utils.get_address_display(frm, "delivery_address_name", "delivery_address", false); } }, - pickup_address_name: function(frm) { - if (frm.doc.pickup_from_type == 'Company') { - erpnext.utils.get_address_display(frm, 'pickup_address_name', 'pickup_address', true); + pickup_address_name: function (frm) { + if (frm.doc.pickup_from_type == "Company") { + erpnext.utils.get_address_display(frm, "pickup_address_name", "pickup_address", true); } else { - erpnext.utils.get_address_display(frm, 'pickup_address_name', 'pickup_address', false); + erpnext.utils.get_address_display(frm, "pickup_address_name", "pickup_address", false); } }, - get_contact_display: function(frm, contact_name, contact_type) { + get_contact_display: function (frm, contact_name, contact_type) { frappe.call({ method: "frappe.contacts.doctype.contact.contact.get_contact_details", args: { contact: contact_name }, - callback: function(r) { + callback: function (r) { if (r.message) { if (!(r.message.contact_email && (r.message.contact_phone || r.message.contact_mobile))) { - if (contact_type == 'Delivery') { - frm.set_value('delivery_contact_name', ''); - frm.set_value('delivery_contact', ''); + if (contact_type == "Delivery") { + frm.set_value("delivery_contact_name", ""); + frm.set_value("delivery_contact", ""); } else { - frm.set_value('pickup_contact_name', ''); - frm.set_value('pickup_contact', ''); + frm.set_value("pickup_contact_name", ""); + frm.set_value("pickup_contact", ""); } - frappe.throw(__("Email or Phone/Mobile of the Contact are mandatory to continue.") - + "
      " + __("Please set Email/Phone for the contact") - + ` ${contact_name}`); + frappe.throw( + __("Email or Phone/Mobile of the Contact are mandatory to continue.") + + "
      " + + __("Please set Email/Phone for the contact") + + ` ${contact_name}` + ); } let contact_display = r.message.contact_display; if (r.message.contact_email) { - contact_display += '
      ' + r.message.contact_email; + contact_display += "
      " + r.message.contact_email; } if (r.message.contact_phone) { - contact_display += '
      ' + r.message.contact_phone; + contact_display += "
      " + r.message.contact_phone; } if (r.message.contact_mobile && !r.message.contact_phone) { - contact_display += '
      ' + r.message.contact_mobile; + contact_display += "
      " + r.message.contact_mobile; } - if (contact_type == 'Delivery') { - frm.set_value('delivery_contact', contact_display); + if (contact_type == "Delivery") { + frm.set_value("delivery_contact", contact_display); if (r.message.contact_email) { - frm.set_value('delivery_contact_email', r.message.contact_email); + frm.set_value("delivery_contact_email", r.message.contact_email); } } else { - frm.set_value('pickup_contact', contact_display); + frm.set_value("pickup_contact", contact_display); if (r.message.contact_email) { - frm.set_value('pickup_contact_email', r.message.contact_email); + frm.set_value("pickup_contact_email", r.message.contact_email); } } } - } + }, }); }, - delivery_contact_name: function(frm) { + delivery_contact_name: function (frm) { if (frm.doc.delivery_contact_name) { - frm.events.get_contact_display(frm, frm.doc.delivery_contact_name, 'Delivery'); + frm.events.get_contact_display(frm, frm.doc.delivery_contact_name, "Delivery"); } }, - pickup_contact_name: function(frm) { + pickup_contact_name: function (frm) { if (frm.doc.pickup_contact_name) { - frm.events.get_contact_display(frm, frm.doc.pickup_contact_name, 'Pickup'); + frm.events.get_contact_display(frm, frm.doc.pickup_contact_name, "Pickup"); } }, - pickup_contact_person: function(frm) { + pickup_contact_person: function (frm) { if (frm.doc.pickup_contact_person) { frappe.call({ method: "erpnext.stock.doctype.shipment.shipment.get_company_contact", args: { user: frm.doc.pickup_contact_person }, - callback: function({ message }) { + callback: function ({ message }) { const r = message; let contact_display = `${r.first_name} ${r.last_name}`; if (r.email) { - contact_display += `
      ${ r.email }`; - frm.set_value('pickup_contact_email', r.email); + contact_display += `
      ${r.email}`; + frm.set_value("pickup_contact_email", r.email); } if (r.phone) { - contact_display += `
      ${ r.phone }`; + contact_display += `
      ${r.phone}`; } if (r.mobile_no && !r.phone) { - contact_display += `
      ${ r.mobile_no }`; + contact_display += `
      ${r.mobile_no}`; } - frm.set_value('pickup_contact', contact_display); - } + frm.set_value("pickup_contact", contact_display); + }, }); } else { - if (frm.doc.pickup_from_type === 'Company') { + if (frm.doc.pickup_from_type === "Company") { frappe.call({ method: "erpnext.stock.doctype.shipment.shipment.get_company_contact", args: { user: frappe.session.user }, - callback: function({ message }) { + callback: function ({ message }) { const r = message; let contact_display = `${r.first_name} ${r.last_name}`; if (r.email) { - contact_display += `
      ${ r.email }`; - frm.set_value('pickup_contact_email', r.email); + contact_display += `
      ${r.email}`; + frm.set_value("pickup_contact_email", r.email); } if (r.phone) { - contact_display += `
      ${ r.phone }`; + contact_display += `
      ${r.phone}`; } if (r.mobile_no && !r.phone) { - contact_display += `
      ${ r.mobile_no }`; + contact_display += `
      ${r.mobile_no}`; } - frm.set_value('pickup_contact', contact_display); - } + frm.set_value("pickup_contact", contact_display); + }, }); } } }, - set_company_contact: function(frm, delivery_type) { - frappe.db.get_value('User', { name: frappe.session.user }, ['full_name', 'last_name', 'email', 'phone', 'mobile_no'], (r) => { - if (!(r.last_name && r.email && (r.phone || r.mobile_no))) { - if (delivery_type == 'Delivery') { - frm.set_value('delivery_company', ''); - frm.set_value('delivery_contact', ''); + set_company_contact: function (frm, delivery_type) { + frappe.db.get_value( + "User", + { name: frappe.session.user }, + ["full_name", "last_name", "email", "phone", "mobile_no"], + (r) => { + if (!(r.last_name && r.email && (r.phone || r.mobile_no))) { + if (delivery_type == "Delivery") { + frm.set_value("delivery_company", ""); + frm.set_value("delivery_contact", ""); + } else { + frm.set_value("pickup_company", ""); + frm.set_value("pickup_contact", ""); + } + frappe.throw( + __("Last Name, Email or Phone/Mobile of the user are mandatory to continue.") + + "
      " + + __("Please first set Last Name, Email and Phone for the user") + + ` ${frappe.session.user}` + ); + } + let contact_display = r.full_name; + if (r.email) { + contact_display += "
      " + r.email; + } + if (r.phone) { + contact_display += "
      " + r.phone; + } + if (r.mobile_no && !r.phone) { + contact_display += "
      " + r.mobile_no; + } + if (delivery_type == "Delivery") { + frm.set_value("delivery_contact", contact_display); + if (r.email) { + frm.set_value("delivery_contact_email", r.email); + } } else { - frm.set_value('pickup_company', ''); - frm.set_value('pickup_contact', ''); - } - frappe.throw(__("Last Name, Email or Phone/Mobile of the user are mandatory to continue.") + "
      " - + __("Please first set Last Name, Email and Phone for the user") - + ` ${frappe.session.user}`); - } - let contact_display = r.full_name; - if (r.email) { - contact_display += '
      ' + r.email; - } - if (r.phone) { - contact_display += '
      ' + r.phone; - } - if (r.mobile_no && !r.phone) { - contact_display += '
      ' + r.mobile_no; - } - if (delivery_type == 'Delivery') { - frm.set_value('delivery_contact', contact_display); - if (r.email) { - frm.set_value('delivery_contact_email', r.email); - } - } else { - frm.set_value('pickup_contact', contact_display); - if (r.email) { - frm.set_value('pickup_contact_email', r.email); + frm.set_value("pickup_contact", contact_display); + if (r.email) { + frm.set_value("pickup_contact_email", r.email); + } } } - }); - frm.set_value('pickup_contact_person', frappe.session.user); + ); + frm.set_value("pickup_contact_person", frappe.session.user); }, - pickup_company: function(frm) { - if (frm.doc.pickup_from_type == 'Company' && frm.doc.pickup_company) { - frm.trigger('set_pickup_company_address'); - frm.events.set_company_contact(frm, 'Pickup'); + pickup_company: function (frm) { + if (frm.doc.pickup_from_type == "Company" && frm.doc.pickup_company) { + frm.trigger("set_pickup_company_address"); + frm.events.set_company_contact(frm, "Pickup"); } }, - delivery_company: function(frm) { - if (frm.doc.delivery_to_type == 'Company' && frm.doc.delivery_company) { - frm.trigger('set_delivery_company_address'); - frm.events.set_company_contact(frm, 'Delivery'); + delivery_company: function (frm) { + if (frm.doc.delivery_to_type == "Company" && frm.doc.delivery_company) { + frm.trigger("set_delivery_company_address"); + frm.events.set_company_contact(frm, "Delivery"); } }, - delivery_customer: function(frm) { - frm.trigger('clear_delivery_fields'); + delivery_customer: function (frm) { + frm.trigger("clear_delivery_fields"); if (frm.doc.delivery_customer) { - frm.events.set_address_name(frm, 'Customer', frm.doc.delivery_customer, 'Delivery'); - frm.events.set_contact_name(frm, 'Customer', frm.doc.delivery_customer, 'Delivery'); + frm.events.set_address_name(frm, "Customer", frm.doc.delivery_customer, "Delivery"); + frm.events.set_contact_name(frm, "Customer", frm.doc.delivery_customer, "Delivery"); } }, - delivery_supplier: function(frm) { - frm.trigger('clear_delivery_fields'); + delivery_supplier: function (frm) { + frm.trigger("clear_delivery_fields"); if (frm.doc.delivery_supplier) { - frm.events.set_address_name(frm, 'Supplier', frm.doc.delivery_supplier, 'Delivery'); - frm.events.set_contact_name(frm, 'Supplier', frm.doc.delivery_supplier, 'Delivery'); + frm.events.set_address_name(frm, "Supplier", frm.doc.delivery_supplier, "Delivery"); + frm.events.set_contact_name(frm, "Supplier", frm.doc.delivery_supplier, "Delivery"); } }, - pickup_customer: function(frm) { + pickup_customer: function (frm) { if (frm.doc.pickup_customer) { - frm.events.set_address_name(frm, 'Customer', frm.doc.pickup_customer, 'Pickup'); - frm.events.set_contact_name(frm, 'Customer', frm.doc.pickup_customer, 'Pickup'); + frm.events.set_address_name(frm, "Customer", frm.doc.pickup_customer, "Pickup"); + frm.events.set_contact_name(frm, "Customer", frm.doc.pickup_customer, "Pickup"); } }, - pickup_supplier: function(frm) { + pickup_supplier: function (frm) { if (frm.doc.pickup_supplier) { - frm.events.set_address_name(frm, 'Supplier', frm.doc.pickup_supplier, 'Pickup'); - frm.events.set_contact_name(frm, 'Supplier', frm.doc.pickup_supplier, 'Pickup'); + frm.events.set_address_name(frm, "Supplier", frm.doc.pickup_supplier, "Pickup"); + frm.events.set_contact_name(frm, "Supplier", frm.doc.pickup_supplier, "Pickup"); } }, - set_address_name: function(frm, ref_doctype, ref_docname, delivery_type) { + set_address_name: function (frm, ref_doctype, ref_docname, delivery_type) { frappe.call({ method: "erpnext.stock.doctype.shipment.shipment.get_address_name", args: { ref_doctype: ref_doctype, - docname: ref_docname + docname: ref_docname, }, - callback: function(r) { + callback: function (r) { if (r.message) { - if (delivery_type == 'Delivery') { - frm.set_value('delivery_address_name', r.message); + if (delivery_type == "Delivery") { + frm.set_value("delivery_address_name", r.message); } else { - frm.set_value('pickup_address_name', r.message); + frm.set_value("pickup_address_name", r.message); } } - } + }, }); }, - set_contact_name: function(frm, ref_doctype, ref_docname, delivery_type) { + set_contact_name: function (frm, ref_doctype, ref_docname, delivery_type) { frappe.call({ method: "erpnext.stock.doctype.shipment.shipment.get_contact_name", args: { ref_doctype: ref_doctype, - docname: ref_docname + docname: ref_docname, }, - callback: function(r) { + callback: function (r) { if (r.message) { - if (delivery_type == 'Delivery') { - frm.set_value('delivery_contact_name', r.message); + if (delivery_type == "Delivery") { + frm.set_value("delivery_contact_name", r.message); } else { - frm.set_value('pickup_contact_name', r.message); + frm.set_value("pickup_contact_name", r.message); } } - } + }, }); }, - add_template: function(frm) { + add_template: function (frm) { if (frm.doc.parcel_template) { frappe.model.with_doc("Shipment Parcel Template", frm.doc.parcel_template, () => { - let parcel_template = frappe.model.get_doc("Shipment Parcel Template", frm.doc.parcel_template); + let parcel_template = frappe.model.get_doc( + "Shipment Parcel Template", + frm.doc.parcel_template + ); let row = frappe.model.add_child(frm.doc, "Shipment Parcel", "shipment_parcel"); row.length = parcel_template.length; row.width = parcel_template.width; @@ -359,56 +393,71 @@ frappe.ui.form.on('Shipment', { }); } }, - pickup_date: function(frm) { + pickup_date: function (frm) { if (frm.doc.pickup_date < frappe.datetime.get_today()) { frappe.throw(__("Pickup Date cannot be before this day")); } }, - clear_pickup_fields: function(frm) { - let fields = ["pickup_address_name", "pickup_contact_name", "pickup_address", "pickup_contact", "pickup_contact_email", "pickup_contact_person"]; + clear_pickup_fields: function (frm) { + let fields = [ + "pickup_address_name", + "pickup_contact_name", + "pickup_address", + "pickup_contact", + "pickup_contact_email", + "pickup_contact_person", + ]; for (let field of fields) { - frm.set_value(field, ''); + frm.set_value(field, ""); } }, - clear_delivery_fields: function(frm) { - let fields = ["delivery_address_name", "delivery_contact_name", "delivery_address", "delivery_contact", "delivery_contact_email"]; + clear_delivery_fields: function (frm) { + let fields = [ + "delivery_address_name", + "delivery_contact_name", + "delivery_address", + "delivery_contact", + "delivery_contact_email", + ]; for (let field of fields) { - frm.set_value(field, ''); + frm.set_value(field, ""); } }, - remove_email_row: function(frm, table, fieldname) { - $.each(frm.doc[table] || [], function(i, detail) { + remove_email_row: function (frm, table, fieldname) { + $.each(frm.doc[table] || [], function (i, detail) { if (detail.email === fieldname) { cur_frm.get_field(table).grid.grid_rows[i].remove(); } }); - } + }, }); -frappe.ui.form.on('Shipment Delivery Note', { - delivery_note: function(frm, cdt, cdn) { +frappe.ui.form.on("Shipment Delivery Note", { + delivery_note: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; if (row.delivery_note) { let row_index = row.idx - 1; - if (validate_duplicate(frm, 'shipment_delivery_note', row.delivery_note, row_index)) { - frappe.throw(__("You have entered a duplicate Delivery Note on Row") + ` ${row.idx}. ` + __("Please rectify and try again.")); + if (validate_duplicate(frm, "shipment_delivery_note", row.delivery_note, row_index)) { + frappe.throw( + __("You have entered a duplicate Delivery Note on Row") + + ` ${row.idx}. ` + + __("Please rectify and try again.") + ); } } }, - grand_total: function(frm, cdt, cdn) { + grand_total: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; if (row.grand_total) { - var value_of_goods = parseFloat(frm.doc.value_of_goods)+parseFloat(row.grand_total); + var value_of_goods = parseFloat(frm.doc.value_of_goods) + parseFloat(row.grand_total); frm.set_value("value_of_goods", Math.round(value_of_goods)); frm.refresh_fields("value_of_goods"); } }, }); -var validate_duplicate = function(frm, table, fieldname, index) { - return ( - table === 'shipment_delivery_note' - ? frm.doc[table].some((detail, i) => detail.delivery_note === fieldname && !(index === i)) - : frm.doc[table].some((detail, i) => detail.email === fieldname && !(index === i)) - ); +var validate_duplicate = function (frm, table, fieldname, index) { + return table === "shipment_delivery_note" + ? frm.doc[table].some((detail, i) => detail.delivery_note === fieldname && !(index === i)) + : frm.doc[table].some((detail, i) => detail.email === fieldname && !(index === i)); }; diff --git a/erpnext/stock/doctype/shipment/shipment_list.js b/erpnext/stock/doctype/shipment/shipment_list.js index ae6a3c154e8..b333ccc817f 100644 --- a/erpnext/stock/doctype/shipment/shipment_list.js +++ b/erpnext/stock/doctype/shipment/shipment_list.js @@ -1,8 +1,8 @@ -frappe.listview_settings['Shipment'] = { +frappe.listview_settings["Shipment"] = { add_fields: ["status"], - get_indicator: function(doc) { - if (doc.status=='Booked') { + get_indicator: function (doc) { + if (doc.status == "Booked") { return [__("Booked"), "green"]; } - } + }, }; diff --git a/erpnext/stock/doctype/shipment_parcel_template/shipment_parcel_template.js b/erpnext/stock/doctype/shipment_parcel_template/shipment_parcel_template.js index 785a3b304de..3ef90fa81f3 100644 --- a/erpnext/stock/doctype/shipment_parcel_template/shipment_parcel_template.js +++ b/erpnext/stock/doctype/shipment_parcel_template/shipment_parcel_template.js @@ -1,8 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Shipment Parcel Template', { +frappe.ui.form.on("Shipment Parcel Template", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 1b7089b9558..ac2fe5814d3 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -5,91 +5,106 @@ frappe.provide("erpnext.accounts.dimensions"); erpnext.landed_cost_taxes_and_charges.setup_triggers("Stock Entry"); -frappe.ui.form.on('Stock Entry', { - setup: function(frm) { - frm.ignore_doctypes_on_cancel_all = ['Serial and Batch Bundle']; +frappe.ui.form.on("Stock Entry", { + setup: function (frm) { + frm.ignore_doctypes_on_cancel_all = ["Serial and Batch Bundle"]; - frm.set_indicator_formatter('item_code', function(doc) { + frm.set_indicator_formatter("item_code", function (doc) { if (!doc.s_warehouse) { - return 'blue'; + return "blue"; } else { - return (doc.qty<=doc.actual_qty) ? 'green' : 'orange'; + return doc.qty <= doc.actual_qty ? "green" : "orange"; } }); - frm.set_query('work_order', function() { + frm.set_query("work_order", function () { return { filters: [ - ['Work Order', 'docstatus', '=', 1], - ['Work Order', 'qty', '>','`tabWork Order`.produced_qty'], - ['Work Order', 'company', '=', frm.doc.company] - ] - } + ["Work Order", "docstatus", "=", 1], + ["Work Order", "qty", ">", "`tabWork Order`.produced_qty"], + ["Work Order", "company", "=", frm.doc.company], + ], + }; }); - frm.set_query('outgoing_stock_entry', function() { + frm.set_query("outgoing_stock_entry", function () { return { filters: [ - ['Stock Entry', 'docstatus', '=', 1], - ['Stock Entry', 'per_transferred', '<','100'], - ] - } + ["Stock Entry", "docstatus", "=", 1], + ["Stock Entry", "per_transferred", "<", "100"], + ], + }; }); - frm.set_query('source_warehouse_address', function() { + frm.set_query("source_warehouse_address", function () { return { filters: { - link_doctype: 'Warehouse', - link_name: frm.doc.from_warehouse - } - } + link_doctype: "Warehouse", + link_name: frm.doc.from_warehouse, + }, + }; }); - frm.set_query('target_warehouse_address', function() { + frm.set_query("target_warehouse_address", function () { return { filters: { - link_doctype: 'Warehouse', - link_name: frm.doc.to_warehouse + link_doctype: "Warehouse", + link_name: frm.doc.to_warehouse, + }, + }; + }); + + frappe.db.get_value( + "Stock Settings", + { name: "Stock Settings" }, + "sample_retention_warehouse", + (r) => { + if (r.sample_retention_warehouse) { + let filters = [ + ["Warehouse", "company", "=", frm.doc.company], + ["Warehouse", "is_group", "=", 0], + ["Warehouse", "name", "!=", r.sample_retention_warehouse], + ]; + frm.set_query("from_warehouse", function () { + return { + filters: filters, + }; + }); + frm.set_query("s_warehouse", "items", function () { + return { + filters: filters, + }; + }); } } - }); + ); - frappe.db.get_value('Stock Settings', {name: 'Stock Settings'}, 'sample_retention_warehouse', (r) => { - if (r.sample_retention_warehouse) { - let filters = [ - ["Warehouse", 'company', '=', frm.doc.company], - ["Warehouse", "is_group", "=",0], - ['Warehouse', 'name', '!=', r.sample_retention_warehouse] - ] - frm.set_query("from_warehouse", function() { - return { - filters: filters - }; - }); - frm.set_query("s_warehouse", "items", function() { - return { - filters: filters - }; - }); - } - }); - - frm.set_query('batch_no', 'items', function(doc, cdt, cdn) { + frm.set_query("batch_no", "items", function (doc, cdt, cdn) { let item = locals[cdt][cdn]; let filters = {}; - if(!item.item_code) { + if (!item.item_code) { frappe.throw(__("Please enter Item Code to get Batch Number")); } else { - if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"], doc.purpose)) { + if ( + in_list( + [ + "Material Transfer for Manufacture", + "Manufacture", + "Repack", + "Send to Subcontractor", + ], + doc.purpose + ) + ) { filters = { - 'item_code': item.item_code, - 'posting_date': frm.doc.posting_date || frappe.datetime.nowdate() - } + item_code: item.item_code, + posting_date: frm.doc.posting_date || frappe.datetime.nowdate(), + }; } else { filters = { - 'item_code': item.item_code - } + item_code: item.item_code, + }; } // User could want to select a manually created empty batch (no warehouse) @@ -99,9 +114,9 @@ frappe.ui.form.on('Stock Entry', { } return { - query : "erpnext.controllers.queries.get_batch_no", - filters: filters - } + query: "erpnext.controllers.queries.get_batch_no", + filters: filters, + }; } }); @@ -109,119 +124,125 @@ frappe.ui.form.on('Stock Entry', { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ["in", [doc.name, ""]], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); - frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); - frappe.db.get_single_value('Stock Settings', 'disable_serial_no_and_batch_selector') - .then((value) => { + frappe.db.get_single_value("Stock Settings", "disable_serial_no_and_batch_selector").then((value) => { if (value) { frappe.flags.hide_serial_batch_dialog = true; } }); attach_bom_items(frm.doc.bom_no); - if(!check_should_not_attach_bom_items(frm.doc.bom_no)) { + if (!check_should_not_attach_bom_items(frm.doc.bom_no)) { erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); } }, - setup_quality_inspection: function(frm) { + setup_quality_inspection: function (frm) { if (!frm.doc.inspection_required) { return; } if (!frm.is_new() && frm.doc.docstatus === 0) { - frm.add_custom_button(__("Quality Inspection(s)"), () => { - let transaction_controller = new erpnext.TransactionController({ frm: frm }); - transaction_controller.make_quality_inspection(); - }, __("Create")); - frm.page.set_inner_btn_group_as_primary(__('Create')); + frm.add_custom_button( + __("Quality Inspection(s)"), + () => { + let transaction_controller = new erpnext.TransactionController({ frm: frm }); + transaction_controller.make_quality_inspection(); + }, + __("Create") + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } let quality_inspection_field = frm.get_docfield("items", "quality_inspection"); - quality_inspection_field.get_route_options_for_new_doc = function(row) { + quality_inspection_field.get_route_options_for_new_doc = function (row) { if (frm.is_new()) return {}; return { - "inspection_type": "Incoming", - "reference_type": frm.doc.doctype, - "reference_name": frm.doc.name, - "item_code": row.doc.item_code, - "description": row.doc.description, - "item_serial_no": row.doc.serial_no ? row.doc.serial_no.split("\n")[0] : null, - "batch_no": row.doc.batch_no - } - } + inspection_type: "Incoming", + reference_type: frm.doc.doctype, + reference_name: frm.doc.name, + item_code: row.doc.item_code, + description: row.doc.description, + item_serial_no: row.doc.serial_no ? row.doc.serial_no.split("\n")[0] : null, + batch_no: row.doc.batch_no, + }; + }; - frm.set_query("quality_inspection", "items", function(doc, cdt, cdn) { + frm.set_query("quality_inspection", "items", function (doc, cdt, cdn) { var d = locals[cdt][cdn]; return { - query:"erpnext.stock.doctype.quality_inspection.quality_inspection.quality_inspection_query", + query: "erpnext.stock.doctype.quality_inspection.quality_inspection.quality_inspection_query", filters: { - 'item_code': d.item_code, - 'reference_name': doc.name - } - } + item_code: d.item_code, + reference_name: doc.name, + }, + }; }); }, - outgoing_stock_entry: function(frm) { + outgoing_stock_entry: function (frm) { frappe.call({ doc: frm.doc, method: "set_items_for_stock_in", - callback: function() { - refresh_field('items'); - } + callback: function () { + refresh_field("items"); + }, }); }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("get_items_from_transit_entry"); - if(!frm.doc.docstatus) { - frm.trigger('validate_purpose_consumption'); - frm.add_custom_button(__('Material Request'), function() { - frappe.model.with_doctype('Material Request', function() { - var mr = frappe.model.get_new_doc('Material Request'); - var items = frm.get_field('items').grid.get_selected_children(); - if(!items.length) { - items = frm.doc.items; - } + if (!frm.doc.docstatus) { + frm.trigger("validate_purpose_consumption"); + frm.add_custom_button( + __("Material Request"), + function () { + frappe.model.with_doctype("Material Request", function () { + var mr = frappe.model.get_new_doc("Material Request"); + var items = frm.get_field("items").grid.get_selected_children(); + if (!items.length) { + items = frm.doc.items; + } - mr.work_order = frm.doc.work_order; - items.forEach(function(item) { - var mr_item = frappe.model.add_child(mr, 'items'); - mr_item.item_code = item.item_code; - mr_item.item_name = item.item_name; - mr_item.uom = item.uom; - mr_item.stock_uom = item.stock_uom; - mr_item.conversion_factor = item.conversion_factor; - mr_item.item_group = item.item_group; - mr_item.description = item.description; - mr_item.image = item.image; - mr_item.qty = item.qty; - mr_item.warehouse = item.s_warehouse; - mr_item.required_date = frappe.datetime.nowdate(); + mr.work_order = frm.doc.work_order; + items.forEach(function (item) { + var mr_item = frappe.model.add_child(mr, "items"); + mr_item.item_code = item.item_code; + mr_item.item_name = item.item_name; + mr_item.uom = item.uom; + mr_item.stock_uom = item.stock_uom; + mr_item.conversion_factor = item.conversion_factor; + mr_item.item_group = item.item_group; + mr_item.description = item.description; + mr_item.image = item.image; + mr_item.qty = item.qty; + mr_item.warehouse = item.s_warehouse; + mr_item.required_date = frappe.datetime.nowdate(); + }); + frappe.set_route("Form", "Material Request", mr.name); }); - frappe.set_route('Form', 'Material Request', mr.name); - }); - }, __("Create")); + }, + __("Create") + ); } - if(frm.doc.items) { - const has_alternative = frm.doc.items.find(i => i.allow_alternative_item === 1); + if (frm.doc.items) { + const has_alternative = frm.doc.items.find((i) => i.allow_alternative_item === 1); if (frm.doc.docstatus == 0 && has_alternative) { - frm.add_custom_button(__('Alternate Item'), () => { + frm.add_custom_button(__("Alternate Item"), () => { erpnext.utils.select_alternate_items({ frm: frm, child_docname: "items", @@ -229,111 +250,139 @@ frappe.ui.form.on('Stock Entry', { child_doctype: "Stock Entry Detail", original_item_field: "original_item", condition: (d) => { - if (d.s_warehouse && d.allow_alternative_item) {return true;} - } - }) + if (d.s_warehouse && d.allow_alternative_item) { + return true; + } + }, + }); }); } } if (frm.doc.docstatus === 1) { - if (frm.doc.add_to_transit && frm.doc.purpose=='Material Transfer' && frm.doc.per_transferred < 100) { - frm.add_custom_button(__('End Transit'), function() { + if ( + frm.doc.add_to_transit && + frm.doc.purpose == "Material Transfer" && + frm.doc.per_transferred < 100 + ) { + frm.add_custom_button(__("End Transit"), function () { frappe.model.open_mapped_doc({ method: "erpnext.stock.doctype.stock_entry.stock_entry.make_stock_in_entry", - frm: frm - }) + frm: frm, + }); }); } if (frm.doc.per_transferred > 0) { - frm.add_custom_button(__('Received Stock Entries'), function() { - frappe.route_options = { - 'outgoing_stock_entry': frm.doc.name, - 'docstatus': ['!=', 2] - }; + frm.add_custom_button( + __("Received Stock Entries"), + function () { + frappe.route_options = { + outgoing_stock_entry: frm.doc.name, + docstatus: ["!=", 2], + }; - frappe.set_route('List', 'Stock Entry'); - }, __("View")); + frappe.set_route("List", "Stock Entry"); + }, + __("View") + ); } } if (frm.doc.docstatus === 0) { - frm.add_custom_button(__('Purchase Invoice'), function() { - erpnext.utils.map_current_doc({ - method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_stock_entry", - source_doctype: "Purchase Invoice", - target: frm, - date_field: "posting_date", - setters: { - supplier: frm.doc.supplier || undefined, - }, - get_query_filters: { - docstatus: 1 - } - }) - }, __("Get Items From")); - - frm.add_custom_button(__('Material Request'), function() { - const allowed_request_types = ["Material Transfer", "Material Issue", "Customer Provided"]; - const depends_on_condition = "eval:doc.material_request_type==='Customer Provided'"; - const d = erpnext.utils.map_current_doc({ - method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry", - source_doctype: "Material Request", - target: frm, - date_field: "schedule_date", - setters: [{ - fieldtype: 'Select', - label: __('Purpose'), - options: allowed_request_types.join("\n"), - fieldname: 'material_request_type', - default: "Material Transfer", - mandatory: 1, - change() { - if (this.value === 'Customer Provided') { - d.dialog.get_field("customer").set_focus(); - } + frm.add_custom_button( + __("Purchase Invoice"), + function () { + erpnext.utils.map_current_doc({ + method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_stock_entry", + source_doctype: "Purchase Invoice", + target: frm, + date_field: "posting_date", + setters: { + supplier: frm.doc.supplier || undefined, }, - }, - { - fieldtype: 'Link', - label: __('Customer'), - options: 'Customer', - fieldname: 'customer', - depends_on: depends_on_condition, - mandatory_depends_on: depends_on_condition, - }], - get_query_filters: { - docstatus: 1, - material_request_type: ["in", allowed_request_types], - status: ["not in", ["Transferred", "Issued", "Cancelled", "Stopped"]] - } - }) - }, __("Get Items From")); + get_query_filters: { + docstatus: 1, + }, + }); + }, + __("Get Items From") + ); + + frm.add_custom_button( + __("Material Request"), + function () { + const allowed_request_types = [ + "Material Transfer", + "Material Issue", + "Customer Provided", + ]; + const depends_on_condition = "eval:doc.material_request_type==='Customer Provided'"; + const d = erpnext.utils.map_current_doc({ + method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry", + source_doctype: "Material Request", + target: frm, + date_field: "schedule_date", + setters: [ + { + fieldtype: "Select", + label: __("Purpose"), + options: allowed_request_types.join("\n"), + fieldname: "material_request_type", + default: "Material Transfer", + mandatory: 1, + change() { + if (this.value === "Customer Provided") { + d.dialog.get_field("customer").set_focus(); + } + }, + }, + { + fieldtype: "Link", + label: __("Customer"), + options: "Customer", + fieldname: "customer", + depends_on: depends_on_condition, + mandatory_depends_on: depends_on_condition, + }, + ], + get_query_filters: { + docstatus: 1, + material_request_type: ["in", allowed_request_types], + status: ["not in", ["Transferred", "Issued", "Cancelled", "Stopped"]], + }, + }); + }, + __("Get Items From") + ); } if (frm.doc.docstatus === 0 && frm.doc.purpose == "Material Issue") { - frm.add_custom_button(__('Expired Batches'), function() { - frappe.call({ - method: "erpnext.stock.doctype.stock_entry.stock_entry.get_expired_batch_items", - callback: function(r) { - if (!r.exc && r.message) { - frm.set_value("items", []); - r.message.forEach(function(element) { - let d = frm.add_child("items"); - d.item_code = element.item; - d.s_warehouse = element.warehouse; - d.qty = element.qty; - d.uom = element.stock_uom; - d.conversion_factor = 1; - d.batch_no = element.batch_no; - d.transfer_qty = element.qty; - frm.refresh_fields(); - }); - } - } - }); - }, __("Get Items From")); + frm.add_custom_button( + __("Expired Batches"), + function () { + frappe.call({ + method: "erpnext.stock.doctype.stock_entry.stock_entry.get_expired_batch_items", + callback: function (r) { + if (!r.exc && r.message) { + frm.set_value("items", []); + r.message.forEach(function (element) { + let d = frm.add_child("items"); + d.item_code = element.item; + d.s_warehouse = element.warehouse; + d.qty = element.qty; + d.uom = element.stock_uom; + d.conversion_factor = 1; + d.batch_no = element.batch_no; + d.transfer_qty = element.qty; + frm.refresh_fields(); + }); + } + }, + }); + }, + __("Get Items From") + ); } frm.events.show_bom_custom_button(frm); @@ -342,8 +391,12 @@ frappe.ui.form.on('Stock Entry', { frm.trigger("toggle_display_account_head"); } - if(frm.doc.docstatus==1 && frm.doc.purpose == "Material Receipt" && frm.get_sum('items', 'sample_quantity')) { - frm.add_custom_button(__('Create Sample Retention Stock Entry'), function () { + if ( + frm.doc.docstatus == 1 && + frm.doc.purpose == "Material Receipt" && + frm.get_sum("items", "sample_quantity") + ) { + frm.add_custom_button(__("Create Sample Retention Stock Entry"), function () { frm.trigger("make_retention_stock_entry"); }); } @@ -351,81 +404,88 @@ frappe.ui.form.on('Stock Entry', { frm.trigger("setup_quality_inspection"); attach_bom_items(frm.doc.bom_no); - if(!check_should_not_attach_bom_items(frm.doc.bom_no)) { + if (!check_should_not_attach_bom_items(frm.doc.bom_no)) { erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); } - let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); + let sbb_field = frm.get_docfield("items", "serial_and_batch_bundle"); if (sbb_field) { sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } + item_code: row.doc.item_code, + voucher_type: frm.doc.doctype, + }; }; } }, - get_items_from_transit_entry: function(frm) { - if (frm.doc.docstatus===0) { - frm.add_custom_button(__('Transit Entry'), function() { - erpnext.utils.map_current_doc({ - method: "erpnext.stock.doctype.stock_entry.stock_entry.make_stock_in_entry", - source_doctype: "Stock Entry", - target: frm, - date_field: "posting_date", - setters: { - stock_entry_type: "Material Transfer", - purpose: "Material Transfer", - }, - get_query_filters: { - docstatus: 1, - purpose: "Material Transfer", - add_to_transit: 1, - } - }) - }, __("Get Items From")); + get_items_from_transit_entry: function (frm) { + if (frm.doc.docstatus === 0) { + frm.add_custom_button( + __("Transit Entry"), + function () { + erpnext.utils.map_current_doc({ + method: "erpnext.stock.doctype.stock_entry.stock_entry.make_stock_in_entry", + source_doctype: "Stock Entry", + target: frm, + date_field: "posting_date", + setters: { + stock_entry_type: "Material Transfer", + purpose: "Material Transfer", + }, + get_query_filters: { + docstatus: 1, + purpose: "Material Transfer", + add_to_transit: 1, + }, + }); + }, + __("Get Items From") + ); } }, - before_save: function(frm) { + before_save: function (frm) { frm.doc.items.forEach((item) => { item.uom = item.uom || item.stock_uom; - }) + }); }, - stock_entry_type: function(frm){ - frm.remove_custom_button('Bill of Materials', "Get Items From"); + stock_entry_type: function (frm) { + frm.remove_custom_button("Bill of Materials", "Get Items From"); frm.events.show_bom_custom_button(frm); - frm.trigger('add_to_transit'); + frm.trigger("add_to_transit"); frm.fields_dict.items.grid.update_docfield_property( - 'basic_rate', 'read_only', frm.doc.purpose == "Material Receipt" ? 0 : 1 + "basic_rate", + "read_only", + frm.doc.purpose == "Material Receipt" ? 0 : 1 ); }, - purpose: function(frm) { - frm.trigger('validate_purpose_consumption'); + purpose: function (frm) { + frm.trigger("validate_purpose_consumption"); frm.fields_dict.items.grid.refresh(); frm.cscript.toggle_related_fields(frm.doc); }, - validate_purpose_consumption: function(frm) { - frappe.call({ - method: "erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings.is_material_consumption_enabled", - }).then(r => { - if (cint(r.message) == 0 - && frm.doc.purpose=="Material Consumption for Manufacture") { - frm.set_value("purpose", 'Manufacture'); - frappe.throw(__('Material Consumption is not set in Manufacturing Settings.')); - } - }); + validate_purpose_consumption: function (frm) { + frappe + .call({ + method: "erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings.is_material_consumption_enabled", + }) + .then((r) => { + if (cint(r.message) == 0 && frm.doc.purpose == "Material Consumption for Manufacture") { + frm.set_value("purpose", "Manufacture"); + frappe.throw(__("Material Consumption is not set in Manufacturing Settings.")); + } + }); }, - company: function(frm) { - if(frm.doc.company) { + company: function (frm) { + if (frm.doc.company) { var company_doc = frappe.get_doc(":Company", frm.doc.company); - if(company_doc.default_letter_head) { + if (company_doc.default_letter_head) { frm.set_value("letter_head", company_doc.default_letter_head); } frm.trigger("toggle_display_account_head"); @@ -434,83 +494,84 @@ frappe.ui.form.on('Stock Entry', { } }, - make_retention_stock_entry: function(frm) { + make_retention_stock_entry: function (frm) { frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.move_sample_to_retention_warehouse", - args:{ - "company": frm.doc.company, - "items": frm.doc.items + args: { + company: frm.doc.company, + items: frm.doc.items, }, callback: function (r) { if (r.message) { var doc = frappe.model.sync(r.message)[0]; frappe.set_route("Form", doc.doctype, doc.name); + } else { + frappe.msgprint( + __("Retention Stock Entry already created or Sample Quantity not provided") + ); } - else { - frappe.msgprint(__("Retention Stock Entry already created or Sample Quantity not provided")); - } - } + }, }); }, - toggle_display_account_head: function(frm) { + toggle_display_account_head: function (frm) { var enabled = erpnext.is_perpetual_inventory_enabled(frm.doc.company); frm.fields_dict["items"].grid.set_column_disp(["cost_center", "expense_account"], enabled); }, - set_basic_rate: function(frm, cdt, cdn) { + set_basic_rate: function (frm, cdt, cdn) { const item = locals[cdt][cdn]; item.transfer_qty = flt(item.qty) * flt(item.conversion_factor); const args = { - 'item_code' : item.item_code, - 'posting_date' : frm.doc.posting_date, - 'posting_time' : frm.doc.posting_time, - 'warehouse' : cstr(item.s_warehouse) || cstr(item.t_warehouse), - 'serial_no' : item.serial_no, - 'batch_no' : item.batch_no, - 'company' : frm.doc.company, - 'qty' : item.s_warehouse ? -1*flt(item.transfer_qty) : flt(item.transfer_qty), - 'voucher_type' : frm.doc.doctype, - 'voucher_no' : item.name, - 'allow_zero_valuation': 1, + item_code: item.item_code, + posting_date: frm.doc.posting_date, + posting_time: frm.doc.posting_time, + warehouse: cstr(item.s_warehouse) || cstr(item.t_warehouse), + serial_no: item.serial_no, + batch_no: item.batch_no, + company: frm.doc.company, + qty: item.s_warehouse ? -1 * flt(item.transfer_qty) : flt(item.transfer_qty), + voucher_type: frm.doc.doctype, + voucher_no: item.name, + allow_zero_valuation: 1, }; if (item.item_code || item.serial_no) { frappe.call({ method: "erpnext.stock.utils.get_incoming_rate", args: { - args: args + args: args, }, - callback: function(r) { - frappe.model.set_value(cdt, cdn, 'basic_rate', (r.message || 0.0)); + callback: function (r) { + frappe.model.set_value(cdt, cdn, "basic_rate", r.message || 0.0); frm.events.calculate_basic_amount(frm, item); - } + }, }); } }, - get_warehouse_details: function(frm, cdt, cdn) { + get_warehouse_details: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - if(!child.bom_no) { + if (!child.bom_no) { frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.get_warehouse_details", args: { - "args": { - 'item_code': child.item_code, - 'warehouse': cstr(child.s_warehouse) || cstr(child.t_warehouse), - 'transfer_qty': child.transfer_qty, - 'serial_and_batch_bundle': child.serial_and_batch_bundle, - 'qty': child.s_warehouse ? -1* child.transfer_qty : child.transfer_qty, - 'posting_date': frm.doc.posting_date, - 'posting_time': frm.doc.posting_time, - 'company': frm.doc.company, - 'voucher_type': frm.doc.doctype, - 'voucher_no': child.name, - 'allow_zero_valuation': 1 - } + args: { + item_code: child.item_code, + warehouse: cstr(child.s_warehouse) || cstr(child.t_warehouse), + transfer_qty: child.transfer_qty, + serial_and_batch_bundle: child.serial_and_batch_bundle, + qty: child.s_warehouse ? -1 * child.transfer_qty : child.transfer_qty, + posting_date: frm.doc.posting_date, + posting_time: frm.doc.posting_time, + company: frm.doc.company, + voucher_type: frm.doc.doctype, + voucher_no: child.name, + allow_zero_valuation: 1, + }, }, - callback: function(r) { + callback: function (r) { if (!r.exc) { let fields = ["actual_qty", "basic_rate"]; if (frm.doc.purpose == "Material Receipt") { @@ -518,72 +579,97 @@ frappe.ui.form.on('Stock Entry', { } fields.forEach((field) => { - frappe.model.set_value(cdt, cdn, field, (r.message[field] || 0.0)); + frappe.model.set_value(cdt, cdn, field, r.message[field] || 0.0); }); frm.events.calculate_basic_amount(frm, child); } - } + }, }); } }, - show_bom_custom_button: function(frm){ - if (frm.doc.docstatus === 0 && - ['Material Issue', 'Material Receipt', 'Material Transfer', 'Send to Subcontractor'].includes(frm.doc.purpose)) { - frm.add_custom_button(__('Bill of Materials'), function() { - frm.events.get_items_from_bom(frm); - }, __("Get Items From")); + show_bom_custom_button: function (frm) { + if ( + frm.doc.docstatus === 0 && + ["Material Issue", "Material Receipt", "Material Transfer", "Send to Subcontractor"].includes( + frm.doc.purpose + ) + ) { + frm.add_custom_button( + __("Bill of Materials"), + function () { + frm.events.get_items_from_bom(frm); + }, + __("Get Items From") + ); } }, - get_items_from_bom: function(frm) { - let filters = function(){ - return {filters: { docstatus:1 }}; - } + get_items_from_bom: function (frm) { + let filters = function () { + return { filters: { docstatus: 1 } }; + }; let fields = [ - {"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"), - options:"BOM", reqd: 1, get_query: () => { - return {filters: { docstatus:1, "is_active": 1 }}; - }}, - {"fieldname":"source_warehouse", "fieldtype":"Link", "label":__("Source Warehouse"), - options:"Warehouse"}, - {"fieldname":"target_warehouse", "fieldtype":"Link", "label":__("Target Warehouse"), - options:"Warehouse"}, - {"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"), - reqd: 1, "default": 1}, - {"fieldname":"fetch_exploded", "fieldtype":"Check", - "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}, - {"fieldname":"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"} - ] + { + fieldname: "bom", + fieldtype: "Link", + label: __("BOM"), + options: "BOM", + reqd: 1, + get_query: () => { + return { filters: { docstatus: 1, is_active: 1 } }; + }, + }, + { + fieldname: "source_warehouse", + fieldtype: "Link", + label: __("Source Warehouse"), + options: "Warehouse", + }, + { + fieldname: "target_warehouse", + fieldtype: "Link", + label: __("Target Warehouse"), + options: "Warehouse", + }, + { fieldname: "qty", fieldtype: "Float", label: __("Quantity"), reqd: 1, default: 1 }, + { + fieldname: "fetch_exploded", + fieldtype: "Check", + label: __("Fetch exploded BOM (including sub-assemblies)"), + default: 1, + }, + { fieldname: "fetch", label: __("Get Items from BOM"), fieldtype: "Button" }, + ]; // Exclude field 'Target Warehouse' in case of Material Issue - if (frm.doc.purpose == 'Material Issue'){ - fields.splice(2,1); + if (frm.doc.purpose == "Material Issue") { + fields.splice(2, 1); } // Exclude field 'Source Warehouse' in case of Material Receipt - else if(frm.doc.purpose == 'Material Receipt'){ - fields.splice(1,1); + else if (frm.doc.purpose == "Material Receipt") { + fields.splice(1, 1); } let d = new frappe.ui.Dialog({ title: __("Get Items from BOM"), - fields: fields + fields: fields, }); - d.get_input("fetch").on("click", function() { + d.get_input("fetch").on("click", function () { let values = d.get_values(); - if(!values) return; + if (!values) return; values["company"] = frm.doc.company; - if(!frm.doc.company) frappe.throw(__("Company field is required")); + if (!frm.doc.company) frappe.throw(__("Company field is required")); frappe.call({ method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items", args: values, - callback: function(r) { + callback: function (r) { if (!r.message) { frappe.throw(__("BOM does not contain any stock item")); } else { erpnext.utils.remove_empty_first_row(frm, "items"); - $.each(r.message, function(i, item) { + $.each(r.message, function (i, item) { let d = frappe.model.add_child(cur_frm.doc, "Stock Entry Detail", "items"); d.item_code = item.item_code; d.item_name = item.item_name; @@ -601,65 +687,74 @@ frappe.ui.form.on('Stock Entry', { } d.hide(); refresh_field("items"); - } + }, }); - }); d.show(); }, - calculate_basic_amount: function(frm, item) { - item.basic_amount = flt(flt(item.transfer_qty) * flt(item.basic_rate), - precision("basic_amount", item)); + calculate_basic_amount: function (frm, item) { + item.basic_amount = flt( + flt(item.transfer_qty) * flt(item.basic_rate), + precision("basic_amount", item) + ); frm.events.calculate_total_additional_costs(frm); }, - calculate_total_additional_costs: function(frm) { + calculate_total_additional_costs: function (frm) { const total_additional_costs = frappe.utils.sum( - (frm.doc.additional_costs || []).map(function(c) { return flt(c.base_amount); }) + (frm.doc.additional_costs || []).map(function (c) { + return flt(c.base_amount); + }) ); - frm.set_value("total_additional_costs", - flt(total_additional_costs, precision("total_additional_costs"))); + frm.set_value( + "total_additional_costs", + flt(total_additional_costs, precision("total_additional_costs")) + ); }, - source_warehouse_address: function(frm) { - erpnext.utils.get_address_display(frm, 'source_warehouse_address', 'source_address_display', false); + source_warehouse_address: function (frm) { + erpnext.utils.get_address_display(frm, "source_warehouse_address", "source_address_display", false); }, - target_warehouse_address: function(frm) { - erpnext.utils.get_address_display(frm, 'target_warehouse_address', 'target_address_display', false); + target_warehouse_address: function (frm) { + erpnext.utils.get_address_display(frm, "target_warehouse_address", "target_address_display", false); }, - add_to_transit: function(frm) { - if(frm.doc.purpose=='Material Transfer') { + add_to_transit: function (frm) { + if (frm.doc.purpose == "Material Transfer") { var filters = { - 'is_group': 0, - 'company': frm.doc.company + is_group: 0, + company: frm.doc.company, + }; + + if (frm.doc.add_to_transit) { + filters["warehouse_type"] = "Transit"; + frm.set_value("to_warehouse", ""); + frm.trigger("set_transit_warehouse"); } - if(frm.doc.add_to_transit){ - filters['warehouse_type'] = 'Transit'; - frm.set_value('to_warehouse', ''); - frm.trigger('set_transit_warehouse'); - } - - frm.fields_dict.to_warehouse.get_query = function() { + frm.fields_dict.to_warehouse.get_query = function () { return { - filters:filters + filters: filters, }; }; } }, - set_transit_warehouse: function(frm) { - if(frm.doc.add_to_transit && frm.doc.purpose == 'Material Transfer' && !frm.doc.to_warehouse - && frm.doc.from_warehouse) { - let dt = frm.doc.from_warehouse ? 'Warehouse' : 'Company'; + set_transit_warehouse: function (frm) { + if ( + frm.doc.add_to_transit && + frm.doc.purpose == "Material Transfer" && + !frm.doc.to_warehouse && + frm.doc.from_warehouse + ) { + let dt = frm.doc.from_warehouse ? "Warehouse" : "Company"; let dn = frm.doc.from_warehouse ? frm.doc.from_warehouse : frm.doc.company; - frappe.db.get_value(dt, dn, 'default_in_transit_warehouse', (r) => { + frappe.db.get_value(dt, dn, "default_in_transit_warehouse", (r) => { if (r.default_in_transit_warehouse) { - frm.set_value('to_warehouse', r.default_in_transit_warehouse); + frm.set_value("to_warehouse", r.default_in_transit_warehouse); } }); } @@ -673,7 +768,7 @@ frappe.ui.form.on('Stock Entry', { if (frm.doc.purchase_order) { frm.set_value("subcontracting_order", ""); erpnext.utils.map_current_doc({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry.get_items_from_subcontract_order', + method: "erpnext.stock.doctype.stock_entry.stock_entry.get_items_from_subcontract_order", source_name: frm.doc.purchase_order, target_doc: frm, freeze: true, @@ -685,7 +780,7 @@ frappe.ui.form.on('Stock Entry', { if (frm.doc.subcontracting_order) { frm.set_value("purchase_order", ""); erpnext.utils.map_current_doc({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry.get_items_from_subcontract_order', + method: "erpnext.stock.doctype.stock_entry.stock_entry.get_items_from_subcontract_order", source_name: frm.doc.subcontracting_order, target_doc: frm, freeze: true, @@ -695,20 +790,26 @@ frappe.ui.form.on('Stock Entry', { process_loss_qty(frm) { if (frm.doc.process_loss_qty) { - frm.doc.process_loss_percentage = flt(frm.doc.process_loss_qty / frm.doc.fg_completed_qty * 100, precision("process_loss_qty", frm.doc)); + frm.doc.process_loss_percentage = flt( + (frm.doc.process_loss_qty / frm.doc.fg_completed_qty) * 100, + precision("process_loss_qty", frm.doc) + ); refresh_field("process_loss_percentage"); } }, process_loss_percentage(frm) { if (frm.doc.process_loss_percentage) { - frm.doc.process_loss_qty = flt((frm.doc.fg_completed_qty * frm.doc.process_loss_percentage) / 100 , precision("process_loss_qty", frm.doc)); + frm.doc.process_loss_qty = flt( + (frm.doc.fg_completed_qty * frm.doc.process_loss_percentage) / 100, + precision("process_loss_qty", frm.doc) + ); refresh_field("process_loss_qty"); } - } + }, }); -frappe.ui.form.on('Stock Entry Detail', { +frappe.ui.form.on("Stock Entry Detail", { qty(frm, cdt, cdn) { frm.events.set_basic_rate(frm, cdt, cdn); }, @@ -738,50 +839,50 @@ frappe.ui.form.on('Stock Entry Detail', { uom(doc, cdt, cdn) { var d = locals[cdt][cdn]; - if(d.uom && d.item_code){ + if (d.uom && d.item_code) { return frappe.call({ method: "erpnext.stock.doctype.stock_entry.stock_entry.get_uom_details", args: { item_code: d.item_code, uom: d.uom, - qty: d.qty + qty: d.qty, }, - callback: function(r) { - if(r.message) { + callback: function (r) { + if (r.message) { frappe.model.set_value(cdt, cdn, r.message); } - } + }, }); } }, item_code(frm, cdt, cdn) { var d = locals[cdt][cdn]; - if(d.item_code) { + if (d.item_code) { var args = { - 'item_code' : d.item_code, - 'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse), - 'transfer_qty' : d.transfer_qty, - 'serial_no' : d.serial_no, - 'batch_no' : d.batch_no, - 'bom_no' : d.bom_no, - 'expense_account' : d.expense_account, - 'cost_center' : d.cost_center, - 'company' : frm.doc.company, - 'qty' : d.qty, - 'voucher_type' : frm.doc.doctype, - 'voucher_no' : d.name, - 'allow_zero_valuation': 1, + item_code: d.item_code, + warehouse: cstr(d.s_warehouse) || cstr(d.t_warehouse), + transfer_qty: d.transfer_qty, + serial_no: d.serial_no, + batch_no: d.batch_no, + bom_no: d.bom_no, + expense_account: d.expense_account, + cost_center: d.cost_center, + company: frm.doc.company, + qty: d.qty, + voucher_type: frm.doc.doctype, + voucher_no: d.name, + allow_zero_valuation: 1, }; return frappe.call({ doc: frm.doc, method: "get_item_details", args: args, - callback: function(r) { - if(r.message) { + callback: function (r) { + if (r.message) { var d = locals[cdt][cdn]; - $.each(r.message, function(k, v) { + $.each(r.message, function (k, v) { if (v) { frappe.model.set_value(cdt, cdn, k, v); // qty and it's subsequent fields weren't triggered } @@ -793,14 +894,18 @@ frappe.ui.form.on('Stock Entry Detail', { no_batch_serial_number_value = true; } - if (no_batch_serial_number_value && !frappe.flags.hide_serial_batch_dialog && !frappe.flags.dialog_set) { + if ( + no_batch_serial_number_value && + !frappe.flags.hide_serial_batch_dialog && + !frappe.flags.dialog_set + ) { frappe.flags.dialog_set = true; erpnext.stock.select_batch_and_serial_no(frm, d); } else { frappe.flags.dialog_set = false; } } - } + }, }); } }, @@ -824,36 +929,35 @@ frappe.ui.form.on('Stock Entry Detail', { add_serial_batch_bundle(frm, cdt, cdn) { var child = locals[cdt][cdn]; erpnext.stock.select_batch_and_serial_no(frm, child); - } + }, }); -var validate_sample_quantity = function(frm, cdt, cdn) { +var validate_sample_quantity = function (frm, cdt, cdn) { var d = locals[cdt][cdn]; if (d.sample_quantity && frm.doc.purpose == "Material Receipt") { frappe.call({ - method: 'erpnext.stock.doctype.stock_entry.stock_entry.validate_sample_quantity', + method: "erpnext.stock.doctype.stock_entry.stock_entry.validate_sample_quantity", args: { batch_no: d.batch_no, item_code: d.item_code, sample_quantity: d.sample_quantity, - qty: d.transfer_qty + qty: d.transfer_qty, }, callback: (r) => { frappe.model.set_value(cdt, cdn, "sample_quantity", r.message); - } + }, }); } }; -frappe.ui.form.on('Landed Cost Taxes and Charges', { - amount: function(frm, cdt, cdn) { +frappe.ui.form.on("Landed Cost Taxes and Charges", { + amount: function (frm, cdt, cdn) { frm.events.set_base_amount(frm, cdt, cdn); - }, - expense_account: function(frm, cdt, cdn) { + expense_account: function (frm, cdt, cdn) { frm.events.set_account_currency(frm, cdt, cdn); - } + }, }); erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockController { @@ -862,69 +966,68 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle this.setup_posting_date_time_check(); - this.frm.fields_dict.bom_no.get_query = function() { + this.frm.fields_dict.bom_no.get_query = function () { return { - filters:{ - "docstatus": 1, - "is_active": 1 - } + filters: { + docstatus: 1, + is_active: 1, + }, }; }; - this.frm.fields_dict.items.grid.get_field('item_code').get_query = function() { - return erpnext.queries.item({is_stock_item: 1}); + this.frm.fields_dict.items.grid.get_field("item_code").get_query = function () { + return erpnext.queries.item({ is_stock_item: 1 }); }; - this.frm.set_query("purchase_order", function() { + this.frm.set_query("purchase_order", function () { return { - "filters": { - "docstatus": 1, - "is_old_subcontracting_flow": 1, - "company": me.frm.doc.company - } + filters: { + docstatus: 1, + is_old_subcontracting_flow: 1, + company: me.frm.doc.company, + }, }; }); - this.frm.set_query("subcontracting_order", function() { + this.frm.set_query("subcontracting_order", function () { return { - "filters": { - "docstatus": 1, - "company": me.frm.doc.company, - "status": ["not in", ["Completed", "Closed"]] - } + filters: { + docstatus: 1, + company: me.frm.doc.company, + status: ["not in", ["Completed", "Closed"]], + }, }; }); - if(me.frm.doc.company && erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { + if (me.frm.doc.company && erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); } - this.frm.fields_dict.items.grid.get_field('expense_account').get_query = function() { + this.frm.fields_dict.items.grid.get_field("expense_account").get_query = function () { if (erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { return { filters: { - "company": me.frm.doc.company, - "is_group": 0 - } - } + company: me.frm.doc.company, + is_group: 0, + }, + }; } - } + }; if (me.frm.doc.purchase_order) { this.frm.add_fetch("purchase_order", "supplier", "supplier"); - } - else { + } else { this.frm.add_fetch("subcontracting_order", "supplier", "supplier"); } - frappe.dynamic_link = { doc: this.frm.doc, fieldname: 'supplier', doctype: 'Supplier' } - this.frm.set_query("supplier_address", erpnext.queries.address_query) + frappe.dynamic_link = { doc: this.frm.doc, fieldname: "supplier", doctype: "Supplier" }; + this.frm.set_query("supplier_address", erpnext.queries.address_query); } onload_post_render() { var me = this; - this.set_default_account(function() { - if(me.frm.doc.__islocal && me.frm.doc.company && !me.frm.doc.amended_from) { + this.set_default_account(function () { + if (me.frm.doc.__islocal && me.frm.doc.company && !me.frm.doc.amended_from) { me.frm.trigger("company"); } }); @@ -940,7 +1043,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle this.show_stock_ledger(); this.set_fields_onload_for_line_item(); erpnext.utils.view_serial_batch_nos(this.frm); - if (this.frm.doc.docstatus===1 && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { + if (this.frm.doc.docstatus === 1 && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { this.show_general_ledger(); } erpnext.hide_company(this.frm); @@ -952,7 +1055,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle if (item?.serial_no) { // Replace all occurences of comma with line feed - item.serial_no = item.serial_no.replace(/,/g, '\n'); + item.serial_no = item.serial_no.replace(/,/g, "\n"); item.conversion_factor = item.conversion_factor || 1; let valid_serial_nos = []; @@ -962,23 +1065,30 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle valid_serial_nos.push(serialnos[i]); } } - frappe.model.set_value(item.doctype, item.name, - "qty", valid_serial_nos.length / item.conversion_factor); + frappe.model.set_value( + item.doctype, + item.name, + "qty", + valid_serial_nos.length / item.conversion_factor + ); } } set_fields_onload_for_line_item() { - if (this.frm.is_new() && this.frm.doc?.items - && cint(frappe.user_defaults?.use_serial_batch_fields) === 1) { - this.frm.doc.items.forEach(item => { + if ( + this.frm.is_new() && + this.frm.doc?.items && + cint(frappe.user_defaults?.use_serial_batch_fields) === 1 + ) { + this.frm.doc.items.forEach((item) => { frappe.model.set_value(item.doctype, item.name, "use_serial_batch_fields", 1); - }) + }); } } scan_barcode() { frappe.flags.dialog_set = false; - const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm}); + const barcode_scanner = new erpnext.utils.BarcodeScanner({ frm: this.frm }); barcode_scanner.process_scan(); } @@ -993,32 +1103,35 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle set_default_account(callback) { var me = this; - if(this.frm.doc.company && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { + if (this.frm.doc.company && erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { return this.frm.call({ method: "erpnext.accounts.utils.get_company_default", args: { - "fieldname": "stock_adjustment_account", - "company": this.frm.doc.company + fieldname: "stock_adjustment_account", + company: this.frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (!r.exc) { - $.each(me.frm.doc.items || [], function(i, d) { - if(!d.expense_account) d.expense_account = r.message; + $.each(me.frm.doc.items || [], function (i, d) { + if (!d.expense_account) d.expense_account = r.message; }); - if(callback) callback(); + if (callback) callback(); } - } + }, }); } } clean_up() { // Clear Work Order record from locals, because it is updated via Stock Entry - if(this.frm.doc.work_order && - in_list(["Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture"], - this.frm.doc.purpose)) { - frappe.model.remove_from_locals("Work Order", - this.frm.doc.work_order); + if ( + this.frm.doc.work_order && + in_list( + ["Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture"], + this.frm.doc.purpose + ) + ) { + frappe.model.remove_from_locals("Work Order", this.frm.doc.work_order); } } @@ -1028,22 +1141,22 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle get_items() { var me = this; - if(!this.frm.doc.fg_completed_qty || !this.frm.doc.bom_no) + if (!this.frm.doc.fg_completed_qty || !this.frm.doc.bom_no) frappe.throw(__("BOM and Manufacturing Quantity are required")); - if(this.frm.doc.work_order || this.frm.doc.bom_no) { + if (this.frm.doc.work_order || this.frm.doc.bom_no) { // if work order / bom is mentioned, get items return this.frm.call({ doc: me.frm.doc, freeze: true, method: "get_items", - callback: function(r) { - if(!r.exc) refresh_field("items"); - if(me.frm.doc.bom_no) { + callback: function (r) { + if (!r.exc) refresh_field("items"); + if (me.frm.doc.bom_no) { attach_bom_items(me.frm.doc.bom_no); erpnext.accounts.dimensions.update_dimension(me.frm, me.frm.doctype); } - } + }, }); } } @@ -1051,7 +1164,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle work_order() { var me = this; this.toggle_enable_bom(); - if(!me.frm.doc.work_order || me.frm.doc.job_card) { + if (!me.frm.doc.work_order || me.frm.doc.job_card) { return; } @@ -1059,27 +1172,34 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle method: "erpnext.stock.doctype.stock_entry.stock_entry.get_work_order_details", args: { work_order: me.frm.doc.work_order, - company: me.frm.doc.company + company: me.frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (!r.exc) { - $.each(["from_bom", "bom_no", "fg_completed_qty", "use_multi_level_bom"], function(i, field) { - me.frm.set_value(field, r.message[field]); - }) + $.each( + ["from_bom", "bom_no", "fg_completed_qty", "use_multi_level_bom"], + function (i, field) { + me.frm.set_value(field, r.message[field]); + } + ); if (me.frm.doc.purpose == "Material Transfer for Manufacture" && !me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["wip_warehouse"]); - - if (me.frm.doc.purpose == "Manufacture" || me.frm.doc.purpose == "Material Consumption for Manufacture" ) { + if ( + me.frm.doc.purpose == "Manufacture" || + me.frm.doc.purpose == "Material Consumption for Manufacture" + ) { if (me.frm.doc.purpose == "Manufacture") { - if (!me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["fg_warehouse"]); + if (!me.frm.doc.to_warehouse) + me.frm.set_value("to_warehouse", r.message["fg_warehouse"]); } - if (!me.frm.doc.from_warehouse) me.frm.set_value("from_warehouse", r.message["wip_warehouse"]); + if (!me.frm.doc.from_warehouse) + me.frm.set_value("from_warehouse", r.message["wip_warehouse"]); } me.get_items(); } - } + }, }); } @@ -1088,13 +1208,17 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle } add_excise_button() { - if(frappe.boot.sysdefaults.country === "India") - this.frm.add_custom_button(__("Excise Invoice"), function() { - var excise = frappe.model.make_new_doc_and_get_name('Journal Entry'); - excise = locals['Journal Entry'][excise]; - excise.voucher_type = 'Excise Entry'; - frappe.set_route('Form', 'Journal Entry', excise.name); - }, __('Create')); + if (frappe.boot.sysdefaults.country === "India") + this.frm.add_custom_button( + __("Excise Invoice"), + function () { + var excise = frappe.model.make_new_doc_and_get_name("Journal Entry"); + excise = locals["Journal Entry"][excise]; + excise.voucher_type = "Excise Entry"; + frappe.set_route("Form", "Journal Entry", excise.name); + }, + __("Create") + ); } items_add(doc, cdt, cdn) { @@ -1104,8 +1228,8 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle this.frm.script_manager.copy_from_first_row("items", row, ["expense_account", "cost_center"]); } - if(!row.s_warehouse) row.s_warehouse = this.frm.doc.from_warehouse; - if(!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse; + if (!row.s_warehouse) row.s_warehouse = this.frm.doc.from_warehouse; + if (!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse; if (cint(frappe.user_defaults?.use_serial_batch_fields)) { frappe.model.set_value(row.doctype, row.name, "use_serial_batch_fields", 1); @@ -1113,7 +1237,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle } from_warehouse(doc) { - this.frm.trigger('set_transit_warehouse'); + this.frm.trigger("set_transit_warehouse"); this.set_warehouse_in_children(doc.items, "s_warehouse", doc.from_warehouse); } @@ -1131,32 +1255,54 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle } toggle_related_fields(doc) { - this.frm.toggle_enable("from_warehouse", doc.purpose!='Material Receipt'); - this.frm.toggle_enable("to_warehouse", doc.purpose!='Material Issue'); + this.frm.toggle_enable("from_warehouse", doc.purpose != "Material Receipt"); + this.frm.toggle_enable("to_warehouse", doc.purpose != "Material Issue"); - this.frm.fields_dict["items"].grid.set_column_disp("retain_sample", doc.purpose=='Material Receipt'); - this.frm.fields_dict["items"].grid.set_column_disp("sample_quantity", doc.purpose=='Material Receipt'); + this.frm.fields_dict["items"].grid.set_column_disp( + "retain_sample", + doc.purpose == "Material Receipt" + ); + this.frm.fields_dict["items"].grid.set_column_disp( + "sample_quantity", + doc.purpose == "Material Receipt" + ); this.frm.cscript.toggle_enable_bom(); - if (doc.purpose == 'Send to Subcontractor') { - doc.customer = doc.customer_name = doc.customer_address = - doc.delivery_note_no = doc.sales_invoice_no = null; + if (doc.purpose == "Send to Subcontractor") { + doc.customer = + doc.customer_name = + doc.customer_address = + doc.delivery_note_no = + doc.sales_invoice_no = + null; } else { - doc.customer = doc.customer_name = doc.customer_address = - doc.delivery_note_no = doc.sales_invoice_no = doc.supplier = - doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no = - doc.address_display = null; + doc.customer = + doc.customer_name = + doc.customer_address = + doc.delivery_note_no = + doc.sales_invoice_no = + doc.supplier = + doc.supplier_name = + doc.supplier_address = + doc.purchase_receipt_no = + doc.address_display = + null; } - if(doc.purpose == "Material Receipt") { + if (doc.purpose == "Material Receipt") { this.frm.set_value("from_bom", 0); } // Addition costs based on purpose - this.frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"], - doc.purpose!='Material Issue'); + this.frm.toggle_display( + ["additional_costs", "total_additional_costs", "additional_costs_section"], + doc.purpose != "Material Issue" + ); - this.frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue'); + this.frm.fields_dict["items"].grid.set_column_disp( + "additional_cost", + doc.purpose != "Material Issue" + ); } supplier(doc) { @@ -1167,50 +1313,46 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle erpnext.stock.select_batch_and_serial_no = (frm, item) => { let path = "assets/erpnext/js/utils/serial_no_batch_selector.js"; - frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]) - .then((r) => { - if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { - item.has_serial_no = r.message.has_serial_no; - item.has_batch_no = r.message.has_batch_no; - item.type_of_transaction = item.s_warehouse ? "Outward" : "Inward"; + frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"]).then((r) => { + if (r.message && (r.message.has_batch_no || r.message.has_serial_no)) { + item.has_serial_no = r.message.has_serial_no; + item.has_batch_no = r.message.has_batch_no; + item.type_of_transaction = item.s_warehouse ? "Outward" : "Inward"; - frappe.require(path, function() { - new erpnext.SerialBatchPackageSelector( - frm, item, (r) => { - if (r) { - frappe.model.set_value(item.doctype, item.name, { - "serial_and_batch_bundle": r.name, - "use_serial_batch_fields": 0, - "qty": Math.abs(r.total_qty) / flt(item.conversion_factor || 1, precision("conversion_factor", item)) - }); - } - } - ); + frappe.require(path, function () { + new erpnext.SerialBatchPackageSelector(frm, item, (r) => { + if (r) { + frappe.model.set_value(item.doctype, item.name, { + serial_and_batch_bundle: r.name, + use_serial_batch_fields: 0, + qty: + Math.abs(r.total_qty) / + flt(item.conversion_factor || 1, precision("conversion_factor", item)), + }); + } }); - } - }); -} + }); + } + }); +}; function attach_bom_items(bom_no) { if (!bom_no) { - return + return; } - if (check_should_not_attach_bom_items(bom_no)) return - frappe.db.get_doc("BOM",bom_no).then(bom => { - const {name, items} = bom - erpnext.stock.bom = {name, items:{}} - items.forEach(item => { + if (check_should_not_attach_bom_items(bom_no)) return; + frappe.db.get_doc("BOM", bom_no).then((bom) => { + const { name, items } = bom; + erpnext.stock.bom = { name, items: {} }; + items.forEach((item) => { erpnext.stock.bom.items[item.item_code] = item; }); }); } function check_should_not_attach_bom_items(bom_no) { - return ( - bom_no === undefined || - (erpnext.stock.bom && erpnext.stock.bom.name === bom_no) - ); + return bom_no === undefined || (erpnext.stock.bom && erpnext.stock.bom.name === bom_no); } -extend_cscript(cur_frm.cscript, new erpnext.stock.StockEntry({frm: cur_frm})); +extend_cscript(cur_frm.cscript, new erpnext.stock.StockEntry({ frm: cur_frm })); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_list.js b/erpnext/stock/doctype/stock_entry/stock_entry_list.js index af29d495ff7..8a1c808cd91 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry_list.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry_list.js @@ -1,19 +1,25 @@ -frappe.listview_settings['Stock Entry'] = { - add_fields: ["`tabStock Entry`.`from_warehouse`", "`tabStock Entry`.`to_warehouse`", - "`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`", - "`tabStock Entry`.`is_return`"], +frappe.listview_settings["Stock Entry"] = { + add_fields: [ + "`tabStock Entry`.`from_warehouse`", + "`tabStock Entry`.`to_warehouse`", + "`tabStock Entry`.`purpose`", + "`tabStock Entry`.`work_order`", + "`tabStock Entry`.`bom_no`", + "`tabStock Entry`.`is_return`", + ], get_indicator: function (doc) { - if(doc.is_return===1 && doc.purpose === "Material Transfer for Manufacture") { - return [__("Material Returned from WIP"), "orange", - "is_return,=,1|purpose,=,Material Transfer for Manufacture|docstatus,<,2"]; + if (doc.is_return === 1 && doc.purpose === "Material Transfer for Manufacture") { + return [ + __("Material Returned from WIP"), + "orange", + "is_return,=,1|purpose,=,Material Transfer for Manufacture|docstatus,<,2", + ]; } else if (doc.docstatus === 0) { return [__("Draft"), "red", "docstatus,=,0"]; - - } else if (doc.purpose === 'Send to Warehouse' && doc.per_transferred < 100) { + } else if (doc.purpose === "Send to Warehouse" && doc.per_transferred < 100) { // not delivered & overdue return [__("Goods In Transit"), "grey", "per_transferred,<,100"]; - - } else if (doc.purpose === 'Send to Warehouse' && doc.per_transferred === 100) { + } else if (doc.purpose === "Send to Warehouse" && doc.per_transferred === 100) { return [__("Goods Transferred"), "green", "per_transferred,=,100"]; } else if (doc.docstatus === 2) { return [__("Canceled"), "red", "docstatus,=,2"]; @@ -22,21 +28,30 @@ frappe.listview_settings['Stock Entry'] = { } }, column_render: { - "from_warehouse": function(doc) { + from_warehouse: function (doc) { var html = ""; - if(doc.from_warehouse) { - html += '' - +doc.from_warehouse+' '; + if (doc.from_warehouse) { + html += + '' + + doc.from_warehouse + + " "; } // if(doc.from_warehouse || doc.to_warehouse) { // html += ' '; // } - if(doc.to_warehouse) { - html += ''+doc.to_warehouse+''; + if (doc.to_warehouse) { + html += + '' + + doc.to_warehouse + + ""; } return html; - } - } + }, + }, }; diff --git a/erpnext/stock/doctype/stock_entry_type/stock_entry_type.js b/erpnext/stock/doctype/stock_entry_type/stock_entry_type.js index c554278334b..21e60fbcae4 100644 --- a/erpnext/stock/doctype/stock_entry_type/stock_entry_type.js +++ b/erpnext/stock/doctype/stock_entry_type/stock_entry_type.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Stock Entry Type', { +frappe.ui.form.on("Stock Entry Type", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.js b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.js index 23018aa615b..7196dc9f1e3 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.js +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.js @@ -1,8 +1,8 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Stock Ledger Entry', { - refresh: function(frm) { - frm.page.btn_secondary.hide() - } +frappe.ui.form.on("Stock Ledger Entry", { + refresh: function (frm) { + frm.page.btn_secondary.hide(); + }, }); diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index ba7f9c58a8b..4a85360235a 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -6,27 +6,27 @@ frappe.provide("erpnext.accounts.dimensions"); frappe.ui.form.on("Stock Reconciliation", { setup(frm) { - frm.ignore_doctypes_on_cancel_all = ['Serial and Batch Bundle']; + frm.ignore_doctypes_on_cancel_all = ["Serial and Batch Bundle"]; }, - onload: function(frm) { + onload: function (frm) { frm.add_fetch("item_code", "item_name", "item_name"); // end of life - frm.set_query("item_code", "items", function(doc, cdt, cdn) { + frm.set_query("item_code", "items", function (doc, cdt, cdn) { return { query: "erpnext.controllers.queries.item_query", - filters:{ - "is_stock_item": 1 - } - } + filters: { + is_stock_item: 1, + }, + }; }); - frm.set_query("batch_no", "items", function(doc, cdt, cdn) { + frm.set_query("batch_no", "items", function (doc, cdt, cdn) { var item = locals[cdt][cdn]; return { filters: { - 'item': item.item_code - } + item: item.item_code, + }, }; }); @@ -34,27 +34,27 @@ frappe.ui.form.on("Stock Reconciliation", { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ["in", [doc.name, ""]], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); - let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); + let sbb_field = frm.get_docfield("items", "serial_and_batch_bundle"); if (sbb_field) { sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'warehouse': row.doc.warehouse, - 'voucher_type': frm.doc.doctype, - } + item_code: row.doc.item_code, + warehouse: row.doc.warehouse, + voucher_type: frm.doc.doctype, + }; }; } if (frm.doc.company) { - erpnext.queries.setup_queries(frm, "Warehouse", function() { + erpnext.queries.setup_queries(frm, "Warehouse", function () { return erpnext.queries.warehouse(frm.doc); }); } @@ -66,57 +66,57 @@ frappe.ui.form.on("Stock Reconciliation", { erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); }, - company: function(frm) { + company: function (frm) { frm.trigger("toggle_display_account_head"); erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); }, - refresh: function(frm) { - if(frm.doc.docstatus < 1) { - frm.add_custom_button(__("Fetch Items from Warehouse"), function() { + refresh: function (frm) { + if (frm.doc.docstatus < 1) { + frm.add_custom_button(__("Fetch Items from Warehouse"), function () { frm.events.get_items(frm); }); } - if(frm.doc.company) { + if (frm.doc.company) { frm.trigger("toggle_display_account_head"); } }, - scan_barcode: function(frm) { - const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:frm}); + scan_barcode: function (frm) { + const barcode_scanner = new erpnext.utils.BarcodeScanner({ frm: frm }); barcode_scanner.process_scan(); }, - scan_mode: function(frm) { + scan_mode: function (frm) { if (frm.doc.scan_mode) { frappe.show_alert({ message: __("Scan mode enabled, existing quantity will not be fetched."), - indicator: "green" + indicator: "green", }); } }, - set_warehouse: function(frm) { - let transaction_controller = new erpnext.TransactionController({frm:frm}); + set_warehouse: function (frm) { + let transaction_controller = new erpnext.TransactionController({ frm: frm }); transaction_controller.autofill_warehouse(frm.doc.items, "warehouse", frm.doc.set_warehouse); }, - get_items: function(frm) { + get_items: function (frm) { let fields = [ { - label: 'Warehouse', - fieldname: 'warehouse', - fieldtype: 'Link', - options: 'Warehouse', + label: "Warehouse", + fieldname: "warehouse", + fieldtype: "Link", + options: "Warehouse", reqd: 1, - "get_query": function() { + get_query: function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; - } + }, }, { label: "Item Code", @@ -127,57 +127,62 @@ frappe.ui.form.on("Stock Reconciliation", { { label: __("Ignore Empty Stock"), fieldname: "ignore_empty_stock", - fieldtype: "Check" - } + fieldtype: "Check", + }, ]; - frappe.prompt(fields, function(data) { - frappe.call({ - method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items", - args: { - warehouse: data.warehouse, - posting_date: frm.doc.posting_date, - posting_time: frm.doc.posting_time, - company: frm.doc.company, - item_code: data.item_code, - ignore_empty_stock: data.ignore_empty_stock - }, - callback: function(r) { - if (r.exc || !r.message || !r.message.length) return; + frappe.prompt( + fields, + function (data) { + frappe.call({ + method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items", + args: { + warehouse: data.warehouse, + posting_date: frm.doc.posting_date, + posting_time: frm.doc.posting_time, + company: frm.doc.company, + item_code: data.item_code, + ignore_empty_stock: data.ignore_empty_stock, + }, + callback: function (r) { + if (r.exc || !r.message || !r.message.length) return; - frm.clear_table("items"); + frm.clear_table("items"); - r.message.forEach((row) => { - let item = frm.add_child("items"); - $.extend(item, row); + r.message.forEach((row) => { + let item = frm.add_child("items"); + $.extend(item, row); - item.qty = item.qty || 0; - item.valuation_rate = item.valuation_rate || 0; - }); - frm.refresh_field("items"); - } - }); - }, __("Get Items"), __("Update")); + item.qty = item.qty || 0; + item.valuation_rate = item.valuation_rate || 0; + }); + frm.refresh_field("items"); + }, + }); + }, + __("Get Items"), + __("Update") + ); }, - posting_date: function(frm) { + posting_date: function (frm) { frm.trigger("set_valuation_rate_and_qty_for_all_items"); }, - posting_time: function(frm) { + posting_time: function (frm) { frm.trigger("set_valuation_rate_and_qty_for_all_items"); }, - set_valuation_rate_and_qty_for_all_items: function(frm) { - frm.doc.items.forEach(row => { + set_valuation_rate_and_qty_for_all_items: function (frm) { + frm.doc.items.forEach((row) => { frm.events.set_valuation_rate_and_qty(frm, row.doctype, row.name); }); }, - set_valuation_rate_and_qty: function(frm, cdt, cdn) { + set_valuation_rate_and_qty: function (frm, cdt, cdn) { var d = frappe.model.get_doc(cdt, cdn); - if(d.item_code && d.warehouse) { + if (d.item_code && d.warehouse) { frappe.call({ method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_stock_balance_for", args: { @@ -185,9 +190,9 @@ frappe.ui.form.on("Stock Reconciliation", { warehouse: d.warehouse, posting_date: frm.doc.posting_date, posting_time: frm.doc.posting_time, - batch_no: d.batch_no + batch_no: d.batch_no, }, - callback: function(r) { + callback: function (r) { const row = frappe.model.get_doc(cdt, cdn); if (!frm.doc.scan_mode) { frappe.model.set_value(cdt, cdn, "qty", r.message.qty); @@ -198,17 +203,22 @@ frappe.ui.form.on("Stock Reconciliation", { frappe.model.set_value(cdt, cdn, "current_amount", r.message.rate * r.message.qty); frappe.model.set_value(cdt, cdn, "amount", row.qty * row.valuation_rate); frappe.model.set_value(cdt, cdn, "current_serial_no", r.message.serial_nos); - frappe.model.set_value(cdt, cdn, "use_serial_batch_fields", r.message.use_serial_batch_fields); + frappe.model.set_value( + cdt, + cdn, + "use_serial_batch_fields", + r.message.use_serial_batch_fields + ); if (frm.doc.purpose == "Stock Reconciliation" && !frm.doc.scan_mode) { frappe.model.set_value(cdt, cdn, "serial_no", r.message.serial_nos); } - } + }, }); } }, - set_amount_quantity: function(doc, cdt, cdn) { + set_amount_quantity: function (doc, cdt, cdn) { var d = frappe.model.get_doc(cdt, cdn); if (d.qty && d.valuation_rate) { frappe.model.set_value(cdt, cdn, "amount", flt(d.qty) * flt(d.valuation_rate)); @@ -216,34 +226,35 @@ frappe.ui.form.on("Stock Reconciliation", { frappe.model.set_value(cdt, cdn, "amount_difference", flt(d.amount) - flt(d.current_amount)); } }, - toggle_display_account_head: function(frm) { - frm.toggle_display(['expense_account', 'cost_center'], - erpnext.is_perpetual_inventory_enabled(frm.doc.company)); + toggle_display_account_head: function (frm) { + frm.toggle_display( + ["expense_account", "cost_center"], + erpnext.is_perpetual_inventory_enabled(frm.doc.company) + ); }, - purpose: function(frm) { + purpose: function (frm) { frm.trigger("set_expense_account"); }, - set_expense_account: function(frm) { + set_expense_account: function (frm) { if (frm.doc.company && erpnext.is_perpetual_inventory_enabled(frm.doc.company)) { return frm.call({ method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_difference_account", args: { - "purpose": frm.doc.purpose, - "company": frm.doc.company + purpose: frm.doc.purpose, + company: frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (!r.exc) { frm.set_value("expense_account", r.message); } - } + }, }); } - } + }, }); frappe.ui.form.on("Stock Reconciliation Item", { - - warehouse: function(frm, cdt, cdn) { + warehouse: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.batch_no && !frm.doc.scan_mode) { frappe.model.set_value(child.cdt, child.cdn, "batch_no", ""); @@ -252,7 +263,7 @@ frappe.ui.form.on("Stock Reconciliation Item", { frm.events.set_valuation_rate_and_qty(frm, cdt, cdn); }, - item_code: function(frm, cdt, cdn) { + item_code: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.batch_no && !frm.doc.scan_mode) { frappe.model.set_value(cdt, cdn, "batch_no", ""); @@ -261,28 +272,28 @@ frappe.ui.form.on("Stock Reconciliation Item", { frm.events.set_valuation_rate_and_qty(frm, cdt, cdn); }, - batch_no: function(frm, cdt, cdn) { + batch_no: function (frm, cdt, cdn) { frm.events.set_valuation_rate_and_qty(frm, cdt, cdn); }, - qty: function(frm, cdt, cdn) { + qty: function (frm, cdt, cdn) { frm.events.set_amount_quantity(frm, cdt, cdn); }, - valuation_rate: function(frm, cdt, cdn) { + valuation_rate: function (frm, cdt, cdn) { frm.events.set_amount_quantity(frm, cdt, cdn); }, - serial_no: function(frm, cdt, cdn) { + serial_no: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.serial_no) { - const serial_nos = child.serial_no.trim().split('\n'); + const serial_nos = child.serial_no.trim().split("\n"); frappe.model.set_value(cdt, cdn, "qty", serial_nos.length); } }, - items_add: function(frm, cdt, cdn) { + items_add: function (frm, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); if (!item.warehouse && frm.doc.set_warehouse) { frappe.model.set_value(cdt, cdn, "warehouse", frm.doc.set_warehouse); @@ -291,8 +302,7 @@ frappe.ui.form.on("Stock Reconciliation Item", { add_serial_batch_bundle(frm, cdt, cdn) { erpnext.utils.pick_serial_and_batch_bundle(frm, cdt, cdn, "Inward"); - } - + }, }); erpnext.stock.StockReconciliation = class StockReconciliation extends erpnext.stock.StockController { @@ -304,30 +314,30 @@ erpnext.stock.StockReconciliation = class StockReconciliation extends erpnext.st if (me.frm.doc.company && erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { this.frm.add_fetch("company", "cost_center", "cost_center"); } - this.frm.fields_dict["expense_account"].get_query = function() { - if(erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { + this.frm.fields_dict["expense_account"].get_query = function () { + if (erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { return { - "filters": { - 'company': me.frm.doc.company, - "is_group": 0 - } - } + filters: { + company: me.frm.doc.company, + is_group: 0, + }, + }; } - } - this.frm.fields_dict["cost_center"].get_query = function() { - if(erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { + }; + this.frm.fields_dict["cost_center"].get_query = function () { + if (erpnext.is_perpetual_inventory_enabled(me.frm.doc.company)) { return { - "filters": { - 'company': me.frm.doc.company, - "is_group": 0 - } - } + filters: { + company: me.frm.doc.company, + is_group: 0, + }, + }; } - } + }; } refresh() { - if(this.frm.doc.docstatus > 0) { + if (this.frm.doc.docstatus > 0) { this.show_stock_ledger(); erpnext.utils.view_serial_batch_nos(this.frm); if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { @@ -335,7 +345,6 @@ erpnext.stock.StockReconciliation = class StockReconciliation extends erpnext.st } } } - }; -cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm}); +cur_frm.cscript = new erpnext.stock.StockReconciliation({ frm: cur_frm }); diff --git a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.js b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.js index 5f81679bade..e8c14372416 100644 --- a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.js +++ b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.js @@ -1,23 +1,23 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Stock Reposting Settings', { - refresh: function(frm) { - frm.trigger('convert_to_item_based_reposting'); +frappe.ui.form.on("Stock Reposting Settings", { + refresh: function (frm) { + frm.trigger("convert_to_item_based_reposting"); }, - convert_to_item_based_reposting: function(frm) { - frm.add_custom_button(__('Convert to Item Based Reposting'), function() { + convert_to_item_based_reposting: function (frm) { + frm.add_custom_button(__("Convert to Item Based Reposting"), function () { frm.call({ - method: 'convert_to_item_wh_reposting', + method: "convert_to_item_wh_reposting", frezz: true, doc: frm.doc, - callback: function(r) { + callback: function (r) { if (!r.exc) { frm.reload_doc(); } - } - }) - }) - } + }, + }); + }); + }, }); diff --git a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.js b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.js index f60a0378b60..a8d56b41a99 100644 --- a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.js +++ b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.js @@ -1,43 +1,43 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Stock Reservation Entry', { +frappe.ui.form.on("Stock Reservation Entry", { refresh(frm) { - frm.trigger('set_queries'); - frm.trigger('toggle_read_only_fields'); - frm.trigger('hide_rate_related_fields'); - frm.trigger('hide_primary_action_button'); - frm.trigger('make_sb_entries_warehouse_read_only'); + frm.trigger("set_queries"); + frm.trigger("toggle_read_only_fields"); + frm.trigger("hide_rate_related_fields"); + frm.trigger("hide_primary_action_button"); + frm.trigger("make_sb_entries_warehouse_read_only"); }, has_serial_no(frm) { - frm.trigger('toggle_read_only_fields'); + frm.trigger("toggle_read_only_fields"); }, has_batch_no(frm) { - frm.trigger('toggle_read_only_fields'); + frm.trigger("toggle_read_only_fields"); }, warehouse(frm) { if (frm.doc.warehouse) { frm.doc.sb_entries.forEach((row) => { - frappe.model.set_value(row.doctype, row.name, 'warehouse', frm.doc.warehouse); + frappe.model.set_value(row.doctype, row.name, "warehouse", frm.doc.warehouse); }); } }, set_queries(frm) { - frm.set_query('warehouse', () => { + frm.set_query("warehouse", () => { return { filters: { - 'is_group': 0, - 'company': frm.doc.company, - } + is_group: 0, + company: frm.doc.company, + }, }; }); - frm.set_query('serial_no', 'sb_entries', function(doc, cdt, cdn) { - var selected_serial_nos = doc.sb_entries.map(row => { + frm.set_query("serial_no", "sb_entries", function (doc, cdt, cdn) { + var selected_serial_nos = doc.sb_entries.map((row) => { return row.serial_no; }); var row = locals[cdt][cdn]; @@ -45,82 +45,86 @@ frappe.ui.form.on('Stock Reservation Entry', { filters: { item_code: doc.item_code, warehouse: row.warehouse, - status: 'Active', - name: ['not in', selected_serial_nos], - } - } + status: "Active", + name: ["not in", selected_serial_nos], + }, + }; }); - frm.set_query('batch_no', 'sb_entries', function(doc, cdt, cdn) { + frm.set_query("batch_no", "sb_entries", function (doc, cdt, cdn) { let filters = { item: doc.item_code, - batch_qty: ['>', 0], + batch_qty: [">", 0], disabled: 0, - } + }; if (!doc.has_serial_no) { - var selected_batch_nos = doc.sb_entries.map(row => { + var selected_batch_nos = doc.sb_entries.map((row) => { return row.batch_no; }); - filters.name = ['not in', selected_batch_nos]; + filters.name = ["not in", selected_batch_nos]; } - return { filters: filters } + return { filters: filters }; }); }, toggle_read_only_fields(frm) { if (frm.doc.has_serial_no) { - frm.doc.sb_entries.forEach(row => { + frm.doc.sb_entries.forEach((row) => { if (row.qty !== 1) { - frappe.model.set_value(row.doctype, row.name, 'qty', 1); + frappe.model.set_value(row.doctype, row.name, "qty", 1); } - }) + }); } frm.fields_dict.sb_entries.grid.update_docfield_property( - 'serial_no', 'read_only', !frm.doc.has_serial_no + "serial_no", + "read_only", + !frm.doc.has_serial_no ); frm.fields_dict.sb_entries.grid.update_docfield_property( - 'batch_no', 'read_only', !frm.doc.has_batch_no + "batch_no", + "read_only", + !frm.doc.has_batch_no ); // Qty will always be 1 for Serial No. - frm.fields_dict.sb_entries.grid.update_docfield_property( - 'qty', 'read_only', frm.doc.has_serial_no - ); + frm.fields_dict.sb_entries.grid.update_docfield_property("qty", "read_only", frm.doc.has_serial_no); - frm.set_df_property('sb_entries', 'allow_on_submit', frm.doc.from_voucher_type == "Pick List" ? 0 : 1); + frm.set_df_property( + "sb_entries", + "allow_on_submit", + frm.doc.from_voucher_type == "Pick List" ? 0 : 1 + ); }, hide_rate_related_fields(frm) { - ['incoming_rate', 'outgoing_rate', 'stock_value_difference', 'is_outward', 'stock_queue'].forEach(field => { - frm.fields_dict.sb_entries.grid.update_docfield_property( - field, 'hidden', 1 - ); - }); + ["incoming_rate", "outgoing_rate", "stock_value_difference", "is_outward", "stock_queue"].forEach( + (field) => { + frm.fields_dict.sb_entries.grid.update_docfield_property(field, "hidden", 1); + } + ); }, hide_primary_action_button(frm) { // Hide 'Amend' button on cancelled document if (frm.doc.docstatus == 2) { - frm.page.btn_primary.hide() + frm.page.btn_primary.hide(); } }, make_sb_entries_warehouse_read_only(frm) { - frm.fields_dict.sb_entries.grid.update_docfield_property( - 'warehouse', 'read_only', 1 - ); + frm.fields_dict.sb_entries.grid.update_docfield_property("warehouse", "read_only", 1); }, }); -frappe.ui.form.on('Serial and Batch Entry', { +frappe.ui.form.on("Serial and Batch Entry", { sb_entries_add(frm, cdt, cdn) { if (frm.doc.warehouse) { - frappe.model.set_value(cdt, cdn, 'warehouse', frm.doc.warehouse); + frappe.model.set_value(cdt, cdn, "warehouse", frm.doc.warehouse); } }, -}); \ No newline at end of file +}); diff --git a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry_list.js b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry_list.js index 5b390f7f1c0..d2194a486c3 100644 --- a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry_list.js +++ b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry_list.js @@ -1,17 +1,17 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.listview_settings['Stock Reservation Entry'] = { +frappe.listview_settings["Stock Reservation Entry"] = { get_indicator: function (doc) { const status_colors = { - 'Draft': 'red', - 'Partially Reserved': 'orange', - 'Reserved': 'blue', - 'Partially Delivered': 'purple', - 'Delivered': 'green', - 'Cancelled': 'red', + Draft: "red", + "Partially Reserved": "orange", + Reserved: "blue", + "Partially Delivered": "purple", + Delivered: "green", + Cancelled: "red", }; - return [__(doc.status), status_colors[doc.status], 'status,=,' + doc.status]; + return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; }, -}; \ No newline at end of file +}; diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 89ac4b5fc90..1972b193732 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -1,29 +1,31 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Stock Settings', { - refresh: function(frm) { - let filters = function() { +frappe.ui.form.on("Stock Settings", { + refresh: function (frm) { + let filters = function () { return { - filters : { - is_group : 0 - } + filters: { + is_group: 0, + }, }; }; frm.set_query("default_warehouse", filters); frm.set_query("sample_retention_warehouse", filters); }, - allow_negative_stock: function(frm) { + allow_negative_stock: function (frm) { if (!frm.doc.allow_negative_stock) { return; } - let msg = __("Using negative stock disables FIFO/Moving average valuation when inventory is negative."); + let msg = __( + "Using negative stock disables FIFO/Moving average valuation when inventory is negative." + ); msg += " "; - msg += __("This is considered dangerous from accounting point of view.") + msg += __("This is considered dangerous from accounting point of view."); msg += "
      "; - msg += ("Do you still want to enable negative inventory?"); + msg += "Do you still want to enable negative inventory?"; frappe.confirm( msg, @@ -32,5 +34,5 @@ frappe.ui.form.on('Stock Settings', { frm.set_value("allow_negative_stock", 0); } ); - } + }, }); diff --git a/erpnext/stock/doctype/uom_category/uom_category.js b/erpnext/stock/doctype/uom_category/uom_category.js index 48026da1bed..b53190f7482 100644 --- a/erpnext/stock/doctype/uom_category/uom_category.js +++ b/erpnext/stock/doctype/uom_category/uom_category.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('UOM Category', { - refresh: function() { - - } +frappe.ui.form.on("UOM Category", { + refresh: function () {}, }); diff --git a/erpnext/stock/doctype/variant_field/variant_field.js b/erpnext/stock/doctype/variant_field/variant_field.js index 13db3f9272d..8455d912531 100644 --- a/erpnext/stock/doctype/variant_field/variant_field.js +++ b/erpnext/stock/doctype/variant_field/variant_field.js @@ -1,8 +1,6 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Variant Field', { - refresh: function() { - - } +frappe.ui.form.on("Variant Field", { + refresh: function () {}, }); diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 3819c0b24a1..195ecb646a2 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -35,18 +35,15 @@ frappe.ui.form.on("Warehouse", { refresh: function (frm) { frm.toggle_display("warehouse_name", frm.doc.__islocal); - frm.toggle_display( - ["address_html", "contact_html"], - !frm.doc.__islocal - ); + frm.toggle_display(["address_html", "contact_html"], !frm.doc.__islocal); if (!frm.is_new()) { frappe.contacts.render_address_and_contact(frm); let enable_toggle = frm.doc.disabled ? "Enable" : "Disable"; frm.add_custom_button(__(enable_toggle), () => { - frm.set_value('disabled', 1 - frm.doc.disabled); - frm.save() + frm.set_value("disabled", 1 - frm.doc.disabled); + frm.save(); }); frm.add_custom_button(__("Stock Balance"), function () { @@ -61,25 +58,20 @@ frappe.ui.form.on("Warehouse", { : __("Convert to Group", null, "Warehouse"), function () { convert_to_group_or_ledger(frm); - }, + } ); - } else { frappe.contacts.clear_address_and_contact(frm); } - if (!frm.doc.is_group && frm.doc.__onload && frm.doc.__onload.account) { - frm.add_custom_button( - __("General Ledger", null, "Warehouse"), - function () { - frappe.route_options = { - account: frm.doc.__onload.account, - company: frm.doc.company, - }; - frappe.set_route("query-report", "General Ledger"); - } - ); + frm.add_custom_button(__("General Ledger", null, "Warehouse"), function () { + frappe.route_options = { + account: frm.doc.__onload.account, + company: frm.doc.company, + }; + frappe.set_route("query-report", "General Ledger"); + }); } frm.toggle_enable(["is_group", "company"], false); diff --git a/erpnext/stock/doctype/warehouse/warehouse_tree.js b/erpnext/stock/doctype/warehouse/warehouse_tree.js index eb635e6757d..d9070b33d10 100644 --- a/erpnext/stock/doctype/warehouse/warehouse_tree.js +++ b/erpnext/stock/doctype/warehouse/warehouse_tree.js @@ -1,20 +1,25 @@ -frappe.treeview_settings['Warehouse'] = { +frappe.treeview_settings["Warehouse"] = { get_tree_nodes: "erpnext.stock.doctype.warehouse.warehouse.get_children", add_tree_node: "erpnext.stock.doctype.warehouse.warehouse.add_node", get_tree_root: false, root_label: "Warehouses", - filters: [{ - fieldname: "company", - fieldtype:"Select", - options: erpnext.utils.get_tree_options("company"), - label: __("Company"), - default: erpnext.utils.get_tree_default("company") - }], - fields:[ - {fieldtype:'Data', fieldname: 'warehouse_name', - label:__('New Warehouse Name'), reqd:true}, - {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'), - description: __("Child nodes can be only created under 'Group' type nodes")} + filters: [ + { + fieldname: "company", + fieldtype: "Select", + options: erpnext.utils.get_tree_options("company"), + label: __("Company"), + default: erpnext.utils.get_tree_default("company"), + }, ], - ignore_fields:["parent_warehouse"], -} + fields: [ + { fieldtype: "Data", fieldname: "warehouse_name", label: __("New Warehouse Name"), reqd: true }, + { + fieldtype: "Check", + fieldname: "is_group", + label: __("Is Group"), + description: __("Child nodes can be only created under 'Group' type nodes"), + }, + ], + ignore_fields: ["parent_warehouse"], +}; diff --git a/erpnext/stock/doctype/warehouse_type/warehouse_type.js b/erpnext/stock/doctype/warehouse_type/warehouse_type.js index 4c4b89ce301..521b07a33d7 100644 --- a/erpnext/stock/doctype/warehouse_type/warehouse_type.js +++ b/erpnext/stock/doctype/warehouse_type/warehouse_type.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Warehouse Type', { +frappe.ui.form.on("Warehouse Type", { // refresh: function(frm) { - // } }); diff --git a/erpnext/stock/page/stock_balance/stock_balance.js b/erpnext/stock/page/stock_balance/stock_balance.js index 90b8d453420..a5fba9f98f3 100644 --- a/erpnext/stock/page/stock_balance/stock_balance.js +++ b/erpnext/stock/page/stock_balance/stock_balance.js @@ -1,103 +1,101 @@ -frappe.pages['stock-balance'].on_page_load = function(wrapper) { +frappe.pages["stock-balance"].on_page_load = function (wrapper) { var page = frappe.ui.make_app_page({ parent: wrapper, - title: __('Stock Summary'), - single_column: true + title: __("Stock Summary"), + single_column: true, }); page.start = 0; page.warehouse_field = page.add_field({ - fieldname: 'warehouse', - label: __('Warehouse'), - fieldtype:'Link', - options:'Warehouse', + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", default: frappe.route_options && frappe.route_options.warehouse, - change: function() { + change: function () { page.item_dashboard.start = 0; page.item_dashboard.refresh(); - } + }, }); page.item_field = page.add_field({ - fieldname: 'item_code', - label: __('Item'), - fieldtype:'Link', - options:'Item', + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", default: frappe.route_options && frappe.route_options.item_code, - change: function() { + change: function () { page.item_dashboard.start = 0; page.item_dashboard.refresh(); - } + }, }); page.item_group_field = page.add_field({ - fieldname: 'item_group', - label: __('Item Group'), - fieldtype:'Link', - options:'Item Group', + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + options: "Item Group", default: frappe.route_options && frappe.route_options.item_group, - change: function() { + change: function () { page.item_dashboard.start = 0; page.item_dashboard.refresh(); - } + }, }); page.sort_selector = new frappe.ui.SortSelector({ - parent: page.wrapper.find('.page-form'), + parent: page.wrapper.find(".page-form"), args: { - sort_by: 'projected_qty', - sort_order: 'asc', + sort_by: "projected_qty", + sort_order: "asc", options: [ - {fieldname: 'projected_qty', label: __('Projected qty')}, - {fieldname: 'reserved_qty', label: __('Reserved for sale')}, - {fieldname: 'reserved_qty_for_production', label: __('Reserved for manufacturing')}, - {fieldname: 'reserved_qty_for_sub_contract', label: __('Reserved for sub contracting')}, - {fieldname: 'actual_qty', label: __('Actual qty in stock')}, - ] + { fieldname: "projected_qty", label: __("Projected qty") }, + { fieldname: "reserved_qty", label: __("Reserved for sale") }, + { fieldname: "reserved_qty_for_production", label: __("Reserved for manufacturing") }, + { fieldname: "reserved_qty_for_sub_contract", label: __("Reserved for sub contracting") }, + { fieldname: "actual_qty", label: __("Actual qty in stock") }, + ], }, - change: function(sort_by, sort_order) { + change: function (sort_by, sort_order) { page.item_dashboard.sort_by = sort_by; page.item_dashboard.sort_order = sort_order; page.item_dashboard.start = 0; page.item_dashboard.refresh(); - } + }, }); // page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'}); - frappe.require('item-dashboard.bundle.js', function() { + frappe.require("item-dashboard.bundle.js", function () { page.item_dashboard = new erpnext.stock.ItemDashboard({ parent: page.main, page_length: 20, - method: 'erpnext.stock.dashboard.item_dashboard.get_data', - template: 'item_dashboard_list' - }) + method: "erpnext.stock.dashboard.item_dashboard.get_data", + template: "item_dashboard_list", + }); - page.item_dashboard.before_refresh = function() { + page.item_dashboard.before_refresh = function () { this.item_code = page.item_field.get_value(); this.warehouse = page.warehouse_field.get_value(); this.item_group = page.item_group_field.get_value(); - } + }; page.item_dashboard.refresh(); // item click - var setup_click = function(doctype) { - page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() { - var name = $(this).attr('data-name'); - var field = page[doctype.toLowerCase() + '_field']; - if(field.get_value()===name) { - frappe.set_route('Form', doctype, name) + var setup_click = function (doctype) { + page.main.on("click", 'a[data-type="' + doctype.toLowerCase() + '"]', function () { + var name = $(this).attr("data-name"); + var field = page[doctype.toLowerCase() + "_field"]; + if (field.get_value() === name) { + frappe.set_route("Form", doctype, name); } else { field.set_input(name); page.item_dashboard.refresh(); } }); - } + }; - setup_click('Item'); - setup_click('Warehouse'); + setup_click("Item"); + setup_click("Warehouse"); }); - - -} +}; diff --git a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js index c175a4ad648..b4502fc94a2 100644 --- a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js +++ b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js @@ -1,98 +1,98 @@ -frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) { +frappe.pages["warehouse-capacity-summary"].on_page_load = function (wrapper) { var page = frappe.ui.make_app_page({ parent: wrapper, - title: __('Warehouse Capacity Summary'), - single_column: true + title: __("Warehouse Capacity Summary"), + single_column: true, }); - page.set_secondary_action('Refresh', () => page.capacity_dashboard.refresh(), 'refresh'); + page.set_secondary_action("Refresh", () => page.capacity_dashboard.refresh(), "refresh"); page.start = 0; page.company_field = page.add_field({ - fieldname: 'company', - label: __('Company'), - fieldtype: 'Link', - options: 'Company', + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", reqd: 1, default: frappe.defaults.get_default("company"), - change: function() { + change: function () { page.capacity_dashboard.start = 0; page.capacity_dashboard.refresh(); - } + }, }); page.warehouse_field = page.add_field({ - fieldname: 'warehouse', - label: __('Warehouse'), - fieldtype: 'Link', - options: 'Warehouse', - change: function() { + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", + change: function () { page.capacity_dashboard.start = 0; page.capacity_dashboard.refresh(); - } + }, }); page.item_field = page.add_field({ - fieldname: 'item_code', - label: __('Item'), - fieldtype: 'Link', - options: 'Item', - change: function() { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", + change: function () { page.capacity_dashboard.start = 0; page.capacity_dashboard.refresh(); - } + }, }); page.parent_warehouse_field = page.add_field({ - fieldname: 'parent_warehouse', - label: __('Parent Warehouse'), - fieldtype: 'Link', - options: 'Warehouse', - get_query: function() { + fieldname: "parent_warehouse", + label: __("Parent Warehouse"), + fieldtype: "Link", + options: "Warehouse", + get_query: function () { return { filters: { - "is_group": 1 - } + is_group: 1, + }, }; }, - change: function() { + change: function () { page.capacity_dashboard.start = 0; page.capacity_dashboard.refresh(); - } + }, }); page.sort_selector = new frappe.ui.SortSelector({ - parent: page.wrapper.find('.page-form'), + parent: page.wrapper.find(".page-form"), args: { - sort_by: 'stock_capacity', - sort_order: 'desc', + sort_by: "stock_capacity", + sort_order: "desc", options: [ - {fieldname: 'stock_capacity', label: __('Capacity (Stock UOM)')}, - {fieldname: 'percent_occupied', label: __('% Occupied')}, - {fieldname: 'actual_qty', label: __('Balance Qty (Stock)')} - ] + { fieldname: "stock_capacity", label: __("Capacity (Stock UOM)") }, + { fieldname: "percent_occupied", label: __("% Occupied") }, + { fieldname: "actual_qty", label: __("Balance Qty (Stock)") }, + ], }, - change: function(sort_by, sort_order) { + change: function (sort_by, sort_order) { page.capacity_dashboard.sort_by = sort_by; page.capacity_dashboard.sort_order = sort_order; page.capacity_dashboard.start = 0; page.capacity_dashboard.refresh(); - } + }, }); - frappe.require('item-dashboard.bundle.js', function() { - $(frappe.render_template('warehouse_capacity_summary_header')).appendTo(page.main); + frappe.require("item-dashboard.bundle.js", function () { + $(frappe.render_template("warehouse_capacity_summary_header")).appendTo(page.main); page.capacity_dashboard = new erpnext.stock.ItemDashboard({ page_name: "warehouse-capacity-summary", page_length: 10, parent: page.main, - sort_by: 'stock_capacity', - sort_order: 'desc', - method: 'erpnext.stock.dashboard.warehouse_capacity_dashboard.get_data', - template: 'warehouse_capacity_summary' + sort_by: "stock_capacity", + sort_order: "desc", + method: "erpnext.stock.dashboard.warehouse_capacity_dashboard.get_data", + template: "warehouse_capacity_summary", }); - page.capacity_dashboard.before_refresh = function() { + page.capacity_dashboard.before_refresh = function () { this.item_code = page.item_field.get_value(); this.warehouse = page.warehouse_field.get_value(); this.parent_warehouse = page.parent_warehouse_field.get_value(); @@ -101,12 +101,12 @@ frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) { page.capacity_dashboard.refresh(); - let setup_click = function(doctype) { - page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() { - var name = $(this).attr('data-name'); - var field = page[doctype.toLowerCase() + '_field']; - if (field.get_value()===name) { - frappe.set_route('Form', doctype, name); + let setup_click = function (doctype) { + page.main.on("click", 'a[data-type="' + doctype.toLowerCase() + '"]', function () { + var name = $(this).attr("data-name"); + var field = page[doctype.toLowerCase() + "_field"]; + if (field.get_value() === name) { + frappe.set_route("Form", doctype, name); } else { field.set_input(name); page.capacity_dashboard.refresh(); @@ -114,7 +114,7 @@ frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) { }); }; - setup_click('Item'); - setup_click('Warehouse'); + setup_click("Item"); + setup_click("Warehouse"); }); }; 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 5ead48d4994..5ec424f4c24 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 @@ -2,34 +2,34 @@ // For license information, please see license.txt frappe.query_reports["Batch Item Expiry Status"] = { - "filters": [ + filters: [ { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], - "reqd": 1, + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], + reqd: 1, }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "default": frappe.datetime.get_today(), - "reqd": 1, + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + default: frappe.datetime.get_today(), + reqd: 1, }, { - "fieldname":"item", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item", - "width": "100", - "get_query": function () { + fieldname: "item", + label: __("Item"), + fieldtype: "Link", + options: "Item", + width: "100", + get_query: function () { return { - filters: {"has_batch_no": 1} - } - } - } - ] -} + filters: { has_batch_no: 1 }, + }; + }, + }, + ], +}; 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 2a65e38970f..352fb19dd93 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 @@ -2,87 +2,90 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Batch-Wise Balance History"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], - "reqd": 1 + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], + reqd: 1, }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "default": frappe.datetime.get_today(), - "reqd": 1 + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + default: frappe.datetime.get_today(), + reqd: 1, }, { - "fieldname":"item_code", - "label": __("Item Code"), - "fieldtype": "Link", - "options": "Item", - "get_query": function() { + fieldname: "item_code", + label: __("Item Code"), + fieldtype: "Link", + options: "Item", + get_query: function () { return { filters: { - "has_batch_no": 1 - } + has_batch_no: 1, + }, }; - } + }, }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", - "get_query": function() { - let company = frappe.query_report.get_filter_value('company'); + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", + get_query: function () { + let company = frappe.query_report.get_filter_value("company"); return { filters: { - "company": company - } + company: company, + }, }; - } + }, }, { - "fieldname":"batch_no", - "label": __("Batch No"), - "fieldtype": "Link", - "options": "Batch", - "get_query": function() { - let item_code = frappe.query_report.get_filter_value('item_code'); + fieldname: "batch_no", + label: __("Batch No"), + fieldtype: "Link", + options: "Batch", + get_query: function () { + let item_code = frappe.query_report.get_filter_value("item_code"); return { filters: { - "item": item_code - } + item: item_code, + }, }; - } + }, }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { if (column.fieldname == "Batch" && data && !!data["Batch"]) { value = data["Batch"]; - column.link_onclick = "frappe.query_reports['Batch-Wise Balance History'].set_batch_route_to_stock_ledger(" + JSON.stringify(data) + ")"; + column.link_onclick = + "frappe.query_reports['Batch-Wise Balance History'].set_batch_route_to_stock_ledger(" + + JSON.stringify(data) + + ")"; } value = default_formatter(value, row, column, data); return value; }, - "set_batch_route_to_stock_ledger": function (data) { + set_batch_route_to_stock_ledger: function (data) { frappe.route_options = { - "batch_no": data["Batch"] + batch_no: data["Batch"], }; frappe.set_route("query-report", "Stock Ledger"); - } -} + }, +}; diff --git a/erpnext/stock/report/bom_search/bom_search.js b/erpnext/stock/report/bom_search/bom_search.js index e9e763cb889..b6f3c9633e1 100644 --- a/erpnext/stock/report/bom_search/bom_search.js +++ b/erpnext/stock/report/bom_search/bom_search.js @@ -2,41 +2,41 @@ // For license information, please see license.txt frappe.query_reports["BOM Search"] = { - "filters": [ + filters: [ { fieldname: "item1", label: __("Item 1"), fieldtype: "Link", - options: "Item" + options: "Item", }, { fieldname: "item2", label: __("Item 2"), fieldtype: "Link", - options: "Item" + options: "Item", }, { fieldname: "item3", label: __("Item 3"), fieldtype: "Link", - options: "Item" + options: "Item", }, { fieldname: "item4", label: __("Item 4"), fieldtype: "Link", - options: "Item" + options: "Item", }, { fieldname: "item5", label: __("Item 5"), fieldtype: "Link", - options: "Item" + options: "Item", }, { fieldname: "search_sub_assemblies", label: __("Search Sub Assemblies"), fieldtype: "Check", }, - ] -} + ], +}; diff --git a/erpnext/stock/report/cogs_by_item_group/cogs_by_item_group.js b/erpnext/stock/report/cogs_by_item_group/cogs_by_item_group.js index a0322851245..ecca3b1ac65 100644 --- a/erpnext/stock/report/cogs_by_item_group/cogs_by_item_group.js +++ b/erpnext/stock/report/cogs_by_item_group/cogs_by_item_group.js @@ -1,31 +1,29 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - - frappe.query_reports["COGS By Item Group"] = { filters: [ - { - label: __("Company"), - fieldname: "company", - fieldtype: "Link", - options: "Company", - mandatory: true, - default: frappe.defaults.get_user_default("Company"), - }, - { - label: __("From Date"), - fieldname: "from_date", - fieldtype: "Date", - mandatory: true, - default: frappe.datetime.year_start(), - }, - { - label: __("To Date"), - fieldname: "to_date", - fieldtype: "Date", - mandatory: true, - default: frappe.datetime.get_today(), - }, - ] + { + label: __("Company"), + fieldname: "company", + fieldtype: "Link", + options: "Company", + mandatory: true, + default: frappe.defaults.get_user_default("Company"), + }, + { + label: __("From Date"), + fieldname: "from_date", + fieldtype: "Date", + mandatory: true, + default: frappe.datetime.year_start(), + }, + { + label: __("To Date"), + fieldname: "to_date", + fieldtype: "Date", + mandatory: true, + default: frappe.datetime.get_today(), + }, + ], }; diff --git a/erpnext/stock/report/delayed_item_report/delayed_item_report.js b/erpnext/stock/report/delayed_item_report/delayed_item_report.js index cf6e12ff476..aecf0fa1d23 100644 --- a/erpnext/stock/report/delayed_item_report/delayed_item_report.js +++ b/erpnext/stock/report/delayed_item_report/delayed_item_report.js @@ -1,62 +1,61 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Delayed Item Report"] = { - "filters": [ + filters: [ { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_default("company"), - reqd: 1 + reqd: 1, }, { - fieldname:"from_date", + fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.datetime.month_start(), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.datetime.now_date(), - reqd: 1 + reqd: 1, }, { - fieldname:"sales_order", + fieldname: "sales_order", label: __("Sales Order"), fieldtype: "Link", options: "Sales Order", }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"customer_group", + fieldname: "customer_group", label: __("Customer Group"), fieldtype: "Link", options: "Customer Group", }, { - fieldname:"item_group", + fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", options: "Item Group", }, { - fieldname:"based_on", + fieldname: "based_on", label: __("Based On"), fieldtype: "Select", options: ["Delivery Note", "Sales Invoice"], default: "Sales Invoice", - reqd: 1 + reqd: 1, }, - ] -} + ], +}; diff --git a/erpnext/stock/report/delayed_order_report/delayed_order_report.js b/erpnext/stock/report/delayed_order_report/delayed_order_report.js index cf489c932e4..3aa6f912197 100644 --- a/erpnext/stock/report/delayed_order_report/delayed_order_report.js +++ b/erpnext/stock/report/delayed_order_report/delayed_order_report.js @@ -1,62 +1,61 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Delayed Order Report"] = { - "filters": [ + filters: [ { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_default("company"), - reqd: 1 + reqd: 1, }, { - fieldname:"from_date", + fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.datetime.month_start(), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.datetime.now_date(), - reqd: 1 + reqd: 1, }, { - fieldname:"sales_order", + fieldname: "sales_order", label: __("Sales Order"), fieldtype: "Link", options: "Sales Order", }, { - fieldname:"customer", + fieldname: "customer", label: __("Customer"), fieldtype: "Link", options: "Customer", }, { - fieldname:"customer_group", + fieldname: "customer_group", label: __("Customer Group"), fieldtype: "Link", options: "Customer Group", }, { - fieldname:"item_group", + fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", options: "Item Group", }, { - fieldname:"based_on", + fieldname: "based_on", label: __("Based On"), fieldtype: "Select", options: ["Delivery Note", "Sales Invoice"], default: "Sales Invoice", - reqd: 1 + reqd: 1, }, - ] -} + ], +}; 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 8a04565c197..5e7dc8b2a63 100644 --- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js +++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/sales_trends_filters.js", function() { +frappe.require("assets/erpnext/js/sales_trends_filters.js", function () { frappe.query_reports["Delivery Note Trends"] = { - filters: erpnext.get_sales_trends_filters() - } + filters: erpnext.get_sales_trends_filters(), + }; }); diff --git a/erpnext/stock/report/fifo_queue_vs_qty_after_transaction_comparison/fifo_queue_vs_qty_after_transaction_comparison.js b/erpnext/stock/report/fifo_queue_vs_qty_after_transaction_comparison/fifo_queue_vs_qty_after_transaction_comparison.js index bc869791321..38266aa99a7 100644 --- a/erpnext/stock/report/fifo_queue_vs_qty_after_transaction_comparison/fifo_queue_vs_qty_after_transaction_comparison.js +++ b/erpnext/stock/report/fifo_queue_vs_qty_after_transaction_comparison/fifo_queue_vs_qty_after_transaction_comparison.js @@ -1,49 +1,45 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - -const DIFFERNCE_FIELD_NAMES = [ - "fifo_qty_diff", - "fifo_value_diff", -]; +const DIFFERNCE_FIELD_NAMES = ["fifo_qty_diff", "fifo_value_diff"]; frappe.query_reports["FIFO Queue vs Qty After Transaction Comparison"] = { - "filters": [ + filters: [ { - "fieldname": "item_code", - "fieldtype": "Link", - "label": "Item", - "options": "Item", - get_query: function() { + fieldname: "item_code", + fieldtype: "Link", + label: "Item", + options: "Item", + get_query: function () { return { - filters: {is_stock_item: 1, has_serial_no: 0} - } - } + filters: { is_stock_item: 1, has_serial_no: 0 }, + }; + }, }, { - "fieldname": "item_group", - "fieldtype": "Link", - "label": "Item Group", - "options": "Item Group", + fieldname: "item_group", + fieldtype: "Link", + label: "Item Group", + options: "Item Group", }, { - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "options": "Warehouse", + fieldname: "warehouse", + fieldtype: "Link", + label: "Warehouse", + options: "Warehouse", }, { - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Posting Date", + fieldname: "from_date", + fieldtype: "Date", + label: "From Posting Date", }, { - "fieldname": "to_date", - "fieldtype": "Date", - "label": "From Posting Date", - } + fieldname: "to_date", + fieldtype: "Date", + label: "From Posting Date", + }, ], - formatter (value, row, column, data, default_formatter) { + formatter(value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (DIFFERNCE_FIELD_NAMES.includes(column.fieldname) && Math.abs(data[column.fieldname]) > 0.001) { value = "" + value + ""; diff --git a/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.js b/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.js index 0f9120ba2f2..8c4e6d4c597 100644 --- a/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.js +++ b/erpnext/stock/report/incorrect_balance_qty_after_transaction/incorrect_balance_qty_after_transaction.js @@ -1,27 +1,26 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Incorrect Balance Qty After Transaction"] = { - "filters": [ + filters: [ { label: __("Company"), fieldtype: "Link", fieldname: "company", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { - label: __('Item Code'), - fieldtype: 'Link', - fieldname: 'item_code', - options: 'Item' + label: __("Item Code"), + fieldtype: "Link", + fieldname: "item_code", + options: "Item", }, { - label: __('Warehouse'), - fieldtype: 'Link', - fieldname: 'warehouse' - } - ] + label: __("Warehouse"), + fieldtype: "Link", + fieldname: "warehouse", + }, + ], }; diff --git a/erpnext/stock/report/incorrect_serial_no_valuation/incorrect_serial_no_valuation.js b/erpnext/stock/report/incorrect_serial_no_valuation/incorrect_serial_no_valuation.js index a061d045f0f..51948ca7644 100644 --- a/erpnext/stock/report/incorrect_serial_no_valuation/incorrect_serial_no_valuation.js +++ b/erpnext/stock/report/incorrect_serial_no_valuation/incorrect_serial_no_valuation.js @@ -1,35 +1,34 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Incorrect Serial No Valuation"] = { - "filters": [ + filters: [ { - label: __('Item Code'), - fieldtype: 'Link', - fieldname: 'item_code', - options: 'Item', - get_query: function() { + label: __("Item Code"), + fieldtype: "Link", + fieldname: "item_code", + options: "Item", + get_query: function () { return { filters: { - 'has_serial_no': 1 - } - } - } + has_serial_no: 1, + }, + }; + }, }, { - label: __('From Date'), - fieldtype: 'Date', - fieldname: 'from_date', + label: __("From Date"), + fieldtype: "Date", + fieldname: "from_date", reqd: 1, default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], }, { - label: __('To Date'), - fieldtype: 'Date', - fieldname: 'to_date', + label: __("To Date"), + fieldtype: "Date", + fieldname: "to_date", reqd: 1, default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2], - } - ] + }, + ], }; diff --git a/erpnext/stock/report/incorrect_stock_value_report/incorrect_stock_value_report.js b/erpnext/stock/report/incorrect_stock_value_report/incorrect_stock_value_report.js index 174d03317d7..0a6ca3f37e5 100644 --- a/erpnext/stock/report/incorrect_stock_value_report/incorrect_stock_value_report.js +++ b/erpnext/stock/report/incorrect_stock_value_report/incorrect_stock_value_report.js @@ -1,36 +1,35 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Incorrect Stock Value Report"] = { - "filters": [ + filters: [ { - "label": __("Company"), - "fieldname": "company", - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + label: __("Company"), + fieldname: "company", + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "label": __("Account"), - "fieldname": "account", - "fieldtype": "Link", - "options": "Account", - get_query: function() { - var company = frappe.query_report.get_filter_value('company'); + label: __("Account"), + fieldname: "account", + fieldtype: "Link", + options: "Account", + get_query: function () { + var company = frappe.query_report.get_filter_value("company"); return { filters: { - "account_type": "Stock", - "company": company - } - } - } + account_type: "Stock", + company: company, + }, + }; + }, }, { - "label": __("From Date"), - "fieldname": "from_date", - "fieldtype": "Date" - } - ] + label: __("From Date"), + fieldname: "from_date", + fieldtype: "Date", + }, + ], }; diff --git a/erpnext/stock/report/item_price_stock/item_price_stock.js b/erpnext/stock/report/item_price_stock/item_price_stock.js index c4684daa9f1..72d8d2315d8 100644 --- a/erpnext/stock/report/item_price_stock/item_price_stock.js +++ b/erpnext/stock/report/item_price_stock/item_price_stock.js @@ -1,14 +1,13 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Item Price Stock"] = { - "filters": [ + filters: [ { - "fieldname":"item_code", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item" - } - ] -} + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", + }, + ], +}; diff --git a/erpnext/stock/report/item_prices/item_prices.js b/erpnext/stock/report/item_prices/item_prices.js index 77bca4466d0..868b503eb73 100644 --- a/erpnext/stock/report/item_prices/item_prices.js +++ b/erpnext/stock/report/item_prices/item_prices.js @@ -2,16 +2,16 @@ // For license information, please see license.txt frappe.query_reports["Item Prices"] = { - "filters": [ + filters: [ { - "fieldname": "items", - "label": __("Items Filter"), - "fieldtype": "Select", - "options": "Enabled Items only\nDisabled Items only\nAll Items", - "default": "Enabled Items only", - "on_change": function(query_report) { + fieldname: "items", + label: __("Items Filter"), + fieldtype: "Select", + options: "Enabled Items only\nDisabled Items only\nAll Items", + default: "Enabled Items only", + on_change: function (query_report) { query_report.trigger_refresh(); - } - } - ] -} + }, + }, + ], +}; diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.js b/erpnext/stock/report/item_shortage_report/item_shortage_report.js index 5642038f3f5..d293b895e5b 100644 --- a/erpnext/stock/report/item_shortage_report/item_shortage_report.js +++ b/erpnext/stock/report/item_shortage_report/item_shortage_report.js @@ -1,26 +1,25 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Item Shortage Report"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "width": "80", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_default("company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + width: "80", + options: "Company", + reqd: 1, + default: frappe.defaults.get_default("company"), }, { - "fieldname": "warehouse", - "label": __("Warehouse"), - "fieldtype": "MultiSelectList", - "width": "100", - get_data: function(txt) { - return frappe.db.get_link_options('Warehouse', txt); - } - } - ] + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "MultiSelectList", + width: "100", + get_data: function (txt) { + return frappe.db.get_link_options("Warehouse", txt); + }, + }, + ], }; diff --git a/erpnext/stock/report/item_variant_details/item_variant_details.js b/erpnext/stock/report/item_variant_details/item_variant_details.js index b9022948f40..37c149a78f8 100644 --- a/erpnext/stock/report/item_variant_details/item_variant_details.js +++ b/erpnext/stock/report/item_variant_details/item_variant_details.js @@ -1,9 +1,8 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Item Variant Details"] = { - "filters": [ + filters: [ { reqd: 1, default: "", @@ -13,9 +12,9 @@ frappe.query_reports["Item Variant Details"] = { fieldtype: "Link", get_query: () => { return { - filters: { "has_variants": 1 } - } - } - } - ] -} + filters: { has_variants: 1 }, + }; + }, + }, + ], +}; 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 3f8d90ddaab..8d46b14a177 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 @@ -2,31 +2,31 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Itemwise Recommended Reorder Level"] = { - "filters": [ + filters: [ { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1], }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), }, { - "fieldname":"item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "options": "Item Group", - "reqd": 1 + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + options: "Item Group", + reqd: 1, }, { - "fieldname":"brand", - "label": __("Brand"), - "fieldtype": "Link", - "options": "Brand" - } - ] -} + fieldname: "brand", + label: __("Brand"), + fieldtype: "Link", + options: "Brand", + }, + ], +}; diff --git a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js index 4458a7245f3..5cef5c70341 100644 --- a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js +++ b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.js @@ -2,51 +2,51 @@ // For license information, please see license.txt frappe.query_reports["Product Bundle Balance"] = { - "filters": [ + filters: [ { - "fieldname":"date", - "label": __("Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.get_today(), + fieldname: "date", + label: __("Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.get_today(), }, { - "fieldname": "item_code", - "label": __("Item"), - "fieldtype": "Link", - "width": "80", - "options": "Item", - "get_query": function() { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + width: "80", + options: "Item", + get_query: function () { return { query: "erpnext.controllers.queries.item_query", - filters: {"is_stock_item": 0} + filters: { is_stock_item: 0 }, }; - } + }, }, { - "fieldname": "item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "width": "80", - "options": "Item Group" + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + width: "80", + options: "Item Group", }, { - "fieldname":"brand", - "label": __("Brand"), - "fieldtype": "Link", - "options": "Brand" + fieldname: "brand", + label: __("Brand"), + fieldtype: "Link", + options: "Brand", }, { - "fieldname": "warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "width": "80", - "options": "Warehouse" + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + width: "80", + options: "Warehouse", }, ], - "initial_depth": 0, - "formatter": function(value, row, column, data, default_formatter) { + initial_depth: 0, + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (!data.parent_item) { value = $(`${value}`); @@ -54,5 +54,5 @@ frappe.query_reports["Product Bundle Balance"] = { value = $value.wrap("

      ").parent().html(); } return value; - } + }, }; 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 695efacb694..bddfe5d7705 100644 --- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js +++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js @@ -1,8 +1,8 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() { +frappe.require("assets/erpnext/js/purchase_trends_filters.js", function () { frappe.query_reports["Purchase Receipt Trends"] = { - filters: erpnext.get_purchase_trends_filters() - } + filters: erpnext.get_purchase_trends_filters(), + }; }); diff --git a/erpnext/stock/report/reserved_stock/reserved_stock.js b/erpnext/stock/report/reserved_stock/reserved_stock.js index 2b075e22765..29a97ad9cb4 100644 --- a/erpnext/stock/report/reserved_stock/reserved_stock.js +++ b/erpnext/stock/report/reserved_stock/reserved_stock.js @@ -15,10 +15,7 @@ frappe.query_reports["Reserved Stock"] = { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", - default: frappe.datetime.add_months( - frappe.datetime.get_today(), - -1 - ), + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), reqd: 1, }, { @@ -72,7 +69,7 @@ frappe.query_reports["Reserved Stock"] = { get_query: () => ({ filters: { name: ["in", ["Sales Order"]], - } + }, }), }, { @@ -98,7 +95,7 @@ frappe.query_reports["Reserved Stock"] = { get_query: () => ({ filters: { name: ["in", ["Pick List", "Purchase Receipt"]], - } + }, }), }, { @@ -126,13 +123,7 @@ frappe.query_reports["Reserved Stock"] = { fieldname: "status", label: __("Status"), fieldtype: "Select", - options: [ - "", - "Partially Reserved", - "Reserved", - "Partially Delivered", - "Delivered", - ], + options: ["", "Partially Reserved", "Reserved", "Partially Delivered", "Delivered"], }, { fieldname: "project", @@ -165,17 +156,14 @@ frappe.query_reports["Reserved Stock"] = { value = "" + value + ""; break; } - } - else if (column.fieldname == "delivered_qty") { + } else if (column.fieldname == "delivered_qty") { if (data.delivered_qty > 0) { if (data.reserved_qty > data.delivered_qty) { value = "" + value + ""; - } - else { + } else { value = "" + value + ""; } - } - else { + } else { value = "" + value + ""; } } diff --git a/erpnext/stock/report/serial_and_batch_summary/serial_and_batch_summary.js b/erpnext/stock/report/serial_and_batch_summary/serial_and_batch_summary.js index 10e5925ff42..3b66cb036a7 100644 --- a/erpnext/stock/report/serial_and_batch_summary/serial_and_batch_summary.js +++ b/erpnext/stock/report/serial_and_batch_summary/serial_and_batch_summary.js @@ -3,93 +3,93 @@ /* eslint-disable */ frappe.query_reports["Serial and Batch Summary"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), }, { - "fieldname":"item_code", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item", + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", }, { - "fieldname":"voucher_type", - "label": __("Voucher Type"), - "fieldtype": "Link", - "options": "DocType", - get_query: function() { + fieldname: "voucher_type", + label: __("Voucher Type"), + fieldtype: "Link", + options: "DocType", + get_query: function () { return { query: "erpnext.stock.report.serial_and_batch_summary.serial_and_batch_summary.get_voucher_type", - } - } + }; + }, }, { - "fieldname":"voucher_no", - "label": __("Voucher No"), - "fieldtype": "MultiSelectList", - get_data: function(txt) { + fieldname: "voucher_no", + label: __("Voucher No"), + fieldtype: "MultiSelectList", + get_data: function (txt) { if (!frappe.query_report.filters) return; - let voucher_type = frappe.query_report.get_filter_value('voucher_type'); + let voucher_type = frappe.query_report.get_filter_value("voucher_type"); if (!voucher_type) return; return frappe.db.get_link_options(voucher_type, txt); }, }, { - "fieldname":"serial_no", - "label": __("Serial No"), - "fieldtype": "Link", - "options": "Serial No", - get_query: function() { + fieldname: "serial_no", + label: __("Serial No"), + fieldtype: "Link", + options: "Serial No", + get_query: function () { return { query: "erpnext.stock.report.serial_and_batch_summary.serial_and_batch_summary.get_serial_nos", filters: { - "item_code": frappe.query_report.get_filter_value('item_code'), - "voucher_type": frappe.query_report.get_filter_value('voucher_type'), - "voucher_no": frappe.query_report.get_filter_value('voucher_no'), - } - } - } + item_code: frappe.query_report.get_filter_value("item_code"), + voucher_type: frappe.query_report.get_filter_value("voucher_type"), + voucher_no: frappe.query_report.get_filter_value("voucher_no"), + }, + }; + }, }, { - "fieldname":"batch_no", - "label": __("Batch No"), - "fieldtype": "Link", - "options": "Batch", - get_query: function() { + fieldname: "batch_no", + label: __("Batch No"), + fieldtype: "Link", + options: "Batch", + get_query: function () { return { query: "erpnext.stock.report.serial_and_batch_summary.serial_and_batch_summary.get_batch_nos", filters: { - "item_code": frappe.query_report.get_filter_value('item_code'), - "voucher_type": frappe.query_report.get_filter_value('voucher_type'), - "voucher_no": frappe.query_report.get_filter_value('voucher_no'), - } - } - } - } - ] + item_code: frappe.query_report.get_filter_value("item_code"), + voucher_type: frappe.query_report.get_filter_value("voucher_type"), + voucher_no: frappe.query_report.get_filter_value("voucher_no"), + }, + }; + }, + }, + ], }; diff --git a/erpnext/stock/report/serial_no_ledger/serial_no_ledger.js b/erpnext/stock/report/serial_no_ledger/serial_no_ledger.js index fe977c6d5cc..376fe41488c 100644 --- a/erpnext/stock/report/serial_no_ledger/serial_no_ledger.js +++ b/erpnext/stock/report/serial_no_ledger/serial_no_ledger.js @@ -1,70 +1,69 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Serial No Ledger"] = { - "filters": [ + filters: [ { - 'label': __('Item Code'), - 'fieldtype': 'Link', - 'fieldname': 'item_code', - 'reqd': 1, - 'options': 'Item', - get_query: function() { + label: __("Item Code"), + fieldtype: "Link", + fieldname: "item_code", + reqd: 1, + options: "Item", + get_query: function () { return { filters: { - 'has_serial_no': 1 - } - } - } + has_serial_no: 1, + }, + }; + }, }, { - 'label': __('Warehouse'), - 'fieldtype': 'Link', - 'fieldname': 'warehouse', - 'options': 'Warehouse', - get_query: function() { - let company = frappe.query_report.get_filter_value('company'); + label: __("Warehouse"), + fieldtype: "Link", + fieldname: "warehouse", + options: "Warehouse", + get_query: function () { + let company = frappe.query_report.get_filter_value("company"); if (company) { return { filters: { - 'company': company - } - } + company: company, + }, + }; } - } + }, }, { - 'label': __('Serial No'), - 'fieldtype': 'Link', - 'fieldname': 'serial_no', - 'options': 'Serial No', - get_query: function() { - let item_code = frappe.query_report.get_filter_value('item_code'); - let warehouse = frappe.query_report.get_filter_value('warehouse'); + label: __("Serial No"), + fieldtype: "Link", + fieldname: "serial_no", + options: "Serial No", + get_query: function () { + let item_code = frappe.query_report.get_filter_value("item_code"); + let warehouse = frappe.query_report.get_filter_value("warehouse"); - let query_filters = {'item_code': item_code}; + let query_filters = { item_code: item_code }; if (warehouse) { - query_filters['warehouse'] = warehouse; + query_filters["warehouse"] = warehouse; } return { - filters: query_filters - } - } + filters: query_filters, + }; + }, }, { - 'label': __('As On Date'), - 'fieldtype': 'Date', - 'fieldname': 'posting_date', - 'default': frappe.datetime.get_today() + label: __("As On Date"), + fieldtype: "Date", + fieldname: "posting_date", + default: frappe.datetime.get_today(), }, { - 'label': __('Posting Time'), - 'fieldtype': 'Time', - 'fieldname': 'posting_time', - 'default': frappe.datetime.get_time() + label: __("Posting Time"), + fieldtype: "Time", + fieldname: "posting_time", + default: frappe.datetime.get_time(), }, - ] + ], }; diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.js b/erpnext/stock/report/stock_ageing/stock_ageing.js index db463b7ca09..641084149ab 100644 --- a/erpnext/stock/report/stock_ageing/stock_ageing.js +++ b/erpnext/stock/report/stock_ageing/stock_ageing.js @@ -2,74 +2,74 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Stock Ageing"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"to_date", - "label": __("As On Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today(), - "reqd": 1 + fieldname: "to_date", + label: __("As On Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), + reqd: 1, }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", get_query: () => { const company = frappe.query_report.get_filter_value("company"); return { filters: { - ...company && {company}, - } + ...(company && { company }), + }, }; - } + }, }, { - "fieldname":"item_code", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item" + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", }, { - "fieldname":"brand", - "label": __("Brand"), - "fieldtype": "Link", - "options": "Brand" + fieldname: "brand", + label: __("Brand"), + fieldtype: "Link", + options: "Brand", }, { - "fieldname":"range1", - "label": __("Ageing Range 1"), - "fieldtype": "Int", - "default": "30", - "reqd": 1 + fieldname: "range1", + label: __("Ageing Range 1"), + fieldtype: "Int", + default: "30", + reqd: 1, }, { - "fieldname":"range2", - "label": __("Ageing Range 2"), - "fieldtype": "Int", - "default": "60", - "reqd": 1 + fieldname: "range2", + label: __("Ageing Range 2"), + fieldtype: "Int", + default: "60", + reqd: 1, }, { - "fieldname":"range3", - "label": __("Ageing Range 3"), - "fieldtype": "Int", - "default": "90", - "reqd": 1 + fieldname: "range3", + label: __("Ageing Range 3"), + fieldtype: "Int", + default: "90", + reqd: 1, }, { - "fieldname":"show_warehouse_wise_stock", - "label": __("Show Warehouse-wise Stock"), - "fieldtype": "Check", - "default": 0 - } - ] -} + fieldname: "show_warehouse_wise_stock", + label: __("Show Warehouse-wise Stock"), + fieldtype: "Check", + default: 0, + }, + ], +}; diff --git a/erpnext/stock/report/stock_analytics/stock_analytics.js b/erpnext/stock/report/stock_analytics/stock_analytics.js index e033fd9a9df..dae64d9ac2c 100644 --- a/erpnext/stock/report/stock_analytics/stock_analytics.js +++ b/erpnext/stock/report/stock_analytics/stock_analytics.js @@ -1,40 +1,39 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Stock Analytics"] = { - "filters": [ + filters: [ { fieldname: "item_group", label: __("Item Group"), fieldtype: "Link", - options:"Item Group", + options: "Item Group", default: "", }, { fieldname: "item_code", label: __("Item"), fieldtype: "Link", - options:"Item", + options: "Item", default: "", - get_query: () => ({filters: { 'is_stock_item': 1 }}), + get_query: () => ({ filters: { is_stock_item: 1 } }), }, { fieldname: "value_quantity", label: __("Value Or Qty"), fieldtype: "Select", options: [ - { "value": "Value", "label": __("Value") }, - { "value": "Quantity", "label": __("Quantity") } + { value: "Value", label: __("Value") }, + { value: "Quantity", label: __("Quantity") }, ], default: "Value", - reqd: 1 + reqd: 1, }, { fieldname: "brand", label: __("Brand"), fieldtype: "Link", - options:"Brand", + options: "Brand", default: "", }, { @@ -51,92 +50,91 @@ frappe.query_reports["Stock Analytics"] = { fieldtype: "Link", options: "Warehouse", default: "", - get_query: function() { - const company = frappe.query_report.get_filter_value('company'); + get_query: function () { + const company = frappe.query_report.get_filter_value("company"); return { - filters: { 'company': company } - } - } + filters: { company: company }, + }; + }, }, { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_start_date"), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_end_date"), - reqd: 1 + reqd: 1, }, { fieldname: "range", label: __("Range"), fieldtype: "Select", options: [ - { "value": "Weekly", "label": __("Weekly") }, - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Weekly", label: __("Weekly") }, + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Yearly", label: __("Yearly") }, ], default: "Monthly", - reqd: 1 - } + reqd: 1, + }, ], - after_datatable_render: function(datatable_obj) { - $(datatable_obj.wrapper).find(".dt-row-0").find('input[type=checkbox]').click(); + after_datatable_render: function (datatable_obj) { + $(datatable_obj.wrapper).find(".dt-row-0").find("input[type=checkbox]").click(); }, get_datatable_options(options) { return Object.assign(options, { checkboxColumn: true, events: { - onCheckRow: function(data) { + onCheckRow: function (data) { let row_name = data[2].content; let row_values = data.slice(7).map(function (column) { return column.content; - }) - let entry = { - 'name':row_name, - 'values':row_values - } + }); + let entry = { + name: row_name, + values: row_values, + }; let raw_data = frappe.query_report.chart.data; let new_datasets = raw_data.datasets; var found = false; - for(var i=0; i < new_datasets.length;i++){ - if(new_datasets[i].name == row_name){ + for (var i = 0; i < new_datasets.length; i++) { + if (new_datasets[i].name == row_name) { found = true; - new_datasets.splice(i,1); + new_datasets.splice(i, 1); break; } } - if(!found){ + if (!found) { new_datasets.push(entry); } let new_data = { labels: raw_data.labels, - datasets: new_datasets - } + datasets: new_datasets, + }; setTimeout(() => { - frappe.query_report.chart.update(new_data) - },500) - + frappe.query_report.chart.update(new_data); + }, 500); setTimeout(() => { frappe.query_report.chart.draw(true); - }, 1000) + }, 1000); frappe.query_report.raw_chart_data = new_data; }, - } + }, }); - } -} + }, +}; diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js index ffef11a20e2..1e2022e66d5 100644 --- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js +++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.js @@ -1,37 +1,36 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Stock and Account Value Comparison"] = { - "filters": [ + filters: [ { - "label": __("Company"), - "fieldname": "company", - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + label: __("Company"), + fieldname: "company", + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "label": __("Account"), - "fieldname": "account", - "fieldtype": "Link", - "options": "Account", - get_query: function() { - var company = frappe.query_report.get_filter_value('company'); + label: __("Account"), + fieldname: "account", + fieldtype: "Link", + options: "Account", + get_query: function () { + var company = frappe.query_report.get_filter_value("company"); return { filters: { - "account_type": "Stock", - "company": company - } - } - } + account_type: "Stock", + company: company, + }, + }; + }, }, { - "label": __("As On Date"), - "fieldname": "as_on_date", - "fieldtype": "Date", - "default": frappe.datetime.get_today(), + label: __("As On Date"), + fieldname: "as_on_date", + fieldtype: "Date", + default: frappe.datetime.get_today(), }, ], @@ -42,7 +41,7 @@ frappe.query_reports["Stock and Account Value Comparison"] = { }, onload(report) { - report.page.add_inner_button(__("Create Reposting Entries"), function() { + report.page.add_inner_button(__("Create Reposting Entries"), function () { let message = `

      Reposting Entries will change the value of @@ -54,7 +53,7 @@ frappe.query_reports["Stock and Account Value Comparison"] = {

      `; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); - let selected_rows = indexes.map(i => frappe.query_report.data[i]); + let selected_rows = indexes.map((i) => frappe.query_report.data[i]); if (!selected_rows.length) { frappe.throw(__("Please select rows to create Reposting Entries")); @@ -65,11 +64,10 @@ frappe.query_reports["Stock and Account Value Comparison"] = { method: "erpnext.stock.report.stock_and_account_value_comparison.stock_and_account_value_comparison.create_reposting_entries", args: { rows: selected_rows, - company: frappe.query_report.get_filter_values().company - } + company: frappe.query_report.get_filter_values().company, + }, }); - }); }); - } + }, }; diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js index fe6e83eddad..ca2c053fdb1 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.js +++ b/erpnext/stock/report/stock_balance/stock_balance.js @@ -2,119 +2,118 @@ // For license information, please see license.txt frappe.query_reports["Stock Balance"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "width": "80", - "options": "Company", - "default": frappe.defaults.get_default("company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + width: "80", + options: "Company", + default: frappe.defaults.get_default("company"), }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.get_today(), }, { - "fieldname": "item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "width": "80", - "options": "Item Group" + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + width: "80", + options: "Item Group", }, { - "fieldname": "item_code", - "label": __("Item"), - "fieldtype": "Link", - "width": "80", - "options": "Item", - "get_query": function() { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + width: "80", + options: "Item", + get_query: function () { return { query: "erpnext.controllers.queries.item_query", }; - } + }, }, { - "fieldname": "warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "width": "80", - "options": "Warehouse", + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + width: "80", + options: "Warehouse", get_query: () => { let warehouse_type = frappe.query_report.get_filter_value("warehouse_type"); let company = frappe.query_report.get_filter_value("company"); return { filters: { - ...warehouse_type && {warehouse_type}, - ...company && {company} - } - } - } + ...(warehouse_type && { warehouse_type }), + ...(company && { company }), + }, + }; + }, }, { - "fieldname": "warehouse_type", - "label": __("Warehouse Type"), - "fieldtype": "Link", - "width": "80", - "options": "Warehouse Type" + fieldname: "warehouse_type", + label: __("Warehouse Type"), + fieldtype: "Link", + width: "80", + options: "Warehouse Type", }, { - "fieldname": "valuation_field_type", - "label": __("Valuation Field Type"), - "fieldtype": "Select", - "width": "80", - "options": "Currency\nFloat", - "default": "Currency" + fieldname: "valuation_field_type", + label: __("Valuation Field Type"), + fieldtype: "Select", + width: "80", + options: "Currency\nFloat", + default: "Currency", }, { - "fieldname":"include_uom", - "label": __("Include UOM"), - "fieldtype": "Link", - "options": "UOM" + fieldname: "include_uom", + label: __("Include UOM"), + fieldtype: "Link", + options: "UOM", }, { - "fieldname": "show_variant_attributes", - "label": __("Show Variant Attributes"), - "fieldtype": "Check" + fieldname: "show_variant_attributes", + label: __("Show Variant Attributes"), + fieldtype: "Check", }, { - "fieldname": 'show_stock_ageing_data', - "label": __('Show Stock Ageing Data'), - "fieldtype": 'Check' + fieldname: "show_stock_ageing_data", + label: __("Show Stock Ageing Data"), + fieldtype: "Check", }, { - "fieldname": 'ignore_closing_balance', - "label": __('Ignore Closing Balance'), - "fieldtype": 'Check', - "default": 0 + fieldname: "ignore_closing_balance", + label: __("Ignore Closing Balance"), + fieldtype: "Check", + default: 0, }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (column.fieldname == "out_qty" && data && data.out_qty > 0) { value = "" + value + ""; - } - else if (column.fieldname == "in_qty" && data && data.in_qty > 0) { + } else if (column.fieldname == "in_qty" && data && data.in_qty > 0) { value = "" + value + ""; } return value; - } + }, }; -erpnext.utils.add_inventory_dimensions('Stock Balance', 8); \ No newline at end of file +erpnext.utils.add_inventory_dimensions("Stock Balance", 8); diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.js b/erpnext/stock/report/stock_ledger/stock_ledger.js index baccd552049..d4c11de74e6 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.js +++ b/erpnext/stock/report/stock_ledger/stock_ledger.js @@ -2,116 +2,115 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Stock Ledger"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), - "reqd": 1 + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), + reqd: 1, }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today(), - "reqd": 1 + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), + reqd: 1, }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", - "get_query": function() { - const company = frappe.query_report.get_filter_value('company'); + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", + get_query: function () { + const company = frappe.query_report.get_filter_value("company"); return { - filters: { 'company': company } - } - } + filters: { company: company }, + }; + }, }, { - "fieldname":"item_code", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item", - "get_query": function() { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", + get_query: function () { return { - query: "erpnext.controllers.queries.item_query" - } - } + query: "erpnext.controllers.queries.item_query", + }; + }, }, { - "fieldname":"item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "options": "Item Group" + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + options: "Item Group", }, { - "fieldname":"batch_no", - "label": __("Batch No"), - "fieldtype": "Link", - "options": "Batch", + fieldname: "batch_no", + label: __("Batch No"), + fieldtype: "Link", + options: "Batch", on_change() { - const batch_no = frappe.query_report.get_filter_value('batch_no'); + const batch_no = frappe.query_report.get_filter_value("batch_no"); if (batch_no) { - frappe.query_report.set_filter_value('segregate_serial_batch_bundle', 1); + frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 1); } else { - frappe.query_report.set_filter_value('segregate_serial_batch_bundle', 0); + frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 0); } - } + }, }, { - "fieldname":"brand", - "label": __("Brand"), - "fieldtype": "Link", - "options": "Brand" + fieldname: "brand", + label: __("Brand"), + fieldtype: "Link", + options: "Brand", }, { - "fieldname":"voucher_no", - "label": __("Voucher #"), - "fieldtype": "Data" + fieldname: "voucher_no", + label: __("Voucher #"), + fieldtype: "Data", }, { - "fieldname":"project", - "label": __("Project"), - "fieldtype": "Link", - "options": "Project" + fieldname: "project", + label: __("Project"), + fieldtype: "Link", + options: "Project", }, { - "fieldname":"include_uom", - "label": __("Include UOM"), - "fieldtype": "Link", - "options": "UOM" + fieldname: "include_uom", + label: __("Include UOM"), + fieldtype: "Link", + options: "UOM", }, { - "fieldname": "valuation_field_type", - "label": __("Valuation Field Type"), - "fieldtype": "Select", - "width": "80", - "options": "Currency\nFloat", - "default": "Currency" + fieldname: "valuation_field_type", + label: __("Valuation Field Type"), + fieldtype: "Select", + width: "80", + options: "Currency\nFloat", + default: "Currency", }, { - "fieldname": "segregate_serial_batch_bundle", - "label": __("Segregate Serial / Batch Bundle"), - "fieldtype": "Check", - "default": 0 - } + fieldname: "segregate_serial_batch_bundle", + label: __("Segregate Serial / Batch Bundle"), + fieldtype: "Check", + default: 0, + }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (column.fieldname == "out_qty" && data && data.out_qty < 0) { value = "" + value + ""; - } - else if (column.fieldname == "in_qty" && data && data.in_qty > 0) { + } else if (column.fieldname == "in_qty" && data && data.in_qty > 0) { value = "" + value + ""; } @@ -119,4 +118,4 @@ frappe.query_reports["Stock Ledger"] = { }, }; -erpnext.utils.add_inventory_dimensions('Stock Ledger', 10); \ No newline at end of file +erpnext.utils.add_inventory_dimensions("Stock Ledger", 10); diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js index 3f67bffa52e..1b05d3a65e4 100644 --- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js +++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js @@ -1,44 +1,43 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - const DIFFERENCE_FIELD_NAMES = [ - 'difference_in_qty', - 'fifo_qty_diff', - 'fifo_value_diff', - 'fifo_valuation_diff', - 'valuation_diff', - 'fifo_difference_diff', - 'diff_value_diff' + "difference_in_qty", + "fifo_qty_diff", + "fifo_value_diff", + "fifo_valuation_diff", + "valuation_diff", + "fifo_difference_diff", + "diff_value_diff", ]; -frappe.query_reports['Stock Ledger Invariant Check'] = { - 'filters': [ +frappe.query_reports["Stock Ledger Invariant Check"] = { + filters: [ { - 'fieldname': 'item_code', - 'fieldtype': 'Link', - 'label': 'Item', - 'mandatory': 1, - 'options': 'Item', - get_query: function() { + fieldname: "item_code", + fieldtype: "Link", + label: "Item", + mandatory: 1, + options: "Item", + get_query: function () { return { - filters: {is_stock_item: 1, has_serial_no: 0} - } - } + filters: { is_stock_item: 1, has_serial_no: 0 }, + }; + }, }, { - 'fieldname': 'warehouse', - 'fieldtype': 'Link', - 'label': 'Warehouse', - 'mandatory': 1, - 'options': 'Warehouse', - } + fieldname: "warehouse", + fieldtype: "Link", + label: "Warehouse", + mandatory: 1, + options: "Warehouse", + }, ], - formatter (value, row, column, data, default_formatter) { + formatter(value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (DIFFERENCE_FIELD_NAMES.includes(column.fieldname) && Math.abs(data[column.fieldname]) > 0.001) { - value = '' + value + ''; + value = '' + value + ""; } return value; }, @@ -50,7 +49,7 @@ frappe.query_reports['Stock Ledger Invariant Check'] = { }, onload(report) { - report.page.add_inner_button(__('Create Reposting Entry'), () => { + report.page.add_inner_button(__("Create Reposting Entry"), () => { let message = `

      @@ -62,23 +61,21 @@ frappe.query_reports['Stock Ledger Invariant Check'] = {

      Are you sure you want to create a Reposting Entry?

      `; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); - let selected_rows = indexes.map(i => frappe.query_report.data[i]); + let selected_rows = indexes.map((i) => frappe.query_report.data[i]); if (!selected_rows.length) { - frappe.throw(__('Please select a row to create a Reposting Entry')); - } - else if (selected_rows.length > 1) { - frappe.throw(__('Please select only one row to create a Reposting Entry')); - } - else { + frappe.throw(__("Please select a row to create a Reposting Entry")); + } else if (selected_rows.length > 1) { + frappe.throw(__("Please select only one row to create a Reposting Entry")); + } else { frappe.confirm(__(message), () => { frappe.call({ - method: 'erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries', + method: "erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries", args: { rows: selected_rows, item_code: frappe.query_report.get_filter_values().item_code, warehouse: frappe.query_report.get_filter_values().warehouse, - } + }, }); }); } diff --git a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js index bf3a397feef..07e7b59b514 100644 --- a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js +++ b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js @@ -8,60 +8,55 @@ const DIFFERENCE_FIELD_NAMES = [ "fifo_valuation_diff", "valuation_diff", "fifo_difference_diff", - "diff_value_diff" + "diff_value_diff", ]; frappe.query_reports["Stock Ledger Variance"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname": "item_code", - "fieldtype": "Link", - "label": __("Item"), - "options": "Item", - get_query: function() { + fieldname: "item_code", + fieldtype: "Link", + label: __("Item"), + options: "Item", + get_query: function () { return { - filters: {is_stock_item: 1, has_serial_no: 0} - } - } + filters: { is_stock_item: 1, has_serial_no: 0 }, + }; + }, }, { - "fieldname": "warehouse", - "fieldtype": "Link", - "label": __("Warehouse"), - "options": "Warehouse", - get_query: function() { + fieldname: "warehouse", + fieldtype: "Link", + label: __("Warehouse"), + options: "Warehouse", + get_query: function () { return { - filters: {is_group: 0, disabled: 0} - } - } + filters: { is_group: 0, disabled: 0 }, + }; + }, }, { - "fieldname": "difference_in", - "fieldtype": "Select", - "label": __("Difference In"), - "options": [ - "", - "Qty", - "Value", - "Valuation", - ], + fieldname: "difference_in", + fieldtype: "Select", + label: __("Difference In"), + options: ["", "Qty", "Value", "Valuation"], }, { - "fieldname": "include_disabled", - "fieldtype": "Check", - "label": __("Include Disabled"), - } + fieldname: "include_disabled", + fieldtype: "Check", + label: __("Include Disabled"), + }, ], - formatter (value, row, column, data, default_formatter) { + formatter(value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (DIFFERENCE_FIELD_NAMES.includes(column.fieldname) && Math.abs(data[column.fieldname]) > 0.001) { @@ -78,7 +73,7 @@ frappe.query_reports["Stock Ledger Variance"] = { }, onload(report) { - report.page.add_inner_button(__('Create Reposting Entries'), () => { + report.page.add_inner_button(__("Create Reposting Entries"), () => { let message = `

      @@ -90,7 +85,7 @@ frappe.query_reports["Stock Ledger Variance"] = {

      Are you sure you want to create Reposting Entries?

      `; let indexes = frappe.query_report.datatable.rowmanager.getCheckedRows(); - let selected_rows = indexes.map(i => frappe.query_report.data[i]); + let selected_rows = indexes.map((i) => frappe.query_report.data[i]); if (!selected_rows.length) { frappe.throw(__("Please select rows to create Reposting Entries")); @@ -98,10 +93,10 @@ frappe.query_reports["Stock Ledger Variance"] = { frappe.confirm(__(message), () => { frappe.call({ - method: 'erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries', + method: "erpnext.stock.report.stock_ledger_invariant_check.stock_ledger_invariant_check.create_reposting_entries", args: { rows: selected_rows, - } + }, }); }); }); diff --git a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.js b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.js index cb109f8050d..6e333aadfa5 100644 --- a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.js +++ b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.js @@ -2,55 +2,55 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Stock Projected Qty"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", - "get_query": () => { + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", + get_query: () => { return { filters: { - company: frappe.query_report.get_filter_value('company') - } - } - } + company: frappe.query_report.get_filter_value("company"), + }, + }; + }, }, { - "fieldname":"item_code", - "label": __("Item"), - "fieldtype": "Link", - "options": "Item", - "get_query": function() { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + options: "Item", + get_query: function () { return { - query: "erpnext.controllers.queries.item_query" - } - } + query: "erpnext.controllers.queries.item_query", + }; + }, }, { - "fieldname":"item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "options": "Item Group" + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + options: "Item Group", }, { - "fieldname":"brand", - "label": __("Brand"), - "fieldtype": "Link", - "options": "Brand" + fieldname: "brand", + label: __("Brand"), + fieldtype: "Link", + options: "Brand", }, { - "fieldname":"include_uom", - "label": __("Include UOM"), - "fieldtype": "Link", - "options": "UOM" - } - ] -} + fieldname: "include_uom", + label: __("Include UOM"), + fieldtype: "Link", + options: "UOM", + }, + ], +}; diff --git a/erpnext/stock/report/stock_qty_vs_serial_no_count/stock_qty_vs_serial_no_count.js b/erpnext/stock/report/stock_qty_vs_serial_no_count/stock_qty_vs_serial_no_count.js index 7a487984956..26cccb88297 100644 --- a/erpnext/stock/report/stock_qty_vs_serial_no_count/stock_qty_vs_serial_no_count.js +++ b/erpnext/stock/report/stock_qty_vs_serial_no_count/stock_qty_vs_serial_no_count.js @@ -1,42 +1,40 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Stock Qty vs Serial No Count"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "options": "Warehouse", - "get_query": function() { - const company = frappe.query_report.get_filter_value('company'); + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + options: "Warehouse", + get_query: function () { + const company = frappe.query_report.get_filter_value("company"); return { - filters: { 'company': company } - } + filters: { company: company }, + }; }, - "reqd": 1 + reqd: 1, }, ], - "formatter": function (value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); if (column.fieldname == "difference" && data) { if (data.difference > 0) { value = "" + value + ""; - } - else if (data.difference < 0) { + } else if (data.difference < 0) { value = "" + value + ""; } } return value; - } + }, }; diff --git a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.js b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.js index 5b006470756..92a01c4ce20 100644 --- a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.js +++ b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.js @@ -2,27 +2,27 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Supplier-Wise Sales Analytics"] = { - "filters": [ + filters: [ { - "fieldname":"supplier", - "label": __("Supplier"), - "fieldtype": "Link", - "options": "Supplier", - "width": "80" + fieldname: "supplier", + label: __("Supplier"), + fieldtype: "Link", + options: "Supplier", + width: "80", }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "default": frappe.datetime.month_start() + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + default: frappe.datetime.month_start(), }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "default": frappe.datetime.month_end() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + default: frappe.datetime.month_end(), }, - ] -} + ], +}; diff --git a/erpnext/stock/report/total_stock_summary/total_stock_summary.js b/erpnext/stock/report/total_stock_summary/total_stock_summary.js index 3d247f67403..1d31566f146 100644 --- a/erpnext/stock/report/total_stock_summary/total_stock_summary.js +++ b/erpnext/stock/report/total_stock_summary/total_stock_summary.js @@ -1,27 +1,26 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Total Stock Summary"] = { - "filters": [ + filters: [ { - "fieldname":"group_by", - "label": __("Group By"), - "fieldtype": "Select", - "width": "80", - "reqd": 1, - "options": ["Warehouse", "Company"], - "default": "Warehouse", + fieldname: "group_by", + label: __("Group By"), + fieldtype: "Select", + width: "80", + reqd: 1, + options: ["Warehouse", "Company"], + default: "Warehouse", }, { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "width": "80", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company"), - "depends_on": "eval: doc.group_by != 'Company'", + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + width: "80", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), + depends_on: "eval: doc.group_by != 'Company'", }, - ] -} + ], +}; diff --git a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js index 8d6b283a156..137c786e44b 100644 --- a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js +++ b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.js @@ -1,51 +1,50 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Warehouse wise Item Balance Age and Value"] = { - "filters": [ -{ - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1), - }, - { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "width": "80", - "reqd": 1, - "default": frappe.datetime.get_today() - }, - { - "fieldname": "item_group", - "label": __("Item Group"), - "fieldtype": "Link", - "width": "80", - "options": "Item Group" - }, - { - "fieldname": "item_code", - "label": __("Item"), - "fieldtype": "Link", - "width": "80", - "options": "Item" - }, - { - "fieldname": "warehouse", - "label": __("Warehouse"), - "fieldtype": "Link", - "width": "80", - "options": "Warehouse" - }, - { - "fieldname": "filter_total_zero_qty", - "label": __("Filter Total Zero Qty"), - "fieldtype": "Check", - "default": 1 - }, - ] -} + filters: [ + { + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), + }, + { + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + width: "80", + reqd: 1, + default: frappe.datetime.get_today(), + }, + { + fieldname: "item_group", + label: __("Item Group"), + fieldtype: "Link", + width: "80", + options: "Item Group", + }, + { + fieldname: "item_code", + label: __("Item"), + fieldtype: "Link", + width: "80", + options: "Item", + }, + { + fieldname: "warehouse", + label: __("Warehouse"), + fieldtype: "Link", + width: "80", + options: "Warehouse", + }, + { + fieldname: "filter_total_zero_qty", + label: __("Filter Total Zero Qty"), + fieldtype: "Check", + default: 1, + }, + ], +}; diff --git a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js index 4a77052a904..ea090922fa9 100644 --- a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js +++ b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.js @@ -1,27 +1,25 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Warehouse Wise Stock Balance"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company") + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname":"show_disabled_warehouses", - "label": __("Show Disabled Warehouses"), - "fieldtype": "Check", - "default": 0 - - } + fieldname: "show_disabled_warehouses", + label: __("Show Disabled Warehouses"), + fieldtype: "Check", + default: 0, + }, ], - "initial_depth": 3, - "tree": true, - "parent_field": "parent_warehouse", - "name_field": "warehouse" + initial_depth: 3, + tree: true, + parent_field: "parent_warehouse", + name_field: "warehouse", }; diff --git a/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.js b/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.js index a7f0d7a20b4..43aac4a4146 100644 --- a/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.js +++ b/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.js @@ -1,40 +1,40 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Subcontracting BOM', { - setup: (frm) => { - frm.trigger('set_queries'); +frappe.ui.form.on("Subcontracting BOM", { + setup: (frm) => { + frm.trigger("set_queries"); }, - set_queries: (frm) => { - frm.set_query('finished_good', () => { - return { - filters: { - disabled: 0, - is_stock_item: 1, - default_bom: ['!=', ''], - is_sub_contracted_item: 1, - } - } - }); + set_queries: (frm) => { + frm.set_query("finished_good", () => { + return { + filters: { + disabled: 0, + is_stock_item: 1, + default_bom: ["!=", ""], + is_sub_contracted_item: 1, + }, + }; + }); - frm.set_query('finished_good_bom', () => { - return { - filters: { - docstatus: 1, - is_active: 1, - item: frm.doc.finished_good, - } - } - }); + frm.set_query("finished_good_bom", () => { + return { + filters: { + docstatus: 1, + is_active: 1, + item: frm.doc.finished_good, + }, + }; + }); - frm.set_query('service_item', () => { - return { - filters: { - disabled: 0, - is_stock_item: 0, - } - } - }); - } + frm.set_query("service_item", () => { + return { + filters: { + disabled: 0, + is_stock_item: 0, + }, + }; + }); + }, }); diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js index 4c8a0ad60ed..9d788f0809d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js @@ -1,101 +1,100 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.provide('erpnext.buying'); +frappe.provide("erpnext.buying"); erpnext.landed_cost_taxes_and_charges.setup_triggers("Subcontracting Order"); -frappe.ui.form.on('Subcontracting Order', { +frappe.ui.form.on("Subcontracting Order", { setup: (frm) => { frm.get_field("items").grid.cannot_add_rows = true; frm.get_field("items").grid.only_sortable(); - frm.set_indicator_formatter('item_code', - (doc) => (doc.qty <= doc.received_qty) ? 'green' : 'orange'); + frm.set_indicator_formatter("item_code", (doc) => (doc.qty <= doc.received_qty ? "green" : "orange")); - frm.set_query('supplier_warehouse', () => { + frm.set_query("supplier_warehouse", () => { return { filters: { company: frm.doc.company, - is_group: 0 - } + is_group: 0, + }, }; }); - frm.set_query('purchase_order', () => { + frm.set_query("purchase_order", () => { return { filters: { docstatus: 1, is_subcontracted: 1, - is_old_subcontracting_flow: 0 - } + is_old_subcontracting_flow: 0, + }, }; }); - frm.set_query('set_warehouse', () => { + frm.set_query("set_warehouse", () => { return { filters: { company: frm.doc.company, - is_group: 0 - } + is_group: 0, + }, }; }); - frm.set_query('warehouse', 'items', () => ({ + frm.set_query("warehouse", "items", () => ({ filters: { company: frm.doc.company, - is_group: 0 - } + is_group: 0, + }, })); - frm.set_query('expense_account', 'items', () => ({ - query: 'erpnext.controllers.queries.get_expense_account', + frm.set_query("expense_account", "items", () => ({ + query: "erpnext.controllers.queries.get_expense_account", filters: { - company: frm.doc.company - } + company: frm.doc.company, + }, })); - frm.set_query('bom', 'items', (doc, cdt, cdn) => { + frm.set_query("bom", "items", (doc, cdt, cdn) => { let d = locals[cdt][cdn]; return { filters: { item: d.item_code, is_active: 1, docstatus: 1, - company: frm.doc.company - } + company: frm.doc.company, + }, }; }); - frm.set_query('set_reserve_warehouse', () => { + frm.set_query("set_reserve_warehouse", () => { return { filters: { company: frm.doc.company, - name: ['!=', frm.doc.supplier_warehouse], - is_group: 0 - } + name: ["!=", frm.doc.supplier_warehouse], + is_group: 0, + }, }; }); }, onload: (frm) => { if (!frm.doc.transaction_date) { - frm.set_value('transaction_date', frappe.datetime.get_today()); + frm.set_value("transaction_date", frappe.datetime.get_today()); } }, purchase_order: (frm) => { - frm.set_value('service_items', null); - frm.set_value('items', null); - frm.set_value('supplied_items', null); + frm.set_value("service_items", null); + frm.set_value("items", null); + frm.set_value("supplied_items", null); if (frm.doc.purchase_order) { erpnext.utils.map_current_doc({ - method: 'erpnext.buying.doctype.purchase_order.purchase_order.make_subcontracting_order', + method: "erpnext.buying.doctype.purchase_order.purchase_order.make_subcontracting_order", source_name: frm.doc.purchase_order, target_doc: frm, freeze: true, - freeze_message: __('Mapping Subcontracting Order ...'), + freeze_message: __("Mapping Subcontracting Order ..."), }); } }, @@ -103,13 +102,21 @@ frappe.ui.form.on('Subcontracting Order', { refresh: function (frm) { if (frm.doc.docstatus == 1 && frm.has_perm("submit")) { if (frm.doc.status == "Closed") { - frm.add_custom_button(__('Re-open'), () => frm.events.update_subcontracting_order_status(frm), __("Status")); - } else if(flt(frm.doc.per_received, 2) < 100) { - frm.add_custom_button(__('Close'), () => frm.events.update_subcontracting_order_status(frm, "Closed"), __("Status")); + frm.add_custom_button( + __("Re-open"), + () => frm.events.update_subcontracting_order_status(frm), + __("Status") + ); + } else if (flt(frm.doc.per_received, 2) < 100) { + frm.add_custom_button( + __("Close"), + () => frm.events.update_subcontracting_order_status(frm, "Closed"), + __("Status") + ); } } - frm.trigger('get_materials_from_supplier'); + frm.trigger("get_materials_from_supplier"); }, update_subcontracting_order_status(frm, status) { @@ -131,7 +138,7 @@ frappe.ui.form.on('Subcontracting Order', { let sco_rm_details = []; if (frm.doc.status != "Closed" && frm.doc.supplied_items) { - frm.doc.supplied_items.forEach(d => { + frm.doc.supplied_items.forEach((d) => { if (d.total_supplied_qty > 0 && d.total_supplied_qty != d.consumed_qty) { sco_rm_details.push(d.name); } @@ -139,43 +146,47 @@ frappe.ui.form.on('Subcontracting Order', { } if (sco_rm_details && sco_rm_details.length) { - frm.add_custom_button(__('Return of Components'), () => { - frm.call({ - method: 'erpnext.controllers.subcontracting_controller.get_materials_from_supplier', - freeze: true, - freeze_message: __('Creating Stock Entry'), - args: { - subcontract_order: frm.doc.name, - rm_details: sco_rm_details, - order_doctype: cur_frm.doc.doctype - }, - callback: function (r) { - if (r && r.message) { - const doc = frappe.model.sync(r.message); - frappe.set_route("Form", doc[0].doctype, doc[0].name); - } - } - }); - }, __('Create')); + frm.add_custom_button( + __("Return of Components"), + () => { + frm.call({ + method: "erpnext.controllers.subcontracting_controller.get_materials_from_supplier", + freeze: true, + freeze_message: __("Creating Stock Entry"), + args: { + subcontract_order: frm.doc.name, + rm_details: sco_rm_details, + order_doctype: cur_frm.doc.doctype, + }, + callback: function (r) { + if (r && r.message) { + const doc = frappe.model.sync(r.message); + frappe.set_route("Form", doc[0].doctype, doc[0].name); + } + }, + }); + }, + __("Create") + ); } - } + }, }); -frappe.ui.form.on('Landed Cost Taxes and Charges', { +frappe.ui.form.on("Landed Cost Taxes and Charges", { amount: function (frm, cdt, cdn) { frm.events.set_base_amount(frm, cdt, cdn); }, expense_account: function (frm, cdt, cdn) { frm.events.set_account_currency(frm, cdt, cdn); - } + }, }); erpnext.buying.SubcontractingOrderController = class SubcontractingOrderController { setup() { this.frm.custom_make_buttons = { - 'Subcontracting Receipt': 'Subcontracting Receipt', - 'Stock Entry': 'Material to Supplier', + "Subcontracting Receipt": "Subcontracting Receipt", + "Stock Entry": "Material to Supplier", }; } @@ -183,14 +194,22 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll var me = this; if (doc.docstatus == 1) { - if (!['Closed', 'Completed'].includes(doc.status)) { + if (!["Closed", "Completed"].includes(doc.status)) { if (flt(doc.per_received) < 100) { - cur_frm.add_custom_button(__('Subcontracting Receipt'), this.make_subcontracting_receipt, __('Create')); + cur_frm.add_custom_button( + __("Subcontracting Receipt"), + this.make_subcontracting_receipt, + __("Create") + ); if (me.has_unsupplied_items()) { - cur_frm.add_custom_button(__('Material to Supplier'), this.make_stock_entry, __('Transfer')); + cur_frm.add_custom_button( + __("Material to Supplier"), + this.make_stock_entry, + __("Transfer") + ); } } - cur_frm.page.set_inner_btn_group_as_primary(__('Create')); + cur_frm.page.set_inner_btn_group_as_primary(__("Create")); } } } @@ -216,30 +235,32 @@ erpnext.buying.SubcontractingOrderController = class SubcontractingOrderControll } has_unsupplied_items() { - return this.frm.doc['supplied_items'].some(item => item.required_qty > (item.supplied_qty - item.returned_qty)); + return this.frm.doc["supplied_items"].some( + (item) => item.required_qty > item.supplied_qty - item.returned_qty + ); } make_subcontracting_receipt() { frappe.model.open_mapped_doc({ - method: 'erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order.make_subcontracting_receipt', + method: "erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order.make_subcontracting_receipt", frm: cur_frm, - freeze_message: __('Creating Subcontracting Receipt ...') + freeze_message: __("Creating Subcontracting Receipt ..."), }); } make_stock_entry() { frappe.call({ - method: 'erpnext.controllers.subcontracting_controller.make_rm_stock_entry', + method: "erpnext.controllers.subcontracting_controller.make_rm_stock_entry", args: { subcontract_order: cur_frm.doc.name, - order_doctype: cur_frm.doc.doctype + order_doctype: cur_frm.doc.doctype, }, callback: (r) => { var doclist = frappe.model.sync(r.message); - frappe.set_route('Form', doclist[0].doctype, doclist[0].name); - } + frappe.set_route("Form", doclist[0].doctype, doclist[0].name); + }, }); } }; -extend_cscript(cur_frm.cscript, new erpnext.buying.SubcontractingOrderController({ frm: cur_frm })); \ No newline at end of file +extend_cscript(cur_frm.cscript, new erpnext.buying.SubcontractingOrderController({ frm: cur_frm })); diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js index ec54944a849..895ffdbf88c 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order_list.js @@ -1,18 +1,18 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.listview_settings['Subcontracting Order'] = { +frappe.listview_settings["Subcontracting Order"] = { get_indicator: function (doc) { const status_colors = { - "Draft": "grey", - "Open": "orange", + Draft: "grey", + Open: "orange", "Partially Received": "yellow", - "Completed": "green", + Completed: "green", "Partial Material Transferred": "purple", "Material Transferred": "blue", - "Closed": "green", - "Cancelled": "red", + Closed: "green", + Cancelled: "red", }; return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; }, -}; \ No newline at end of file +}; diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index 05357999a1b..aeff2f6d58f 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -1,20 +1,20 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.provide('erpnext.buying'); +frappe.provide("erpnext.buying"); -erpnext.landed_cost_taxes_and_charges.setup_triggers('Subcontracting Receipt'); +erpnext.landed_cost_taxes_and_charges.setup_triggers("Subcontracting Receipt"); -frappe.ui.form.on('Subcontracting Receipt', { +frappe.ui.form.on("Subcontracting Receipt", { setup: (frm) => { - frm.ignore_doctypes_on_cancel_all = ['Serial and Batch Bundle']; - frm.get_field('supplied_items').grid.cannot_add_rows = true; - frm.get_field('supplied_items').grid.only_sortable(); - frm.trigger('set_queries'); + frm.ignore_doctypes_on_cancel_all = ["Serial and Batch Bundle"]; + frm.get_field("supplied_items").grid.cannot_add_rows = true; + frm.get_field("supplied_items").grid.only_sortable(); + frm.trigger("set_queries"); frm.custom_make_buttons = { - 'Purchase Receipt': 'Purchase Receipt', - } + "Purchase Receipt": "Purchase Receipt", + }; }, on_submit(frm) { @@ -24,198 +24,222 @@ frappe.ui.form.on('Subcontracting Receipt', { refresh_serial_batch_bundle_field(frm) { frappe.route_hooks.after_submit = (frm_obj) => { frm_obj.reload_doc(); - } + }; }, refresh: (frm) => { if (frm.doc.docstatus === 1) { - frm.add_custom_button(__('Stock Ledger'), () => { - frappe.route_options = { - voucher_no: frm.doc.name, - from_date: frm.doc.posting_date, - to_date: moment(frm.doc.modified).format('YYYY-MM-DD'), - company: frm.doc.company, - show_cancelled_entries: frm.doc.docstatus === 2 - } - frappe.set_route('query-report', 'Stock Ledger'); - }, __('View')); + frm.add_custom_button( + __("Stock Ledger"), + () => { + frappe.route_options = { + voucher_no: frm.doc.name, + from_date: frm.doc.posting_date, + to_date: moment(frm.doc.modified).format("YYYY-MM-DD"), + company: frm.doc.company, + show_cancelled_entries: frm.doc.docstatus === 2, + }; + frappe.set_route("query-report", "Stock Ledger"); + }, + __("View") + ); - frm.add_custom_button(__('Accounting Ledger'), () => { - frappe.route_options = { - voucher_no: frm.doc.name, - from_date: frm.doc.posting_date, - to_date: moment(frm.doc.modified).format('YYYY-MM-DD'), - company: frm.doc.company, - group_by: 'Group by Voucher (Consolidated)', - show_cancelled_entries: frm.doc.docstatus === 2 - } - frappe.set_route('query-report', 'General Ledger'); - }, __('View')); + frm.add_custom_button( + __("Accounting Ledger"), + () => { + frappe.route_options = { + voucher_no: frm.doc.name, + from_date: frm.doc.posting_date, + to_date: moment(frm.doc.modified).format("YYYY-MM-DD"), + company: frm.doc.company, + group_by: "Group by Voucher (Consolidated)", + show_cancelled_entries: frm.doc.docstatus === 2, + }; + frappe.set_route("query-report", "General Ledger"); + }, + __("View") + ); if (frm.doc.is_return === 0) { - frm.add_custom_button(__('Purchase Receipt'), () => { - frappe.model.open_mapped_doc({ - method: 'erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_purchase_receipt', - frm: frm, - freeze: true, - freeze_message: __('Creating Purchase Receipt ...') - }); - }, __('Create')); + frm.add_custom_button( + __("Purchase Receipt"), + () => { + frappe.model.open_mapped_doc({ + method: "erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_purchase_receipt", + frm: frm, + freeze: true, + freeze_message: __("Creating Purchase Receipt ..."), + }); + }, + __("Create") + ); } } if (!frm.doc.is_return && frm.doc.docstatus === 1 && frm.doc.per_returned < 100) { - frm.add_custom_button(__('Subcontract Return'), () => { - frappe.model.open_mapped_doc({ - method: 'erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_subcontract_return', - frm: frm - }); - }, __('Create')); - frm.page.set_inner_btn_group_as_primary(__('Create')); + frm.add_custom_button( + __("Subcontract Return"), + () => { + frappe.model.open_mapped_doc({ + method: "erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_subcontract_return", + frm: frm, + }); + }, + __("Create") + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } if (frm.doc.docstatus === 0) { - frm.add_custom_button(__('Subcontracting Order'), () => { - if (!frm.doc.supplier) { - frappe.throw({ - title: __('Mandatory'), - message: __('Please Select a Supplier') - }); - } - - erpnext.utils.map_current_doc({ - method: 'erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order.make_subcontracting_receipt', - source_doctype: 'Subcontracting Order', - target: frm, - setters: { - supplier: frm.doc.supplier, - }, - get_query_filters: { - docstatus: 1, - per_received: ['<', 100], - company: frm.doc.company, - status: ['!=', 'Closed'], + frm.add_custom_button( + __("Subcontracting Order"), + () => { + if (!frm.doc.supplier) { + frappe.throw({ + title: __("Mandatory"), + message: __("Please Select a Supplier"), + }); } - }); - }, __('Get Items From')); - frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty', 'read_only', frm.doc.__onload && frm.doc.__onload.backflush_based_on === 'BOM'); + erpnext.utils.map_current_doc({ + method: "erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order.make_subcontracting_receipt", + source_doctype: "Subcontracting Order", + target: frm, + setters: { + supplier: frm.doc.supplier, + }, + get_query_filters: { + docstatus: 1, + per_received: ["<", 100], + company: frm.doc.company, + status: ["!=", "Closed"], + }, + }); + }, + __("Get Items From") + ); + + frm.fields_dict.supplied_items.grid.update_docfield_property( + "consumed_qty", + "read_only", + frm.doc.__onload && frm.doc.__onload.backflush_based_on === "BOM" + ); } - frm.trigger('setup_quality_inspection'); - frm.trigger('set_route_options_for_new_doc'); + frm.trigger("setup_quality_inspection"); + frm.trigger("set_route_options_for_new_doc"); }, set_warehouse: (frm) => { - set_warehouse_in_children(frm.doc.items, 'warehouse', frm.doc.set_warehouse); + set_warehouse_in_children(frm.doc.items, "warehouse", frm.doc.set_warehouse); }, rejected_warehouse: (frm) => { - set_warehouse_in_children(frm.doc.items, 'rejected_warehouse', frm.doc.rejected_warehouse); + set_warehouse_in_children(frm.doc.items, "rejected_warehouse", frm.doc.rejected_warehouse); }, get_scrap_items: (frm) => { frappe.call({ doc: frm.doc, - method: 'get_scrap_items', + method: "get_scrap_items", args: { - recalculate_rate: true + recalculate_rate: true, }, freeze: true, - freeze_message: __('Getting Scrap Items'), + freeze_message: __("Getting Scrap Items"), callback: (r) => { if (!r.exc) { frm.refresh(); } - } + }, }); }, set_queries: (frm) => { - frm.set_query('set_warehouse', () => { + frm.set_query("set_warehouse", () => { return { filters: { company: frm.doc.company, - is_group: 0 - } - } + is_group: 0, + }, + }; }); - frm.set_query('rejected_warehouse', () => { + frm.set_query("rejected_warehouse", () => { return { filters: { company: frm.doc.company, - is_group: 0 - } - } + is_group: 0, + }, + }; }); - frm.set_query('supplier_warehouse', () => { + frm.set_query("supplier_warehouse", () => { return { filters: { company: frm.doc.company, - is_group: 0 - } - } + is_group: 0, + }, + }; }); - frm.set_query('warehouse', 'items', () => ({ + frm.set_query("warehouse", "items", () => ({ filters: { company: frm.doc.company, - is_group: 0 - } + is_group: 0, + }, })); - frm.set_query('rejected_warehouse', 'items', () => ({ + frm.set_query("rejected_warehouse", "items", () => ({ filters: { company: frm.doc.company, - is_group: 0 - } + is_group: 0, + }, })); - frm.set_query('expense_account', 'items', () => { + frm.set_query("expense_account", "items", () => { return { - query: 'erpnext.controllers.queries.get_expense_account', - filters: { 'company': frm.doc.company } - } + query: "erpnext.controllers.queries.get_expense_account", + filters: { company: frm.doc.company }, + }; }); - frm.set_query('batch_no', 'items', (doc, cdt, cdn) => { + frm.set_query("batch_no", "items", (doc, cdt, cdn) => { var row = locals[cdt][cdn]; return { filters: { - item: row.item_code - } - } + item: row.item_code, + }, + }; }); - frm.set_query('serial_and_batch_bundle', 'items', (doc, cdt, cdn) => { + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { return frm.events.get_serial_and_batch_bundle_filters(doc, cdt, cdn); }); - frm.set_query('rejected_serial_and_batch_bundle', 'items', (doc, cdt, cdn) => { + frm.set_query("rejected_serial_and_batch_bundle", "items", (doc, cdt, cdn) => { return frm.events.get_serial_and_batch_bundle_filters(doc, cdt, cdn); }); - frm.set_query('batch_no', 'supplied_items', (doc, cdt, cdn) => { + frm.set_query("batch_no", "supplied_items", (doc, cdt, cdn) => { var row = locals[cdt][cdn]; return { filters: { - item: row.rm_item_code - } - } + item: row.rm_item_code, + }, + }; }); - frm.set_query('serial_and_batch_bundle', 'supplied_items', (doc, cdt, cdn) => { + frm.set_query("serial_and_batch_bundle", "supplied_items", (doc, cdt, cdn) => { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.rm_item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ['in', [doc.name, '']], - 'is_cancelled': 0, - } - } + item_code: row.rm_item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }); }, @@ -223,12 +247,12 @@ frappe.ui.form.on('Subcontracting Receipt', { let row = locals[cdt][cdn]; return { filters: { - 'item_code': row.item_code, - 'voucher_type': doc.doctype, - 'voucher_no': ['in', [doc.name, '']], - 'is_cancelled': 0, - } - } + item_code: row.item_code, + voucher_type: doc.doctype, + voucher_no: ["in", [doc.name, ""]], + is_cancelled: 0, + }, + }; }, setup_quality_inspection: (frm) => { @@ -239,48 +263,48 @@ frappe.ui.form.on('Subcontracting Receipt', { }, set_route_options_for_new_doc: (frm) => { - let batch_no_field = frm.get_docfield('items', 'batch_no'); + let batch_no_field = frm.get_docfield("items", "batch_no"); if (batch_no_field) { batch_no_field.get_route_options_for_new_doc = (row) => { return { - 'item': row.doc.item_code - } - } + item: row.doc.item_code, + }; + }; } - let item_sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); + let item_sbb_field = frm.get_docfield("items", "serial_and_batch_bundle"); if (item_sbb_field) { item_sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } - } + item_code: row.doc.item_code, + voucher_type: frm.doc.doctype, + }; + }; } - let rejected_item_sbb_field = frm.get_docfield('items', 'rejected_serial_and_batch_bundle'); + let rejected_item_sbb_field = frm.get_docfield("items", "rejected_serial_and_batch_bundle"); if (rejected_item_sbb_field) { rejected_item_sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } - } + item_code: row.doc.item_code, + voucher_type: frm.doc.doctype, + }; + }; } - let rm_sbb_field = frm.get_docfield('supplied_items', 'serial_and_batch_bundle'); + let rm_sbb_field = frm.get_docfield("supplied_items", "serial_and_batch_bundle"); if (rm_sbb_field) { rm_sbb_field.get_route_options_for_new_doc = (row) => { return { - 'item_code': row.doc.rm_item_code, - 'voucher_type': frm.doc.doctype, - } - } + item_code: row.doc.rm_item_code, + voucher_type: frm.doc.doctype, + }; + }; } }, }); -frappe.ui.form.on('Landed Cost Taxes and Charges', { +frappe.ui.form.on("Landed Cost Taxes and Charges", { amount: (frm, cdt, cdn) => { set_missing_values(frm); frm.events.set_base_amount(frm, cdt, cdn); @@ -292,10 +316,10 @@ frappe.ui.form.on('Landed Cost Taxes and Charges', { additional_costs_remove: (frm) => { set_missing_values(frm); - } + }, }); -frappe.ui.form.on('Subcontracting Receipt Item', { +frappe.ui.form.on("Subcontracting Receipt Item", { item_code(frm) { set_missing_values(frm); }, @@ -313,7 +337,7 @@ frappe.ui.form.on('Subcontracting Receipt Item', { }, }); -frappe.ui.form.on('Subcontracting Receipt Supplied Item', { +frappe.ui.form.on("Subcontracting Receipt Supplied Item", { consumed_qty(frm) { set_missing_values(frm); }, @@ -322,14 +346,14 @@ frappe.ui.form.on('Subcontracting Receipt Supplied Item', { let set_warehouse_in_children = (child_table, warehouse_field, warehouse) => { let transaction_controller = new erpnext.TransactionController(); transaction_controller.autofill_warehouse(child_table, warehouse_field, warehouse); -} +}; let set_missing_values = (frm) => { frappe.call({ doc: frm.doc, - method: 'set_missing_values', + method: "set_missing_values", callback: (r) => { if (!r.exc) frm.refresh(); }, }); -} +}; diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_list.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_list.js index 14a4e4ad6cb..be6c0d0b18f 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_list.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt_list.js @@ -1,14 +1,14 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.listview_settings['Subcontracting Receipt'] = { +frappe.listview_settings["Subcontracting Receipt"] = { get_indicator: function (doc) { const status_colors = { - "Draft": "grey", - "Return": "gray", + Draft: "grey", + Return: "gray", "Return Issued": "grey", - "Completed": "green", + Completed: "green", }; return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; }, -}; \ No newline at end of file +}; diff --git a/erpnext/support/doctype/issue/issue.js b/erpnext/support/doctype/issue/issue.js index 9f91dc1726d..03d209e99e3 100644 --- a/erpnext/support/doctype/issue/issue.js +++ b/erpnext/support/doctype/issue/issue.js @@ -1,40 +1,47 @@ frappe.ui.form.on("Issue", { - onload: function(frm) { + onload: function (frm) { frm.email_field = "raised_by"; - frappe.db.get_value("Support Settings", {name: "Support Settings"}, - ["allow_resetting_service_level_agreement", "track_service_level_agreement"], (r) => { + frappe.db.get_value( + "Support Settings", + { name: "Support Settings" }, + ["allow_resetting_service_level_agreement", "track_service_level_agreement"], + (r) => { if (r && r.track_service_level_agreement == "0") { frm.set_df_property("service_level_section", "hidden", 1); } if (r && r.allow_resetting_service_level_agreement == "0") { frm.set_df_property("reset_service_level_agreement", "hidden", 1); } - }); + } + ); // buttons if (frm.doc.status !== "Closed") { - frm.add_custom_button(__("Close"), function() { + frm.add_custom_button(__("Close"), function () { frm.set_value("status", "Closed"); frm.save(); }); - frm.add_custom_button(__("Task"), function() { - frappe.model.open_mapped_doc({ - method: "erpnext.support.doctype.issue.issue.make_task", - frm: frm - }); - }, __("Create")); - + frm.add_custom_button( + __("Task"), + function () { + frappe.model.open_mapped_doc({ + method: "erpnext.support.doctype.issue.issue.make_task", + frm: frm, + }); + }, + __("Create") + ); } else { - frm.add_custom_button(__("Reopen"), function() { + frm.add_custom_button(__("Reopen"), function () { frm.set_value("status", "Open"); frm.save(); }); } }, - reset_service_level_agreement: function(frm) { + reset_service_level_agreement: function (frm) { let reset_sla = new frappe.ui.Dialog({ title: __("Reset Service Level Agreement"), fields: [ @@ -42,8 +49,8 @@ frappe.ui.form.on("Issue", { fieldtype: "Data", fieldname: "reason", label: __("Reason"), - reqd: 1 - } + reqd: 1, + }, ], primary_action_label: __("Reset"), primary_action: (values) => { @@ -53,39 +60,42 @@ frappe.ui.form.on("Issue", { frappe.show_alert({ indicator: "green", - message: __("Resetting Service Level Agreement.") + message: __("Resetting Service Level Agreement."), }); - frappe.call("erpnext.support.doctype.service_level_agreement.service_level_agreement.reset_service_level_agreement", { - reason: values.reason, - user: frappe.session.user_email, - doctype: frm.doc.doctype, - docname: frm.doc.name, - }, () => { - reset_sla.enable_primary_action(); - frm.refresh(); - frappe.msgprint(__("Service Level Agreement was reset.")); - }); - } + frappe.call( + "erpnext.support.doctype.service_level_agreement.service_level_agreement.reset_service_level_agreement", + { + reason: values.reason, + user: frappe.session.user_email, + doctype: frm.doc.doctype, + docname: frm.doc.name, + }, + () => { + reset_sla.enable_primary_action(); + frm.refresh(); + frappe.msgprint(__("Service Level Agreement was reset.")); + } + ); + }, }); reset_sla.show(); }, - - timeline_refresh: function(frm) { + timeline_refresh: function (frm) { if (!frm.timeline.wrapper.find(".btn-split-issue").length) { let split_issue_btn = $(` - ${frappe.utils.icon('branch', 'sm')} + ${frappe.utils.icon("branch", "sm")} `); let communication_box = frm.timeline.wrapper.find('.timeline-item[data-doctype="Communication"]'); - communication_box.find('.actions').prepend(split_issue_btn); + communication_box.find(".actions").prepend(split_issue_btn); if (!frm.timeline.wrapper.data("split-issue-event-attached")) { - frm.timeline.wrapper.on('click', '.btn-split-issue', (e) => { + frm.timeline.wrapper.on("click", ".btn-split-issue", (e) => { var dialog = new frappe.ui.Dialog({ title: __("Split Issue"), fields: [ @@ -94,20 +104,30 @@ frappe.ui.form.on("Issue", { fieldtype: "Data", reqd: 1, label: __("Subject"), - description: __("All communications including and above this shall be moved into the new Issue") - } + description: __( + "All communications including and above this shall be moved into the new Issue" + ), + }, ], primary_action_label: __("Split"), primary_action: () => { - frm.call("split_issue", { - subject: dialog.fields_dict.subject.value, - communication_id: e.currentTarget.closest(".timeline-item").getAttribute("data-name") - }, (r) => { - frappe.msgprint(`New issue created: ${r.message}`); - frm.reload_doc(); - dialog.hide(); - }); - } + frm.call( + "split_issue", + { + subject: dialog.fields_dict.subject.value, + communication_id: e.currentTarget + .closest(".timeline-item") + .getAttribute("data-name"), + }, + (r) => { + frappe.msgprint( + `New issue created: ${r.message}` + ); + frm.reload_doc(); + dialog.hide(); + } + ); + }, }); dialog.show(); }); diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js index 5c9d4ed9890..8aa1650c599 100644 --- a/erpnext/support/doctype/issue/issue_list.js +++ b/erpnext/support/doctype/issue/issue_list.js @@ -1,30 +1,30 @@ -frappe.listview_settings['Issue'] = { - colwidths: {"subject": 6}, - add_fields: ['priority'], +frappe.listview_settings["Issue"] = { + colwidths: { subject: 6 }, + add_fields: ["priority"], filters: [["status", "=", "Open"]], - onload: function(listview) { + onload: function (listview) { var method = "erpnext.support.doctype.issue.issue.set_multiple_status"; - listview.page.add_action_item(__("Set as Open"), function() { - listview.call_for_selected_items(method, {"status": "Open"}); + listview.page.add_action_item(__("Set as Open"), function () { + listview.call_for_selected_items(method, { status: "Open" }); }); - listview.page.add_action_item(__("Set as Closed"), function() { - listview.call_for_selected_items(method, {"status": "Closed"}); + listview.page.add_action_item(__("Set as Closed"), function () { + listview.call_for_selected_items(method, { status: "Closed" }); }); }, - get_indicator: function(doc) { - if (doc.status === 'Open') { + get_indicator: function (doc) { + if (doc.status === "Open") { const color = { - 'Low': 'yellow', - 'Medium': 'orange', - 'High': 'red' + Low: "yellow", + Medium: "orange", + High: "red", }; - return [__(doc.status), color[doc.priority] || 'red', `status,=,Open`]; - } else if (doc.status === 'Closed') { + return [__(doc.status), color[doc.priority] || "red", `status,=,Open`]; + } else if (doc.status === "Closed") { return [__(doc.status), "green", "status,=," + doc.status]; } else { return [__(doc.status), "gray", "status,=," + doc.status]; } - } -} + }, +}; diff --git a/erpnext/support/doctype/issue_priority/issue_priority.js b/erpnext/support/doctype/issue_priority/issue_priority.js index 37ce6a54bf7..e777d0690ca 100644 --- a/erpnext/support/doctype/issue_priority/issue_priority.js +++ b/erpnext/support/doctype/issue_priority/issue_priority.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Issue Priority', { +frappe.ui.form.on("Issue Priority", { // refresh: function(frm) { - // } }); diff --git a/erpnext/support/doctype/issue_type/issue_type.js b/erpnext/support/doctype/issue_type/issue_type.js index 2b3d14ef712..aa0c4565d6c 100644 --- a/erpnext/support/doctype/issue_type/issue_type.js +++ b/erpnext/support/doctype/issue_type/issue_type.js @@ -1,8 +1,6 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Issue Type', { - refresh: function(frm) { - - } +frappe.ui.form.on("Issue Type", { + refresh: function (frm) {}, }); diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.js b/erpnext/support/doctype/service_level_agreement/service_level_agreement.js index 4dbb0e7e86f..a8b85de9d6a 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.js +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.js @@ -1,121 +1,145 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Service Level Agreement', { - setup: function(frm) { +frappe.ui.form.on("Service Level Agreement", { + setup: function (frm) { if (cint(frm.doc.apply_sla_for_resolution) === 1) { - frm.get_field('priorities').grid.editable_fields = [ - {fieldname: 'default_priority', columns: 1}, - {fieldname: 'priority', columns: 2}, - {fieldname: 'response_time', columns: 2}, - {fieldname: 'resolution_time', columns: 2} + frm.get_field("priorities").grid.editable_fields = [ + { fieldname: "default_priority", columns: 1 }, + { fieldname: "priority", columns: 2 }, + { fieldname: "response_time", columns: 2 }, + { fieldname: "resolution_time", columns: 2 }, ]; } else { - frm.get_field('priorities').grid.editable_fields = [ - {fieldname: 'default_priority', columns: 1}, - {fieldname: 'priority', columns: 2}, - {fieldname: 'response_time', columns: 3}, + frm.get_field("priorities").grid.editable_fields = [ + { fieldname: "default_priority", columns: 1 }, + { fieldname: "priority", columns: 2 }, + { fieldname: "response_time", columns: 3 }, ]; } }, - refresh: function(frm) { - frm.trigger('fetch_status_fields'); - frm.trigger('toggle_resolution_fields'); - frm.trigger('default_service_level_agreement'); - frm.trigger('entity'); + refresh: function (frm) { + frm.trigger("fetch_status_fields"); + frm.trigger("toggle_resolution_fields"); + frm.trigger("default_service_level_agreement"); + frm.trigger("entity"); }, - default_service_level_agreement: function(frm) { - const field = frm.get_field('default_service_level_agreement'); + default_service_level_agreement: function (frm) { + const field = frm.get_field("default_service_level_agreement"); if (frm.doc.default_service_level_agreement) { - field.set_description(__('SLA will be applied on every {0}', [frm.doc.document_type])); + field.set_description(__("SLA will be applied on every {0}", [frm.doc.document_type])); } else { - field.set_description(__('Enable to apply SLA on every {0}', [frm.doc.document_type])); + field.set_description(__("Enable to apply SLA on every {0}", [frm.doc.document_type])); } }, - document_type: function(frm) { - frm.trigger('fetch_status_fields'); - frm.trigger('default_service_level_agreement'); + document_type: function (frm) { + frm.trigger("fetch_status_fields"); + frm.trigger("default_service_level_agreement"); }, - entity_type: function(frm) { - frm.set_value('entity', undefined); + entity_type: function (frm) { + frm.set_value("entity", undefined); }, - entity: function(frm) { - const field = frm.get_field('entity'); + entity: function (frm) { + const field = frm.get_field("entity"); if (frm.doc.entity) { - const and_descendants = frm.doc.entity_type != 'Customer' ? ' ' + __('or its descendants') : ''; + const and_descendants = frm.doc.entity_type != "Customer" ? " " + __("or its descendants") : ""; field.set_description( - __('SLA will be applied if {1} is set as {2}{3}', [ - frm.doc.document_type, frm.doc.entity_type, - frm.doc.entity, and_descendants + __("SLA will be applied if {1} is set as {2}{3}", [ + frm.doc.document_type, + frm.doc.entity_type, + frm.doc.entity, + and_descendants, ]) ); } else { - field.set_description(''); + field.set_description(""); } }, - fetch_status_fields: function(frm) { + fetch_status_fields: function (frm) { let allow_statuses = []; let exclude_statuses = []; if (frm.doc.document_type) { frappe.model.with_doctype(frm.doc.document_type, () => { - let statuses = frappe.meta.get_docfield(frm.doc.document_type, 'status', frm.doc.name).options; - statuses = statuses.split('\n'); + let statuses = frappe.meta.get_docfield( + frm.doc.document_type, + "status", + frm.doc.name + ).options; + statuses = statuses.split("\n"); - exclude_statuses = ['Open', 'Closed']; + exclude_statuses = ["Open", "Closed"]; allow_statuses = statuses.filter((status) => !exclude_statuses.includes(status)); frm.fields_dict.pause_sla_on.grid.update_docfield_property( - 'status', 'options', [''].concat(allow_statuses) + "status", + "options", + [""].concat(allow_statuses) ); - exclude_statuses = ['Open']; + exclude_statuses = ["Open"]; allow_statuses = statuses.filter((status) => !exclude_statuses.includes(status)); frm.fields_dict.sla_fulfilled_on.grid.update_docfield_property( - 'status', 'options', [''].concat(allow_statuses) + "status", + "options", + [""].concat(allow_statuses) ); }); } - frm.refresh_field('pause_sla_on'); + frm.refresh_field("pause_sla_on"); }, - apply_sla_for_resolution: function(frm) { - frm.trigger('toggle_resolution_fields'); + apply_sla_for_resolution: function (frm) { + frm.trigger("toggle_resolution_fields"); }, - toggle_resolution_fields: function(frm) { + toggle_resolution_fields: function (frm) { if (cint(frm.doc.apply_sla_for_resolution) === 1) { - frm.fields_dict.priorities.grid.update_docfield_property('resolution_time', 'hidden', 0); - frm.fields_dict.priorities.grid.update_docfield_property('resolution_time', 'reqd', 1); + frm.fields_dict.priorities.grid.update_docfield_property("resolution_time", "hidden", 0); + frm.fields_dict.priorities.grid.update_docfield_property("resolution_time", "reqd", 1); } else { - frm.fields_dict.priorities.grid.update_docfield_property('resolution_time', 'hidden', 1); - frm.fields_dict.priorities.grid.update_docfield_property('resolution_time', 'reqd', 0); + frm.fields_dict.priorities.grid.update_docfield_property("resolution_time", "hidden", 1); + frm.fields_dict.priorities.grid.update_docfield_property("resolution_time", "reqd", 0); } - frm.refresh_field('priorities'); + frm.refresh_field("priorities"); }, - onload: function(frm) { - frm.set_query("document_type", function() { + onload: function (frm) { + frm.set_query("document_type", function () { let invalid_doctypes = frappe.model.core_doctypes_list; - invalid_doctypes.push(frm.doc.doctype, 'Cost Center', 'Company'); + invalid_doctypes.push(frm.doc.doctype, "Cost Center", "Company"); return { filters: [ - ['DocType', 'issingle', '=', 0], - ['DocType', 'istable', '=', 0], - ['DocType', 'is_submittable', '=', 0], - ['DocType', 'name', 'not in', invalid_doctypes], - ['DocType', 'module', 'not in', ["Email", "Core", "Custom", "Event Streaming", "Social", "Data Migration", "Geo", "Desk"]] - ] + ["DocType", "issingle", "=", 0], + ["DocType", "istable", "=", 0], + ["DocType", "is_submittable", "=", 0], + ["DocType", "name", "not in", invalid_doctypes], + [ + "DocType", + "module", + "not in", + [ + "Email", + "Core", + "Custom", + "Event Streaming", + "Social", + "Data Migration", + "Geo", + "Desk", + ], + ], + ], }; }); - } + }, }); diff --git a/erpnext/support/doctype/support_settings/support_settings.js b/erpnext/support/doctype/support_settings/support_settings.js index 78adca81ca5..3a1cb84ba85 100644 --- a/erpnext/support/doctype/support_settings/support_settings.js +++ b/erpnext/support/doctype/support_settings/support_settings.js @@ -1,8 +1,8 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Support Settings', { - refresh: function(frm) { +frappe.ui.form.on("Support Settings", { + refresh: function (frm) { // - } + }, }); diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js index 10cb37f5124..d7b77f71c5e 100644 --- a/erpnext/support/doctype/warranty_claim/warranty_claim.js +++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js @@ -43,10 +43,7 @@ frappe.ui.form.on("Warranty Claim", { doctype: "Customer", }; - if ( - !frm.doc.__islocal && - ["Open", "Work In Progress"].includes(frm.doc.status) - ) { + if (!frm.doc.__islocal && ["Open", "Work In Progress"].includes(frm.doc.status)) { frm.add_custom_button(__("Maintenance Visit"), () => { frappe.model.open_mapped_doc({ method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit", diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim_list.js b/erpnext/support/doctype/warranty_claim/warranty_claim_list.js index e162e137ba6..fdafb0ec59f 100644 --- a/erpnext/support/doctype/warranty_claim/warranty_claim_list.js +++ b/erpnext/support/doctype/warranty_claim/warranty_claim_list.js @@ -1,4 +1,4 @@ -frappe.listview_settings['Warranty Claim'] = { +frappe.listview_settings["Warranty Claim"] = { add_fields: ["status", "customer", "item_code"], - filters:[["status","=", "Open"]] + filters: [["status", "=", "Open"]], }; diff --git a/erpnext/support/report/first_response_time_for_issues/first_response_time_for_issues.js b/erpnext/support/report/first_response_time_for_issues/first_response_time_for_issues.js index a133770f6d7..ffe73879450 100644 --- a/erpnext/support/report/first_response_time_for_issues/first_response_time_for_issues.js +++ b/erpnext/support/report/first_response_time_for_issues/first_response_time_for_issues.js @@ -1,43 +1,44 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["First Response Time for Issues"] = { - "filters": [ + filters: [ { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30) + 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", - "reqd": 1, - "default":frappe.datetime.nowdate() - } + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.nowdate(), + }, ], - get_chart_data: function(_columns, result) { + get_chart_data: function (_columns, result) { return { data: { - labels: result.map(d => d.creation_date), - datasets: [{ - name: 'First Response Time', - values: result.map(d => d.first_response_time) - }] + labels: result.map((d) => d.creation_date), + datasets: [ + { + name: "First Response Time", + values: result.map((d) => d.first_response_time), + }, + ], }, type: "line", tooltipOptions: { - formatTooltipY: d => { + formatTooltipY: (d) => { let duration_options = { hide_days: 0, - hide_seconds: 0 + hide_seconds: 0, }; return frappe.utils.get_formatted_duration(d, duration_options); - } - } - } - } + }, + }, + }; + }, }; diff --git a/erpnext/support/report/issue_analytics/issue_analytics.js b/erpnext/support/report/issue_analytics/issue_analytics.js index be45b9b44a5..7a800f45afa 100644 --- a/erpnext/support/report/issue_analytics/issue_analytics.js +++ b/erpnext/support/report/issue_analytics/issue_analytics.js @@ -1,16 +1,15 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Issue Analytics"] = { - "filters": [ + filters: [ { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { fieldname: "based_on", @@ -18,125 +17,124 @@ frappe.query_reports["Issue Analytics"] = { fieldtype: "Select", options: ["Customer", "Issue Type", "Issue Priority", "Assigned To"], default: "Customer", - reqd: 1 + reqd: 1, }, { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_start_date"), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_end_date"), - reqd: 1 + reqd: 1, }, { fieldname: "range", label: __("Range"), fieldtype: "Select", options: [ - { "value": "Weekly", "label": __("Weekly") }, - { "value": "Monthly", "label": __("Monthly") }, - { "value": "Quarterly", "label": __("Quarterly") }, - { "value": "Yearly", "label": __("Yearly") } + { value: "Weekly", label: __("Weekly") }, + { value: "Monthly", label: __("Monthly") }, + { value: "Quarterly", label: __("Quarterly") }, + { value: "Yearly", label: __("Yearly") }, ], default: "Monthly", - reqd: 1 + reqd: 1, }, { fieldname: "status", label: __("Status"), fieldtype: "Select", - options:[ + options: [ "", - {label: __('Open'), value: 'Open'}, - {label: __('Replied'), value: 'Replied'}, - {label: __('Resolved'), value: 'Resolved'}, - {label: __('Closed'), value: 'Closed'} - ] + { label: __("Open"), value: "Open" }, + { label: __("Replied"), value: "Replied" }, + { label: __("Resolved"), value: "Resolved" }, + { label: __("Closed"), value: "Closed" }, + ], }, { fieldname: "priority", label: __("Issue Priority"), fieldtype: "Link", - options: "Issue Priority" + options: "Issue Priority", }, { fieldname: "customer", label: __("Customer"), fieldtype: "Link", - options: "Customer" + options: "Customer", }, { fieldname: "project", label: __("Project"), fieldtype: "Link", - options: "Project" + options: "Project", }, { fieldname: "assigned_to", label: __("Assigned To"), fieldtype: "Link", - options: "User" - } + options: "User", + }, ], - after_datatable_render: function(datatable_obj) { - $(datatable_obj.wrapper).find(".dt-row-0").find('input[type=checkbox]').click(); + after_datatable_render: function (datatable_obj) { + $(datatable_obj.wrapper).find(".dt-row-0").find("input[type=checkbox]").click(); }, get_datatable_options(options) { return Object.assign(options, { checkboxColumn: true, events: { - onCheckRow: function(data) { + onCheckRow: function (data) { if (data && data.length) { let row_name = data[2].content; - let row_values = data.slice(3).map(function(column) { + let row_values = data.slice(3).map(function (column) { return column.content; - }) - let entry = { - 'name': row_name, - 'values': row_values - } + }); + let entry = { + name: row_name, + values: row_values, + }; let raw_data = frappe.query_report.chart.data; let new_datasets = raw_data.datasets; var found = false; - for(var i=0; i < new_datasets.length; i++){ - if (new_datasets[i].name == row_name){ + for (var i = 0; i < new_datasets.length; i++) { + if (new_datasets[i].name == row_name) { found = true; - new_datasets.splice(i,1); + new_datasets.splice(i, 1); break; } } - if (!found){ + if (!found) { new_datasets.push(entry); } let new_data = { labels: raw_data.labels, - datasets: new_datasets - } + datasets: new_datasets, + }; setTimeout(() => { - frappe.query_report.chart.update(new_data) - },500) - + frappe.query_report.chart.update(new_data); + }, 500); setTimeout(() => { frappe.query_report.chart.draw(true); - }, 1000) + }, 1000); frappe.query_report.raw_chart_data = new_data; } }, - } + }, }); - } + }, }; diff --git a/erpnext/support/report/issue_summary/issue_summary.js b/erpnext/support/report/issue_summary/issue_summary.js index aee6f53f17b..79c57d75e9c 100644 --- a/erpnext/support/report/issue_summary/issue_summary.js +++ b/erpnext/support/report/issue_summary/issue_summary.js @@ -1,16 +1,15 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Issue Summary"] = { - "filters": [ + filters: [ { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { fieldname: "based_on", @@ -18,58 +17,58 @@ frappe.query_reports["Issue Summary"] = { fieldtype: "Select", options: ["Customer", "Issue Type", "Issue Priority", "Assigned To"], default: "Customer", - reqd: 1 + reqd: 1, }, { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_start_date"), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.defaults.get_global_default("year_end_date"), - reqd: 1 + reqd: 1, }, { fieldname: "status", label: __("Status"), fieldtype: "Select", - options:[ + options: [ "", - {label: __('Open'), value: 'Open'}, - {label: __('Replied'), value: 'Replied'}, - {label: __('On Hold'), value: 'On Hold'}, - {label: __('Resolved'), value: 'Resolved'}, - {label: __('Closed'), value: 'Closed'} - ] + { label: __("Open"), value: "Open" }, + { label: __("Replied"), value: "Replied" }, + { label: __("On Hold"), value: "On Hold" }, + { label: __("Resolved"), value: "Resolved" }, + { label: __("Closed"), value: "Closed" }, + ], }, { fieldname: "priority", label: __("Issue Priority"), fieldtype: "Link", - options: "Issue Priority" + options: "Issue Priority", }, { fieldname: "customer", label: __("Customer"), fieldtype: "Link", - options: "Customer" + options: "Customer", }, { fieldname: "project", label: __("Project"), fieldtype: "Link", - options: "Project" + options: "Project", }, { fieldname: "assigned_to", label: __("Assigned To"), fieldtype: "Link", - options: "User" - } - ] + options: "User", + }, + ], }; diff --git a/erpnext/support/report/support_hour_distribution/support_hour_distribution.js b/erpnext/support/report/support_hour_distribution/support_hour_distribution.js index 82ccc73bf96..96d8e001c37 100644 --- a/erpnext/support/report/support_hour_distribution/support_hour_distribution.js +++ b/erpnext/support/report/support_hour_distribution/support_hour_distribution.js @@ -1,22 +1,21 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - frappe.query_reports["Support Hour Distribution"] = { - "filters": [ + filters: [ { - 'lable': __("From Date"), - 'fieldname': 'from_date', - 'fieldtype': 'Date', - 'default': frappe.datetime.nowdate(), - 'reqd': 1 + lable: __("From Date"), + fieldname: "from_date", + fieldtype: "Date", + default: frappe.datetime.nowdate(), + reqd: 1, }, { - 'lable': __("To Date"), - 'fieldname': 'to_date', - 'fieldtype': 'Date', - 'default': frappe.datetime.nowdate(), - 'reqd': 1 - } - ] -} + lable: __("To Date"), + fieldname: "to_date", + fieldtype: "Date", + default: frappe.datetime.nowdate(), + reqd: 1, + }, + ], +}; diff --git a/erpnext/support/web_form/issues/issues.js b/erpnext/support/web_form/issues/issues.js index ffc5e984253..8f56ebb353d 100644 --- a/erpnext/support/web_form/issues/issues.js +++ b/erpnext/support/web_form/issues/issues.js @@ -1,3 +1,3 @@ -frappe.ready(function() { +frappe.ready(function () { // bind events here -}) +}); diff --git a/erpnext/telephony/doctype/call_log/call_log.js b/erpnext/telephony/doctype/call_log/call_log.js index e7afa0b7d09..1fd15266003 100644 --- a/erpnext/telephony/doctype/call_log/call_log.js +++ b/erpnext/telephony/doctype/call_log/call_log.js @@ -1,21 +1,21 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Call Log', { - refresh: function(frm) { +frappe.ui.form.on("Call Log", { + refresh: function (frm) { frm.events.setup_recording_audio_control(frm); - const incoming_call = frm.doc.type == 'Incoming'; - frm.add_custom_button(incoming_call ? __('Callback'): __('Call Again'), () => { + const incoming_call = frm.doc.type == "Incoming"; + frm.add_custom_button(incoming_call ? __("Callback") : __("Call Again"), () => { const number = incoming_call ? frm.doc.from : frm.doc.to; frappe.phone_call.handler(number, frm); }); }, setup_recording_audio_control(frm) { - const recording_wrapper = frm.get_field('recording_html').$wrapper; - if (!frm.doc.recording_url || frm.doc.recording_url == 'null') { + const recording_wrapper = frm.get_field("recording_html").$wrapper; + if (!frm.doc.recording_url || frm.doc.recording_url == "null") { recording_wrapper.empty(); } else { - recording_wrapper.addClass('input-max-width'); + recording_wrapper.addClass("input-max-width"); recording_wrapper.html(`