Skip to content

feat: E-Way Bill JSON Generator (GST Portal Compatible) — with review fixes + tests#379

Open
nikhilb2 wants to merge 9 commits into
mainfrom
issue-378-e-way-bill-json-generator
Open

feat: E-Way Bill JSON Generator (GST Portal Compatible) — with review fixes + tests#379
nikhilb2 wants to merge 9 commits into
mainfrom
issue-378-e-way-bill-json-generator

Conversation

@nikhilb2

@nikhilb2 nikhilb2 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

What

Adds a fully integrated E-Way Bill JSON Generator within the Invoice PDF Preview screen.

Backend

  • E-Way Bill service with pre-check (identifies missing data), validation, and JSON generation
  • NIC-compliant JSON schema (v1.0.1118)
  • Transporter profile management (CRUD + auto-fill default)
  • Smart missing data detection — only asks for fields not already available
  • Intra-state vs inter-state tax handling (CGST+SGST vs IGST)
  • Migration for eway_bill_transporters table

Frontend

  • "Generate E-Way Bill" button on invoice PDF preview (visible only for Tax Invoice + Active + GST enabled)
  • Single consolidated form (seller, buyer, supply, transport details)
  • Transporter selector with saved profiles
  • JSON preview with copy and download

Review fixes (committed)

  • Fixed totalValue using total_amount → now uses taxable_amount
  • Added validation for sub_supply_desc when sub-supply type is "Others"
  • Added GST check in frontend button visibility
  • Added 24 comprehensive tests (service layer + API integration)

Tests added

Service layer (13 tests): pre_check with valid/edge cases, validate_form_data with all field combos, generate JSON for intrastate/interstate/transport variations, totalValue fix verification

API integration (11 tests): pre-check endpoints, generate endpoints (200/422/full structure), save transporter on generate, transporter CRUD (list/create/update/delete)

Closes #378


🔍 Review fixes (Clawy — June 14, 2026)

Bugs fixed:

  • totalValue was using total_amount → corrected to taxable_amount
  • Missing validation for sub_supply_desc when sub-supply type is "Others" → added
  • Frontend E-Way Bill button didn't check GST is enabled → added company_gst check per issue requirements

Tests added (24 total):

  • Service layer (13): pre_check (valid/edge cases), validate_form_data (all field combos), generate JSON (intrastate/interstate/transport), totalValue fix verification
  • API integration (11): pre-check endpoints (200/404/auto-fill), generate endpoints (200/422/structure), transporter CRUD (list/create/update/delete)

Pushed as commit 291436f.

Clawy and others added 7 commits June 14, 2026 22:35
Adds:
- Migration for eway_bill_transporters table
- Backend EWB service with pre-check, validation, and JSON generation
- API routes for pre-check, generation, and transporter CRUD
- Frontend E-Way Bill modal integrated into Invoice Preview
- E-Way Bill button shown on Tax Invoice PDF Preview
- Smart missing-data detection + single consolidated form
- Saved transporter profiles with default selection
- NIC schema-compliant JSON output
…y_desc, add comprehensive tests

- Fix totalValue using total_amount instead of taxable_amount
- Add validation for sub_supply_desc when sub_supply_type is 'Others'
- Add GST check in frontend button visibility (matches issue requirements)
- Add 38 backend tests: 13 unit (service layer) + 11 API integration tests
- Test coverage: pre_check, validate_form_data, generate_eway_bill_json, CRUD endpoints, edge cases
…ny settings UI

- Add eway_enabled, eway_local_threshold, eway_interstate_threshold,
  eway_always_show_button fields to company_profiles (migration)
- Remove hardcoded GST check from precheck — eway_enabled controls availability
- Remove ALL upper invoice value restrictions — any amount can generate
- Add threshold warning (guidance only, never blocks) in pre_check
- Add E-Way Bill Configuration card to Company Settings page
- Fix InvoicePreview button visibility: show when module enabled,
  not based on invoice.company_gst
- Add threshold warning and disabled notices in EwayBillModal
- Add GET /api/eway-bill/settings endpoint
- Add 6 new tests: threshold logic, eway_disabled, large invoices,
  custom thresholds, default thresholds
- Closes feedback from @tbhatia2006 on issue #378
The E-Way Bill backend produced portal-invalid JSON and crashed for
common invoices. Targeted rewrite of the service/schema/tests; the
frontend modal and settings plumbing are kept.

- precheck no longer 500s when the buyer has no GSTIN (B2C): all DB
  values are coerced null-safe before building the form
- buyer GSTIN is now optional — unregistered recipients emit "URP"
- NIC-compliant JSON: numeric subSupplyType/transactionType/transMode,
  subSupplyDesc only for "Others", cessNonAdvol, and a balancing
  otherValue so totInvValue reconciles
- intra/inter-state tax nature taken consistently from the invoice's
  IGST amount (was re-derived from form state codes, could disagree)
- blocking errors (missing seller GSTIN, disabled module) surfaced via
  the precheck result and shown in the modal, gating generation
- frontend sends NIC sub-supply codes and adds a Transaction Type field
- rewrote the service test suite (incl. a null-GSTIN regression test),
  renamed it to avoid a basename collision with the API test file
- fixed a test-isolation bug where the API test wiped global
  dependency_overrides and broke ~38 unrelated tests

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nikhilb2 nikhilb2 force-pushed the issue-378-e-way-bill-json-generator branch from 97cc61c to a4cc800 Compare June 14, 2026 20:35
Clawy added 2 commits June 14, 2026 20:46
… array

The transporters GET returned an AxiosResponse object, not a raw array.
Casting it as TransporterProfile[] and calling .find() threw
'transRes.find is not a function', which was caught by the outer try/catch
and set step='error', showing the 'Cannot Generate E-Way Bill' screen.

Fix: catch(() => null) and use transRes?.data ?? [] to correctly extract
the array from the AxiosResponse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: E-Way Bill JSON Generator Integration (GST Portal Compatible)

2 participants