swift_mt_message/fields/
field11s.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::SwiftField;
4
5/// # Field 11S: MT and Date of the Original Message
6///
7/// For Cancellation and Request for Payment messages, this field contains
8/// the message type and date of the original message that is being cancelled or referenced.
9///
10/// **Format**: 3!n6!n4!n4!n
11/// - Message Type (3 digits): The original message type (e.g., 103, 202)
12/// - Date (6 digits): YYMMDD format
13/// - Session Number (4 digits): Session of original message
14/// - Input Sequence Number (4 digits): ISN of original message
15///
16/// Note: The format may include an optional slash (/) before the input sequence number,
17/// but this is handled by the parser which strips it out before processing.
18///
19/// ## Usage
20/// - **MT192**: Request for Cancellation (Customer Transfer)
21/// - **MT292**: Request for Cancellation (Financial Institution Transfer)
22/// - References original message for processing
23///
24/// ## Validation
25/// - Message type must be valid 3-digit MT number
26/// - Date must be valid YYMMDD format within acceptable range
27/// - Session and ISN must be 4-digit numbers
28///
29/// Example: 103231215001/0123 (MT103 dated 2023-12-15, session 0001, ISN 0123)
30#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
31pub struct Field11S {
32    /// Message type of the original message (3 digits)
33    #[component("3!n", validate = ["message_type"])]
34    pub message_type: String,
35
36    /// Date of the original message in YYMMDD format (6 digits)
37    #[component("6!n", validate = ["date_format", "valid_date_range"])]
38    pub date: NaiveDate,
39
40    /// Session number of the original message (4 digits)
41    #[component("4!n", validate = ["session_number"])]
42    pub session_number: String,
43
44    /// Input Sequence Number of the original message (4 digits)
45    #[component("4!n", validate = ["input_sequence_number"])]
46    pub input_sequence_number: String,
47}