swift_mt_message/messages/
mt292.rs

1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// MT292: Request for Cancellation (Category 2 - Financial Institution Transfers)
6///
7/// ## Purpose
8/// Used to request the cancellation of a previously sent financial institution transfer message
9/// (Category 2). This message provides reference information to identify the specific message
10/// to be cancelled and includes reasons for the cancellation request.
11///
12/// ## Scope
13/// This message is:
14/// - Sent by the originator of a Category 2 financial institution transfer to request its cancellation
15/// - Used for MT200, MT202, MT205, MT210, and other Category 2 messages
16/// - Applied when an institutional transfer needs to be cancelled before execution
17/// - Contains precise identifying information of the original message
18/// - May include structured reason codes for the cancellation
19///
20/// ## Key Features
21/// - **Message Identification**: Field 11S provides precise reference to original message
22/// - **Treasury Focus**: Specifically designed for financial institution transfer cancellations
23/// - **Cancellation Control**: Request processing before payment settlement
24/// - **Reference Tracking**: Links to original message through transaction references
25/// - **Reason Documentation**: Optional structured cancellation reasons in field 79
26/// - **Session-Based Tracking**: Field 11S includes session and sequence number details
27///
28/// ## Common Use Cases
29/// - Cancellation of MT202/MT205 institutional transfers
30/// - Prevention of duplicate institutional payments
31/// - Correction of erroneous transfer instructions
32/// - Liquidity management adjustments
33/// - Settlement system error recovery
34/// - Treasury operation corrections
35/// - Cross-border institutional payment cancellations
36///
37/// ## Field Structure
38/// - **20**: Sender's Reference (mandatory) - Message reference for this cancellation request
39/// - **21**: Related Reference (mandatory) - Reference to the original message being cancelled
40/// - **11S**: MT and Date Reference (mandatory) - Precise identification of original message
41/// - **79**: Narrative (optional) - Cancellation reasons and additional information
42///
43/// ## Field 11S Structure
44/// The Field 11S contains critical information for identifying the original message:
45/// - **Message Type**: 3-digit MT number (200, 202, 205, 210, etc.)
46/// - **Date**: 6-digit date (YYMMDD) when original message was sent
47/// - **Session Number**: 4-digit session identifier
48/// - **Input Sequence Number**: 4-digit sequence number within the session
49///
50/// ## Network Validation Rules
51/// - **C1 Rule**: Either field 79 or copy of original message fields must be present
52/// - **Reference Format**: All reference fields must follow SWIFT formatting rules
53/// - **Field 11S Format**: Must contain valid MT type, date, session, and sequence numbers
54/// - **Treasury Message Types**: Field 11S should reference valid Category 2 message types
55/// - **Mandatory Fields**: All required fields must be present and properly formatted
56/// - **Reason Codes**: If field 79 present, should contain valid cancellation reason codes
57///
58/// ## Cancellation Reason Codes
59/// When field 79 is used, it may contain standardized reason codes such as:
60/// - **AGNT**: Agent/Institution Error
61/// - **AM09**: Wrong Amount
62/// - **COVR**: Cover Payment Issue
63/// - **CURR**: Currency Error
64/// - **CUST**: Customer Request
65/// - **CUTA**: Cut-off Time
66/// - **DUPL**: Duplicate Payment
67/// - **FRAD**: Fraud
68/// - **TECH**: Technical Problem
69/// - **UPAY**: Undue Payment
70///
71/// ## Processing Considerations
72/// - **Timing Critical**: Should be sent as soon as possible after error detection
73/// - **Settlement Impact**: Cancellation success depends on settlement timing
74/// - **Institution Coordination**: May require coordination between multiple institutions
75/// - **Audit Trail**: Maintains complete record of cancellation requests
76/// - **Response Required**: Typically followed by MT296 (Answers) message
77///
78/// ## SRG2025 Status
79/// - **Structural Changes**: None - MT292 format remains unchanged in SRG2025
80/// - **Validation Updates**: Enhanced validation for institutional transfer cancellations
81/// - **Processing Improvements**: Improved integration with modern settlement systems
82/// - **Compliance Notes**: Enhanced validation for cross-border and international cancellations
83///
84/// ## Integration Considerations
85/// - **Banking Systems**: Compatible with treasury management and settlement systems
86/// - **API Integration**: RESTful API support for modern institutional transfer platforms
87/// - **Processing Requirements**: Supports urgent processing with time-sensitive cancellation capabilities
88/// - **Compliance Integration**: Built-in validation for regulatory cancellation requirements
89///
90/// ## Relationship to Other Messages
91/// - **Triggers**: Triggered by treasury systems or institutional transfer processing errors
92/// - **Responses**: Generates MT296 (Answers) response messages with cancellation status
93/// - **Related**: Works with original Category 2 messages (MT200, MT202, MT205, MT210, etc.)
94/// - **Alternatives**: Direct system-level cancellation for internal processing corrections
95/// - **Status Updates**: May be followed by replacement transfer if correction needed
96
97#[serde_swift_fields]
98#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
99#[validation_rules(MT292_VALIDATION_RULES)]
100pub struct MT292 {
101    #[field("20")]
102    pub field_20: Field20,
103
104    #[field("21")]
105    pub field_21: Field21NoOption,
106
107    #[field("11S")]
108    pub field_11s: Field11S,
109
110    #[field("79")]
111    pub field_79: Option<Field79>,
112}
113
114/// Enhanced validation rules for MT292
115const MT292_VALIDATION_RULES: &str = r#"{
116  "rules": [
117    {
118      "id": "C1",
119      "description": "Either Field 79 or a copy of mandatory fields from the original message (or both) must be present",
120      "condition": {
121        "!!": {"var": "fields.79"}
122      }
123    }
124  ]
125}"#;