Skip to main content

uls_core/records/
transfer.rs

1//! TA (Transfer/Assignment) record type.
2use super::common::*;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct TransferRecord {
7    pub unique_system_identifier: i64,
8    pub uls_file_number: Option<String>,
9    pub ebf_number: Option<String>,
10    pub pro_forma: Option<char>,
11    pub full_assignment: Option<char>,
12    pub voluntary_involuntary: Option<char>,
13    pub consent_date: Option<String>,
14    pub consummation_date: Option<String>,
15    pub consummation_deadline: Option<String>,
16}
17
18impl TransferRecord {
19    pub fn from_fields(fields: &[&str]) -> Self {
20        Self {
21            unique_system_identifier: parse_i64_or_default(fields.get(1).unwrap_or(&"")),
22            uls_file_number: parse_opt_string(fields.get(2).unwrap_or(&"")),
23            ebf_number: parse_opt_string(fields.get(3).unwrap_or(&"")),
24            pro_forma: parse_opt_char(fields.get(4).unwrap_or(&"")),
25            full_assignment: parse_opt_char(fields.get(5).unwrap_or(&"")),
26            voluntary_involuntary: parse_opt_char(fields.get(8).unwrap_or(&"")),
27            consent_date: parse_opt_string(fields.get(30).unwrap_or(&"")),
28            consummation_date: parse_opt_string(fields.get(31).unwrap_or(&"")),
29            consummation_deadline: parse_opt_string(fields.get(32).unwrap_or(&"")),
30        }
31    }
32}
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37
38    #[test]
39    fn test_transfer_from_fields() {
40        let fields = vec!["TA", "12345", "ULS123", "EBF456", "Y", "Y", "", "", "V"];
41        let ta = TransferRecord::from_fields(&fields);
42
43        assert_eq!(ta.unique_system_identifier, 12345);
44        assert_eq!(ta.pro_forma, Some('Y'));
45        assert_eq!(ta.full_assignment, Some('Y'));
46        assert_eq!(ta.voluntary_involuntary, Some('V'));
47    }
48}