From 4a6c257e294db27aad40fcd3c8709d2e82aba766 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 26 Jan 2024 14:45:43 +0530 Subject: [PATCH 1/5] fix: avoid setting invalid place of supply If gst-state_number and gst_state isn't set in address then place of supply is set to invalid value "None-". Use case: Integrations, refer https://support.frappe.io/helpdesk/tickets/9048 (cherry picked from commit 99f5a9756be314df56999e7b7e7076f5d9a8c82e) --- india_compliance/gst_india/utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 738fe35ac..722ad93a7 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -405,7 +405,8 @@ def get_place_of_supply(party_details, doctype): party_details.customer_address, ("gst_state_number", "gst_state"), ) - return f"{gst_state_number}-{gst_state}" + if gst_state_number and gst_state: + return f"{gst_state_number}-{gst_state}" party_gstin = party_details.billing_address_gstin or party_details.company_gstin else: From 30c494f15210f889ec628679287e97a2e4f78375 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 31 Jan 2024 20:27:29 +0530 Subject: [PATCH 2/5] fix: get correct POS in Payment Entry Doctype (cherry picked from commit 16d5ea02f1bed8b64a7fbb0bfda99569903681a3) --- .../gst_india/client_scripts/payment_entry.js | 4 ++- .../gst_india/overrides/payment_entry.py | 30 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/india_compliance/gst_india/client_scripts/payment_entry.js b/india_compliance/gst_india/client_scripts/payment_entry.js index a0c056cc7..5d54ac0bb 100644 --- a/india_compliance/gst_india/client_scripts/payment_entry.js +++ b/india_compliance/gst_india/client_scripts/payment_entry.js @@ -35,7 +35,9 @@ frappe.ui.form.on("Payment Entry", { ); }, - customer_address: update_gst_details, + customer_address(frm) { + update_gst_details(frm); + }, }); function override_get_outstanding_documents(frm) { diff --git a/india_compliance/gst_india/overrides/payment_entry.py b/india_compliance/gst_india/overrides/payment_entry.py index e55184898..0038d3ee4 100644 --- a/india_compliance/gst_india/overrides/payment_entry.py +++ b/india_compliance/gst_india/overrides/payment_entry.py @@ -2,7 +2,7 @@ from frappe import _ from frappe.contacts.doctype.address.address import get_default_address from frappe.query_builder.functions import Sum -from frappe.utils import cstr, flt, getdate +from frappe.utils import flt, getdate from erpnext.accounts.general_ledger import make_gl_entries from erpnext.accounts.utils import create_payment_ledger_entry from erpnext.controllers.accounts_controller import get_advance_payment_entries @@ -107,6 +107,17 @@ def update_party_details(party_details, doctype, company): address = get_default_address("Customer", party_details.get("customer")) party_details.update(customer_address=address) + # update gst details + if address: + party_details.update( + frappe.db.get_value( + "Address", + address, + ["gstin as billing_address_gstin"], + as_dict=1, + ) + ) + # Update address for update response = { "customer_address": address, # should be set first as gst_category and gstin is fetched from address @@ -116,23 +127,6 @@ def update_party_details(party_details, doctype, company): return response -def update_place_of_supply(doc): - country = frappe.get_cached_value("Company", doc.company, "country") - if country != "India": - return - - address = frappe.db.get_value( - "Address", - doc.get("customer_address"), - ["gst_state", "gst_state_number"], - as_dict=1, - ) - if address and address.gst_state and address.gst_state_number: - doc.place_of_supply = ( - cstr(address.gst_state_number) + "-" + cstr(address.gst_state) - ) - - def make_gst_revesal_entry_from_advance_payment(doc): """ This functionality aims to create a GST reversal entry where GST was paid in advance From 39bdc6e0d43d600148fc474a9a354583ba7e490d Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 31 Jan 2024 14:30:46 +0530 Subject: [PATCH 3/5] chore: update pre-commit hooks to latest (cherry picked from commit 362a180ccb0f766ef8020863786464e51bd57146) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e646da466..f1ababaf7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ fail_fast: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.5.0 hooks: - id: trailing-whitespace files: "india_compliance.*" @@ -16,17 +16,17 @@ repos: - id: check-ast - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: [flake8-isort, flake8-bugbear] From a058a79120448c9b54c4fe582945e3914db2452a Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 31 Jan 2024 15:29:46 +0530 Subject: [PATCH 4/5] chore: formatting changes (cherry picked from commit d8c2469651974cc82a2bb50c93e22f723cbb5b42) --- .../purchase_reconciliation_tool/__init__.py | 6 +++--- .../purchase_reconciliation_tool.py | 16 +++++++++------- .../gst_india/overrides/test_transaction.py | 6 +++--- india_compliance/gst_india/utils/e_invoice.py | 6 +++--- india_compliance/gst_india/utils/e_waybill.py | 16 ++++++++++------ .../gst_india/utils/transaction_data.py | 8 +++++--- .../set_autogenerate_e_waybill_with_e_invoice.py | 11 ++++++++--- 7 files changed, 41 insertions(+), 28 deletions(-) diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py index 23da2e3d2..fd70b830b 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/__init__.py @@ -950,9 +950,9 @@ def get_manually_matched_data(self, purchase_name: str, inward_supply_name: str) reconciliation_data = [ frappe._dict( { - "_inward_supply": inward_supplies[0] - if inward_supplies - else frappe._dict(), + "_inward_supply": ( + inward_supplies[0] if inward_supplies else frappe._dict() + ), "_purchase_invoice": purchases.get(purchase_name, frappe._dict()), } ) diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py index cdad5edac..9208b8be0 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.py @@ -183,14 +183,16 @@ def get_import_history(self, return_type, date_range, for_download=True): status = status.replace("Downloaded", "Uploaded") _dict = { - "Classification": category.value - if return_type is ReturnType.GSTR2A - else "ALL", + "Classification": ( + category.value if return_type is ReturnType.GSTR2A else "ALL" + ), "Status": status, - columns[-1]: "✅  " - + download.last_updated_on.strftime("%d-%m-%Y %H:%M:%S") - if download - else "", + columns[-1]: ( + "✅  " + + download.last_updated_on.strftime("%d-%m-%Y %H:%M:%S") + if download + else "" + ), } if _dict not in data[period]: data[period].append(_dict) diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index d1e13e20e..3a54db2b2 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -642,9 +642,9 @@ def test_invalid_gst_account_outstate(self): def test_invalid_gst_account_instate(self): if self.is_sales_doctype: - self.transaction_details.customer = ( - self.transaction_details.party_name - ) = "_Test Registered Composition Customer" + self.transaction_details.customer = self.transaction_details.party_name = ( + "_Test Registered Composition Customer" + ) else: self.transaction_details.supplier = "_Test Registered InterState Supplier" diff --git a/india_compliance/gst_india/utils/e_invoice.py b/india_compliance/gst_india/utils/e_invoice.py index b155c1c12..f6726d82a 100644 --- a/india_compliance/gst_india/utils/e_invoice.py +++ b/india_compliance/gst_india/utils/e_invoice.py @@ -617,9 +617,9 @@ def update_payment_details(self): self.transaction_details.update( { - "payee_name": self.sanitize_value(self.doc.company) - if paid_amount - else "", + "payee_name": ( + self.sanitize_value(self.doc.company) if paid_amount else "" + ), "mode_of_payment": self.get_mode_of_payment(), "paid_amount": paid_amount, "credit_days": credit_days, diff --git a/india_compliance/gst_india/utils/e_waybill.py b/india_compliance/gst_india/utils/e_waybill.py index 55af491c4..a7a5cc56a 100644 --- a/india_compliance/gst_india/utils/e_waybill.py +++ b/india_compliance/gst_india/utils/e_waybill.py @@ -197,9 +197,11 @@ def _generate_e_waybill(doc, throw=True, force=False): return frappe.msgprint( - _("e-Waybill generated successfully") - if result.validUpto or result.EwbValidTill - else _("e-Waybill (Part A) generated successfully"), + ( + _("e-Waybill generated successfully") + if result.validUpto or result.EwbValidTill + else _("e-Waybill (Part A) generated successfully") + ), indicator="green", alert=True, ) @@ -1560,9 +1562,11 @@ def get_transaction_data(self): self.transaction_details.update( { "company_gstin": REGISTERED_GSTIN, - "name": random_string(6).lstrip("0") - if not frappe.flags.in_test - else "test_invoice_no", + "name": ( + random_string(6).lstrip("0") + if not frappe.flags.in_test + else "test_invoice_no" + ), } ) diff --git a/india_compliance/gst_india/utils/transaction_data.py b/india_compliance/gst_india/utils/transaction_data.py index eac7a3b4c..eaba427c6 100644 --- a/india_compliance/gst_india/utils/transaction_data.py +++ b/india_compliance/gst_india/utils/transaction_data.py @@ -343,9 +343,11 @@ def update_item_tax_details(self, item_details, item): # considers senarios where same item is there multiple times tax_amount = self.get_progressive_item_tax_amount( - tax_rate * item.qty - if row.charge_type == "On Item Quantity" - else tax_rate * item.taxable_value / 100, + ( + tax_rate * item.qty + if row.charge_type == "On Item Quantity" + else tax_rate * item.taxable_value / 100 + ), tax, ) diff --git a/india_compliance/patches/v14/set_autogenerate_e_waybill_with_e_invoice.py b/india_compliance/patches/v14/set_autogenerate_e_waybill_with_e_invoice.py index 8435611ea..2585c7c7c 100644 --- a/india_compliance/patches/v14/set_autogenerate_e_waybill_with_e_invoice.py +++ b/india_compliance/patches/v14/set_autogenerate_e_waybill_with_e_invoice.py @@ -6,7 +6,12 @@ def execute(): settings.db_set( "generate_e_waybill_with_e_invoice", - 0 - if (settings.auto_generate_e_invoice and not settings.auto_generate_e_waybill) - else 1, + ( + 0 + if ( + settings.auto_generate_e_invoice + and not settings.auto_generate_e_waybill + ) + else 1 + ), ) From 0fa979960a35f4f713ace05ed25aff077aa99cdf Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 31 Jan 2024 15:30:19 +0530 Subject: [PATCH 5/5] chore: ignore formatting changes (cherry picked from commit a962fa1b5bcba7bb4e1c5cf9254e67eab64cd8f5) --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index f53c7fc11..9fde85e6d 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -19,3 +19,6 @@ dec2438be2d63eff24da45d6c936ec846d8ab0df # refactor window.ic => window.india_compliance 38a53480c70a2c820049f023cbabbdaa3ea8aad6 + +# updated black in pre-commit +d8c2469651974cc82a2bb50c93e22f723cbb5b42