swift_mt_message/fields/field28.rs
1use serde::{Deserialize, Serialize};
2use swift_mt_message_macros::SwiftField;
3
4/// **Field 28: Statement Number / Sequence Number / Message Index**
5///
6/// ## Purpose
7/// Provides statement numbering, sequence identification, and message indexing capabilities
8/// for financial statements, batch operations, and multi-part message communication.
9/// This field enables proper ordering, continuation tracking, and completeness verification
10/// of related messages or statement sequences.
11///
12/// ## Format Variants
13/// - **Field 28**: `5n[/2n]` - Statement number with optional sequence
14/// - **Field 28C**: `5n[/5n]` - Statement number with extended sequence
15/// - **Field 28D**: `5n/5n` - Message index and total count
16///
17/// ## Presence
18/// - **Status**: Mandatory in statement messages and batch operations
19/// - **Swift Error Codes**: T40 (invalid number), T51 (format violation)
20/// - **Usage Context**: Statement numbering and message sequencing
21///
22/// ## Usage Rules
23/// - **Sequential Numbering**: Numbers must follow logical sequence for statements
24/// - **Index Validation**: Message index must not exceed total count in Field 28D
25/// - **Completeness**: Enables verification that all messages/statements received
26/// - **Ordering**: Facilitates proper chronological ordering of related messages
27///
28/// ## Network Validation Rules
29/// - **Positive Numbers**: All numeric values must be greater than zero
30/// - **Range Validation**: Numbers must be within reasonable business limits
31/// - **Format Compliance**: Must follow exact numeric format specifications
32/// - **Logic Validation**: Index must not exceed total in indexed variants
33///
34/// ## Field Variants and Usage
35///
36/// ### Field 28 - Basic Statement/Sequence Number
37/// - **Format**: `5n[/2n]`
38/// - **Usage**: Account statements with optional sequence numbers
39/// - **Statement Number**: Primary identifier for statement period
40/// - **Sequence Number**: Sub-sequence within statement period
41///
42/// ### Field 28C - Extended Statement/Sequence Number
43/// - **Format**: `5n[/5n]`
44/// - **Usage**: Extended numbering for complex statement structures
45/// - **Enhanced Range**: Larger sequence number capacity
46/// - **Complex Statements**: Multi-part statements with extensive sequences
47///
48/// ### Field 28D - Message Index/Total
49/// - **Format**: `5n/5n`
50/// - **Usage**: Batch message indexing for completeness verification
51/// - **Index Number**: Current message position in sequence
52/// - **Total Count**: Complete count of messages in batch
53/// - **Verification**: Enables receiver to verify all messages received
54///
55/// ## Business Context
56/// - **Statement Management**: Systematic numbering of account statements
57/// - **Batch Processing**: Sequencing multiple related transactions
58/// - **Audit Trail**: Maintaining proper sequence records for compliance
59/// - **Message Integrity**: Ensuring complete message set delivery
60///
61/// ## Examples
62/// ```logic
63/// :28:12345 // Statement 12345 (no sequence)
64/// :28:12345/01 // Statement 12345, sequence 1
65/// :28C:98765/00123 // Extended statement with sequence
66/// :28D:001/010 // Message 1 of 10 total
67/// :28D:010/010 // Final message (10 of 10)
68/// ```
69///
70/// ## Statement Sequencing Logic
71/// - **Daily Statements**: Incremental numbering by business day
72/// - **Monthly Statements**: Period-based numbering with daily sequences
73/// - **Special Statements**: Ad-hoc numbering for specific requirements
74/// - **Continuation**: Sequence numbers for multi-part statements
75///
76/// ## Batch Message Processing
77/// - **Transmission Order**: Sequential transmission of indexed messages
78/// - **Completeness Check**: Verification all messages received
79/// - **Error Recovery**: Re-transmission of missing message indices
80/// - **Processing Logic**: Ordered processing based on index sequence
81///
82/// ## Regional Considerations
83/// - **European Standards**: SEPA statement numbering requirements
84/// - **US Banking**: Federal Reserve statement sequence standards
85/// - **Asian Markets**: Local statement numbering conventions
86/// - **International**: Cross-border statement coordination
87///
88/// ## Error Prevention
89/// - **Number Validation**: Verify numbers are positive and within range
90/// - **Sequence Logic**: Ensure logical progression of sequence numbers
91/// - **Index Validation**: Confirm message index does not exceed total
92/// - **Completeness Check**: Verify all expected messages received
93///
94/// ## Related Fields
95/// - **Field 60**: Opening Balance (statement start information)
96/// - **Field 62**: Closing Balance (statement end information)
97/// - **Field 64**: Closing Available Balance (additional statement data)
98/// - **Block Headers**: Message timestamps and references
99///
100/// ## Processing Applications
101/// - **MT940**: Customer Statement Message (Field 28)
102/// - **MT942**: Interim Transaction Report (Field 28C)
103/// - **MT101**: Request for Transfer (Field 28D)
104/// - **MT102**: Multiple Customer Credit Transfer (Field 28D)
105///
106/// ## STP Compliance
107/// - **Automated Sequencing**: System-generated sequence numbers for STP
108/// - **Integrity Validation**: Automated completeness checking
109/// - **Exception Handling**: Missing sequence detection and alerts
110/// - **Quality Control**: Real-time sequence validation
111///
112/// ## Compliance and Audit
113/// - **Regulatory Reporting**: Sequential statement reporting requirements
114/// - **Audit Trail**: Maintaining complete sequence records
115/// - **Record Keeping**: Statement number preservation for regulatory periods
116/// - **Investigation Support**: Sequence-based transaction reconstruction
117///
118/// ## See Also
119/// - Swift FIN User Handbook: Statement Numbering Standards
120/// - MT940/942 Guidelines: Statement Sequence Requirements
121/// - Batch Processing Standards: Message Indexing Specifications
122/// - Regulatory Guidelines: Statement Numbering Compliance
123/// **Field 28: Basic Statement Number/Sequence Number**
124///
125/// Basic statement numbering with optional sequence for account statements
126/// and transaction reports.
127#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
128pub struct Field28 {
129 /// Statement number
130 ///
131 /// Format: 5n - Up to 5 digits (1-99999)
132 /// Primary identifier for statement period or report
133 #[component("5n")]
134 pub statement_number: u32,
135
136 /// Optional sequence number
137 ///
138 /// Format: [/2n] - Optional 1-2 digits after slash (1-99)
139 /// Used for multi-part statements within same period
140 #[component("[/2n]")]
141 pub sequence_number: Option<u8>,
142}
143
144/// **Field 28C: Extended Statement Number/Sequence Number**
145///
146/// Extended statement numbering with larger sequence capacity for
147/// complex statement structures and detailed transaction reports.
148#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
149pub struct Field28C {
150 /// Statement number
151 ///
152 /// Format: 5n - Up to 5 digits (1-99999)
153 /// Primary identifier for statement period
154 #[component("5n")]
155 pub statement_number: u32,
156
157 /// Optional extended sequence number
158 ///
159 /// Format: [/5n] - Optional 1-5 digits after slash (1-99999)
160 /// Enhanced sequence capacity for complex multi-part statements
161 #[component("[/5n]")]
162 pub sequence_number: Option<u32>,
163}
164
165/// **Field 28D: Message Index/Total**
166///
167/// Message indexing for batch operations enabling completeness verification
168/// and proper sequencing of related messages.
169#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
170pub struct Field28D {
171 /// Message index (current position)
172 ///
173 /// Format: 5n - Current message number in sequence (1-99999)
174 /// Must not exceed total count, enables ordering verification
175 #[component("5n")]
176 pub index: u32,
177
178 /// Total message count
179 ///
180 /// Format: /5n - Complete count of messages in batch (1-99999)
181 /// Enables receiver to verify all messages received
182 #[component("/5n")]
183 pub total: u32,
184}