use std::str::FromStr; use chrono::{FixedOffset, NaiveDate, NaiveTime}; use indexmap::IndexSet; use rust_decimal::Decimal; use swift_iso15022::field::{ Field13C, Field23B, Field32A, Field33B, Field50AOptK, Field52AOptA, Field57AOptA, Field59Opt, Field71A, TimeIndicationCode, }; use swift_iso15022::mt::{MessageTrait, Mt103}; fn main() -> Result<(), Box> { let input = "\ :20:TEST-IBAN001\r\n\ :13C:/SNDTIME/0701+0200\r\n\ :23B:CRED\r\n\ :32A:060804EUR18001,01\r\n\ :33B:EUR18001,01\r\n\ :50K:/KUNDE WO FOO FOO\r\n\ SYMMACH. FOO OREOKASTRO-DIAVATA\r\n\ GR-57008 FOO\r\n\ GREECE\r\n\ :52A://TAGRPRNKGRAAXXX052/S/20115\r\n\ PRNKGRAAXXX\r\n\ :57A:GENODE51LOS\r\n\ :59:/DE66593922000000045500\r\n\ FOO DER VOLKS-RAIFFEISENBANK\r\n\ RAIFFEISENPLATZ\r\n\ D-66787 WADGASSEN-HOSTENBACH\r\n\ GERMANY\r\n\ :70:TEST IBAN 01P DE\r\n\ IBAN FOO\r\n\ :71A:SHA"; let input_parsed = Mt103::builder() .sender_reference("TEST-IBAN001") .time_indication(Field13C { time: NaiveTime::from_hms_opt(07, 01, 0).unwrap(), offset: FixedOffset::east_opt(2 * 3600).unwrap(), time_indication: TimeIndicationCode::SNDTIME, }) .bank_operation_code(Field23B::CRED) .date_currency_amount(Field32A { date: NaiveDate::from_str("06-08-04").unwrap(), iso_currency_code: "EUR".to_string(), amount: Decimal::new(1800101, 2), }) .currency_instructed_amount(Field33B { iso_currency_code: "EUR".to_string(), amount: Decimal::new(1800101, 2), }) .ordering_customer(Field50AOptK { account: None, name_and_address: IndexSet::from([ "/KUNDE WO FOO FOO".to_string(), "SYMMACH. FOO OREOKASTRO-DIAVATA".to_string(), "GR-57008 FOO".to_string(), "GREECE".to_string(), ]), }) .ordering_institution(Field52AOptA { party_identifier: "//TAGRPRNKGRAAXXX052/S/20115".to_string(), identifier_code: "PRNKGRAAXXX".to_string(), }) .account_with_institution(Field57AOptA { party_identifier: None, identifier_code: "GENODE51LOS".to_string(), }) .beneficiary_customer(Field59Opt { account: "DE66593922000000045500".to_string(), name_and_address: IndexSet::from([ "FOO DER VOLKS-RAIFFEISENBANK".to_string(), "RAIFFEISENPLATZ".to_string(), "D-66787 WADGASSEN-HOSTENBACH".to_string(), "GERMANY".to_string(), ]), }) .remittance_information(["TEST IBAN 01P DE".to_string(), "IBAN FOO".to_string()]) .details_of_charges(Field71A::SHA) .build()?; assert_eq!(input_parsed.to_swift_string(), input); Ok(()) }