swift_mt_message/fields/field70.rs
1use crate::SwiftField;
2use serde::{Deserialize, Serialize};
3
4/// # Field 70: Remittance Information
5///
6/// ## Overview
7/// Field 70 contains remittance information in SWIFT payment messages, providing details about
8/// the purpose and context of the payment. This field allows the ordering customer to include
9/// relevant information that helps the beneficiary identify and process the payment, such as
10/// invoice numbers, contract references, or payment descriptions. The remittance information
11/// is crucial for payment reconciliation and business process automation.
12///
13/// ## Format Specification
14/// **Format**: `4*35x`
15/// - **4*35x**: Up to 4 lines of 35 characters each
16/// - **Line structure**: Free-form text for remittance details
17/// - **Character set**: SWIFT character set (A-Z, 0-9, and limited special characters)
18/// - **Line separation**: Each line on separate row
19///
20/// ## Structure
21/// ```text
22/// PAYMENT FOR INVOICE INV-2024-001234
23/// CONTRACT REF: SUPPLY-AGREEMENT-2024
24/// DELIVERY DATE: 15-MAR-2024
25/// NET 30 DAYS PAYMENT TERMS
26/// │ │
27/// └──────────────────────────────┘
28/// Up to 35 characters per line
29/// Maximum 4 lines
30/// ```
31///
32/// ## Field Components
33/// - **Invoice References**: Invoice numbers and billing details
34/// - **Contract Information**: Contract numbers and references
35/// - **Payment Purpose**: Description of goods or services
36/// - **Additional Details**: Delivery dates, terms, or special instructions
37///
38/// ## Usage Context
39/// Field 70 is used in:
40/// - **MT103**: Single Customer Credit Transfer
41/// - **MT200**: Financial Institution Transfer
42/// - **MT202**: General Financial Institution Transfer
43/// - **MT202COV**: Cover for customer credit transfer
44/// - **MT205**: Financial Institution Transfer for its own account
45///
46/// ### Business Applications
47/// - **Payment reconciliation**: Matching payments to invoices
48/// - **Accounts receivable**: Automated payment processing
49/// - **Compliance reporting**: Supporting audit trails
50/// - **Business process automation**: Enabling straight-through processing
51/// - **Customer communication**: Providing payment context
52/// - **Dispute resolution**: Supporting payment inquiries
53///
54/// ## Examples
55/// ```text
56/// :70:PAYMENT FOR INVOICE 12345
57/// └─── Simple invoice payment reference
58///
59/// :70:INVOICE INV-2024-001234
60/// CONTRACT SUPPLY-AGREEMENT-2024
61/// DELIVERY 15-MAR-2024
62/// NET 30 PAYMENT TERMS
63/// └─── Detailed commercial payment information
64///
65/// :70:SALARY PAYMENT MARCH 2024
66/// EMPLOYEE ID: EMP-789012
67/// PAYROLL REF: PR-2024-03
68/// └─── Payroll payment details
69///
70/// :70:TRADE FINANCE SETTLEMENT
71/// LC NUMBER: LC-2024-567890
72/// DOCUMENTS COMPLIANT
73/// PAYMENT AS PER LC TERMS
74/// └─── Trade finance payment reference
75/// ```
76///
77/// ## Remittance Information Types
78/// - **Commercial payments**: Invoice and purchase order references
79/// - **Trade finance**: Letter of credit and documentary collection details
80/// - **Payroll**: Salary and benefit payment information
81/// - **Tax payments**: Tax reference numbers and periods
82/// - **Loan payments**: Loan account and installment details
83/// - **Utility payments**: Account numbers and billing periods
84/// - **Insurance**: Policy numbers and coverage details
85///
86/// ## Validation Rules
87/// 1. **Line count**: Maximum 4 lines
88/// 2. **Line length**: Maximum 35 characters per line
89/// 3. **Character set**: SWIFT character set only
90/// 4. **Content**: Should contain meaningful remittance information
91/// 5. **Empty lines**: Generally avoided for clarity
92/// 6. **Control characters**: Not allowed
93/// 7. **Special characters**: Limited to SWIFT-approved set
94///
95/// ## Network Validated Rules (SWIFT Standards)
96/// - Maximum 4 lines allowed (Error: T26)
97/// - Each line maximum 35 characters (Error: T50)
98/// - Must use SWIFT character set only (Error: T61)
99/// - Content should be meaningful (Error: T40)
100/// - No control characters permitted (Error: T35)
101/// - Field is optional but recommended (Warning: W70)
102///
103
104#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
105#[format("4*35x")]
106pub struct Field70 {
107 /// Remittance information lines (up to 4 lines of 35 characters each)
108 #[format("4*35x")]
109 pub information: Vec<String>,
110}
111
112impl Field70 {
113 pub fn new(information: Vec<String>) -> Self {
114 Self { information }
115 }
116}
117
118#[cfg(test)]
119mod tests {
120 use super::*;
121
122 #[test]
123 fn test_field70_creation() {
124 let info = vec!["PAYMENT FOR INVOICE 12345".to_string()];
125 let field70 = Field70::new(info.clone());
126 assert_eq!(field70.information, info);
127 }
128}