From 7d892438f0e00fe9aacc7989420466212f892051 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 2 Mar 2021 17:50:58 +0530 Subject: [PATCH 01/10] fix: track setting changes --- .../buying/doctype/buying_settings/buying_settings.json | 7 ++++--- .../doctype/mpesa_settings/mpesa_settings.json | 5 +++-- .../doctype/plaid_settings/plaid_settings.json | 5 +++-- .../doctype/shopify_settings/shopify_settings.json | 5 +++-- .../payroll/doctype/payroll_settings/payroll_settings.json | 5 +++-- .../selling/doctype/selling_settings/selling_settings.json | 5 +++-- .../shopping_cart_settings/shopping_cart_settings.json | 5 +++-- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json index 618212da80..248cb9a8a0 100644 --- a/erpnext/buying/doctype/buying_settings/buying_settings.json +++ b/erpnext/buying/doctype/buying_settings/buying_settings.json @@ -96,7 +96,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2020-10-13 12:00:23.276329", + "modified": "2021-03-02 17:34:04.190677", "modified_by": "Administrator", "module": "Buying", "name": "Buying Settings", @@ -113,5 +113,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" -} + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.json b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.json index 407f82616f..8f3b4271c1 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.json +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.json @@ -103,7 +103,7 @@ } ], "links": [], - "modified": "2021-01-29 12:02:16.106942", + "modified": "2021-03-02 17:35:14.084342", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "Mpesa Settings", @@ -147,5 +147,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json index 122aa41f4b..e7176ea945 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.json @@ -70,7 +70,7 @@ ], "issingle": 1, "links": [], - "modified": "2020-10-29 20:24:56.916104", + "modified": "2021-03-02 17:35:27.544259", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "Plaid Settings", @@ -88,5 +88,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json index 20ec06373e..308e7d163f 100644 --- a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json +++ b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json @@ -330,7 +330,7 @@ ], "issingle": 1, "links": [], - "modified": "2020-11-05 20:44:03.664891", + "modified": "2021-03-02 17:35:41.953317", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "Shopify Settings", @@ -348,5 +348,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/payroll/doctype/payroll_settings/payroll_settings.json b/erpnext/payroll/doctype/payroll_settings/payroll_settings.json index c47caa1227..76565d55cb 100644 --- a/erpnext/payroll/doctype/payroll_settings/payroll_settings.json +++ b/erpnext/payroll/doctype/payroll_settings/payroll_settings.json @@ -109,7 +109,7 @@ "icon": "fa fa-cog", "issingle": 1, "links": [], - "modified": "2020-06-22 17:00:58.408030", + "modified": "2021-03-02 17:49:59.579723", "modified_by": "Administrator", "module": "Payroll", "name": "Payroll Settings", @@ -126,5 +126,6 @@ } ], "sort_field": "modified", - "sort_order": "ASC" + "sort_order": "ASC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.json b/erpnext/selling/doctype/selling_settings/selling_settings.json index 4044f09c85..2104c0131c 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.json +++ b/erpnext/selling/doctype/selling_settings/selling_settings.json @@ -140,7 +140,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2020-10-13 12:12:56.784014", + "modified": "2021-03-02 17:35:53.603607", "modified_by": "Administrator", "module": "Selling", "name": "Selling Settings", @@ -157,5 +157,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json index 3691721302..7a4bb20136 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json @@ -190,7 +190,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2021-02-11 18:48:30.433058", + "modified": "2021-03-02 17:34:57.642565", "modified_by": "Administrator", "module": "Shopping Cart", "name": "Shopping Cart Settings", @@ -207,5 +207,6 @@ } ], "sort_field": "modified", - "sort_order": "ASC" + "sort_order": "ASC", + "track_changes": 1 } \ No newline at end of file From a44df63a9119148adda806bae077f96330192bfb Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 1 Mar 2021 17:12:53 +0530 Subject: [PATCH 02/10] fix: Add warning for invalid GST invoice numbers GST Invoice numbers should be 16 characters alphanumeric with dash(/) or slash(-) only. Add check for doc.name before saving and warn about naming series. --- erpnext/hooks.py | 3 +++ erpnext/regional/india/utils.py | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 59639ffc43..f87769c182 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -278,6 +278,9 @@ doc_events = { ('Sales Invoice', 'Sales Order', 'Delivery Note', 'Purchase Invoice', 'Purchase Order', 'Purchase Receipt'): { 'validate': ['erpnext.regional.india.utils.set_place_of_supply'] }, + ('Sales Invoice', 'Purchase Invoice'): { + 'validate': ['erpnext.regional.india.utils.validate_document_name'] + }, "Contact": { "on_trash": "erpnext.support.doctype.issue.issue.update_issue", "after_insert": "erpnext.telephony.doctype.call_log.call_log.link_existing_conversations", diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index cb30605291..7980d0b9ff 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe, re, json from frappe import _ import erpnext -from frappe.utils import cstr, flt, date_diff, nowdate, round_based_on_smallest_currency_fraction, money_in_words +from frappe.utils import cstr, flt, date_diff, nowdate, round_based_on_smallest_currency_fraction, money_in_words, getdate from erpnext.regional.india import states, state_numbers from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount from erpnext.controllers.accounts_controller import get_taxes_and_charges @@ -148,6 +148,20 @@ def get_itemised_tax_breakup_data(doc, account_wise=False): def set_place_of_supply(doc, method=None): doc.place_of_supply = get_place_of_supply(doc, doc.doctype) +def validate_document_name(doc, method=None): + """Validate GST invoice number requirements.""" + country = frappe.get_cached_value("Company", doc.company, "country") + + if country != "India" or getdate(doc.posting_date) < getdate("2021-04-01"): + return + + if len(doc.name) > 16: + frappe.throw(_("Maximum length of document number should be 16 characters as per GST rules. Please change the naming series.")) + + gst_doc_name_pattern = re.compile(r"^[a-zA-Z0-9\-/]+$") + if not gst_doc_name_pattern.match(doc.name): + frappe.throw(_("Document name should only contain alphanumeric values, dash(-) and slash(/) characters as per GST rules. Please change the naming series.")) + # don't remove this function it is used in tests def test_method(): '''test function''' From 9b3f5d5f678507027e8ffd1349259db9f46f6615 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 3 Mar 2021 12:38:52 +0530 Subject: [PATCH 03/10] test: add tests for gst invoice name checks --- erpnext/regional/india/test_utils.py | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 erpnext/regional/india/test_utils.py diff --git a/erpnext/regional/india/test_utils.py b/erpnext/regional/india/test_utils.py new file mode 100644 index 0000000000..7ce27f6cf5 --- /dev/null +++ b/erpnext/regional/india/test_utils.py @@ -0,0 +1,38 @@ +from __future__ import unicode_literals + +import unittest +import frappe +from unittest.mock import patch +from erpnext.regional.india.utils import validate_document_name + + +class TestIndiaUtils(unittest.TestCase): + @patch("frappe.get_cached_value") + def test_validate_document_name(self, mock_get_cached): + mock_get_cached.return_value = "India" # mock country + posting_date = "2021-05-01" + + invalid_names = [ "SI$1231", "012345678901234567", "SI 2020 05", + "SI.2020.0001", "PI2021 - 001" ] + for name in invalid_names: + doc = frappe._dict(name=name, posting_date=posting_date) + self.assertRaises(frappe.ValidationError, validate_document_name, doc) + + valid_names = [ "012345678901236", "SI/2020/0001", "SI/2020-0001", + "2020-PI-0001", "PI2020-0001" ] + for name in valid_names: + doc = frappe._dict(name=name, posting_date=posting_date) + try: + validate_document_name(doc) + except frappe.ValidationError: + self.fail("Valid name {} throwing error".format(name)) + + @patch("frappe.get_cached_value") + def test_validate_document_name_not_india(self, mock_get_cached): + mock_get_cached.return_value = "Not India" + doc = frappe._dict(name="SI$123", posting_date="2021-05-01") + + try: + validate_document_name(doc) + except frappe.ValidationError: + self.fail("Regional validation related to India are being applied to other countries") From 7c4c42ad67c5b358c055bc7e1664f3ea04dd3c9c Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 3 Mar 2021 14:56:19 +0530 Subject: [PATCH 04/10] refactor: move regex patterns to global variables --- erpnext/regional/india/utils.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 7980d0b9ff..1a618d6cf5 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -14,6 +14,13 @@ from erpnext.accounts.general_ledger import make_gl_entries from erpnext.accounts.utils import get_account_currency from frappe.model.utils import get_fetch_values + +GST_INVOICE_NUMBER_FORMAT = re.compile(r"^[a-zA-Z0-9\-/]+$") #alphanumeric and - / +GSTIN_FORMAT = re.compile("^[0-9]{2}[A-Z]{4}[0-9A-Z]{1}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[1-9A-Z]{1}[0-9A-Z]{1}$") +GSTIN_UIN_FORMAT = re.compile("^[0-9]{4}[A-Z]{3}[0-9]{5}[0-9A-Z]{3}") +PAN_NUMBER_FORMAT = re.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}") + + def validate_gstin_for_india(doc, method): if hasattr(doc, 'gst_state') and doc.gst_state: doc.gst_state_number = state_numbers[doc.gst_state] @@ -37,12 +44,10 @@ def validate_gstin_for_india(doc, method): frappe.throw(_("Invalid GSTIN! A GSTIN must have 15 characters.")) if gst_category and gst_category == 'UIN Holders': - p = re.compile("^[0-9]{4}[A-Z]{3}[0-9]{5}[0-9A-Z]{3}") - if not p.match(doc.gstin): + if not GSTIN_UIN_FORMAT.match(doc.gstin): frappe.throw(_("Invalid GSTIN! The input you've entered doesn't match the GSTIN format for UIN Holders or Non-Resident OIDAR Service Providers")) else: - p = re.compile("^[0-9]{2}[A-Z]{4}[0-9A-Z]{1}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[1-9A-Z]{1}[0-9A-Z]{1}$") - if not p.match(doc.gstin): + if not GSTIN_FORMAT.match(doc.gstin): frappe.throw(_("Invalid GSTIN! The input you've entered doesn't match the format of GSTIN.")) validate_gstin_check_digit(doc.gstin) @@ -59,8 +64,7 @@ def validate_pan_for_india(doc, method): if doc.get('country') != 'India' or not doc.pan: return - p = re.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}") - if not p.match(doc.pan): + if not PAN_NUMBER_FORMAT.match(doc.pan): frappe.throw(_("Invalid PAN No. The input you've entered doesn't match the format of PAN.")) def validate_tax_category(doc, method): @@ -152,14 +156,14 @@ def validate_document_name(doc, method=None): """Validate GST invoice number requirements.""" country = frappe.get_cached_value("Company", doc.company, "country") + # Date was chosen as start of next FY to avoid irritating current users. if country != "India" or getdate(doc.posting_date) < getdate("2021-04-01"): return if len(doc.name) > 16: frappe.throw(_("Maximum length of document number should be 16 characters as per GST rules. Please change the naming series.")) - gst_doc_name_pattern = re.compile(r"^[a-zA-Z0-9\-/]+$") - if not gst_doc_name_pattern.match(doc.name): + if not GST_INVOICE_NUMBER_FORMAT.match(doc.name): frappe.throw(_("Document name should only contain alphanumeric values, dash(-) and slash(/) characters as per GST rules. Please change the naming series.")) # don't remove this function it is used in tests @@ -814,4 +818,4 @@ def get_regional_round_off_accounts(company, account_list): account_list.extend(gst_account_list) - return account_list \ No newline at end of file + return account_list From 53d261702afd06aaf95fb9a8022d01d2f9f8cf3f Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 3 Mar 2021 11:52:48 +0100 Subject: [PATCH 05/10] fix: make quick entry for Tax Category work --- erpnext/accounts/doctype/tax_category/tax_category.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/tax_category/tax_category.json b/erpnext/accounts/doctype/tax_category/tax_category.json index 6f682a0466..f7145af44c 100644 --- a/erpnext/accounts/doctype/tax_category/tax_category.json +++ b/erpnext/accounts/doctype/tax_category/tax_category.json @@ -11,15 +11,18 @@ ], "fields": [ { + "allow_in_quick_entry": 1, "fieldname": "title", "fieldtype": "Data", + "in_list_view": 1, "label": "Title", + "reqd": 1, "unique": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2020-08-30 19:41:25.783852", + "modified": "2021-03-03 11:50:38.748872", "modified_by": "Administrator", "module": "Accounts", "name": "Tax Category", From 27ea23223d67b072c0ee62acebb9c72cf28a9bf1 Mon Sep 17 00:00:00 2001 From: UrvashiKishnani <41088003+UrvashiKishnani@users.noreply.github.com> Date: Thu, 4 Mar 2021 09:21:25 +0400 Subject: [PATCH 06/10] fix: total row in AR/AP summary report --- .../report/accounts_receivable/accounts_receivable.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index 79a6aabd98..f4fd06ba03 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -258,7 +258,7 @@ {% } %} {% } else { %} {% if(data[i]["party"]|| " ") { %} - {% if((data[i]["party"]) != __("'Total'")) { %} + {% if(!data[i]["is_total_row"]) { %} {% if(!(filters.customer || filters.supplier)) { %} {%= data[i]["party"] %} From 9b4a258c896dd19bbd57367b8c55ef5ec0c38226 Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Thu, 4 Mar 2021 00:15:46 -0600 Subject: [PATCH 07/10] Chart Of Accounts -> Chart of Accounts --- erpnext/accounts/workspace/accounting/accounting.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/workspace/accounting/accounting.json b/erpnext/accounts/workspace/accounting/accounting.json index 8d24ca8291..fadb66535f 100644 --- a/erpnext/accounts/workspace/accounting/accounting.json +++ b/erpnext/accounts/workspace/accounting/accounting.json @@ -1061,7 +1061,7 @@ "type": "Link" } ], - "modified": "2020-12-01 13:38:35.349024", + "modified": "2021-03-04 00:38:35.349024", "modified_by": "Administrator", "module": "Accounts", "name": "Accounting", @@ -1071,7 +1071,7 @@ "pin_to_top": 0, "shortcuts": [ { - "label": "Chart Of Accounts", + "label": "Chart of Accounts", "link_to": "Account", "type": "DocType" }, @@ -1116,4 +1116,4 @@ "type": "Dashboard" } ] -} \ No newline at end of file +} From 92b0691c68a401c5b54567e6dc563d16cf441e54 Mon Sep 17 00:00:00 2001 From: Saqib Date: Sat, 6 Mar 2021 19:00:08 +0530 Subject: [PATCH 08/10] fix: einvoice button visiblity condition (#24800) --- .../print_format/gst_e_invoice/gst_e_invoice.html | 6 +++--- erpnext/regional/india/e_invoice/einvoice.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html index 8eef2adce3..71c26e8c55 100644 --- a/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html +++ b/erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html @@ -22,8 +22,8 @@

{% endif %} +
1. Transaction Details
-
1. Transaction Details
@@ -54,8 +54,8 @@
+
2. Party Details
-
2. Party Details
{%- set seller = einvoice.SellerDtls -%}
Seller
@@ -89,7 +89,7 @@
-
3. Item Details
+
3. Item Details
diff --git a/erpnext/regional/india/e_invoice/einvoice.js b/erpnext/regional/india/e_invoice/einvoice.js index a756b57eb7..7cd64f2fc0 100644 --- a/erpnext/regional/india/e_invoice/einvoice.js +++ b/erpnext/regional/india/e_invoice/einvoice.js @@ -1,12 +1,12 @@ erpnext.setup_einvoice_actions = (doctype) => { frappe.ui.form.on(doctype, { - refresh(frm) { - const einvoicing_enabled = frappe.db.get_value("E Invoice Settings", "E Invoice Settings", "enable"); + async refresh(frm) { + const einvoicing_enabled = await frappe.db.get_single_value("E Invoice Settings", "enable"); const supply_type = frm.doc.gst_category; const valid_supply_type = ['Registered Regular', 'SEZ', 'Overseas', 'Deemed Export'].includes(supply_type); const company_transaction = frm.doc.billing_address_gstin == frm.doc.company_gstin; - if (!einvoicing_enabled || !valid_supply_type || company_transaction) return; + if (cint(einvoicing_enabled) == 0 || !valid_supply_type || company_transaction) return; const { doctype, irn, irn_cancelled, ewaybill, eway_bill_cancelled, name, __unsaved } = frm.doc; @@ -83,7 +83,7 @@ erpnext.setup_einvoice_actions = (doctype) => { const action = () => { const d = new frappe.ui.Dialog({ title: __('Generate E-Way Bill'), - wide: 1, + size: "large", fields: get_ewaybill_fields(frm), primary_action: function() { const data = d.get_values(); @@ -252,7 +252,7 @@ const request_irn_generation = (frm) => { const get_preview_dialog = (frm, action) => { const dialog = new frappe.ui.Dialog({ title: __("Preview"), - wide: 1, + size: "large", fields: [ { "label": "Preview", From 4c089b585208f235656955a2a0287b189f02ae2d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sun, 7 Mar 2021 11:25:03 +0530 Subject: [PATCH 09/10] minor fixes --- .../manufacturing/doctype/work_order/work_order.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index ca530bbadd..3d64ad4318 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -528,6 +528,10 @@ class WorkOrder(Document): if not reset_only_qty: self.required_items = [] + operation = None + if self.get('operations') and len(self.operations) == 1: + operation = self.operations[0].operation + if self.bom_no and self.qty: item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=self.qty, fetch_exploded = self.use_multi_level_bom) @@ -536,6 +540,9 @@ class WorkOrder(Document): for d in self.get("required_items"): if item_dict.get(d.item_code): d.required_qty = item_dict.get(d.item_code).get("qty") + + if not d.operation: + d.operation = operation else: # Attribute a big number (999) to idx for sorting putpose in case idx is NULL # For instance in BOM Explosion Item child table, the items coming from sub assembly items @@ -543,7 +550,7 @@ class WorkOrder(Document): self.append('required_items', { 'rate': item.rate, 'amount': item.amount, - 'operation': item.operation, + 'operation': item.operation or operation, 'item_code': item.item_code, 'item_name': item.item_name, 'description': item.description, @@ -879,7 +886,7 @@ def create_job_card(work_order, row, qty=0, enable_capacity_planning=False, auto doc.schedule_time_logs(row) doc.insert() - frappe.msgprint(_("Job card {0} created").format(get_link_to_form("Job Card", doc.name))) + frappe.msgprint(_("Job card {0} created").format(get_link_to_form("Job Card", doc.name)), alert=True) return doc From d95b59e90c4d1b0a58a8e2ddb0f2ae908070a6bd Mon Sep 17 00:00:00 2001 From: Afshan Date: Mon, 8 Mar 2021 18:19:53 +0530 Subject: [PATCH 10/10] fix: call function when arguments available --- .../public/js/controllers/taxes_and_totals.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index d81321b291..3a3ee3858b 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -158,16 +158,18 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ let me = this; frappe.flags.round_off_applicable_accounts = []; - return frappe.call({ - "method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts", - "args": { - "company": me.frm.doc.company, - "account_list": frappe.flags.round_off_applicable_accounts - }, - callback: function(r) { - frappe.flags.round_off_applicable_accounts.push(...r.message); - } - }); + if (me.frm.doc.company) { + return frappe.call({ + "method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts", + "args": { + "company": me.frm.doc.company, + "account_list": frappe.flags.round_off_applicable_accounts + }, + callback: function(r) { + frappe.flags.round_off_applicable_accounts.push(...r.message); + } + }); + } }, determine_exclusive_rate: function() {