Skip to content

Commit ddfc116

Browse files
committed
Merge branch 'contracts' into 'main'
feat: Implement versioned contract system with M:N segment relationships See merge request 701/netbox/cesnet_service_path_plugin!45
2 parents 6629c64 + 50c650b commit ddfc116

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3436
-812
lines changed

CHANGELOG.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,138 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [5.4.0] - 2025-12-08
9+
10+
### Added
11+
12+
- **Contract Information Management System**: Complete replacement of SegmentFinancialInfo with ContractInfo
13+
- Versioned contract system with linear version chains (similar to Git commits)
14+
- Support for contract amendments and renewals through NetBox clone functionality
15+
- Many-to-many relationship between contracts and segments (one contract can cover multiple segments)
16+
- Contract metadata tracking: contract number, type (new/amendment/renewal), effective dates
17+
- Enhanced recurring charge tracking with configurable periods (monthly, quarterly, annually, etc.)
18+
- Commitment end date calculation and tracking with visual indicators
19+
- Contract version history visualization in UI
20+
21+
- **Contract Versioning Features**:
22+
- Linear version chain using linked list pattern (previous_version/superseded_by)
23+
- Automatic version numbering (v1, v2, v3...)
24+
- Version navigation: get first version, latest version, full version history
25+
- Active/superseded contract status tracking
26+
- Clone functionality for creating amendments and renewals
27+
28+
- **Contract Financial Tracking**:
29+
- Recurring charges with customizable periods (monthly, quarterly, semi-annually, annually, bi-annually)
30+
- Number of recurring charge periods tracking
31+
- Non-recurring charges for setup/installation fees
32+
- Multi-currency support with immutable currency (set at contract creation)
33+
- Automatic financial calculations:
34+
- Total recurring cost (recurring charge × number of periods)
35+
- Total contract value (recurring + non-recurring charges)
36+
- Commitment end date (start date + recurring periods)
37+
38+
- **Contract UI Components**:
39+
- ContractInfo list view with advanced filtering
40+
- Contract detail view with version history timeline
41+
- Color-coded date badges for contract status (green/orange/red/gray)
42+
- Interactive tooltips showing days remaining and contract status
43+
- Version chain visualization showing contract evolution
44+
- Financial summary panel with all calculations
45+
- Navigation menu integration
46+
47+
- **Contract API Enhancements**:
48+
- New `/api/plugins/cesnet-service-path-plugin/contract-info/` endpoint
49+
- Support for versioning fields in API:
50+
- `previous_version`: Link to previous contract version
51+
- `superseded_by`: Link to superseding contract version
52+
- `is_active`: Boolean indicating if contract is current version
53+
- `version`: Calculated version number
54+
- Computed financial fields in API responses
55+
- Advanced filtering: by active status, version status, contract type, currency, dates
56+
57+
- **Segment View Enhancements**:
58+
- M:N contract relationship support in segment detail view
59+
- Display all contracts associated with a segment
60+
- Color-coded contract status indicators
61+
- Contract end date and commitment end date visualization
62+
63+
- **GraphQL Support**:
64+
- Updated GraphQL schema for ContractInfo model
65+
- Support for querying contract versions and relationships
66+
- Financial calculations available in GraphQL queries
67+
68+
### Changed
69+
70+
- **Breaking**: Replaced SegmentFinancialInfo model with ContractInfo model
71+
- Changed from 1:1 segment-financial relationship to M:N segment-contract relationship
72+
- Financial information now managed through contracts rather than directly on segments
73+
- API endpoint changed from `/segment-financial-info/` to `/contract-info/`
74+
75+
- **Database Schema**:
76+
- Removed SegmentFinancialInfo table
77+
- Added ContractInfo table with versioning support
78+
- Added ContractSegmentMapping join table for M:N relationships
79+
- Migration automatically converts existing financial data to contracts
80+
81+
- **Financial Field Changes**:
82+
- Renamed `monthly_charge` to `recurring_charge` with configurable period
83+
- Added `recurring_charge_period` field (monthly, quarterly, annually, etc.)
84+
- Renamed `commitment_period_months` to `number_of_recurring_charges`
85+
- Renamed `recurring_charge_end_date` to `commitment_end_date` for clarity
86+
- Made recurring charge fields nullable to support amendments without recurring charges
87+
88+
- **Model Improvements**:
89+
- Currency is now immutable after contract creation (cannot be changed in amendments)
90+
- All contract attributes can be updated through versioning (except currency)
91+
- Enhanced clone functionality for proper M2M relationship handling
92+
- Improved date calculations and validations
93+
94+
- **Color-Coded Date Visualization**:
95+
- Contract end dates now show color-coded status badges
96+
- Commitment end dates display with visual indicators:
97+
- Green: Date has passed
98+
- Orange: Within 30 days of expiration
99+
- Red: More than 30 days remaining
100+
- Gray: Date not set
101+
- Interactive tooltips showing exact dates and days remaining
102+
103+
### Removed
104+
105+
- **Breaking**: SegmentFinancialInfo model and related components
106+
- Removed `/api/plugins/cesnet-service-path-plugin/segment-financial-info/` endpoint
107+
- Removed SegmentFinancialInfo views, forms, tables, and serializers
108+
- Removed direct financial relationship from segments
109+
110+
### Fixed
111+
112+
- Improved decimal handling in financial calculations
113+
- Enhanced date validation for contract periods
114+
- Better error handling for version chain operations
115+
- Fixed M2M relationship serialization in API responses
116+
117+
### Migration Notes
118+
119+
- **Database Migration Required**: Migration 0033 automatically converts SegmentFinancialInfo to ContractInfo
120+
- **Data Preservation**: All existing financial data is preserved during migration:
121+
- Monthly charges → recurring charges (monthly period)
122+
- Commitment period months → number of recurring charges
123+
- Segment install/termination dates → contract start/end dates
124+
- Notes and tags are fully preserved
125+
- Created/updated timestamps are maintained
126+
- **API Breaking Change**: Update API clients to use `/contract-info/` endpoint instead of `/segment-financial-info/`
127+
- **Permission Updates**: New permissions for ContractInfo (view, add, change, delete)
128+
- **M:N Relationships**: Segments can now be associated with multiple contracts
129+
- **Versioning Workflow**: Use NetBox clone functionality to create contract amendments
130+
131+
### Upgrade Instructions
132+
133+
1. **Backup your database** before upgrading (important for any major version)
134+
2. Update the plugin: `pip install --upgrade cesnet_service_path_plugin`
135+
3. Run migrations: `python manage.py migrate cesnet_service_path_plugin`
136+
4. Update API integrations to use new `/contract-info/` endpoint
137+
5. Review and update user permissions for ContractInfo model
138+
6. Test contract creation and amendment workflow in UI
139+
8140
## [5.3.0] - 2025-11-19
9141

10142
### Added

0 commit comments

Comments
 (0)