VSN-2114 : Short version of saving a new default contract.
Merge Request Description
Title
Short Contract Creation with Lots Association & Error Handling
Overview
This merge request introduces a new feature for creating a short contract, including support for associating multiple Lots, robust error handling, and full API exposition.
The implementation spans DTOs, repositories, services, exception mappings, and controllers, ensuring a complete and production-ready workflow.
Detailed Changes
1. Contract Request & Data Model
- Extended the ContractRequest DTO by adding a new field:
-
lotsUuids: a list of UUIDs representing the Lots associated with the contract.
-
- This enables linking contracts to multiple Lots in a single request, simplifying contract creation flows.
2. Repository Layer
- Added a new repository method to retrieve Lots by a list of UUIDs.
- Ensures efficient batch fetching and validation of Lots before contract persistence.
- Updated the Maven POM version to reflect the introduction of this new feature set.
3. Service Layer
- Defined a new service method signature dedicated to saving a short contract.
- Implemented the service logic to:
- Validate input data.
- Fetch and validate associated Lots.
- Apply business rules related to contracts and Lots.
- Persist the contract with its associations.
- Finalized the implementation to ensure consistency with existing contract workflows.
4. Error Handling & Exceptions
- Introduced new exception mappings related to contracts, improving clarity and maintainability.
- Defined a dedicated Lot Error Code enumeration to:
- Standardize error reporting.
- Clearly distinguish Lot-related validation and business errors.
- Ensures meaningful and consistent error responses across the API.
5. API Layer (Controller)
- Added a new action path for short contract creation.
- Exposed the feature via the controller, making it accessible to external clients.
- Ensured proper request/response handling and propagation of validation or business errors.
Benefits
- Functional completeness: Enables short contract creation with associated Lots in one operation.
- Improved validation: Centralized and explicit error codes for contract and Lot-related issues.
- Scalability: Batch retrieval of Lots avoids inefficient per-item queries.
- Clean architecture: Clear separation between DTOs, repositories, services, and controllers.
- API clarity: Well-defined endpoint and request structure for consumers.
Impact & Compatibility
- No breaking changes to existing contract features.
- Existing APIs and services remain unaffected.
- The new endpoint is additive and backward-compatible.
Conclusion
This merge request delivers a fully integrated short contract creation feature, enhanced with Lots association, structured error handling, and clean API exposition. It strengthens the contract domain while maintaining architectural consistency and extensibility.
Closes VSN-2114