swift_mt_message/messages/
mt210.rs

1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// MT210: Notice to Receive
6///
7/// ## Purpose
8/// Used to inform a financial institution that funds will be credited to their account.
9/// This message serves as advance notification of incoming funds, allowing the receiving
10/// institution to prepare for and reconcile expected payments.
11///
12/// ## Scope
13/// This message is:
14/// - Sent by a financial institution to notify another institution of pending credits
15/// - Used for liquidity management and cash flow planning
16/// - Applicable to various payment scenarios requiring advance notification
17/// - Essential for correspondent banking relationships
18/// - Used in settlement systems requiring pre-advice of incoming funds
19///
20/// ## Key Features
21/// - **Pre-Advice Functionality**: Advance notification of incoming payments
22/// - **Repetitive Sequence Structure**: Multiple payment notifications in single message
23/// - **Flexible Identification**: Either ordering customer (50) or ordering institution (52) required
24/// - **Account Management**: Optional account identification for specific crediting
25/// - **Multi-Currency Support**: Individual currency and amount per sequence
26/// - **Correspondent Banking**: Support for intermediary institution chains
27///
28/// ## Common Use Cases
29/// - Correspondent bank payment notifications
30/// - Treasury department cash flow management
31/// - Settlement system pre-advice messages
32/// - Liquidity management notifications
33/// - Expected payment confirmations
34/// - Cross-border payment notifications
35/// - Multi-currency portfolio funding advice
36///
37/// ## Message Structure
38/// ### Header Section
39/// - **20**: Transaction Reference (mandatory) - Unique message identifier
40/// - **25**: Account Identification (optional) - Specific account to be credited
41/// - **30**: Value Date (mandatory) - Date when funds will be available
42///
43/// ### Repetitive Sequence (Multiple entries allowed)
44/// - **21**: Related Reference (mandatory) - Reference to related payment/transaction
45/// - **32B**: Currency and Amount (mandatory) - Currency code and amount to be credited
46/// - **50**: Ordering Customer (optional) - Customer initiating the payment
47/// - **52**: Ordering Institution (optional) - Institution initiating the payment
48/// - **56**: Intermediary Institution (optional) - Intermediary in payment chain
49///
50/// ## Network Validation Rules
51/// - **C2 Rule**: Either field 50 (Ordering Customer) or field 52 (Ordering Institution) must be present, but not both
52/// - **Currency Consistency**: All 32B fields should use consistent currency (when multiple sequences)
53/// - **Reference Format**: Transaction and related references must follow SWIFT format rules
54/// - **Date Validation**: Value date must be valid and properly formatted (YYMMDD)
55/// - **Amount Validation**: All amounts must be positive and within acceptable ranges
56/// - **Institution Codes**: BIC codes must be valid when institution fields are used
57///
58/// ## MT210Sequence Details
59/// Each sequence within the message represents a separate payment notification and contains:
60/// - Individual payment reference (field 21)
61/// - Specific currency and amount (field 32B)
62/// - Payment originator identification (either field 50 or 52)
63/// - Optional intermediary institution details (field 56)
64///
65/// ## Processing Considerations
66/// - **Advance Notice**: Typically sent before the actual payment message
67/// - **Reconciliation**: Used for matching expected vs. actual payments
68/// - **Liquidity Planning**: Enables receiving institution to plan cash positions
69/// - **Settlement Timing**: Coordinates with payment system settlement cycles
70/// - **Exception Handling**: Facilitates investigation of missing payments
71///
72/// ## SRG2025 Status
73/// - **No Structural Changes**: MT210 format remains unchanged in SRG2025
74/// - **Enhanced Validation**: Additional validation rules for payment notification accuracy
75/// - **Cross-Border Compliance**: Enhanced validation for international payment notifications
76/// - **Settlement Integration**: Improved integration with modern settlement systems
77///
78/// ## Integration Considerations
79/// - **Banking Systems**: Compatible with liquidity management and treasury systems
80/// - **API Integration**: RESTful API support for modern cash management platforms
81/// - **Processing Requirements**: Supports real-time notification and cash flow planning
82/// - **Compliance Integration**: Built-in validation for correspondent banking requirements
83///
84/// ## Relationship to Other Messages
85/// - **Triggers**: Often precedes actual payment messages like MT202, MT103, or MT205
86/// - **Responses**: May generate acknowledgment or status confirmation messages
87/// - **Related**: Works with account reporting messages and settlement confirmations
88/// - **Alternatives**: Direct payment messages for immediate transfer without pre-advice
89/// - **Status Updates**: Enables reconciliation of expected vs. actual payments received
90
91#[serde_swift_fields]
92#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
93#[validation_rules(MT210_VALIDATION_RULES)]
94pub struct MT210 {
95    #[field("20")]
96    pub field_20: Field20, // Transaction Reference Number
97
98    #[field("25")]
99    pub field_25: Option<Field25NoOption>, // Account Identification
100
101    #[field("30")]
102    pub field_30: Field30, // Value Date (YYMMDD)
103
104    #[field("#")]
105    pub sequence: Vec<MT210Sequence>, // Sequence of Fields
106}
107
108#[serde_swift_fields]
109#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
110#[validation_rules(MT210_SEQUENCE_VALIDATION_RULES)]
111pub struct MT210Sequence {
112    #[field("21")]
113    pub field_21: Field21NoOption, // Related Reference
114
115    #[field("32B")]
116    pub field_32b: Field32B, // Currency and Amount
117
118    #[field("50")]
119    pub field_50: Option<Field50OrderingCustomerNCF>, // Ordering Customer (C, F options)
120
121    #[field("52")]
122    pub field_52: Option<Field52OrderingInstitution>, // Ordering Institution (A, D options)
123
124    #[field("56")]
125    pub field_56: Option<Field56Intermediary>, // Intermediary Institution (A, D options)
126}
127
128/// Validation rules for MT210 - Notice to Receive
129const MT210_VALIDATION_RULES: &str = r##"{
130  "rules": [
131    {
132      "id": "C1",
133      "description": "The repetitive sequence (fields 50a-32B) must not appear more than 10 times",
134      "condition": {
135        "if": [
136          {"exists": ["fields", "#"]},
137          {"<=": [{"length": {"var": "fields.#"}}, 10]},
138          true
139        ]
140      }
141    }
142  ]
143}"##;
144
145/// Validation rules for MT210Sequence - Individual sequence validation
146const MT210_SEQUENCE_VALIDATION_RULES: &str = r##"{
147  "rules": [
148    {
149      "id": "C2",
150      "description": "Either field 50a or field 52a must be present, but not both",
151      "condition": {
152        "or": [
153          {
154            "and": [
155              {"exists": ["fields", "50"]},
156              {"!": {"exists": ["fields", "52"]}}
157            ]
158          },
159          {
160            "and": [
161              {"!": {"exists": ["fields", "50"]}},
162              {"exists": ["fields", "52"]}
163            ]
164          }
165        ]
166      }
167    }
168  ]
169}"##;