swift_mt_message/messages/
mt199.rs

1use crate::fields::*;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
4
5/// # MT199: Free Format Message (Category 1)
6///
7/// MT199 is used for information where no specific message type exists.
8/// This message type is used in Category 1 (customer payments and cheques).
9///
10/// ## Key Features:
11/// - Used for free format information exchange
12/// - Category 1 routing (customer payments)
13/// - Can contain reject/return information when narrative starts with /REJT/ or /RETN/
14///
15/// ## Fields:
16/// - **20**: Transaction Reference Number (Mandatory) - 16x
17/// - **21**: Related Reference (Optional) - 16x  
18/// - **79**: Narrative (Mandatory) - 50*35x
19#[serde_swift_fields]
20#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
21#[validation_rules(MT199_VALIDATION_RULES)]
22pub struct MT199 {
23    // Mandatory Fields
24    #[field("20", mandatory)]
25    pub field_20: GenericReferenceField,
26
27    #[field("79", mandatory)]
28    pub field_79: Field79,
29
30    // Optional Fields
31    #[field("21", optional)]
32    pub field_21: Option<GenericReferenceField>,
33}
34
35const MT199_VALIDATION_RULES: &str = r#"{
36  "rules": [
37    {
38      "id": "NARRATIVE_FORMAT",
39      "description": "If narrative starts with /REJT/ or /RETN/, it must follow Payments Reject/Return Guidelines",
40      "condition": true
41    }
42  ]
43}"#;