swift_mt_message/fields/field51.rs
1use serde::{Deserialize, Serialize};
2use swift_mt_message_macros::SwiftField;
3
4/// **Field 51A: Sending Institution**
5///
6/// ## Purpose
7/// Identifies the Sender of the message, primarily used in FileAct messages
8/// and specialized transaction contexts. This field provides explicit identification
9/// of the message originator when additional clarity is required beyond the
10/// message header information. Essential for proper message routing and accountability.
11///
12/// ## Format
13/// - **Swift Format**: `[/1!a][/34x]4!a2!a2!c[3!c]`
14/// - **Party Identifier**: `[/1!a][/34x]` - Optional clearing system identifier
15/// - **BIC Component**: `4!a2!a2!c[3!c]` - Bank Identifier Code (8 or 11 characters)
16/// - **Usage Context**: FileAct messages and institutional identification
17///
18/// ## Presence
19/// - **Status**: Optional in most contexts, conditional for FileAct messages
20/// - **Swift Error Codes**: T27/T28/T29 (invalid BIC), T45 (unregistered BIC), D63 (invalid context)
21/// - **Usage Context**: Message sender identification and institutional routing
22///
23/// ## Usage Rules
24/// - **FileAct Context**: Mandatory for FileAct message identification
25/// - **BIC Validation**: Must be registered financial institution BIC
26/// - **Originator Match**: First 8 characters must match message originator
27/// - **Reference Coordination**: Works with Field 20 for transaction reference
28///
29/// ## Network Validation Rules
30/// - **BIC Registration**: Must be valid and registered financial institution
31/// - **Format Compliance**: Exact adherence to BIC format requirements
32/// - **Originator Consistency**: BIC prefix must match sending institution
33/// - **Context Validation**: Only valid in appropriate message types
34/// - **Character Set**: Alphanumeric characters only in specified positions
35///
36/// ## Business Context
37/// - **Message Identification**: Explicit sender identification for complex routing
38/// - **FileAct Operations**: Essential component of file transfer messages
39/// - **Institutional Clarity**: Removes ambiguity in multi-party transactions
40/// - **Audit Trail**: Provides clear originator identification for compliance
41///
42/// ## Party Identifier Formats
43/// - **Clearing System Codes**: Single character codes for domestic systems
44/// - **Account References**: Up to 34 character institutional identifiers
45/// - **Optional Usage**: May be omitted when not required for routing
46/// - **System Specific**: Aligned with local clearing system requirements
47///
48/// ## Examples
49/// ```logic
50/// :51A:DEUTDEFFXXX // Deutsche Bank Frankfurt (basic BIC)
51/// :51A:/DCHAPSFFXXX // With clearing system identifier
52/// :51A:/12345678MIDLGB22 // With account reference and BIC
53/// ```
54///
55/// ## FileAct Message Integration
56/// - **Message Routing**: Critical for FileAct message delivery
57/// - **Security Context**: Supports authentication and authorization
58/// - **Service Integration**: Enables proper service endpoint identification
59/// - **Error Handling**: Facilitates proper error message routing
60///
61/// ## Clearing System Codes
62/// - **Domestic Systems**: Single character codes for national clearing
63/// - **International Routing**: Multi-character codes for cross-border
64/// - **Bilateral Agreements**: Custom codes for specific institution pairs
65/// - **Regional Networks**: Codes for regional payment systems
66///
67/// ## Regional Considerations
68/// - **European Networks**: TARGET2 and SEPA routing requirements
69/// - **US Systems**: Fedwire and ACH routing considerations
70/// - **Asian Markets**: Local clearing system integration requirements
71/// - **Cross-Border**: International correspondent banking arrangements
72///
73/// ## Error Prevention
74/// - **BIC Validation**: Verify BIC is registered and reachable
75/// - **Context Checking**: Ensure appropriate message type usage
76/// - **Originator Matching**: Confirm BIC alignment with sender
77/// - **Format Verification**: Validate exact format compliance
78///
79/// ## Related Fields
80/// - **Field 20**: Transaction Reference (coordination with sender ID)
81/// - **Field 52A**: Ordering Institution (institution hierarchy)
82/// - **Message Header**: Basic Application Header (sender information)
83/// - **Field 53A**: Sender's Correspondent (relationship definition)
84///
85/// ## Institutional Hierarchy
86/// - **Primary Sender**: Main institution originating message
87/// - **Department/Branch**: Specific department within institution
88/// - **Service Provider**: Third-party service acting for institution
89/// - **Correspondent Network**: Institution acting through correspondent
90///
91/// ## STP Processing
92/// - **Automated Routing**: System-driven message routing based on BIC
93/// - **Validation Enhancement**: Real-time BIC validation and verification
94/// - **Error Reduction**: Automated detection of routing inconsistencies
95/// - **Processing Efficiency**: Streamlined handling of institutional identification
96///
97/// ## Compliance Framework
98/// - **Regulatory Identification**: Clear sender identification for compliance
99/// - **Audit Documentation**: Complete institutional identification trail
100/// - **Risk Management**: Proper sender identification for risk assessment
101/// - **Investigation Support**: Clear originator details for compliance reviews
102///
103/// ## FileAct Specific Applications
104/// - **File Transfer Security**: Sender authentication for file operations
105/// - **Service Discovery**: Proper routing to file handling services
106/// - **Message Correlation**: Linking file operations to sending institution
107/// - **Error Resolution**: Proper routing of file operation errors
108///
109/// ## See Also
110/// - Swift FIN User Handbook: Sending Institution Specifications
111/// - FileAct Message Standards: Sender Identification Requirements
112/// - BIC Directory: Valid Financial Institution Codes
113/// - Message Routing Guidelines: Institutional Identification Standards
114
115#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
116pub struct Field51A {
117 /// Optional party identifier for clearing system or account reference
118 ///
119 /// Format: [/1!a][/34x] - Single character code + up to 34 character identifier
120 /// Used for domestic clearing systems and institutional account references
121 #[component("[/1!a][/34x]")]
122 pub party_identifier: Option<String>,
123
124 /// Bank Identifier Code of the sending institution
125 ///
126 /// Format: 4!a2!a2!c\[3!c\] - 8 or 11 character BIC code
127 /// Must be registered financial institution BIC matching message originator
128 #[component("4!a2!a2!c[3!c]")]
129 pub bic: String,
130}