swift_mt_message/fields/
field57.rs

1use serde::{Deserialize, Serialize};
2use swift_mt_message_macros::SwiftField;
3
4///   **Field 57: Account With Institution**
5///
6/// ## Purpose
7/// Specifies the financial institution that services the account for the beneficiary customer
8/// (Field 59A). This field identifies the beneficiary's bank where the account is maintained
9/// and where funds will ultimately be credited. Essential for final delivery of funds and
10/// beneficiary account identification. Critical component of payment settlement chain.
11///
12/// ## Format Options Overview
13/// - **Option A**: BIC with optional party identifier - structured beneficiary bank identification
14/// - **Option B**: Party identifier with location - domestic beneficiary bank routing
15/// - **Option C**: Party identifier only - simplified beneficiary bank reference
16/// - **Option D**: Party identifier with name/address - detailed beneficiary bank information
17///
18/// ## Business Context Applications
19/// - **Beneficiary Bank**: Institution maintaining beneficiary's account
20/// - **Final Settlement**: Ultimate destination for payment funds
21/// - **Account Services**: Institution providing account services to beneficiary
22/// - **Regulatory Reporting**: Required for beneficiary institution identification
23///
24/// ## Usage Rules and Conditions
25/// - **Conditional Presence**: Required based on Rules C5 and C10
26/// - **Receiver Default**: When absent, Receiver is also the account with institution
27/// - **IBAN Compatibility**: Applicable even when Field 59A contains IBAN
28/// - **Direct Settlement**: Enables direct settlement when Receiver is account institution
29///
30/// ## Special Payment Method Codes
31/// ### Critical Settlement Instructions
32/// - **//FW**: Fedwire routing - Required by US banks for Fedwire settlement
33/// - **//RT**: Real-Time Gross Settlement - Binding instruction for RTGS systems
34/// - **//AU**: Australian payment system settlement
35/// - **//IN**: Indian payment system settlement
36///
37/// ### Code Usage Rules
38/// - **Single Usage**: Codes //FW, //AU, //IN, //RT should appear only once in Field 56A or 57A
39/// - **Binding Nature**: //RT code is binding and cannot be followed by other information
40/// - **Final Settlement**: Ensures proper final settlement through appropriate systems
41/// - **System Integration**: Enables automated settlement in national payment systems
42///
43/// ## Network Validation Requirements
44/// - **BIC Registration**: All BIC codes must be registered financial institutions
45/// - **Account Services**: Institution must provide account services to beneficiaries
46/// - **Settlement Capability**: Must support final settlement in transaction currency
47/// - **Regulatory Compliance**: Must meet beneficiary institution requirements
48///
49/// ## Settlement Logic and Processing
50/// ### Direct Settlement
51/// - **Receiver as Account Institution**: Simplest settlement scenario
52/// - **Direct Relationship**: When Sender has direct relationship with beneficiary bank
53/// - **Bilateral Agreements**: Pre-established settlement arrangements
54/// - **Currency Considerations**: Direct settlement in transaction currency
55///
56/// ### Intermediated Settlement
57/// - **Through Intermediary**: Settlement via Field 56A intermediary
58/// - **Correspondent Network**: Utilizing correspondent banking relationships
59/// - **Multi-Hop Settlement**: Complex settlement chains with multiple institutions
60/// - **Optimization**: Most efficient settlement path selection
61///
62/// ## Regional Payment System Integration
63/// ### North American Systems
64/// - **Fedwire (//FW)**: US Federal Reserve final settlement system
65/// - **ACH Networks**: Automated clearing house final settlement
66/// - **Canadian Systems**: Canadian payment system final settlement
67///
68/// ### European Systems
69/// - **TARGET2**: European Central Bank RTGS final settlement
70/// - **SEPA**: Single Euro Payments Area account crediting
71/// - **National Systems**: Country-specific final settlement systems
72///
73/// ### Asia-Pacific Systems
74/// - **Australian (//AU)**: Australian payment system final settlement
75/// - **Indian (//IN)**: Indian payment system final settlement
76/// - **Regional Networks**: ASEAN and other regional final settlement
77///
78/// ## Beneficiary Protection and Compliance
79/// - **Account Verification**: Ensuring beneficiary account exists and is operational
80/// - **Name Matching**: Coordination with beneficiary customer name in Field 59A
81/// - **Regulatory Requirements**: Meeting beneficiary institution reporting requirements
82/// - **Sanctions Screening**: Beneficiary institution sanctions compliance
83///
84/// ## STP Processing Benefits
85/// - **Automated Settlement**: System-driven final settlement based on clear identification
86/// - **Account Integration**: Direct integration with beneficiary account systems
87/// - **Exception Reduction**: Proper institution identification reduces settlement failures
88/// - **Straight-Through Processing**: Enhanced STP through structured settlement data
89///
90/// ## Error Prevention Guidelines
91/// - **Institution Verification**: Confirm institution provides account services
92/// - **Account Relationship**: Verify institution-beneficiary account relationship
93/// - **System Compatibility**: Ensure institution supports required settlement systems
94/// - **Currency Support**: Confirm institution handles transaction currency
95///
96/// ## Related Fields Integration
97/// - **Field 59A**: Beneficiary Customer (account holder identification)
98/// - **Field 56A**: Intermediary (settlement routing)
99/// - **Field 32A**: Value Date, Currency, Amount (settlement details)
100/// - **Field 70**: Remittance Information (payment purpose)
101///
102/// ## Compliance Framework
103/// - **Beneficiary Institution Due Diligence**: Enhanced due diligence requirements
104/// - **Account Verification**: Regulatory account verification requirements
105/// - **Settlement Documentation**: Complete settlement chain documentation
106/// - **Audit Trail**: Comprehensive beneficiary institution audit trail
107///
108/// ## Performance and Risk Management
109/// - **Settlement Speed**: Optimized settlement speed through proper institution identification
110/// - **Settlement Risk**: Risk mitigation through established institution relationships
111/// - **Operational Risk**: Backup settlement arrangements for business continuity
112/// - **Cost Optimization**: Efficient settlement cost management
113///
114/// ## See Also
115/// - Swift FIN User Handbook: Account With Institution Specifications
116/// - Payment Settlement Guidelines: Beneficiary Institution Requirements
117/// - Cross-Border Payments: Final Settlement Standards
118/// - Regulatory Compliance: Beneficiary Institution Due Diligence
119///
120///   **Field 57A: Account With Institution (BIC with Party Identifier)**
121///
122/// Structured beneficiary bank identification using BIC code with optional party identifier.
123/// Preferred option for automated settlement and final fund delivery.
124#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
125pub struct Field57A {
126    /// Optional party identifier for settlement and payment method codes
127    ///
128    /// Format: \[/1!a\]\[/34x\] - Single character code + up to 34 character identifier
129    /// May contain special codes: //FW (Fedwire), //RT (RTGS), //AU (Australian), //IN (Indian)
130    #[component("[/1!a][/34x]")]
131    pub party_identifier: Option<String>,
132
133    /// Bank Identifier Code of the account with institution
134    ///
135    /// Format: 4!a2!a2!c\[3!c\] - 8 or 11 character BIC code
136    /// Must be registered financial institution providing account services
137    #[component("4!a2!a2!c[3!c]")]
138    pub bic: String,
139}
140
141///   **Field 57B: Account With Institution (Party Identifier with Location)**
142///
143/// Domestic beneficiary bank routing using party identifier and location details.
144/// Used for location-based settlement in domestic payment systems.
145#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
146pub struct Field57B {
147    /// Optional party identifier for settlement routing
148    ///
149    /// Format: \[/1!a\]\[/34x\] - Single character code + up to 34 character identifier
150    /// Used for domestic clearing codes and beneficiary bank identification
151    #[component("[/1!a][/34x]")]
152    pub party_identifier: Option<String>,
153
154    /// Location information for beneficiary bank routing
155    ///
156    /// Format: \[35x\] - Up to 35 character location identifier
157    /// Used for location-based settlement within domestic systems
158    #[component("[35x]")]
159    pub location: Option<String>,
160}
161
162///   **Field 57C: Account With Institution (Party Identifier Only)**
163///
164/// Simplified beneficiary bank reference using party identifier only.
165/// Used when BIC is not required or available for settlement purposes.
166#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
167pub struct Field57C {
168    /// Party identifier for beneficiary bank settlement
169    ///
170    /// Format: /34x - Mandatory slash prefix + up to 34 character identifier
171    /// Used for domestic settlement codes and clearing system identifiers
172    #[component("/34x")]
173    pub party_identifier: String,
174}
175
176///   **Field 57D: Account With Institution (Party Identifier with Name and Address)**
177///
178/// Detailed beneficiary bank identification with full name and address information.
179/// Used when structured BIC identification is not available for beneficiary bank.
180#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
181pub struct Field57D {
182    /// Optional party identifier for settlement routing
183    ///
184    /// Format: \[/1!a\]\[/34x\] - Single character code + up to 34 character identifier
185    /// Used for settlement codes and beneficiary bank identification
186    #[component("[/1!a][/34x]")]
187    pub party_identifier: Option<String>,
188
189    /// Name and address of the account with institution
190    ///
191    /// Format: 4*35x - Up to 4 lines of 35 characters each
192    /// Contains institution name, address, city, country details
193    #[component("4*35x")]
194    pub name_and_address: Vec<String>,
195}
196
197#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SwiftField)]
198pub enum Field57AccountWithInstitution {
199    A(Field57A),
200    B(Field57B),
201    C(Field57C),
202    D(Field57D),
203}
204
205#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SwiftField)]
206pub enum Field57DebtorBank {
207    A(Field57A),
208    C(Field57C),
209    D(Field57D),
210}
211
212#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SwiftField)]
213pub enum Field57DebtInstitution {
214    A(Field57A),
215    B(Field57B),
216    D(Field57D),
217}