Skip to content

fix: correct from and to statecode in e-waybill for sez invoice.#4141

Open
ljain112 wants to merge 3 commits intoresilient-tech:developfrom
ljain112:fix-sez-ewaybill
Open

fix: correct from and to statecode in e-waybill for sez invoice.#4141
ljain112 wants to merge 3 commits intoresilient-tech:developfrom
ljain112:fix-sez-ewaybill

Conversation

@ljain112
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 27, 2026

Confidence Score: 5/5

Safe to merge — fixes a real API compliance bug, logic is correct for all SEZ permutations, and new tests verify each case.

No P0/P1 findings. The copy-before-override pattern correctly preserves actFromStateCode/actToStateCode. The to_state_code condition handles both is_return and SEZ outward cases. BUYING_DOCTYPES refactor is safe. All existing test expectations updated appropriately.

No files require special attention.

Important Files Changed

Filename Overview
india_compliance/gst_india/utils/e_waybill.py Core fix: SEZ state_number override (96) applied per-party before ship_to/ship_from copy, preserving actual physical state codes; to_state_code logic extended to use bill_to.state_number when the buyer is SEZ.
india_compliance/gst_india/utils/transaction_data.py Fetches gst_category from Address and includes it in the returned address_details dict so downstream callers can check party-level SEZ status.
india_compliance/gst_india/constants/e_waybill.py Adds BUYING_DOCTYPES set computed from ADDRESS_FIELDS via identity check on buying_address, replacing the hardcoded tuple.
india_compliance/gst_india/utils/test_e_waybill.py Adds five new integration tests covering SEZ state codes for outward sales invoice, sales return, stock entry, purchase invoice, and purchase return.

Reviews (3): Last reviewed commit: "test: add gst_category field to address ..." | Re-trigger Greptile

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a82f662e-80d5-4008-a7fb-e62b5489375c

📥 Commits

Reviewing files that changed from the base of the PR and between a35ec1c and 66ee129.

📒 Files selected for processing (6)
  • india_compliance/gst_india/constants/e_waybill.py
  • india_compliance/gst_india/overrides/test_transaction_data.py
  • india_compliance/gst_india/utils/e_waybill.py
  • india_compliance/gst_india/utils/test_e_waybill.py
  • india_compliance/gst_india/utils/transaction_data.py
  • india_compliance/tests/test_records.json
✅ Files skipped from review due to trivial changes (1)
  • india_compliance/tests/test_records.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • india_compliance/gst_india/utils/transaction_data.py
  • india_compliance/gst_india/utils/test_e_waybill.py

📝 Walkthrough

Walkthrough

E-waybill behavior for SEZ addresses was adjusted: set_party_address_details() now sets state_number = 96 on both bill_from and bill_to when an address has gst_category == "SEZ". Buying-side detection was refactored to use a new BUYING_DOCTYPES constant. get_transaction_data() adds a sandbox SEZ_GSTIN override when appropriate and selects to_state_code from bill_to.state_number for returns or when bill_to.gst_category == "SEZ". get_address_details() now returns gst_category. Five SEZ-related e-waybill tests and a test Address record were added.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a pull request description explaining the SEZ state-code fix, affected document types, and testing approach to provide context for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: correcting from and to statecode in e-waybill for SEZ invoices, which aligns with the implementation of SEZ state-code mapping across multiple document types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6129094d-9af7-4ae3-82ae-7de1b5ce0069

📥 Commits

Reviewing files that changed from the base of the PR and between bc4a6e2 and ede6c32.

📒 Files selected for processing (2)
  • india_compliance/gst_india/utils/e_waybill.py
  • india_compliance/gst_india/utils/test_e_waybill.py

@ljain112
Copy link
Copy Markdown
Member Author

@greptileai

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
india_compliance/gst_india/utils/test_e_waybill.py (1)

1395-1504: Add a sandbox regression for the new SEZ GSTIN branch.

These cases lock down the state-code swaps, but none run with sandbox_mode = 1, so the new SEZ_GSTIN path in india_compliance/gst_india/utils/e_waybill.py Lines 1810-1867 is still untested. One sandbox assert on fromGstin / toGstin would cover the other half of this change.

🧪 Suggested test shape
+    `@change_settings`(
+        "GST Settings",
+        {"sandbox_mode": 1, "enable_overseas_transactions": 1},
+    )
+    def test_e_waybill_for_sez_outward_invoice_in_sandbox(self):
+        si = create_sales_invoice(
+            vehicle_no="GJ07DL9009",
+            company_address="_Test Indian Registered Company-Billing",
+            customer_address="_Test Registered Customer-Billing-1",
+            is_out_state=1,
+            is_export_with_gst=1,
+        )
+
+        e_waybill_data = EWaybillData(si).get_data()
+
+        self.assertEqual(e_waybill_data.get("toGstin"), "27AAJCS5738D1Z6")

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be9332d4-d8f7-4e93-b7e6-a87a58693224

📥 Commits

Reviewing files that changed from the base of the PR and between ede6c32 and f006688.

📒 Files selected for processing (5)
  • india_compliance/gst_india/constants/e_waybill.py
  • india_compliance/gst_india/utils/e_waybill.py
  • india_compliance/gst_india/utils/test_e_waybill.py
  • india_compliance/gst_india/utils/transaction_data.py
  • india_compliance/tests/test_records.json
✅ Files skipped from review due to trivial changes (1)
  • india_compliance/tests/test_records.json

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity

Metric Results
Complexity 7

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@ljain112
Copy link
Copy Markdown
Member Author

ljain112 commented Apr 1, 2026

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant