swift_mt_message/fields/field61.rs
1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::SwiftField;
4
5/// **Field 61: Statement Line**
6///
7/// ## Purpose
8/// Represents individual transaction entries in customer statement messages (MT 940),
9/// providing detailed information about each debit or credit transaction affecting
10/// the account balance. This field is fundamental to statement processing, enabling
11/// detailed transaction tracking, reconciliation, and audit trail maintenance.
12///
13/// ## Format Specification
14/// - **Swift Format**: `6!n[4!n]2a[1!a]15d1!a3!c[16x][//16x][34x]`
15/// - **Complex Structure**: Multiple components with optional elements
16/// - **Variable Length**: Components can be present or absent based on transaction type
17/// - **Structured Data**: Each component serves specific business purpose
18///
19/// ## Business Context Applications
20/// - **Customer Statements**: Core component of MT 940 Customer Statement Message
21/// - **Transaction Detail**: Complete transaction information for account holders
22/// - **Reconciliation**: Detailed transaction data for account reconciliation
23/// - **Audit Trail**: Complete transaction history for compliance and audit
24///
25/// ## Component Structure
26/// ### Mandatory Components
27/// - **Value Date**: Date when transaction affects account balance
28/// - **Debit/Credit Mark**: Transaction direction (debit/credit)
29/// - **Amount**: Transaction amount in account currency
30/// - **Transaction Type**: Classification of transaction type
31///
32/// ### Optional Components
33/// - **Entry Date**: Date transaction was posted (if different from value date)
34/// - **Funds Code**: Availability of funds (immediate/float)
35/// - **Customer Reference**: Transaction reference for customer
36/// - **Bank Reference**: Bank's internal transaction reference
37/// - **Supplementary Details**: Additional transaction information
38///
39/// ## Network Validation Requirements
40/// - **Date Validation**: Value date must be valid calendar date
41/// - **Amount Format**: Decimal amount with proper precision
42/// - **Reference Format**: References must follow specified format rules
43/// - **Transaction Code**: Must be valid transaction type code
44/// - **Character Set**: All components must use valid character sets
45///
46/// ## Transaction Processing
47/// ### Balance Impact
48/// - **Debit Transactions**: Reduce account balance (payments, charges, withdrawals)
49/// - **Credit Transactions**: Increase account balance (deposits, transfers, interest)
50/// - **Reversal Transactions**: Correct previous transaction errors
51/// - **Adjustment Transactions**: Administrative balance adjustments
52///
53/// ### Transaction Types
54/// - **Customer Transfers**: Payments and receipts
55/// - **Bank Services**: Fees, charges, and service transactions
56/// - **Interest**: Interest credits and debits
57/// - **Foreign Exchange**: Currency conversion transactions
58///
59/// ## Regional Considerations
60/// - **European Banking**: SEPA transaction processing and reporting
61/// - **US Banking**: ACH, wire transfer, and check processing
62/// - **Asian Markets**: Local payment system integration
63/// - **Cross-Border**: International transaction processing
64///
65/// ## Error Prevention Guidelines
66/// - **Date Consistency**: Verify dates are logical and within statement period
67/// - **Amount Verification**: Confirm amount format and precision
68/// - **Reference Validation**: Ensure references follow format requirements
69/// - **Balance Verification**: Confirm transactions sum to balance changes
70///
71/// ## Related Fields Integration
72/// - **Field 60**: Opening Balance (starting position)
73/// - **Field 62**: Closing Balance (ending position after transactions)
74/// - **Field 64**: Closing Available Balance (availability impact)
75/// - **Field 86**: Information to Account Owner (additional details)
76///
77/// ## Compliance Framework
78/// - **Banking Regulations**: Transaction reporting requirements
79/// - **Audit Standards**: Complete transaction documentation
80/// - **Customer Rights**: Detailed transaction information provision
81/// - **Data Retention**: Transaction history retention requirements
82///
83/// ## See Also
84/// - Swift FIN User Handbook: Statement Line Specifications
85/// - MT 940 Message Standards: Customer Statement Processing
86/// - Transaction Processing: Banking Transaction Standards
87/// - Account Statement Requirements: Regional Banking Regulations
88#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
89pub struct Field61 {
90 /// Value date (6!n format, YYMMDD)
91 #[component("6!n")]
92 pub value_date: NaiveDate,
93
94 /// Optional entry date (4!n format, MMDD)
95 #[component("[4!n]")]
96 pub entry_date: Option<String>,
97
98 /// Debit/Credit mark (2a format: D, C, RD, RC)
99 #[component("2a")]
100 pub debit_credit_mark: String,
101
102 /// Optional funds code (1!a format)
103 #[component("[1!a]")]
104 pub funds_code: Option<char>,
105
106 /// Amount (15d format)
107 #[component("15d")]
108 pub amount: f64,
109
110 /// Transaction type identification code (4!a format)
111 #[component("1!a3!c")]
112 pub transaction_type: String,
113
114 /// Customer reference (2!a format)
115 #[component("16x")]
116 pub customer_reference: String,
117
118 /// Bank reference (16x format, preceded by //)
119 #[component("[//16x]")]
120 pub bank_reference: Option<String>,
121
122 /// Optional supplementary details (34x format)
123 #[component("[34x]")]
124 pub supplementary_details: Option<String>,
125}