swift_mt_message/messages/mt935.rs
1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// MT935: Rate Change Advice
6///
7/// ## Purpose
8/// Used to advise changes in interest rates, exchange rates, or other financial rates that
9/// affect existing agreements, accounts, or financial instruments. This message provides
10/// formal notification of rate changes with effective dates and detailed rate information.
11///
12/// ## Scope
13/// This message is:
14/// - Sent by financial institutions to notify customers or correspondents of rate changes
15/// - Used for interest rate changes on deposits, loans, and credit facilities
16/// - Applied to foreign exchange rate notifications and updates
17/// - Essential for pricing transparency and regulatory compliance
18/// - Part of relationship management and customer communication processes
19///
20/// ## Key Features
21/// - **Rate Change Notification**: Formal advice of rate modifications
22/// - **Multiple Rate Changes**: Support for up to 10 rate changes in a single message
23/// - **Effective Dating**: Precise effective dates for each rate change
24/// - **Flexible Identification**: Either function code (field 23) or account (field 25) identification
25/// - **Detailed Rate Information**: Comprehensive rate details using field 37H
26/// - **Additional Information**: Optional narrative for context and explanations
27///
28/// ## Common Use Cases
29/// - Interest rate changes on deposit accounts
30/// - Loan and credit facility rate adjustments
31/// - Foreign exchange rate updates for currency accounts
32/// - Investment product rate notifications
33/// - Central bank rate change implementations
34/// - Correspondent banking rate adjustments
35/// - Treasury and money market rate updates
36/// - Regulatory rate change compliance notifications
37///
38/// ## Message Structure
39/// ### Header Section
40/// - **20**: Transaction Reference (mandatory) - Unique reference for this rate change advice
41/// - **Rate Changes**: Repetitive sequence (1-10 occurrences) of rate change details
42/// - **72**: Sender to Receiver Information (optional) - Additional context and explanations
43///
44/// ### Rate Change Sequence (MT935RateChange)
45/// Each rate change sequence contains:
46/// - **23**: Function Code (optional) - Type of rate change or product code
47/// - **25**: Account Identification (optional) - Specific account affected by rate change
48/// - **30**: Effective Date (mandatory) - Date when new rate becomes effective
49/// - **37H**: New Rate (mandatory, repetitive) - Detailed rate information
50///
51/// ## Network Validation Rules
52/// - **C1 Rule**: Rate change sequences must occur 1-10 times
53/// - **C2 Rule**: Either field 23 (Function Code) or field 25 (Account) must be present, but not both
54/// - **Reference Format**: Transaction references must follow SWIFT formatting standards
55/// - **Required Fields**: All mandatory fields must be present and properly formatted
56/// - **Date Validation**: Effective dates must be valid and properly formatted
57/// - **Rate Validation**: Rate information must be complete and valid
58///
59/// ## Field 23 - Function Codes
60/// When used, field 23 may contain codes such as:
61/// - **DEPOSIT**: Interest rates for deposit products
62/// - **LOAN**: Interest rates for lending products
63/// - **FX**: Foreign exchange rates
64/// - **CREDIT**: Credit facility rates
65/// - **INVEST**: Investment product rates
66/// - **MONEY**: Money market rates
67///
68/// ## Field 37H - Rate Information
69/// Provides detailed rate information including:
70/// - Rate type and classification
71/// - Percentage rates or basis point changes
72/// - Spread information over reference rates
73/// - Tier-based or graduated rate structures
74/// - Minimum and maximum rate constraints
75///
76/// ## Processing Context
77/// ### Rate Change Implementation
78/// 1. Rate change decision made by institution
79/// 2. MT935 prepared with effective date and rate details
80/// 3. Message sent to affected customers/correspondents
81/// 4. Recipients update systems and communicate changes
82/// 5. New rates become effective on specified date
83///
84/// ### Regulatory Compliance
85/// - Documentation of rate change notifications
86/// - Audit trail for regulatory review
87/// - Customer communication requirements
88/// - Transparency and disclosure obligations
89///
90/// ## SRG2025 Status
91/// - **No Structural Changes**: MT935 format remains unchanged in SRG2025
92/// - **Enhanced Validation**: Additional validation for rate accuracy and completeness
93/// - **Digital Integration**: Improved support for automated rate change processing
94/// - **Regulatory Compliance**: Enhanced support for regulatory reporting requirements
95///
96/// ## Integration Considerations
97/// - **Banking Systems**: Direct integration with rate management and pricing systems
98/// - **Customer Systems**: Input for customer treasury and financial management systems
99/// - **Compliance Systems**: Essential for regulatory reporting and audit trail maintenance
100/// - **Communication Platforms**: Integration with multi-channel customer notification systems
101///
102/// ## Relationship to Other Messages
103/// - **Supports**: Rate-sensitive account management and transaction processing
104/// - **Complements**: Statement messages (MT940, MT950) that reflect rate changes
105/// - **Integrates with**: Customer communication and relationship management processes
106/// - **Documentation**: Provides formal record of rate change notifications for compliance
107
108#[serde_swift_fields]
109#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
110#[validation_rules(MT935_VALIDATION_RULES)]
111pub struct MT935 {
112 #[field("20")]
113 pub field_20: Field20,
114
115 #[field("#")]
116 pub rate_changes: Vec<MT935RateChange>,
117
118 #[field("72")]
119 pub field_72: Option<Field72>,
120}
121
122#[serde_swift_fields]
123#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
124pub struct MT935RateChange {
125 #[field("23")]
126 pub field_23: Option<Field23>,
127
128 #[field("25")]
129 pub field_25: Option<Field25NoOption>,
130
131 #[field("30")]
132 pub field_30: Field30,
133
134 #[field("37H")]
135 pub field_37h: Vec<Field37H>,
136}
137
138/// Validation rules for MT935 - Rate Change Advice
139const MT935_VALIDATION_RULES: &str = r#"{
140 "rules": [
141 {
142 "id": "C1",
143 "description": "The repetitive sequence (fields 23/25 to 37H) must appear at least once but no more than ten times",
144 "condition": {
145 "and": [
146 {">=": [{"length": {"var": "fields.#"}}, 1]},
147 {"<=": [{"length": {"var": "fields.#"}}, 10]}
148 ]
149 }
150 },
151 {
152 "id": "C2",
153 "description": "In each repetitive sequence, either field 23 or field 25, but not both, must be present",
154 "condition": {
155 "none": [
156 {"var": "fields.#"},
157 {
158 "and": [
159 {"exists": ["fields", "23"]},
160 {"exists": ["fields", "25"]}
161 ]
162 }
163 ]
164 }
165 }
166 ]
167}"#;