swift_mt_message/messages/
mt950.rs

1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// MT950: Statement Message
6///
7/// ## Purpose
8/// Used to transmit account statement information with a simplified structure focusing
9/// on balance information and essential transaction data. This message provides streamlined
10/// account reporting for efficient processing and communication.
11///
12/// ## Scope
13/// This message is:
14/// - Sent by account servicing institutions for streamlined statement delivery
15/// - Used for simplified account reporting with essential information
16/// - Applied when detailed narrative information is not required
17/// - Essential for automated processing and high-volume account reporting
18/// - Part of efficient account management and customer communication systems
19///
20/// ## Key Features
21/// - **Simplified Structure**: Streamlined format for efficient processing
22/// - **Essential Information**: Focus on key balance and transaction data
23/// - **Multiple Transactions**: Support for multiple statement line entries
24/// - **Balance Information**: Opening and closing balance with currency consistency
25/// - **Available Balance**: Optional available balance information
26/// - **Automated Processing**: Optimized for automated statement processing systems
27///
28/// ## Common Use Cases
29/// - High-volume account statement processing
30/// - Automated statement delivery systems
31/// - Simplified account reporting for operational accounts
32/// - Batch processing of multiple account statements
33/// - System-to-system account information exchange
34/// - Streamlined cash management reporting
35/// - Efficient correspondent banking statement delivery
36/// - Simplified regulatory reporting requirements
37///
38/// ## Field Structure
39/// - **20**: Transaction Reference (mandatory) - Unique statement reference
40/// - **25**: Account Identification (mandatory) - Account being reported
41/// - **28C**: Statement Number/Sequence (mandatory) - Statement numbering
42/// - **60**: Opening Balance (mandatory) - Starting balance for statement period
43/// - **61**: Statement Line (mandatory, repetitive) - Individual transaction entries
44/// - **62**: Closing Balance (mandatory) - Ending balance for statement period
45/// - **64**: Available Balance (optional) - Available balance information
46///
47/// ## Field Details
48/// ### Field 61 - Statement Line
49/// Multiple statement lines can be included, each containing:
50/// - **Value Date**: Date when transaction becomes effective
51/// - **Entry Date**: Date when transaction was posted (optional)
52/// - **Credit/Debit Mark**: C (Credit) or D (Debit) entry
53/// - **Amount**: Transaction amount
54/// - **Transaction Type**: SWIFT transaction type identification
55/// - **Reference**: Transaction reference number
56///
57/// ## Network Validation Rules
58/// - **Currency Consistency**: Opening and closing balances must use the same currency
59/// - **Available Balance Currency**: Available balances must use same currency as main balances
60/// - **Reference Format**: Transaction references must follow SWIFT formatting standards
61/// - **Required Fields**: All mandatory fields must be present and properly formatted
62/// - **Balance Logic**: Closing balance should reflect opening balance plus/minus transactions
63/// - **Date Validation**: All dates must be valid and properly sequenced
64///
65/// ## Processing Context
66/// ### Simplified Statement Generation
67/// 1. Account activity summarized for statement period
68/// 2. Essential transactions selected for reporting
69/// 3. Opening balance carried forward from previous period
70/// 4. MT950 generated with streamlined transaction detail
71/// 5. Closing balance calculated and validated
72///
73/// ### Automated Processing
74/// - High-volume statement batch processing
75/// - Automated account reconciliation
76/// - System integration and data exchange
77/// - Efficient customer communication
78/// - Streamlined compliance reporting
79///
80/// ## SRG2025 Status
81/// - **Structural Changes**: None - MT950 format remains unchanged in SRG2025
82/// - **Validation Updates**: Additional validation for statement accuracy and completeness
83/// - **Processing Improvements**: Improved support for digital banking integration
84/// - **Compliance Notes**: Enhanced support for high-volume automated processing
85///
86/// ## Integration Considerations
87/// - **Banking Systems**: Efficient integration with core banking platforms and statement processing
88/// - **Customer Systems**: Streamlined input for customer financial management systems
89/// - **API Integration**: Optimized for modern API-based banking services and digital platforms
90/// - **Compliance Integration**: Simplified compliance and audit trail maintenance requirements
91///
92/// ## Relationship to Other Messages
93/// - **Triggers**: Often triggered by MT920 (Request Message) for streamlined statement delivery
94/// - **Responses**: Provides simplified alternative to MT940 when detailed information is not required
95/// - **Related**: Works with other cash management and account reporting messages
96/// - **Alternatives**: MT940 for detailed transaction information when comprehensive reporting is needed
97/// - **Status Updates**: Supports efficient account management and customer communication workflows
98
99#[serde_swift_fields]
100#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
101#[validation_rules(MT950_VALIDATION_RULES)]
102pub struct MT950 {
103    #[field("20")]
104    pub field_20: Field20,
105
106    #[field("25")]
107    pub field_25: Field25NoOption,
108
109    #[field("28C")]
110    pub field_28c: Field28C,
111
112    #[field("60")]
113    pub field_60: Field60,
114
115    #[field("61")]
116    pub field_61: Option<Vec<Field61>>,
117
118    #[field("62")]
119    pub field_62: Field62,
120
121    #[field("64")]
122    pub field_64: Option<Field64>,
123}
124
125/// Validation rules for MT950 - Statement Message
126const MT950_VALIDATION_RULES: &str = r#"{
127  "rules": [
128    {
129      "id": "C1",
130      "description": "The first two characters of the three-character currency code in fields 60a, 62a, and 64 must be the same",
131      "condition": {
132        "and": [
133          {"==": [
134            {"substr": [
135              {"if": [
136                {"exists": ["fields", "60", "F"]},
137                {"var": "fields.60.F.currency"},
138                {"var": "fields.60.M.currency"}
139              ]}, 0, 2]},
140            {"substr": [
141              {"if": [
142                {"exists": ["fields", "62", "F"]},
143                {"var": "fields.62.F.currency"},
144                {"var": "fields.62.M.currency"}
145              ]}, 0, 2]}
146          ]},
147          {
148            "if": [
149              {"exists": ["fields", "64"]},
150              {"==": [
151                {"substr": [
152                  {"if": [
153                    {"exists": ["fields", "60", "F"]},
154                    {"var": "fields.60.F.currency"},
155                    {"var": "fields.60.M.currency"}
156                  ]}, 0, 2]},
157                {"substr": [{"var": "fields.64.currency"}, 0, 2]}
158              ]},
159              true
160            ]
161          }
162        ]
163      }
164    }
165  ]
166}"#;