swift_mt_message/fields/
field64.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use swift_mt_message_macros::SwiftField;
4
5///   **Field 64: Closing Available Balance**
6///
7/// ## Purpose
8/// Specifies the closing available balance of an account, representing the funds that are
9/// immediately available for use by the account holder. This field distinguishes between
10/// the book balance (Field 62) and the available balance, accounting for holds, pending
11/// transactions, and other restrictions that may limit fund availability.
12///
13/// ## Business Context Applications
14/// - **Cash Management**: Available funds for immediate use
15/// - **Liquidity Assessment**: Actual usable funds for operations
16/// - **Credit Decisions**: Available balance for credit facilities
17/// - **Risk Management**: Available funds for risk assessment
18///
19/// ## Network Validation Requirements
20/// - **Date Validation**: Value date must be valid calendar date
21/// - **Currency Validation**: Must be valid ISO 4217 currency code
22/// - **Amount Format**: Decimal amount with proper precision
23/// - **Mark Validation**: Debit/Credit mark must be D (Debit) or C (Credit)
24/// - **Balance Logic**: Available balance should not exceed book balance for most scenarios
25///
26/// ## Available Balance Calculation
27/// ### Balance Components
28/// ```logic
29/// Available Balance = Book Balance - Holds - Pending Debits + Pending Credits - Reserves
30/// ```
31///
32/// ### Availability Factors
33/// - **Holds**: Funds held for pending transactions or legal requirements
34/// - **Float**: Funds not yet cleared or collected
35/// - **Reserves**: Required reserves or minimum balance requirements
36/// - **Credit Facilities**: Available credit lines that increase available balance
37///
38/// ## Regional Considerations
39/// - **European Banking**: European fund availability regulations
40/// - **US Banking**: Regulation CC and fund availability requirements
41/// - **Asian Markets**: Local fund availability and hold practices
42/// - **Cross-Border**: International fund availability considerations
43///
44/// ## Error Prevention Guidelines
45/// - **Balance Logic**: Verify available balance is consistent with book balance
46/// - **Date Alignment**: Ensure value date aligns with statement period
47/// - **Currency Consistency**: Verify currency matches account currency
48/// - **Amount Validation**: Confirm precision meets currency standards
49///
50/// ## Related Fields Integration
51/// - **Field 62**: Closing Balance (book balance comparison)
52/// - **Field 65**: Forward Available Balance (future availability)
53/// - **Field 60**: Opening Balance (period context)
54/// - **Field 61**: Statement Line (transactions affecting availability)
55///
56/// ## Compliance Framework
57/// - **Regulatory Requirements**: Fund availability disclosure requirements
58/// - **Consumer Protection**: Clear communication of available funds
59/// - **Risk Management**: Available balance for credit and operational risk
60/// - **Audit Documentation**: Proper available balance calculation documentation
61///
62/// ## See Also
63/// - Swift FIN User Handbook: Available Balance Specifications
64/// - Banking Regulations: Fund Availability Requirements
65/// - Cash Management Standards: Available Balance Calculation
66/// - Risk Management: Available Fund Assessment
67///
68///   **Field 64: Closing Available Balance Structure**
69///
70/// Contains the closing available balance with debit/credit indication, value date,
71/// currency, and amount representing immediately usable funds.
72#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
73pub struct Field64 {
74    /// Debit or Credit mark
75    ///
76    /// Format: 1!a - 'D' (Debit) or 'C' (Credit)
77    /// Indicates whether the available balance is a debit or credit position
78    #[component("1!a")]
79    pub debit_credit_mark: String,
80
81    /// Value date of the available balance
82    ///
83    /// Format: 6!n (YYMMDD) - Date when balance is effective
84    /// Typically aligns with statement period end date
85    #[component("6!n")]
86    pub value_date: NaiveDate,
87
88    /// Currency of the available balance
89    ///
90    /// Format: 3!a - ISO 4217 currency code (USD, EUR, GBP, etc.)
91    /// Must match account currency for consistency
92    #[component("3!a")]
93    pub currency: String,
94
95    /// Available balance amount
96    ///
97    /// Format: 15d - Decimal amount with comma separator
98    /// Represents funds immediately available for use
99    #[component("15d")]
100    pub amount: f64,
101}