fix: enforce integer type for distance in e-Waybill calculations#4553
fix: enforce integer type for distance in e-Waybill calculations#4553ljain112 wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
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.
Confidence Score: 5/5Safe 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.
|
| 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
📝 WalkthroughWalkthroughThis change updates e-Waybill distance handling to consistently use integer values instead of floats. In Changes
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, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
india_compliance/gst_india/utils/e_waybill.py (1)
649-649: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coercion tests for e_waybill distance fields
india_compliance/gst_india/utils/test_e_waybill.pystill lacks coverage for fractional andNonedistance/remaining_distanceinputs throughupdate_transaction,extend_validity, andget_extend_validity_data.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6d2e877a-5b7d-4bc0-8133-7be013faac93
📒 Files selected for processing (4)
india_compliance/gst_india/client_scripts/e_waybill_actions.jsindia_compliance/gst_india/overrides/test_transaction_data.pyindia_compliance/gst_india/utils/e_waybill.pyindia_compliance/gst_india/utils/transaction_data.py
Issue: If the user changes the field type to Float, the e-waybill cannot be generated.