swift_mt_message/fields/field59.rs
1use serde::{Deserialize, Serialize};
2use swift_mt_message_macros::SwiftField;
3
4/// **Field 59F: Beneficiary Customer (Option F)**
5///
6/// ## Purpose
7/// Provides detailed beneficiary customer identification using party identifier combined
8/// with structured name and address information. This option enables comprehensive
9/// beneficiary documentation while maintaining STP compatibility through structured
10/// format requirements and enhanced customer identification capabilities.
11///
12/// ## Format Specification
13/// - **Swift Format**: `[/34x]4*(1!n/33x)`
14/// - **Party Identifier**: Optional 34-character identifier (account, reference, or ID)
15/// - **Name/Address Lines**: Up to 4 lines with line number + 33 characters each
16/// - **Line Structure**: Each line starts with line number (1-4) followed by content
17///
18/// ## Business Context Applications
19/// - **Enhanced KYC**: Detailed customer identification for compliance
20/// - **Corporate Beneficiaries**: Complex corporate structure identification
21/// - **Multi-jurisdictional**: Cross-border regulatory compliance support
22/// - **High-value Transactions**: Enhanced due diligence requirements
23///
24/// ## Party Identifier Usage
25/// ### Identification Types
26/// - **Account Numbers**: IBAN, domestic account numbers, or special identifiers
27/// - **Customer References**: Internal bank customer reference numbers
28/// - **Government IDs**: Tax identification numbers or business registration numbers
29/// - **Special Codes**: Regulatory or industry-specific identification codes
30///
31/// ## Structured Name and Address Format
32/// ### Line Number Requirements
33/// - **Line 1**: Primary beneficiary name (mandatory)
34/// - **Line 2**: Secondary name or business unit (optional)
35/// - **Line 3**: Street address or PO Box (recommended)
36/// - **Line 4**: City, postal code, country (recommended)
37///
38/// ### Content Guidelines
39/// - **Character Limit**: 33 characters per line (excluding line number)
40/// - **Character Set**: Standard SWIFT character set compliance
41/// - **Address Completeness**: Sufficient detail for payment delivery
42/// - **Name Accuracy**: Legal name matching official documentation
43///
44/// ## STP Processing Advantages
45/// - **Structured Format**: Consistent field parsing and validation
46/// - **Line Numbering**: Automated address field mapping
47/// - **Regulatory Compliance**: Enhanced compliance documentation
48/// - **Data Quality**: Improved accuracy through structured input
49///
50/// ## Network Validation Requirements
51/// - **Line Number Validation**: Must use consecutive numbers 1-4
52/// - **Character Set Compliance**: Standard SWIFT character restrictions
53/// - **Address Sufficiency**: Adequate address detail for delivery
54/// - **Name Consistency**: Consistent beneficiary name across lines
55///
56/// ## Regional Considerations
57/// - **Address Standards**: Local address format compliance
58/// - **Regulatory Requirements**: Enhanced beneficiary documentation
59/// - **Language Requirements**: English language for international payments
60/// - **Cultural Sensitivity**: Appropriate name and address formatting
61///
62/// ## Enhanced Due Diligence Support
63/// ### Compliance Benefits
64/// - **Detailed Records**: Comprehensive beneficiary documentation
65/// - **Audit Trail**: Complete identification information
66/// - **Risk Assessment**: Enhanced risk profiling capabilities
67/// - **Regulatory Reporting**: Structured data for compliance reporting
68///
69/// ## Error Prevention Guidelines
70/// - **Complete Information**: Provide all available identification details
71/// - **Accurate Line Numbering**: Use correct sequential line numbers
72/// - **Character Compliance**: Verify SWIFT character set usage
73/// - **Address Verification**: Confirm address accuracy and completeness
74///
75/// ## Usage Examples
76/// ```logic
77/// :59F:/GB82WEST12345698765432
78/// 1/ACME CORPORATION LIMITED
79/// 2/INTERNATIONAL TRADE DIVISION
80/// 3/123 BUSINESS PARK AVENUE
81/// 4/LONDON EC1A 1BB UNITED KINGDOM
82/// ```
83///
84/// ## Related Fields Integration
85/// - **Field 57A**: Account with Institution (beneficiary bank)
86/// - **Field 70**: Remittance Information (payment purpose)
87/// - **Field 77T**: Structured Remittance Information (enhanced details)
88/// - **Field 72**: Sender to Receiver Information (additional context)
89///
90/// ## Compliance Framework
91/// - **KYC Enhancement**: Detailed customer identification support
92/// - **AML Compliance**: Enhanced anti-money laundering documentation
93/// - **Regulatory Documentation**: Complete beneficiary record keeping
94/// - **Audit Support**: Comprehensive identification audit trail
95///
96/// ## Best Practices
97/// - **Complete Documentation**: Provide all available beneficiary details
98/// - **Structured Approach**: Use consistent line numbering and formatting
99/// - **Accuracy Verification**: Verify all identification information
100/// - **Compliance Awareness**: Understand regulatory documentation requirements
101///
102/// ## See Also
103/// - Swift FIN User Handbook: Option F Beneficiary Specifications
104/// - KYC Guidelines: Enhanced Customer Identification Requirements
105/// - Regulatory Compliance: Beneficiary Documentation Standards
106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
107pub struct Field59F {
108 /// Party identifier
109 #[component("[/34x]")]
110 pub party_identifier: Option<String>,
111
112 /// Name and address lines
113 #[component("4*(1!n/33x)")]
114 pub name_and_address: Vec<String>,
115}
116
117/// **Field 59A: Beneficiary Customer (Option A)**
118///
119/// ## Purpose
120/// Provides structured beneficiary customer identification using BIC-based format
121/// for optimal STP (Straight-Through Processing) compliance. This option combines
122/// optional account information with mandatory BIC identification, enabling
123/// automated processing and efficient routing through the correspondent banking network.
124///
125/// ## Format Specification
126/// - **Swift Format**: `[/34x]4!a2!a2!c[3!c]`
127/// - **Account**: Optional 34-character account identifier
128/// - **BIC Structure**: 8 or 11 character Bank Identifier Code
129/// - **BIC Format**: Bank Code (4) + Country (2) + Location (2) + Optional Branch (3)
130///
131/// ## Business Context Applications
132/// - **STP Processing**: Optimal format for automated payment processing
133/// - **Correspondent Banking**: Direct routing through BIC network
134/// - **High-volume Payments**: Efficient processing for payment batches
135/// - **Standard Transfers**: Most common format for routine payments
136///
137/// ## BIC Code Structure and Validation
138/// ### 8-Character BIC (Head Office)
139/// - **Bank Code**: 4 alphabetic characters (institution identifier)
140/// - **Country Code**: 2 alphabetic characters (ISO 3166-1 alpha-2)
141/// - **Location Code**: 2 alphanumeric characters (city/region identifier)
142/// - **Usage**: Default routing to institution's head office
143///
144/// ### 11-Character BIC (Branch Office)
145/// - **Branch Code**: Additional 3 alphanumeric characters
146/// - **Branch Identification**: Specific branch or department routing
147/// - **Usage**: Direct routing to specific branch location
148/// - **Validation**: Branch code must be valid for the institution
149///
150/// ## Account Information Guidelines
151/// ### Account Format Options
152/// - **IBAN**: International Bank Account Number (preferred for EUR and some currencies)
153/// - **Domestic Account**: Country-specific account number format
154/// - **Special Identifiers**: Institution-specific customer identifiers
155/// - **No Account**: BIC-only identification for certain transaction types
156///
157/// ### Account Validation Requirements
158/// - **IBAN Validation**: Checksum and format validation for IBAN accounts
159/// - **Domestic Standards**: Compliance with local account number formats
160/// - **Character Set**: Standard SWIFT character set restrictions
161/// - **Length Limits**: Maximum 34 characters for account information
162///
163/// ## STP Processing Advantages
164/// - **Automated Routing**: Direct BIC-based routing without manual intervention
165/// - **Validation Efficiency**: Automated BIC verification and reachability checks
166/// - **Processing Speed**: Fastest processing option for payment instructions
167/// - **Cost Effectiveness**: Lower processing costs due to automation
168///
169/// ## Network Validation Requirements
170/// - **BIC Reachability**: BIC must be active and reachable in SWIFT network
171/// - **BIC Format**: Must conform to ISO 9362 standard
172/// - **Account Compatibility**: Account format must be compatible with receiving institution
173/// - **Currency Support**: Institution must support the payment currency
174///
175/// ## Regional Considerations
176/// ### SEPA (Single Euro Payments Area)
177/// - **IBAN Requirement**: IBAN mandatory for EUR payments within SEPA
178/// - **BIC Usage**: BIC required for non-SEPA or high-value SEPA payments
179/// - **Processing Rules**: SEPA-specific validation and routing rules
180///
181/// ### US Dollar Payments
182/// - **Fedwire**: BIC required for USD payments via Fedwire
183/// - **CHIPS**: BIC-based routing for CHIPS network payments
184/// - **Correspondent Banking**: BIC enables correspondent banking relationships
185///
186/// ## Error Prevention Guidelines
187/// - **BIC Verification**: Confirm BIC is active and supports required services
188/// - **Account Validation**: Verify account format matches institution standards
189/// - **Currency Check**: Ensure institution accepts the payment currency
190/// - **Reachability Test**: Confirm institution is reachable for the message type
191///
192/// ## Usage Examples
193/// ```logic
194/// // With IBAN account
195/// :59A:/GB82WEST12345698765432
196/// MIDLGB22XXX
197///
198/// // With domestic account number
199/// :59A:/12345678
200/// CHASUS33XXX
201///
202/// // BIC-only identification
203/// :59A:DEUTDEFFXXX
204/// ```
205///
206/// ## Related Fields Integration
207/// - **Field 57A**: Account with Institution (beneficiary bank BIC)
208/// - **Field 56A**: Intermediary Institution (routing BIC)
209/// - **Field 70**: Remittance Information (payment purpose)
210/// - **Field 33B**: Currency/Amount (currency compatibility check)
211///
212/// ## Compliance Framework
213/// - **STP Standards**: Full compliance with STP processing requirements
214/// - **BIC Directory**: Compliance with SWIFT BIC directory standards
215/// - **Regulatory Requirements**: Meeting regulatory identification standards
216/// - **Audit Trail**: Complete electronic audit trail for automated processing
217///
218/// ## Processing Impact
219/// - **Routing Efficiency**: Direct routing through correspondent banking network
220/// - **Processing Time**: Fastest processing due to automated handling
221/// - **Cost Optimization**: Lower fees due to STP processing
222/// - **Error Reduction**: Reduced manual intervention and error rates
223///
224/// ## Best Practices
225/// - **BIC Accuracy**: Always verify BIC codes before transmission
226/// - **Account Standards**: Follow local account number conventions
227/// - **STP Optimization**: Use this option for maximum processing efficiency
228/// - **Regular Updates**: Keep BIC information current and validated
229///
230/// ## See Also
231/// - Swift FIN User Handbook: Option A Beneficiary Specifications
232/// - ISO 9362 Standard: BIC Code Structure and Validation
233/// - STP Implementation Guide: Beneficiary Identification Best Practices
234#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
235pub struct Field59A {
236 /// Account number (optional)
237 #[component("[/34x]")]
238 pub account: Option<String>,
239 /// BIC code
240 #[component("4!a2!a2!c[3!c]")]
241 pub bic: String,
242}
243
244/// **Field 59 (No Option): Beneficiary Customer**
245///
246/// Flexible variant of [Field 59 module](index.html). Provides beneficiary customer
247/// identification combining optional account information with free-format name and address.
248///
249/// **Components:**
250/// - Account identifier (optional, [/34x])
251/// - Name and address lines (4*35x)
252///
253/// For complete documentation, see the [Field 59 module](index.html).
254#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
255pub struct Field59NoOption {
256 /// Account number (optional)
257 ///
258 /// Format: [/34x] - Optional account identifier up to 34 characters
259 /// Used for IBAN, domestic account numbers, or special identifiers
260 #[component("[/34x]")]
261 pub account: Option<String>,
262
263 /// Name and address lines
264 ///
265 /// Format: 4*35x - Up to 4 lines of 35 characters each
266 /// Contains beneficiary name and address information in flexible format
267 #[component("4*35x")]
268 pub name_and_address: Vec<String>,
269}
270
271/// **Field 59: Beneficiary Customer**
272///
273/// ## Purpose
274/// Identifies the ultimate beneficiary of the payment instruction. The beneficiary customer
275/// is the final recipient of the funds being transferred. Different options provide various
276/// levels of detail and identification methods to accommodate different business scenarios.
277///
278/// ## Options Overview
279/// - **Option A**: Account + BIC identification (structured, STP-preferred)
280/// - **Option F**: Party identifier + name/address (detailed identification)
281/// - **No Option**: Account + name/address (flexible format)
282///
283/// ## STP Compliance Requirements
284/// - **STP Preferred**: Option A with valid BIC and account information
285/// - **STP Compatible**: No option with complete account and address details
286/// - **Manual Processing**: Incomplete or incorrectly formatted beneficiary information
287///
288/// ## Network Validation Rules
289/// - **Account Validation**: Account numbers must conform to domestic standards when provided
290/// - **BIC Validation**: BIC codes must be valid and reachable when specified
291/// - **Name Validation**: Beneficiary name must not match sanctions screening lists
292/// - **Address Completeness**: Sufficient address detail for regulatory compliance
293///
294/// ## Regional Considerations
295/// - **SEPA**: IBAN mandatory for EUR payments within SEPA zone
296/// - **US**: Fedwire and ACH routing information may be required
297/// - **UK**: Sort code and account number validation for GBP payments
298/// - **Emerging Markets**: Enhanced beneficiary documentation may be required
299///
300/// ## Anti-Money Laundering (AML) Requirements
301/// - **Customer Due Diligence**: Beneficiary information must support KYC requirements
302/// - **Sanctions Screening**: Real-time screening against global watchlists
303/// - **Regulatory Reporting**: Some jurisdictions require detailed beneficiary reporting
304/// - **Record Keeping**: Beneficiary details retained for compliance periods
305///
306/// ## Examples by Option
307/// ```logic
308/// // Option A: BIC-based (STP preferred)
309/// :59A:/GB82WEST12345698765432
310/// MIDLGB22XXX
311///
312/// // Option F: Party identifier with details
313/// :59F:/GB82WEST12345698765432
314/// 1/ACME CORPORATION LIMITED
315/// 2/123 BUSINESS STREET
316/// 3/LONDON EC1A 1BB
317/// 4/UNITED KINGDOM
318///
319/// // No option: Flexible format
320/// :59:/GB82WEST12345698765432
321/// JOHN SMITH
322/// 456 RESIDENTIAL AVENUE
323/// MANCHESTER M1 1AA
324/// UNITED KINGDOM
325/// ```
326///
327/// ## Related Fields
328/// - **Field 57a**: Account With Institution (beneficiary's bank)
329/// - **Field 70**: Remittance Information (payment purpose/reference)
330/// - **Field 77T**: Structured Remittance Information (REMIT messages)
331/// - **Field 72**: Sender to Receiver Information (additional beneficiary details)
332///
333/// ## Error Prevention Guidelines
334/// - **Complete Information**: Provide full name, address, and account details
335/// - **Accurate BICs**: Verify BIC codes before transmission
336/// - **Consistent Formatting**: Follow domestic account number standards
337/// - **Sanctions Compliance**: Screen against current sanctions lists
338///
339/// ## See Also
340/// - Swift FIN User Handbook: Beneficiary Customer Specifications
341/// - FATF Guidelines: Customer Due Diligence Requirements
342/// - Regional Payment Guides: Country-specific beneficiary requirements
343/// - AML/CFT Compliance: Beneficiary Screening Best Practices
344#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SwiftField)]
345pub enum Field59 {
346 /// Option A: BIC-based identification with optional account
347 /// Preferred for STP processing with structured bank identification
348 A(Field59A),
349
350 /// Option F: Party identifier with detailed name and address
351 /// Used when enhanced beneficiary identification is required
352 F(Field59F),
353
354 /// No option: Account and name/address in flexible format
355 /// Most common option providing balance of structure and flexibility
356 NoOption(Field59NoOption),
357}
358
359#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, SwiftField)]
360pub enum Field59Debtor {
361 A(Field59A),
362 NoOption(Field59NoOption),
363}