Skip to content

Refactor license model and add new endpoints for fines and licenses - #73

Closed
vthish wants to merge 11 commits into
mainfrom
development
Closed

vthish wants to merge 11 commits into
mainfrom
development

Conversation

@vthish

@vthish vthish commented Jun 23, 2026

Copy link
Copy Markdown
Owner

This pull request introduces several important changes to the fines management system, focusing on improved fine issuance logic, enhanced status handling for licenses and fines, and new features for traffic officers. The changes touch both the Prisma schema and the service/controller layers, ensuring more robust business logic and better support for real-world scenarios like court cases, suspensions, and device security.

Key changes include:

Fine and License Status Logic Improvements

  • Refined the fine issuance logic to use a scanToken (JWT) for secure license identification, and implemented point accumulation for licenses, with automatic transitions to SUSPENDED or REVOKED status based on point thresholds. Added support for handling court cases and their impact on license status. [1] [2]
  • Added automatic activation of licenses when suspensions expire or all fines are cleared, and automated processing of overdue fines.
  • Updated fine payment logic to distinguish between normal, overdue, and court case fines, ensuring correct status updates and messages are returned to users. Bulk fine payment logic is similarly improved. [1] [2]
  • Changed the default points for new licenses from 24 to 0 and added a suspended_Until field to track suspension periods.

Prisma Schema Enhancements

  • Added new fields and relations to support tracking which officer issued a scan or temporary license, and established corresponding relations in the Traffic_Officer, QR_Scan_History, and Temporary_License models. [1] [2] [3]
  • Introduced a new COURT_CASE status for fines, allowing for explicit handling of court-related offenses.

Traffic Officer Features

  • Added endpoints for traffic officers to retrieve their statistics and issued fines, protected by role-based guards.
  • Extended the Traffic_Officer model to include relations to QR scans and temporary licenses for better tracking.

Security and Error Handling

  • Improved device security by returning a structured error with a specific code and requiring OTP verification when a device mismatch is detected during login.
  • Standardized error handling in the service layer, using generic exceptions for missing data and reducing information leakage. [1] [2] [3] [4] [5] [6]

Miscellaneous Improvements

  • Added JWT module registration to the fines module for secure token operations.
  • Updated various queries to ensure data consistency, such as ordering problematic licenses by points descending and including related data in fine queries. [1] [2]

These updates collectively make the fines system more secure, robust, and aligned with real-world traffic law enforcement workflows.

@vthish
vthish requested a review from Copilot June 23, 2026 19:38

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vthish vthish closed this Jun 23, 2026
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.

2 participants