From 3af060c78751de312636253eb9820981a2846512 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 19 Oct 2021 13:38:50 +0530 Subject: [PATCH 1/3] fix: TaxJar update - added nexus list, making api call only for nexus (backport #27497) (#27940) * fix: TaxJar update - nexus, selective api call (cherry picked from commit b01fe1c3e2db9f1cd39a8a96c3539dbf50d59bf6) * fix: sales_tax attribute in api call before submit (cherry picked from commit 3bb60a439a54350765d82c017bfa061cf41004e0) * Update erpnext/erpnext_integrations/taxjar_integration.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 0e527311b959fcb0d980ebebff671c75ca997f28) * Update erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 486d7c3a39fb77f23de49d650b91c05758c7fbd7) * Update erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 435a5e4fa318801c7b6e0f84c37a5894ed4c2043) * Update erpnext/erpnext_integrations/taxjar_integration.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 11bd42467e5346c1d286c2fd9ec4b1d032b32d85) * fix: Renamed child table doctype, delete taxes for non nexus state (cherry picked from commit 5c18654113d58363aa52dde30be3b65621747363) * fix: updated patch, add fields only if fields are checked (cherry picked from commit 54754f4eb8a615d92d52d1322dad41ccfe9e8556) # Conflicts: # erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py * fix: patch fix, fields disabling (cherry picked from commit 0a28fed679a6ce22a9d88d45ca3f05ea7cdb68d9) * fix: using db.exists and get_value instead of get_doc (cherry picked from commit 8675ca5bdd838460d56be8eadf6790cadc605ba3) * fix: dt instead of document in set_value query (cherry picked from commit d3bb920e715a49ee47e52eef1b53d40dc573d877) * minor fixes (cherry picked from commit 254b20bc093805a6642e6ddedcd8917a535d42b1) * fix: improved on_update method, added validation for tax calculation, sandbox mode checks (cherry picked from commit 7114659eccfa13c50ba6ce8d7fb2ad74838169d5) * fix: linters fix (cherry picked from commit 3ece05a9f7976a031efcb441defa77d51c351145) * fix: patch fix added reload_doctype (cherry picked from commit eaa3614155838df0ddcdb11f3154a9cb94f86b11) * fix: patch fixes- force reload doc, check for company (cherry picked from commit 1b25e69af4f4069c5e8df713bc852aee06b8acb8) * fix: 'Taxjar' type fix (cherry picked from commit ea2038489fd6b225154eb0d11bf9ce5eb5983e14) * fix: Update pacthes.txt (cherry picked from commit 5d4c919c5ce8ce0c112e368fb94b1fb862ea3c78) * fix: Patch (cherry picked from commit 2d19e2d54b3d03f70996ac104508a14b21bc2911) # Conflicts: # erpnext/patches.txt * fix: Move product tax category folder to taxjar settings (cherry picked from commit bd8cfb2e3079012f4e9c0732f3d14db93917bd31) * Update custom_fields_for_taxjar_integration.py * fix: conflicts * fix: linter issues removed extra line * fix: patch fix einvoicing deprecation patch removed Co-authored-by: Subin Tom Co-authored-by: Subin Tom <36098155+nemesis189@users.noreply.github.com> Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Co-authored-by: Deepesh Garg Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com> --- .../doctype/taxjar_nexus/__init__.py | 0 .../doctype/taxjar_nexus/taxjar_nexus.json | 51 ++++++++++ .../doctype/taxjar_nexus/taxjar_nexus.py | 9 ++ .../product_tax_category_data.json | 0 .../taxjar_settings/taxjar_settings.js | 13 ++- .../taxjar_settings/taxjar_settings.json | 28 +++++- .../taxjar_settings/taxjar_settings.py | 93 ++++++++++++++++++- .../taxjar_integration.py | 29 +++++- erpnext/patches.txt | 2 + .../custom_fields_for_taxjar_integration.py | 11 ++- erpnext/regional/united_states/setup.py | 40 -------- 11 files changed, 223 insertions(+), 53 deletions(-) create mode 100644 erpnext/erpnext_integrations/doctype/taxjar_nexus/__init__.py create mode 100644 erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.json create mode 100644 erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.py rename erpnext/{regional/united_states => erpnext_integrations/doctype/taxjar_settings}/product_tax_category_data.json (100%) diff --git a/erpnext/erpnext_integrations/doctype/taxjar_nexus/__init__.py b/erpnext/erpnext_integrations/doctype/taxjar_nexus/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.json b/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.json new file mode 100644 index 00000000000..d4d4a512b58 --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.json @@ -0,0 +1,51 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2021-09-11 05:09:53.773838", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "region", + "region_code", + "country", + "country_code" + ], + "fields": [ + { + "fieldname": "region", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Region" + }, + { + "fieldname": "region_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Region Code" + }, + { + "fieldname": "country", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Country" + }, + { + "fieldname": "country_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Country Code" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2021-09-14 05:33:06.444710", + "modified_by": "Administrator", + "module": "ERPNext Integrations", + "name": "TaxJar Nexus", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.py b/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.py new file mode 100644 index 00000000000..c24aa8ca7d4 --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/taxjar_nexus/taxjar_nexus.py @@ -0,0 +1,9 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class TaxJarNexus(Document): + pass diff --git a/erpnext/regional/united_states/product_tax_category_data.json b/erpnext/erpnext_integrations/doctype/taxjar_settings/product_tax_category_data.json similarity index 100% rename from erpnext/regional/united_states/product_tax_category_data.json rename to erpnext/erpnext_integrations/doctype/taxjar_settings/product_tax_category_data.json diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js index 62d5709f51f..d49598932fe 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js @@ -5,5 +5,16 @@ frappe.ui.form.on('TaxJar Settings', { is_sandbox: (frm) => { frm.toggle_reqd("api_key", !frm.doc.is_sandbox); frm.toggle_reqd("sandbox_api_key", frm.doc.is_sandbox); - } + }, + + refresh: (frm) => { + frm.add_custom_button(__('Update Nexus List'), function() { + frm.call({ + doc: frm.doc, + method: 'update_nexus_list' + }); + }); + }, + + }); diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json index c0d60f7a317..2d17f2ed832 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json @@ -6,8 +6,8 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "is_sandbox", "taxjar_calculate_tax", + "is_sandbox", "taxjar_create_transactions", "credentials", "api_key", @@ -16,7 +16,10 @@ "configuration", "tax_account_head", "configuration_cb", - "shipping_account_head" + "shipping_account_head", + "section_break_12", + "nexus_address", + "nexus" ], "fields": [ { @@ -54,6 +57,7 @@ }, { "default": "0", + "depends_on": "taxjar_calculate_tax", "fieldname": "is_sandbox", "fieldtype": "Check", "label": "Sandbox Mode" @@ -69,6 +73,7 @@ }, { "default": "0", + "depends_on": "taxjar_calculate_tax", "fieldname": "taxjar_create_transactions", "fieldtype": "Check", "label": "Create TaxJar Transaction" @@ -82,11 +87,28 @@ { "fieldname": "cb_keys", "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_12", + "fieldtype": "Section Break", + "label": "Nexus List" + }, + { + "fieldname": "nexus_address", + "fieldtype": "HTML", + "label": "Nexus Address" + }, + { + "fieldname": "nexus", + "fieldtype": "Table", + "label": "Nexus", + "options": "TaxJar Nexus", + "read_only": 1 } ], "issingle": 1, "links": [], - "modified": "2020-04-30 04:38:03.311089", + "modified": "2021-10-06 10:59:13.475442", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "TaxJar Settings", diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py index 9dd481747ec..f430a9e9bae 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py @@ -4,9 +4,98 @@ from __future__ import unicode_literals -# import frappe +import json +import os + +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.model.document import Document +from frappe.permissions import add_permission, update_permission_property + +from erpnext.erpnext_integrations.taxjar_integration import get_client class TaxJarSettings(Document): - pass + + def on_update(self): + TAXJAR_CREATE_TRANSACTIONS = frappe.db.get_single_value("TaxJar Settings", "taxjar_create_transactions") + TAXJAR_CALCULATE_TAX = frappe.db.get_single_value("TaxJar Settings", "taxjar_calculate_tax") + TAXJAR_SANDBOX_MODE = frappe.db.get_single_value("TaxJar Settings", "is_sandbox") + + fields_already_exist = frappe.db.exists('Custom Field', {'dt': ('in', ['Item','Sales Invoice Item']), 'fieldname':'product_tax_category'}) + fields_hidden = frappe.get_value('Custom Field', {'dt': ('in', ['Sales Invoice Item'])}, 'hidden') + + if (TAXJAR_CREATE_TRANSACTIONS or TAXJAR_CALCULATE_TAX or TAXJAR_SANDBOX_MODE): + if not fields_already_exist: + add_product_tax_categories() + make_custom_fields() + add_permissions() + frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False) + + elif fields_already_exist and fields_hidden: + toggle_tax_category_fields(hidden='0') + + elif fields_already_exist: + toggle_tax_category_fields(hidden='1') + + def validate(self): + self.calculate_taxes_validation_for_create_transactions() + + @frappe.whitelist() + def update_nexus_list(self): + client = get_client() + nexus = client.nexus_regions() + + new_nexus_list = [frappe._dict(address) for address in nexus] + + self.set('nexus', []) + self.set('nexus', new_nexus_list) + self.save() + + def calculate_taxes_validation_for_create_transactions(self): + if not self.taxjar_calculate_tax and (self.taxjar_create_transactions or self.is_sandbox): + frappe.throw(frappe._('Before enabling Create Transaction or Sandbox Mode, you need to check the Enable Tax Calculation box')) + + +def toggle_tax_category_fields(hidden): + frappe.set_value('Custom Field', {'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'}, 'hidden', hidden) + frappe.set_value('Custom Field', {'dt':'Item', 'fieldname':'product_tax_category'}, 'hidden', hidden) + + +def add_product_tax_categories(): + with open(os.path.join(os.path.dirname(__file__), 'product_tax_category_data.json'), 'r') as f: + tax_categories = json.loads(f.read()) + create_tax_categories(tax_categories['categories']) + +def create_tax_categories(data): + for d in data: + if not frappe.db.exists('Product Tax Category',{'product_tax_code':d.get('product_tax_code')}): + tax_category = frappe.new_doc('Product Tax Category') + tax_category.description = d.get("description") + tax_category.product_tax_code = d.get("product_tax_code") + tax_category.category_name = d.get("name") + tax_category.db_insert() + +def make_custom_fields(update=True): + custom_fields = { + 'Sales Invoice Item': [ + dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', + label='Product Tax Category', fetch_from='item_code.product_tax_category'), + dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', + label='Tax Collectable', read_only=1), + dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', + label='Taxable Amount', read_only=1) + ], + 'Item': [ + dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', + label='Product Tax Category') + ] + } + create_custom_fields(custom_fields, update=update) + +def add_permissions(): + doctype = "Product Tax Category" + for role in ('Accounts Manager', 'Accounts User', 'System Manager','Item Manager', 'Stock Manager'): + add_permission(doctype, role, 0) + update_permission_property(doctype, role, 0, 'write', 1) + update_permission_property(doctype, role, 0, 'create', 1) diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 870a4ef54cc..2a7243c2430 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -4,7 +4,7 @@ import frappe import taxjar from frappe import _ from frappe.contacts.doctype.address.address import get_company_address -from frappe.utils import cint +from frappe.utils import cint, flt from erpnext import get_default_company @@ -103,7 +103,7 @@ def get_tax_data(doc): shipping = sum([tax.tax_amount for tax in doc.taxes if tax.account_head == SHIP_ACCOUNT_HEAD]) - line_items = [get_line_item_dict(item) for item in doc.items] + line_items = [get_line_item_dict(item, doc.docstatus) for item in doc.items] if from_shipping_state not in SUPPORTED_STATE_CODES: from_shipping_state = get_state_code(from_address, 'Company') @@ -139,14 +139,21 @@ def get_state_code(address, location): return state_code -def get_line_item_dict(item): - return dict( +def get_line_item_dict(item, docstatus): + tax_dict = dict( id = item.get('idx'), quantity = item.get('qty'), unit_price = item.get('rate'), product_tax_code = item.get('product_tax_category') ) + if docstatus == 1: + tax_dict.update({ + 'sales_tax':item.get('tax_collectable') + }) + + return tax_dict + def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: return @@ -164,6 +171,9 @@ def set_sales_tax(doc, method): setattr(doc, "taxes", [tax for tax in doc.taxes if tax.account_head != TAX_ACCOUNT_HEAD]) return + # check if delivering within a nexus + check_for_nexus(doc, tax_dict) + tax_data = validate_tax_request(tax_dict) if tax_data is not None: if not tax_data.amount_to_collect: @@ -191,6 +201,17 @@ def set_sales_tax(doc, method): doc.run_method("calculate_taxes_and_totals") +def check_for_nexus(doc, tax_dict): + if not frappe.db.get_value('TaxJar Nexus', {'region_code': tax_dict["to_state"]}): + for item in doc.get("items"): + item.tax_collectable = flt(0) + item.taxable_amount = flt(0) + + for tax in doc.taxes: + if tax.account_head == TAX_ACCOUNT_HEAD: + doc.taxes.remove(tax) + return + def check_sales_tax_exemption(doc): # if the party is exempt from sales tax, then set all tax account heads to zero sales_tax_exempted = hasattr(doc, "exempt_from_sales_tax") and doc.exempt_from_sales_tax \ diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4ce8717952d..41d14bd7402 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -306,6 +306,8 @@ erpnext.patches.v13_0.add_custom_field_for_south_africa #2 erpnext.patches.v13_0.rename_discharge_ordered_date_in_ip_record erpnext.patches.v13_0.migrate_stripe_api erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries +execute:frappe.reload_doc("erpnext_integrations", "doctype", "TaxJar Settings") +execute:frappe.reload_doc("erpnext_integrations", "doctype", "Product Tax Category") erpnext.patches.v13_0.custom_fields_for_taxjar_integration erpnext.patches.v13_0.set_operation_time_based_on_operating_cost erpnext.patches.v13_0.validate_options_for_data_field diff --git a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py index 43a9aeb6fe6..e136d64bb56 100644 --- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py +++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields -from erpnext.regional.united_states.setup import add_permissions +from erpnext.erpnext_integrations.doctype.taxjar_settings.taxjar_settings import add_permissions def execute(): @@ -11,7 +11,12 @@ def execute(): if not company: return - frappe.reload_doc("regional", "doctype", "product_tax_category") + TAXJAR_CREATE_TRANSACTIONS = frappe.db.get_single_value("TaxJar Settings", "taxjar_create_transactions") + TAXJAR_CALCULATE_TAX = frappe.db.get_single_value("TaxJar Settings", "taxjar_calculate_tax") + TAXJAR_SANDBOX_MODE = frappe.db.get_single_value("TaxJar Settings", "is_sandbox") + + if (not TAXJAR_CREATE_TRANSACTIONS and not TAXJAR_CALCULATE_TAX and not TAXJAR_SANDBOX_MODE): + return custom_fields = { 'Sales Invoice Item': [ @@ -29,4 +34,4 @@ def execute(): } create_custom_fields(custom_fields, update=True) add_permissions() - frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=True) \ No newline at end of file + frappe.enqueue('erpnext.erpnext_integrations.doctype.taxjar_settings.taxjar_settings.add_product_tax_categories', now=True) diff --git a/erpnext/regional/united_states/setup.py b/erpnext/regional/united_states/setup.py index 25982b81227..f7b921a491b 100644 --- a/erpnext/regional/united_states/setup.py +++ b/erpnext/regional/united_states/setup.py @@ -16,30 +16,9 @@ def setup(company=None, patch=True): setup_company_independent_fixtures(patch=patch) def setup_company_independent_fixtures(company=None, patch=True): - add_product_tax_categories() make_custom_fields() - add_permissions() - frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False) add_print_formats() -# Product Tax categories imported from taxjar api -def add_product_tax_categories(): - with open(os.path.join(os.path.dirname(__file__), 'product_tax_category_data.json'), 'r') as f: - tax_categories = json.loads(f.read()) - create_tax_categories(tax_categories['categories']) - -def create_tax_categories(data): - for d in data: - tax_category = frappe.new_doc('Product Tax Category') - tax_category.description = d.get("description") - tax_category.product_tax_code = d.get("product_tax_code") - tax_category.category_name = d.get("name") - try: - tax_category.db_insert() - except frappe.DuplicateEntryError: - pass - - def make_custom_fields(update=True): custom_fields = { 'Supplier': [ @@ -61,29 +40,10 @@ def make_custom_fields(update=True): 'Quotation': [ dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', label='Is customer exempted from sales tax?') - ], - 'Sales Invoice Item': [ - dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', - label='Product Tax Category', fetch_from='item_code.product_tax_category'), - dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', - label='Tax Collectable', read_only=1), - dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', - label='Taxable Amount', read_only=1) - ], - 'Item': [ - dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', - label='Product Tax Category') ] } create_custom_fields(custom_fields, update=update) -def add_permissions(): - doctype = "Product Tax Category" - for role in ('Accounts Manager', 'Accounts User', 'System Manager','Item Manager', 'Stock Manager'): - add_permission(doctype, role, 0) - update_permission_property(doctype, role, 0, 'write', 1) - update_permission_property(doctype, role, 0, 'create', 1) - def add_print_formats(): frappe.reload_doc("regional", "print_format", "irs_1099_form") frappe.db.set_value("Print Format", "IRS 1099 Form", "disabled", 0) From 35448886bcc1aaf44e1ef373fedeec5b20111552 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 19 Oct 2021 14:33:57 +0530 Subject: [PATCH 2/3] Merge pull request #27999 from frappe/mergify/bp/version-13-hotfix/pr-27990 fix: changes in schedules gets overwritten on save (backport #27990) --- .../doctype/maintenance_schedule/maintenance_schedule.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py index a1df9cfd0eb..adb57f9f397 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py @@ -199,12 +199,16 @@ class MaintenanceSchedule(TransactionBase): if chk: throw(_("Maintenance Schedule {0} exists against {1}").format(chk[0][0], d.sales_order)) + def validate_no_of_visits(self): + return len(self.schedules) != sum(d.no_of_visits for d in self.items) + def validate(self): self.validate_end_date_visits() self.validate_maintenance_detail() self.validate_dates_with_periodicity() self.validate_sales_order() - self.generate_schedule() + if not self.schedules or self.validate_no_of_visits(): + self.generate_schedule() def on_update(self): frappe.db.set(self, 'status', 'Draft') From ebe68c1a7a47f5e711cc9fc1d40c07e140b76888 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Tue, 19 Oct 2021 15:08:05 +0530 Subject: [PATCH 3/3] fix: Totals row incorrect value in GL Entry (#27867) --- erpnext/accounts/report/general_ledger/general_ledger.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 5bd6e583dbb..0094bc2eebe 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -421,8 +421,6 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map): update_value_in_dict(totals, 'closing', gle) elif gle.posting_date <= to_date: - update_value_in_dict(gle_map[gle.get(group_by)].totals, 'total', gle) - update_value_in_dict(totals, 'total', gle) if filters.get("group_by") != 'Group by Voucher (Consolidated)': gle_map[gle.get(group_by)].entries.append(gle) elif filters.get("group_by") == 'Group by Voucher (Consolidated)': @@ -436,10 +434,11 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map): else: update_value_in_dict(consolidated_gle, key, gle) - update_value_in_dict(gle_map[gle.get(group_by)].totals, 'closing', gle) - update_value_in_dict(totals, 'closing', gle) - for key, value in consolidated_gle.items(): + update_value_in_dict(gle_map[value.get(group_by)].totals, 'total', value) + update_value_in_dict(totals, 'total', value) + update_value_in_dict(gle_map[value.get(group_by)].totals, 'closing', value) + update_value_in_dict(totals, 'closing', value) entries.append(value) return totals, entries