Skip to content

fix: enforce integer type for distance in e-Waybill calculations#4553

Open
ljain112 wants to merge 1 commit into
resilient-tech:developfrom
ljain112:distance-e-waybill
Open

fix: enforce integer type for distance in e-Waybill calculations#4553
ljain112 wants to merge 1 commit into
resilient-tech:developfrom
ljain112:distance-e-waybill

Conversation

@ljain112

@ljain112 ljain112 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Issue: If the user changes the field type to Float, the e-waybill cannot be generated.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge — the change is tightly scoped to distance coercion and has no impact on other e-Waybill fields or document lifecycle.

The fix is minimal and defensive: cint() is idempotent for values already stored as integers, and the boundary condition (< 4000) retains exactly the same semantics as before. The new test covers all three meaningful cases (fractional, at-limit, normal) and the UI change prevents fractional entry at the source.

No files require special attention.

Important Files Changed

Filename Overview
india_compliance/gst_india/utils/transaction_data.py Adds cint() coercion to set_transporter_details, correctly preserving the < 4000 boundary reset and handling None/float values from modified custom fields.
india_compliance/gst_india/utils/e_waybill.py Replaces bare int() with cint() for remainingDistance and distance in update_transaction/extend_validity, and stores the coerced int back to the document via db_set.
india_compliance/gst_india/client_scripts/e_waybill_actions.js Changes distance and remaining_distance dialog field types from Float to Int, preventing fractional entry at the UI level.
india_compliance/gst_india/overrides/test_transaction_data.py Adds test_set_transporter_details_distance_is_coerced_to_int covering fractional truncation, the 4000 km boundary reset, and normal integer pass-through.

Reviews (1): Last reviewed commit: "fix: enforce integer type for distance i..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change updates e-Waybill distance handling to consistently use integer values instead of floats. In transaction_data.py, distance is coerced via cint() before comparison against the 4000 km threshold. In e_waybill.py, cint casting is applied to distance and remaining distance values in update, extend-validity, and payload-generation flows. Client-side dialog fields for "Distance (in km)" and "Remaining Distance (in km)" changed fieldtype from Float to Int. A new test validates the coercion behavior for fractional, boundary, and normal distance values.

Changes

File Change Summary
client_scripts/e_waybill_actions.js Changed two dialog field types from Float to Int for distance fields
overrides/test_transaction_data.py Added test validating distance coercion to int in set_transporter_details
utils/e_waybill.py Added cint import; applied it to distance/remainingDistance in three locations
utils/transaction_data.py Added cint import; applied it to distance computation with 4000 km cutoff logic

Sequence Diagram(s)

Not applicable — this change consists of straightforward type coercion and field type edits without new control flow.

Related Issues: Not specified in provided context.

Related PRs: Not specified in provided context.

Suggested labels: bug, e-waybill

Suggested reviewers: Not specified in provided context.

Poem

A rabbit hopped through fields of km,
Found floats where whole numbers should reign,
"Four thousand's the line," it said with a grin,
Now cint keeps the distance sane,
Hop, hop — the fractions all fade away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: enforcing integer distance values for e-Waybill calculations.
Description check ✅ Passed The description is directly related to the change and describes the Float-to-integer e-waybill issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/e_waybill.py (1)

649-649: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coercion tests for e_waybill distance fields
india_compliance/gst_india/utils/test_e_waybill.py still lacks coverage for fractional and None distance/remaining_distance inputs through update_transaction, extend_validity, and get_extend_validity_data.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d2e877a-5b7d-4bc0-8133-7be013faac93

📥 Commits

Reviewing files that changed from the base of the PR and between a8439f8 and 1f6dc19.

📒 Files selected for processing (4)
  • india_compliance/gst_india/client_scripts/e_waybill_actions.js
  • india_compliance/gst_india/overrides/test_transaction_data.py
  • india_compliance/gst_india/utils/e_waybill.py
  • india_compliance/gst_india/utils/transaction_data.py

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.

2 participants