swift_mt_message/messages/mt110.rs
1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// MT110: Advice of Cheque(s)
6///
7/// ## Purpose
8/// Used to advise the receipt of cheque(s) for collection or deposit between financial institutions.
9/// This message provides detailed information about each cheque including amounts, dates, and processing
10/// instructions to facilitate efficient cheque clearing and collection processes.
11///
12/// ## Scope
13/// This message is:
14/// - Used for cheque collection advice between financial institutions
15/// - Applicable for bulk cheque processing with individual cheque identification
16/// - Designed for correspondent banking relationships in cheque clearing
17/// - Compatible with domestic and cross-border cheque collection schemes
18/// - Subject to cheque validation rules for proper clearing procedures
19/// - Integrated with traditional paper-based and electronic cheque processing systems
20///
21/// ## Key Features
22/// - **Comprehensive Cheque Details**: Individual cheque information with amounts, dates, and references
23/// - **Correspondent Banking Support**: Fields for sender/receiver correspondents (53A/54A)
24/// - **Collection Processing Framework**: Structured information for cheque collection and clearing
25/// - **Bulk Operations Support**: Multiple cheques can be advised in a single message
26/// - **Reference Tracking**: Unique identification for each cheque in the collection
27/// - **Currency Validation**: Ensures all cheques in a message use the same currency
28///
29/// ## Common Use Cases
30/// - Bank-to-bank cheque collection advice for deposited cheques
31/// - Correspondent banking cheque clearing operations
32/// - Cross-border cheque collection for foreign currency cheques
33/// - Bulk cheque deposit processing for corporate customers
34/// - Cheque truncation and electronic presentment advice
35/// - Collection of returned or dishonored cheques
36/// - High-value cheque collection requiring special handling
37///
38/// ## Message Structure
39/// ### Message Header
40/// - **Field 20**: Sender's Reference (mandatory) - Unique message identifier
41/// - **Field 53A**: Sender's Correspondent (optional) - Sender's correspondent bank
42/// - **Field 54A**: Receiver's Correspondent (optional) - Receiver's correspondent bank
43/// - **Field 72**: Sender to Receiver Information (optional) - Additional processing instructions
44///
45/// ### Cheque Details (Repetitive Sequence)
46/// - **Field 21**: Cheque Reference (mandatory) - Unique reference for each cheque
47/// - **Field 30**: Date of Issue (mandatory) - Date when cheque was issued (YYMMDD)
48/// - **Field 32**: Currency/Amount (mandatory) - Cheque amount and currency code
49/// - **Field 50**: Ordering Customer (optional) - Drawer/issuer of the cheque
50/// - **Field 52**: Drawer Bank (optional) - Bank on which cheque is drawn
51/// - **Field 59**: Beneficiary Customer (mandatory) - Payee of the cheque
52///
53/// ## Network Validation Rules
54/// - **Cheque Quantity Limits**: Maximum 10 cheques per message for processing efficiency
55/// - **Currency Consistency**: All cheques must have the same currency within a single message
56/// - **Reference Uniqueness**: Each cheque reference must be unique within the message
57/// - **Date Validation**: Date of issue must be in valid YYMMDD format
58/// - **Reference Format**: Cheque references must not contain '/' or '//' characters
59/// - **Minimum Requirements**: At least one cheque required per advice message
60/// - **Correspondent Validation**: Proper BIC validation for correspondent bank fields
61///
62/// ## SRG2025 Status
63/// - **Structural Changes**: None - MT110 format remains stable for cheque processing
64/// - **Validation Updates**: Enhanced validation rules for electronic cheque processing
65/// - **Processing Improvements**: Improved handling of cheque truncation scenarios
66/// - **Compliance Notes**: Maintained compatibility with traditional cheque clearing systems
67///
68/// ## Integration Considerations
69/// - **Banking Systems**: Compatible with cheque processing systems and clearing houses
70/// - **API Integration**: RESTful API support for modern cheque collection platforms
71/// - **Processing Requirements**: Supports both batch and real-time cheque collection processing
72/// - **Compliance Integration**: Built-in validation for regulatory cheque processing requirements
73///
74/// ## Relationship to Other Messages
75/// - **Triggers**: Often triggered by cheque deposit systems or collection processing
76/// - **Responses**: May generate status messages or collection confirmation messages
77/// - **Related**: Works with cheque clearing messages and account reporting systems
78/// - **Alternatives**: Electronic payment messages for digital payment alternatives
79/// - **Status Updates**: May receive notifications about cheque clearing success or failure
80#[serde_swift_fields]
81#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
82#[validation_rules(MT110_VALIDATION_RULES)]
83pub struct MT110 {
84 #[field("20")]
85 pub field_20: Field20,
86
87 #[field("53A")]
88 pub field_53a: Option<Field53SenderCorrespondent>,
89
90 #[field("54A")]
91 pub field_54a: Option<Field54ReceiverCorrespondent>,
92
93 #[field("72")]
94 pub field_72: Option<Field72>,
95
96 #[field("#")]
97 pub cheques: Vec<MT110Cheque>,
98}
99
100/// MT110 Cheque (Repetitive Sequence)
101///
102/// ## Purpose
103/// Represents individual cheque details within an MT110 advice message.
104/// Each occurrence provides complete information for one cheque being advised.
105///
106/// ## Field Details
107/// - **21**: Cheque Reference (mandatory) - Unique reference for this cheque
108/// - **32B**: Currency/Amount - Cheque amount and currency
109/// - **30**: Date - Cheque date or value date
110/// - **25**: Account - Related account information
111///
112/// ## Validation Notes
113/// - Each cheque must have a unique reference (21)
114/// - Amount (32B) must be positive for valid cheque advice
115/// - Date information (30) required for proper clearing
116#[serde_swift_fields]
117#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
118pub struct MT110Cheque {
119 #[field("21")]
120 pub field_21: Field21NoOption,
121
122 #[field("30")]
123 pub field_30: Field30,
124
125 #[field("32")]
126 pub field_32: Field32,
127
128 #[field("50")]
129 pub field_50: Option<Field50OrderingCustomerAFK>,
130
131 #[field("52")]
132 pub field_52: Option<Field52DrawerBank>,
133
134 #[field("59")]
135 pub field_59: Field59,
136}
137
138/// Enhanced validation rules with forEach support for repetitive sequences
139const MT110_VALIDATION_RULES: &str = r#"{
140 "rules": [
141 {
142 "id": "C1",
143 "description": "The repetitive sequence (Cheque details) must not occur more than 10 times",
144 "condition": {
145 "<=": [{"length": {"var": "fields.#"}}, 10]
146 }
147 },
148 {
149 "id": "C2",
150 "description": "The currency code in field 32a must be the same in all occurrences of that field",
151 "condition": {
152 "if": [
153 {">=": [{"length": {"var": "fields.#"}}, 2]},
154 {
155 "all": [
156 {"var": "fields.#"},
157 {
158 "==": [
159 {"var": "32.currency"},
160 {"var": "fields.#.0.32.currency"}
161 ]
162 }
163 ]
164 },
165 true
166 ]
167 }
168 },
169 {
170 "id": "CHQ_MIN",
171 "description": "At least one cheque required",
172 "condition": {
173 ">=": [{"length": {"var": "fields.#"}}, 1]
174 }
175 }
176 ]
177}"#;