1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! HKCCS, SEPA-Einzelüberweisung (SEPA credit transfer). Messages 2022,
//! C.10.2.1.
use super::common::Kti1;
use crate::codec::{An, Bin, Segment};
/// HKCCS version 1, customer order. Messages 2022, C.10.2.1.
///
/// ```text
/// Nr. Name Typ Format Länge Status Anzahl
/// 1 Segmentkopf DEG M 1
/// 2 Kontoverbindung international DEG kti # M 1
/// 3 SEPA Descriptor DE an ..256 M 1
/// 4 SEPA pain message DE bin .. M 1
/// ```
///
/// The account is the debtor account; IBAN and BIC must match the pain
/// message. The descriptor names the pain.001 schema (a URN allowed by
/// HISPAS or the BPD of the order).
#[derive(Debug, Clone, PartialEq, Eq, Segment)]
#[segment(code = "HKCCS", version = 1)]
pub struct HkCcs1 {
/// 2 Kontoverbindung international.
pub account: Kti1,
/// 3 SEPA Descriptor.
#[de(max = 256)]
pub descriptor: An,
/// 4 SEPA pain message.
pub message: Bin,
}
#[cfg(test)]
pub(crate) const SAMPLES: &[&str] = &[
"HKCCS:3:1+DE00120300009900012345:BYLADEM1001+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.09+@11@<Document/>'",
];
#[cfg(test)]
mod tests {
use super::*;
use crate::codec::defs::testing::round_trip;
use crate::codec::from_wire;
#[test]
fn wire_round_trips() {
let v: HkCcs1 = round_trip(SAMPLES[0]);
assert_eq!(
v.account.iban.as_ref().map(An::as_str),
Some("DE00120300009900012345")
);
assert_eq!(
v.descriptor.as_str(),
"urn:iso:std:iso:20022:tech:xsd:pain.001.001.09"
);
assert_eq!(v.message.0, b"<Document/>");
}
#[test]
fn a_missing_message_is_an_error() {
let e =
from_wire::<HkCcs1>(b"HKCCS:3:1+DE00120300009900012345:BYLADEM1001+pain'").unwrap_err();
assert_eq!(e.field, "message");
}
}