use crate::parser::XmlReader;
use crate::XmlError;
use crate::XmlResult;
use beef::lean::Cow;
use core::str::FromStr as _;
use quick_xml::events::BytesStart;
use rust_decimal::Decimal;
use time::Date;
use time::OffsetDateTime;
mod external_bank_transaction_codes;
mod external_code_sets;
mod manual;
pub use self::external_bank_transaction_codes::*;
pub use self::manual::*;
#[derive(Clone, Debug)]
pub enum Iso20022Message<'a> {
#[doc = "Scope\r\nThe BankToCustomerAccountReport message is sent by the account servicer to an account owner or to a party authorised by the account owner to receive the message. It can be used to inform the account owner, or authorised party, of the entries reported to the account, and/or to provide the owner with balance information on the account at a given point in time.\r\nUsage\r\nThe BankToCustomerAccountReport message can contain reports for more than one account. It provides information for cash management and/or reconciliation. It can be used to:\r\n- report pending and booked items;\r\n- provide balance information.\r\nIt can include underlying details of transactions that have been included in the entry.\r\nIt is possible that the receiver of the message is not the account owner, but a party entitled by the account owner to receive the account information (also known as recipient).\r\nFor a statement, the Bank-to-Customer Account Statement message should be used."]
BankToCustomerAccountReportV02(BankToCustomerAccountReportV02<'a>),
#[doc = "Scope\r\nThe BankToCustomerAccountReport message is sent by the account servicer to an account owner or to a party authorised by the account owner to receive the message. It can be used to inform the account owner, or authorised party, of the entries reported to the account, and/or to provide the owner with balance information on the account at a given point in time.\r\nUsage\r\nThe BankToCustomerAccountReport message can contain reports for more than one account. It provides information for cash management and/or reconciliation. It can be used to:\r\n- report pending and booked items;\r\n- provide balance information.\r\nIt can include underlying details of transactions that have been included in the entry.\r\nIt is possible that the receiver of the message is not the account owner, but a party entitled by the account owner to receive the account information (also known as recipient).\r\nFor a statement, the Bank-to-Customer Account Statement message should be used."]
BankToCustomerAccountReportV08(BankToCustomerAccountReportV08<'a>),
}
impl<'a> TryFrom<&'a str> for Iso20022Message<'a> {
type Error = XmlError;
fn try_from(document: &'a str) -> XmlResult<Self> {
let mut reader = XmlReader::from_str(document);
reader.try_declaration()?;
let root_start = reader.expect_start_tag()?;
let root_tag = core::str::from_utf8(root_start.name().into_inner())?;
let namespace = root_start
.try_get_attribute("xmlns")?
.ok_or_else(|| -> XmlError { todo!() })?
.unescape_value()?;
let value = match (root_tag, &*namespace) {
("Document", "urn:iso:std:iso:20022:tech:xsd:camt.052.001.02") => {
let inner = reader.parse_element(
"BkToCstmrAcctRpt",
<BankToCustomerAccountReportV02<'a>>::parse,
)?;
Self::BankToCustomerAccountReportV02(inner)
}
("Document", "urn:iso:std:iso:20022:tech:xsd:camt.052.001.08") => {
let inner = reader.parse_element(
"BkToCstmrAcctRpt",
<BankToCustomerAccountReportV08<'a>>::parse,
)?;
Self::BankToCustomerAccountReportV08(inner)
}
_ => todo!(),
};
reader.expect_element_end(root_start)?;
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Scope\r\nThe BankToCustomerAccountReport message is sent by the account servicer to an account owner or to a party authorised by the account owner to receive the message. It can be used to inform the account owner, or authorised party, of the entries reported to the account, and/or to provide the owner with balance information on the account at a given point in time.\r\nUsage\r\nThe BankToCustomerAccountReport message can contain reports for more than one account. It provides information for cash management and/or reconciliation. It can be used to:\r\n- report pending and booked items;\r\n- provide balance information.\r\nIt can include underlying details of transactions that have been included in the entry.\r\nIt is possible that the receiver of the message is not the account owner, but a party entitled by the account owner to receive the account information (also known as recipient).\r\nFor a statement, the Bank-to-Customer Account Statement message should be used."]
pub struct BankToCustomerAccountReportV08<'a> {
#[doc = "Common information for the message."]
pub group_header: GroupHeader81<'a>,
#[doc = "Reports on a cash account."]
pub report: Vec<AccountReport25<'a>>,
#[doc = "Additional information that cannot be captured in the structured elements and/or any other specific block."]
pub supplementary_data: Vec<SupplementaryData1<'a>>,
}
impl<'a> BankToCustomerAccountReportV08<'a> {
pub fn from_str(document: &'a str) -> XmlResult<Self> {
let mut reader = XmlReader::from_str(document);
reader.try_declaration()?;
reader.parse_element("Document", |reader, _| {
reader.parse_element("BkToCstmrAcctRpt", Self::parse)
})
}
}
impl<'a> BankToCustomerAccountReportV08<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let group_header = reader.parse_element("GrpHdr", <GroupHeader81<'a>>::parse)?;
let report = reader.parse_list("Rpt", <AccountReport25<'a>>::parse)?;
let supplementary_data =
reader.parse_list("SplmtryData", <SupplementaryData1<'a>>::parse)?;
Ok(Self {
group_header,
report,
supplementary_data,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details of the account report."]
pub struct AccountReport25<'a> {
#[doc = "Unique identification, as assigned by the account servicer, to unambiguously identify the account report."]
pub identification: Max35Text<'a>,
#[doc = "Provides details on the page number of the report.\r\n\r\nUsage: The pagination of the report is only allowed when agreed between the parties."]
pub report_pagination: Option<Pagination1<'a>>,
#[doc = "Sequential number of the report, as assigned by the account servicer. \nUsage: The sequential number is increased incrementally for each report sent electronically."]
pub electronic_sequence_number: Option<Number>,
#[doc = "Specifies the range of identification sequence numbers, as provided in the request."]
pub reporting_sequence: Option<SequenceRange1Choice<'a>>,
#[doc = "Legal sequential number of the report, as assigned by the account servicer. It is increased incrementally for each report sent."]
pub legal_sequence_number: Option<Number>,
#[doc = "Date and time at which the report was created."]
pub creation_date_time: Option<IsoDateTime>,
#[doc = "Range of time between a start date and an end date for which the account report is issued."]
pub from_to_date: Option<DateTimePeriod1>,
#[doc = "Indicates whether the document is a copy, a duplicate, or a duplicate of a copy."]
pub copy_duplicate_indicator: Option<CopyDuplicate1Code>,
#[doc = "Specifies the application used to generate the reporting."]
pub reporting_source: Option<ReportingSource1Choice<'a>>,
#[doc = "Unambiguous identification of the account to which credit and debit entries are made."]
pub account: CashAccount39<'a>,
#[doc = "Identifies the parent account of the account for which the report has been issued."]
pub related_account: Option<CashAccount38<'a>>,
#[doc = "Provides general interest information that applies to the account at a particular moment in time."]
pub interest: Vec<AccountInterest4<'a>>,
#[doc = "Set of elements used to define the balance as a numerical representation of the net increases and decreases in an account at a specific point in time."]
pub balance: Vec<CashBalance8<'a>>,
#[doc = "Provides summary information on entries."]
pub transactions_summary: Option<TotalTransactions6<'a>>,
#[doc = "Specifies an entry in the report.\r\nUsage: At least one reference must be provided to identify the entry and its underlying transaction(s).\r\n\r\nUsage Rule: In case of a Payments R-transaction the creditor / debtor referenced of the original payment initiation messages is also used for reporting of the R-transaction. The original debtor/creditor in the reporting of R-Transactions is not inverted. \r\nFollowing elements all defined in the TransactionDetails in RelatedParties or RelatedAgents are impacted by this usage rule:\r\nCreditor, UltimateCreditor, CreditorAccount, CreditorAgent, Debtor, UltimateDebtor, DebtorAccount and DebtorAgent.\r\n"]
pub entry: Vec<ReportEntry10<'a>>,
#[doc = "Further details of the account report."]
pub additional_report_information: Option<Max500Text<'a>>,
}
impl<'a> AccountReport25<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let report_pagination =
reader.parse_optional_element("RptPgntn", <Pagination1<'a>>::parse)?;
let electronic_sequence_number =
reader.parse_optional_element("ElctrncSeqNb", <Number>::parse)?;
let reporting_sequence =
reader.parse_optional_element("RptgSeq", <SequenceRange1Choice<'a>>::parse)?;
let legal_sequence_number = reader.parse_optional_element("LglSeqNb", <Number>::parse)?;
let creation_date_time = reader.parse_optional_element("CreDtTm", <IsoDateTime>::parse)?;
let from_to_date = reader.parse_optional_element("FrToDt", <DateTimePeriod1>::parse)?;
let copy_duplicate_indicator =
reader.parse_optional_element("CpyDplctInd", <CopyDuplicate1Code>::parse)?;
let reporting_source =
reader.parse_optional_element("RptgSrc", <ReportingSource1Choice<'a>>::parse)?;
let account = reader.parse_element("Acct", <CashAccount39<'a>>::parse)?;
let related_account =
reader.parse_optional_element("RltdAcct", <CashAccount38<'a>>::parse)?;
let interest = reader.parse_list("Intrst", <AccountInterest4<'a>>::parse)?;
let balance = reader.parse_list("Bal", <CashBalance8<'a>>::parse)?;
let transactions_summary =
reader.parse_optional_element("TxsSummry", <TotalTransactions6<'a>>::parse)?;
let entry = reader.parse_list("Ntry", <ReportEntry10<'a>>::parse)?;
let additional_report_information =
reader.parse_optional_element("AddtlRptInf", <Max500Text<'a>>::parse)?;
Ok(Self {
identification,
report_pagination,
electronic_sequence_number,
reporting_sequence,
legal_sequence_number,
creation_date_time,
from_to_date,
copy_duplicate_indicator,
reporting_source,
account,
related_account,
interest,
balance,
transactions_summary,
entry,
additional_report_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details on an entry in the report."]
pub struct ReportEntry10<'a> {
#[doc = "Unique reference for the entry."]
pub entry_reference: Option<Max35Text<'a>>,
#[doc = "Amount of money in the cash entry."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the entry is a credit or a debit entry."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Indicates whether or not the entry is the result of a reversal.\nUsage: This element should only be present if the entry is the result of a reversal.\nIf the CreditDebitIndicator is CRDT and ReversalIndicator is Yes, the original operation was a debit entry.\nIf the CreditDebitIndicator is DBIT and ReversalIndicator is Yes, the original operation was a credit entry."]
pub reversal_indicator: Option<TrueFalseIndicator>,
#[doc = "Status of an entry on the books of the account servicer."]
pub status: EntryStatus1Choice<'a>,
#[doc = "Date and time when an entry is posted to an account on the account servicer's books.\n\nUsage: Booking date is the expected booking date, unless the status is booked, in which case it is the actual booking date."]
pub booking_date: Option<DateAndDateTime2Choice>,
#[doc = "Date and time at which assets become available to the account owner in case of a credit entry, or cease to be available to the account owner in case of a debit entry.\nUsage: If entry status is pending and value date is present, then the value date refers to an expected/requested value date.\nFor entries subject to availability/float and for which availability information is provided, the value date must not be used. In this case the availability component identifies the number of availability days."]
pub value_date: Option<DateAndDateTime2Choice>,
#[doc = "Unique reference as assigned by the account servicing institution to unambiguously identify the entry."]
pub account_servicer_reference: Option<Max35Text<'a>>,
#[doc = "Indicates when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashAvailability1<'a>>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: BankTransactionCodeStructure4<'a>,
#[doc = "Indicates whether the transaction is exempt from commission."]
pub commission_waiver_indicator: Option<YesNoIndicator>,
#[doc = "Indicates whether the underlying transaction details are provided through a separate message, as in the case of aggregate bookings."]
pub additional_information_indicator: Option<MessageIdentification2<'a>>,
#[doc = "Provides information on the original amount.\n\nUsage: This component (on entry level) should be used when a total original batch or aggregate amount has to be provided. If required, the individual original amounts can be included in the same component on transaction details level."]
pub amount_details: Option<AmountAndCurrencyExchange3<'a>>,
#[doc = "Provides information on the charges, pre-advised or included in the entry amount.\r\n\r\nUsage: This component is used on entry level in case of batch or aggregate bookings.\r\n"]
pub charges: Option<Charges6<'a>>,
#[doc = "Channel used to technically input the instruction related to the entry."]
pub technical_input_channel: Option<TechnicalInputChannel1Choice<'a>>,
#[doc = "Provides details of the interest amount included in the entry amount.\n\nUsage: This component is used on entry level in the case of batch or aggregate bookings."]
pub interest: Option<TransactionInterest4<'a>>,
#[doc = "Provides details of the card transaction included in the entry amount, when globalised by the account servicer."]
pub card_transaction: Option<CardEntry4<'a>>,
#[doc = "Provides details on the entry."]
pub entry_details: Vec<EntryDetails9<'a>>,
#[doc = "Further details of the entry."]
pub additional_entry_information: Option<Max500Text<'a>>,
}
impl<'a> ReportEntry10<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let entry_reference = reader.parse_optional_element("NtryRef", <Max35Text<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let reversal_indicator =
reader.parse_optional_element("RvslInd", <TrueFalseIndicator>::parse)?;
let status = reader.parse_element("Sts", <EntryStatus1Choice<'a>>::parse)?;
let booking_date =
reader.parse_optional_element("BookgDt", <DateAndDateTime2Choice>::parse)?;
let value_date = reader.parse_optional_element("ValDt", <DateAndDateTime2Choice>::parse)?;
let account_servicer_reference =
reader.parse_optional_element("AcctSvcrRef", <Max35Text<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashAvailability1<'a>>::parse)?;
let bank_transaction_code =
reader.parse_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let commission_waiver_indicator =
reader.parse_optional_element("ComssnWvrInd", <YesNoIndicator>::parse)?;
let additional_information_indicator =
reader.parse_optional_element("AddtlInfInd", <MessageIdentification2<'a>>::parse)?;
let amount_details =
reader.parse_optional_element("AmtDtls", <AmountAndCurrencyExchange3<'a>>::parse)?;
let charges = reader.parse_optional_element("Chrgs", <Charges6<'a>>::parse)?;
let technical_input_channel = reader
.parse_optional_element("TechInptChanl", <TechnicalInputChannel1Choice<'a>>::parse)?;
let interest =
reader.parse_optional_element("Intrst", <TransactionInterest4<'a>>::parse)?;
let card_transaction = reader.parse_optional_element("CardTx", <CardEntry4<'a>>::parse)?;
let entry_details = reader.parse_list("NtryDtls", <EntryDetails9<'a>>::parse)?;
let additional_entry_information =
reader.parse_optional_element("AddtlNtryInf", <Max500Text<'a>>::parse)?;
Ok(Self {
entry_reference,
amount,
credit_debit_indicator,
reversal_indicator,
status,
booking_date,
value_date,
account_servicer_reference,
availability,
bank_transaction_code,
commission_waiver_indicator,
additional_information_indicator,
amount_details,
charges,
technical_input_channel,
interest,
card_transaction,
entry_details,
additional_entry_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Identifies the underlying transaction(s) and/or batched entries."]
pub struct EntryDetails9<'a> {
#[doc = "Provides details on batched transactions."]
pub batch: Option<BatchInformation2<'a>>,
#[doc = "Provides information on the underlying transaction(s)."]
pub transaction_details: Vec<EntryTransaction10<'a>>,
}
impl<'a> EntryDetails9<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let batch = reader.parse_optional_element("Btch", <BatchInformation2<'a>>::parse)?;
let transaction_details = reader.parse_list("TxDtls", <EntryTransaction10<'a>>::parse)?;
Ok(Self {
batch,
transaction_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Identifies the underlying transaction."]
pub struct EntryTransaction10<'a> {
#[doc = "Provides the identification of the underlying transaction."]
pub references: Option<TransactionReferences6<'a>>,
#[doc = "Amount of money in the cash transaction."]
pub amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Indicates whether the transaction is a credit or a debit transaction."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Provides detailed information on the original amount.\n\nUsage: This component (on transaction level) should be used in case booking is for a single transaction and the original amount is different from the entry amount. It can also be used in case individual original amounts are provided in case of a batch or aggregate booking."]
pub amount_details: Option<AmountAndCurrencyExchange3<'a>>,
#[doc = "Indicates when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashAvailability1<'a>>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: Option<BankTransactionCodeStructure4<'a>>,
#[doc = "Provides information on the charges, pre-advised or included in the entry amount.\r\n\r\nUsage: This component (on transaction level) can be used in case the booking is for a single transaction, and charges are included in the entry amount. It can also be used in case individual charge amounts are applied to individual transactions in case of a batch or aggregate amount booking."]
pub charges: Option<Charges6<'a>>,
#[doc = "Provides details of the interest amount included in the entry amount.\n\nUsage: This component (on transaction level) can be used if the booking is for a single transaction, and interest amount is included in the entry amount. It can also be used if individual interest amounts are applied to individual transactions in the case of a batch or aggregate amount booking."]
pub interest: Option<TransactionInterest4<'a>>,
#[doc = "Set of elements used to identify the parties related to the underlying transaction."]
pub related_parties: Option<TransactionParties6<'a>>,
#[doc = "Set of elements used to identify the agents related to the underlying transaction."]
pub related_agents: Option<TransactionAgents5<'a>>,
#[doc = "User community specific instrument.\nUsage: This element is used to specify a local instrument, local clearing option and/or further qualify the service or service level."]
pub local_instrument: Option<LocalInstrument2Choice<'a>>,
#[doc = "Underlying reason for the payment transaction.\nUsage: Purpose is used by the end-customers, that is initiating party, (ultimate) debtor, (ultimate) creditor to provide information concerning the nature of the payment. Purpose is a content element, which is not used for processing by any of the agents involved in the payment chain."]
pub purpose: Option<Purpose2Choice<'a>>,
#[doc = "Provides information related to the handling of the remittance information by any of the agents in the transaction processing chain."]
pub related_remittance_information: Vec<RemittanceLocation7<'a>>,
#[doc = "Structured information that enables the matching, that is reconciliation, of a payment with the items that the payment is intended to settle, such as commercial invoices in an account receivable system."]
pub remittance_information: Option<RemittanceInformation16<'a>>,
#[doc = "Set of elements used to identify the dates related to the underlying transactions."]
pub related_dates: Option<TransactionDates3<'a>>,
#[doc = "Set of elements used to identify the price information related to the underlying transaction."]
pub related_price: Option<TransactionPrice4Choice<'a>>,
#[doc = "Set of elements used to identify the related quantities, such as securities, in the underlying transaction."]
pub related_quantities: Vec<TransactionQuantities3Choice<'a>>,
#[doc = "Identification of a security, as assigned under a formal or proprietary identification scheme."]
pub financial_instrument_identification: Option<SecurityIdentification19<'a>>,
#[doc = "Provides details on the tax."]
pub tax: Option<TaxInformation8<'a>>,
#[doc = "Provides the return information."]
pub return_information: Option<PaymentReturnReason5<'a>>,
#[doc = "Set of elements used to identify the underlying corporate action."]
pub corporate_action: Option<CorporateAction9<'a>>,
#[doc = "Safekeeping or investment account. A safekeeping account is an account on which a securities entry is made. An investment account is an account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family."]
pub safekeeping_account: Option<SecuritiesAccount19<'a>>,
#[doc = "Provides the details of a cash deposit for an amount of money in cash notes and/or coins."]
pub cash_deposit: Vec<CashDeposit1<'a>>,
#[doc = "Provides the data related to the card (number, scheme), terminal (number, identification) and transactional data used to uniquely identify a card transaction."]
pub card_transaction: Option<CardTransaction17<'a>>,
#[doc = "Further details of the transaction."]
pub additional_transaction_information: Option<Max500Text<'a>>,
#[doc = "Additional information that cannot be captured in the structured elements and/or any other specific block."]
pub supplementary_data: Vec<SupplementaryData1<'a>>,
}
impl<'a> EntryTransaction10<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let references =
reader.parse_optional_element("Refs", <TransactionReferences6<'a>>::parse)?;
let amount =
reader.parse_optional_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let amount_details =
reader.parse_optional_element("AmtDtls", <AmountAndCurrencyExchange3<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashAvailability1<'a>>::parse)?;
let bank_transaction_code =
reader.parse_optional_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let charges = reader.parse_optional_element("Chrgs", <Charges6<'a>>::parse)?;
let interest =
reader.parse_optional_element("Intrst", <TransactionInterest4<'a>>::parse)?;
let related_parties =
reader.parse_optional_element("RltdPties", <TransactionParties6<'a>>::parse)?;
let related_agents =
reader.parse_optional_element("RltdAgts", <TransactionAgents5<'a>>::parse)?;
let local_instrument =
reader.parse_optional_element("LclInstrm", <LocalInstrument2Choice<'a>>::parse)?;
let purpose = reader.parse_optional_element("Purp", <Purpose2Choice<'a>>::parse)?;
let related_remittance_information =
reader.parse_list("RltdRmtInf", <RemittanceLocation7<'a>>::parse)?;
let remittance_information =
reader.parse_optional_element("RmtInf", <RemittanceInformation16<'a>>::parse)?;
let related_dates =
reader.parse_optional_element("RltdDts", <TransactionDates3<'a>>::parse)?;
let related_price =
reader.parse_optional_element("RltdPric", <TransactionPrice4Choice<'a>>::parse)?;
let related_quantities =
reader.parse_list("RltdQties", <TransactionQuantities3Choice<'a>>::parse)?;
let financial_instrument_identification =
reader.parse_optional_element("FinInstrmId", <SecurityIdentification19<'a>>::parse)?;
let tax = reader.parse_optional_element("Tax", <TaxInformation8<'a>>::parse)?;
let return_information =
reader.parse_optional_element("RtrInf", <PaymentReturnReason5<'a>>::parse)?;
let corporate_action =
reader.parse_optional_element("CorpActn", <CorporateAction9<'a>>::parse)?;
let safekeeping_account =
reader.parse_optional_element("SfkpgAcct", <SecuritiesAccount19<'a>>::parse)?;
let cash_deposit = reader.parse_list("CshDpst", <CashDeposit1<'a>>::parse)?;
let card_transaction =
reader.parse_optional_element("CardTx", <CardTransaction17<'a>>::parse)?;
let additional_transaction_information =
reader.parse_optional_element("AddtlTxInf", <Max500Text<'a>>::parse)?;
let supplementary_data =
reader.parse_list("SplmtryData", <SupplementaryData1<'a>>::parse)?;
Ok(Self {
references,
amount,
credit_debit_indicator,
amount_details,
availability,
bank_transaction_code,
charges,
interest,
related_parties,
related_agents,
local_instrument,
purpose,
related_remittance_information,
remittance_information,
related_dates,
related_price,
related_quantities,
financial_instrument_identification,
tax,
return_information,
corporate_action,
safekeeping_account,
cash_deposit,
card_transaction,
additional_transaction_information,
supplementary_data,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Additional information that can not be captured in the structured fields and/or any other specific block."]
pub struct SupplementaryData1<'a> {
#[doc = "Unambiguous reference to the location where the supplementary data must be inserted in the message instance.\r\nIn the case of XML, this is expressed by a valid XPath."]
pub place_and_name: Option<Max350Text<'a>>,
#[doc = "Technical element wrapping the supplementary data."]
pub envelope: SupplementaryDataEnvelope1,
}
impl<'a> SupplementaryData1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let place_and_name = reader.parse_optional_element("PlcAndNm", <Max350Text<'a>>::parse)?;
let envelope = reader.parse_element("Envlp", <SupplementaryDataEnvelope1>::parse)?;
Ok(Self {
place_and_name,
envelope,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 350 characters."]
pub struct Max350Text<'a>(Cow<'a, str>);
impl<'a> Max350Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=350usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Card transaction details."]
pub struct CardTransaction17<'a> {
#[doc = "Electronic money product that provides the cardholder with a portable and specialised computer device, which typically contains a microprocessor."]
pub card: Option<PaymentCard4<'a>>,
#[doc = "Physical or logical card payment terminal containing software and hardware components."]
pub poi: Option<PointOfInteraction1<'a>>,
#[doc = "Card transaction details, which can be either globalised by the acquirer or individual transaction."]
pub transaction: Option<CardTransaction3Choice<'a>>,
#[doc = "Prepaid account for the transfer or loading of an amount of money."]
pub pre_paid_account: Option<CashAccount38<'a>>,
}
impl<'a> CardTransaction17<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let card = reader.parse_optional_element("Card", <PaymentCard4<'a>>::parse)?;
let poi = reader.parse_optional_element("POI", <PointOfInteraction1<'a>>::parse)?;
let transaction =
reader.parse_optional_element("Tx", <CardTransaction3Choice<'a>>::parse)?;
let pre_paid_account =
reader.parse_optional_element("PrePdAcct", <CashAccount38<'a>>::parse)?;
Ok(Self {
card,
poi,
transaction,
pre_paid_account,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between an acquirer globalised card transaction or an individual card transaction."]
pub enum CardTransaction3Choice<'a> {
#[doc = "Card transaction details, based on card transaction aggregated data performed by the card acquirer."]
Aggregated(CardAggregated2<'a>),
#[doc = "Card transaction details for the individual transaction, as recorded at the POI (point of interaction)."]
Individual(CardIndividualTransaction2<'a>),
}
impl<'a> CardTransaction3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Aggtd".as_bytes() => {
let inner = reader.parse_element("Aggtd", <CardAggregated2<'a>>::parse)?;
Self::Aggregated(inner)
}
name if name == "Indv".as_bytes() => {
let inner =
reader.parse_element("Indv", <CardIndividualTransaction2<'a>>::parse)?;
Self::Individual(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Individual card transaction entry details."]
pub struct CardIndividualTransaction2<'a> {
#[doc = "Data related to an integrated circuit card application."]
pub icc_related_data: Option<Max1025Text<'a>>,
#[doc = "Context of the card payment transaction."]
pub payment_context: Option<PaymentContext3>,
#[doc = "Service in addition to the main service."]
pub additional_service: Option<CardPaymentServiceType2Code>,
#[doc = "Category code conform to ISO 18245, related to the type of services or goods the merchant provides for the transaction.\r\nThis element is also known as the MerchantCategoryCode."]
pub transaction_category: Option<ExternalCardTransactionCategory1Code>,
#[doc = "Unique identification of the sales reconciliation period between the acceptor and the acquirer. This identification might be linked to the identification of the settlement for further verification by the merchant."]
pub sale_reconciliation_identification: Option<Max35Text<'a>>,
#[doc = "Unique reference of the sales as provided by the merchant."]
pub sale_reference_number: Option<Max35Text<'a>>,
#[doc = "Reason for representment of a card transaction."]
pub re_presentment_reason: Option<ExternalRePresentmentReason1Code>,
#[doc = "Sequential number of the card transaction, as assigned by the POI (Point of Interaction). \nUsage: The sequential number is increased incrementally for each transaction."]
pub sequence_number: Option<Max35Text<'a>>,
#[doc = "Identification of the transaction assigned by the POI (Point Of Interaction)."]
pub transaction_identification: Option<TransactionIdentifier1<'a>>,
#[doc = "Product purchased with the transaction."]
pub product: Option<Product2<'a>>,
#[doc = "Date when the deposit was validated by the financial institution that collected the cash."]
pub validation_date: Option<IsoDate>,
#[doc = "Sequential number of the validation of the cash deposit.\r\nUsage: The sequential number is increased incrementally for each transaction."]
pub validation_sequence_number: Option<Max35Text<'a>>,
}
impl<'a> CardIndividualTransaction2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let icc_related_data =
reader.parse_optional_element("ICCRltdData", <Max1025Text<'a>>::parse)?;
let payment_context =
reader.parse_optional_element("PmtCntxt", <PaymentContext3>::parse)?;
let additional_service =
reader.parse_optional_element("AddtlSvc", <CardPaymentServiceType2Code>::parse)?;
let transaction_category = reader
.parse_optional_element("TxCtgy", <ExternalCardTransactionCategory1Code>::parse)?;
let sale_reconciliation_identification =
reader.parse_optional_element("SaleRcncltnId", <Max35Text<'a>>::parse)?;
let sale_reference_number =
reader.parse_optional_element("SaleRefNb", <Max35Text<'a>>::parse)?;
let re_presentment_reason = reader
.parse_optional_element("RePresntmntRsn", <ExternalRePresentmentReason1Code>::parse)?;
let sequence_number = reader.parse_optional_element("SeqNb", <Max35Text<'a>>::parse)?;
let transaction_identification =
reader.parse_optional_element("TxId", <TransactionIdentifier1<'a>>::parse)?;
let product = reader.parse_optional_element("Pdct", <Product2<'a>>::parse)?;
let validation_date = reader.parse_optional_element("VldtnDt", <IsoDate>::parse)?;
let validation_sequence_number =
reader.parse_optional_element("VldtnSeqNb", <Max35Text<'a>>::parse)?;
Ok(Self {
icc_related_data,
payment_context,
additional_service,
transaction_category,
sale_reconciliation_identification,
sale_reference_number,
re_presentment_reason,
sequence_number,
transaction_identification,
product,
validation_date,
validation_sequence_number,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Product purchased to be paid."]
pub struct Product2<'a> {
#[doc = "Product code of the item purchased."]
pub product_code: Max70Text<'a>,
#[doc = "Unit of measure of the item purchased."]
pub unit_of_measure: Option<UnitOfMeasure1Code>,
#[doc = "Product quantity."]
pub product_quantity: Option<DecimalNumber>,
#[doc = "Price per unit of product."]
pub unit_price: Option<ImpliedCurrencyAndAmount>,
#[doc = "Monetary value of purchased product."]
pub product_amount: Option<ImpliedCurrencyAndAmount>,
#[doc = "Information on tax paid on the product."]
pub tax_type: Option<Max35Text<'a>>,
#[doc = "Additional information related to the product."]
pub additional_product_information: Option<Max35Text<'a>>,
}
impl<'a> Product2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let product_code = reader.parse_element("PdctCd", <Max70Text<'a>>::parse)?;
let unit_of_measure =
reader.parse_optional_element("UnitOfMeasr", <UnitOfMeasure1Code>::parse)?;
let product_quantity = reader.parse_optional_element("PdctQty", <DecimalNumber>::parse)?;
let unit_price =
reader.parse_optional_element("UnitPric", <ImpliedCurrencyAndAmount>::parse)?;
let product_amount =
reader.parse_optional_element("PdctAmt", <ImpliedCurrencyAndAmount>::parse)?;
let tax_type = reader.parse_optional_element("TaxTp", <Max35Text<'a>>::parse)?;
let additional_product_information =
reader.parse_optional_element("AddtlPdctInf", <Max35Text<'a>>::parse)?;
Ok(Self {
product_code,
unit_of_measure,
product_quantity,
unit_price,
product_amount,
tax_type,
additional_product_information,
})
}
}
pub type UnitOfMeasure1Code = UnitOfMeasureCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Identifies the unit of measure by means of a code."]
pub enum UnitOfMeasureCode {
#[doc = "Basic unit of mass in the SI system, 1000 grams."]
Kilogram,
#[doc = "Standard length of cloth, wallpaper, as an item for sale or amount of a substance."]
Piece,
#[doc = "Measure of weight, in Britain 2240lb (long ton)and in the US 2000lb (short ton)."]
Ton,
#[doc = "Unit of length in the metric system, equal to 39.37 inches."]
Metre,
#[doc = "Measure of length equal to 2.54 cm."]
Inch,
#[doc = "Unit of length equal to 3 feet or 0.9144 metre."]
Yard,
#[doc = "Unit of volume that is equal to 8 pints."]
GbGallon,
#[doc = "Unit of measure that is equal to a 1, 000th of a kilo."]
Gram,
#[doc = "Unit of measure that is equal to one hundredth of a metre."]
Centimetre,
#[doc = "Measure of a surface, one metre by one metre."]
SquareMetre,
#[doc = "Unit of length equal to 1/3 yard."]
Foot,
#[doc = "Unit of length equal to 1, 760 yards."]
Mile,
#[doc = "Measure of a surface, one inch by one inch."]
SquareInch,
#[doc = "Measure of a surface, one foot by one foot."]
SquareFoot,
#[doc = "Measure of a surface, one mile by one mile."]
SquareMile,
#[doc = "Unit of weight equal to a sixteenth of a pound."]
GbOunce,
#[doc = "Unit of weight equal to a sixteenth of a pound."]
UsOunce,
#[doc = "Unit of volume that is equal to 568 cubic centimetres."]
GbPint,
#[doc = "Unit of volume that is equal to 473 cubic centimetres."]
UsPint,
#[doc = "Unit of volume that is equal to 2 pints."]
GbQuart,
#[doc = "Unit of volume that is equal to 2 pints."]
UsQuart,
#[doc = "Unit of volume that is equal to 8 pints."]
UsGallon,
#[doc = "Unit of measure that is a thousandth of one metre."]
Millimetre,
#[doc = "Unit of measure that is equal to 1, 000 meters."]
Kilometre,
#[doc = "Measure of a surface, one yard by one yard."]
SquareYard,
#[doc = "Unit of measure equal to 4, 840 square yards."]
Acre,
#[doc = "Unit of measure equal to a 100 square meters."]
Are,
#[doc = "Measure of a surface, one millimetre by one millimetre."]
SquareMillimetre,
#[doc = "Measure of a surface, one centimetre by one centimetre."]
SquareCentimetre,
#[doc = "Unit of measure that is equal to 10, 000 square meters."]
Hectare,
#[doc = "Measure of a surface, one kilometre by one kilometre."]
SquareKilometre,
#[doc = "Unit of volume that is equal to one thousandth of a litre."]
MilliLitre,
#[doc = "Unit of volume that is equal to one hundredth of a litre."]
Centilitre,
#[doc = "Unit of volume that is equal to a thousand cubic centimetres."]
Litre,
#[doc = "Unit of weight equal to 0.454 kilograms."]
Pound,
#[doc = "Amount of money deducted from a price or an amount due."]
Allowances,
#[doc = "Number of monetary units specified in a currency, where the unit of currency is explicit and compliant with ISO 4217."]
AmountOfCurrency,
#[doc = "Unit of volume that is equal to 42 US gallons."]
Barrels,
#[doc = "Unit of measure for large volumes of natural gas equivalent to 28316846 cubic meters."]
BillionCubicFeet,
#[doc = "Measure of length equal to 144 cubic inches."]
BoardFeet,
#[doc = "Unit of weight that is equal to 8 gallons. Mostly used for agricultural products with a specification of weight defined for each commodity differently."]
Bushels,
#[doc = "Unit of emissions type (or carbon credits) issued by the Clean Development Mechanism (CDM) Executive Board for emission reductions achieved by CDM projects and verified by a DOE (Designated Operational Entity) under the rules of the Kyoto Protocol."]
CertifiedEmissionsReduction,
#[doc = "Unit of offset credits used by the Climate Action Reserve. One Climate Reserve Tonne is equal to one metric ton of Greenhouse Gas (GHG) reduced/sequestered."]
ClimateReserveTonnes,
#[doc = "Unit of volume that is equal to one meter in length, breadth and height or also equal to 1000 liters."]
CubicMeters,
#[doc = "Unit of time that is equal to 24 hours."]
Days,
#[doc = "Unit of weight that is equal to the same mass value as a metric ton excluding moisture."]
DryMetricTons,
#[doc = "Unit of measure for ownership of credit (or allowance) of carbon dioxide emission (in metric ton)."]
EnvironmentalCredit,
#[doc = "Unit of measure for reduction of carbon dioxide emission (in metric ton) that may result in Environmental Credit."]
EnvironmentalOffset,
#[doc = "Unit of weight or mass of various values in the Imperial Unit System also known as quintal, cental or centum."]
Hundredweight,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000 watt in one day."]
KilowattDayCapacity,
#[doc = "Unit of measure that is equal to the power consumption of one kilowatt during one hour."]
KilowattHours,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000 watt in one hour."]
KilowattHoursCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000 watt in one minute."]
KilowattMinuteCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000 watt in one month."]
KilowattMonthCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000 watt in one year."]
KilowattYearCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000000 watt in one day."]
MegawattDayCapacity,
#[doc = "Unit of measure that is equal to the power consumption of one megawatt during one hour."]
MegawattHours,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000000 watt in one hour."]
MegawattHoursCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000000 watt in one minute."]
MegawattMinuteCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000000 watt in one month."]
MegawattMonthCapacity,
#[doc = "Unit of measure of the capacity of production of electric power equal to 1000000 watt in one year."]
MegawattYearCapacity,
#[doc = "Unit of mass equal to 1000 kilograms; equivalent to approximately 2,204.6 pounds, 1.102 short tons (US) or 0.984 long tons (imperial)."]
MetricTons,
#[doc = "Unit of volume that is equal to 1 million barrels equivalent to 42.000.000 US gallons."]
MillionBarrels,
#[doc = "Unit of measure of heat equal to one million British thermal unit (BTU)."]
OneMillionBtu,
#[doc = "Unit of weight equal to 31.1034768 grams. Used in precious metals."]
TroyOunces,
#[doc = "Unit of weight or mass of various values in the US Customary System also known as quintal, cental or centum. Equal to 100 lbs."]
UsHundredweight,
#[doc = "Decimal number used to calculate an amount or a price."]
IndexPoint,
#[doc = "Amount of money borrowed, or part of that amount which remains unpaid (excluding interest)."]
PrincipalWithRelationToDebtInstrument,
#[doc = "Amount of fuel alternative equal to one gallon of diesel."]
DieselGallonEquivalent,
#[doc = "Amount of fuel alternative equal to one gallon of gasoline."]
GasolineGallonEquivalent,
#[doc = "Tons of carbon dioxide."]
TonsOfCarbonDioxide,
#[doc = "Financial instrument that gives the owner right to dividends paid by a company and the most junior claim on the companies assets in the event of a bankruptcy."]
Shares,
#[doc = "Unit of heat, often used a unit of measure for natural gas in the UK."]
Therms,
#[doc = "Exchange traded contract that defines an agreement to buy specific quantities of a commodity or financial instrument at an agreed time in the future."]
Future,
#[doc = "Unit of measure that is equal to the power consumption of one Gigawatt during one hour."]
GigawattHours,
#[doc = "Unit of measure of heat required to raise the temperature of one pound of water by one degree Fahrenheit."]
BritishThermalUnit,
#[doc = "Indication of the unit of measurement."]
Lot,
#[doc = "Code for a bag."]
Bag,
#[doc = "Code for a bale."]
Bale,
#[doc = "Code for a bottle."]
Bottle,
#[doc = "Code for a box."]
Box,
#[doc = "Code for a carton."]
Carton,
#[doc = "Code for a container."]
Container,
#[doc = "Code for a crate."]
Crate,
#[doc = "Measure of a volume, one inch by one inch by one inch."]
CubicInch,
#[doc = "Unit of volume that is equal to one thousandth of a litre."]
CubicMillimetre,
#[doc = "Unit of volume equal to 2, 841 306 centilitre."]
GbFuildOunce,
#[doc = "Measure of weight, in Britain 2240 lb (long ton)."]
GbTon,
#[doc = "Unit of volume equal to 158, 9873 litre."]
UsBarrel,
#[doc = "Unit of volume equal to 2, 957353 centilitre."]
UsFluidOunce,
#[doc = "Measure of weight, in the US 2000 lb (short ton)."]
UsTon,
#[doc = "Cooling degree day"]
CoolingDegreeDay,
#[doc = "Heating degree day"]
HeatingDegreeDay,
#[doc = "Critical precipitation day"]
CriticalPrecipitationDay,
}
impl<'a> UnitOfMeasureCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"KILO" => Self::Kilogram,
"PIEC" => Self::Piece,
"TONS" => Self::Ton,
"METR" => Self::Metre,
"INCH" => Self::Inch,
"YARD" => Self::Yard,
"GBGA" => Self::GbGallon,
"GRAM" => Self::Gram,
"CMET" => Self::Centimetre,
"SMET" => Self::SquareMetre,
"FOOT" => Self::Foot,
"MILE" => Self::Mile,
"SQIN" => Self::SquareInch,
"SQFO" => Self::SquareFoot,
"SQMI" => Self::SquareMile,
"GBOU" => Self::GbOunce,
"USOU" => Self::UsOunce,
"GBPI" => Self::GbPint,
"USPI" => Self::UsPint,
"GBQA" => Self::GbQuart,
"USQA" => Self::UsQuart,
"USGA" => Self::UsGallon,
"MMET" => Self::Millimetre,
"KMET" => Self::Kilometre,
"SQYA" => Self::SquareYard,
"ACRE" => Self::Acre,
"ARES" => Self::Are,
"SMIL" => Self::SquareMillimetre,
"SCMT" => Self::SquareCentimetre,
"HECT" => Self::Hectare,
"SQKI" => Self::SquareKilometre,
"MILI" => Self::MilliLitre,
"CELI" => Self::Centilitre,
"LITR" => Self::Litre,
"PUND" => Self::Pound,
"ALOW" => Self::Allowances,
"ACCY" => Self::AmountOfCurrency,
"BARL" => Self::Barrels,
"BCUF" => Self::BillionCubicFeet,
"BDFT" => Self::BoardFeet,
"BUSL" => Self::Bushels,
"CEER" => Self::CertifiedEmissionsReduction,
"CLRT" => Self::ClimateReserveTonnes,
"CBME" => Self::CubicMeters,
"DAYS" => Self::Days,
"DMET" => Self::DryMetricTons,
"ENVC" => Self::EnvironmentalCredit,
"ENVO" => Self::EnvironmentalOffset,
"HUWG" => Self::Hundredweight,
"KWDC" => Self::KilowattDayCapacity,
"KWHO" => Self::KilowattHours,
"KWHC" => Self::KilowattHoursCapacity,
"KMOC" => Self::KilowattMinuteCapacity,
"KWMC" => Self::KilowattMonthCapacity,
"KWYC" => Self::KilowattYearCapacity,
"MWDC" => Self::MegawattDayCapacity,
"MWHO" => Self::MegawattHours,
"MWHC" => Self::MegawattHoursCapacity,
"MWMC" => Self::MegawattMinuteCapacity,
"MMOC" => Self::MegawattMonthCapacity,
"MWYC" => Self::MegawattYearCapacity,
"TONE" => Self::MetricTons,
"MIBA" => Self::MillionBarrels,
"MBTU" => Self::OneMillionBtu,
"OZTR" => Self::TroyOunces,
"UCWT" => Self::UsHundredweight,
"IPNT" => Self::IndexPoint,
"PWRD" => Self::PrincipalWithRelationToDebtInstrument,
"DGEU" => Self::DieselGallonEquivalent,
"GGEU" => Self::GasolineGallonEquivalent,
"TOCD" => Self::TonsOfCarbonDioxide,
"SHAS" => Self::Shares,
"THMS" => Self::Therms,
"FUTU" => Self::Future,
"GWHO" => Self::GigawattHours,
"BRTU" => Self::BritishThermalUnit,
"LOTS" => Self::Lot,
"BAGG" => Self::Bag,
"BALE" => Self::Bale,
"BOTL" => Self::Bottle,
"BOXX" => Self::Box,
"CRTN" => Self::Carton,
"CNTR" => Self::Container,
"CRAT" => Self::Crate,
"CBIN" => Self::CubicInch,
"CBML" => Self::CubicMillimetre,
"GBFO" => Self::GbFuildOunce,
"GBTN" => Self::GbTon,
"USBA" => Self::UsBarrel,
"USFO" => Self::UsFluidOunce,
"USTN" => Self::UsTon,
"CDDA" => Self::CoolingDegreeDay,
"HDDA" => Self::HeatingDegreeDay,
"CPDA" => Self::CriticalPrecipitationDay,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Identification of the transaction in an unambiguous way."]
pub struct TransactionIdentifier1<'a> {
#[doc = "Local date and time of the transaction assigned by the POI (Point Of Interaction)."]
pub transaction_date_time: IsoDateTime,
#[doc = "Identification of the transaction that has to be unique for a time period."]
pub transaction_reference: Max35Text<'a>,
}
impl<'a> TransactionIdentifier1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let transaction_date_time = reader.parse_element("TxDtTm", <IsoDateTime>::parse)?;
let transaction_reference = reader.parse_element("TxRef", <Max35Text<'a>>::parse)?;
Ok(Self {
transaction_date_time,
transaction_reference,
})
}
}
pub use self::external_code_sets::ExternalRePresentmentReason1Code;
#[derive(Clone, Debug)]
#[doc = "Payment context in which the transaction is performed."]
pub struct PaymentContext3 {
#[doc = "Indicates whether the transaction has been initiated by a card physically present or not."]
pub card_present: Option<TrueFalseIndicator>,
#[doc = "Indicates whether the transaction has been initiated in presence of the cardholder or not."]
pub cardholder_present: Option<TrueFalseIndicator>,
#[doc = "On-line or off-line context of the transaction."]
pub on_line_context: Option<TrueFalseIndicator>,
#[doc = "Human attendance at the POI location during the transaction."]
pub attendance_context: Option<AttendanceContext1Code>,
#[doc = "Indicates the environment of the transaction."]
pub transaction_environment: Option<TransactionEnvironment1Code>,
#[doc = "Identifies the type of the communication channels used by the cardholder to the acceptor system."]
pub transaction_channel: Option<TransactionChannel1Code>,
#[doc = "Indicates whether a message can be sent or not on an attendant display (attendant display present or not)."]
pub attendant_message_capable: Option<TrueFalseIndicator>,
#[doc = "Language used to display messages to the attendant."]
pub attendant_language: Option<IsoLanguageCode>,
#[doc = "Entry mode of the card data."]
pub card_data_entry_mode: CardDataReading1Code,
#[doc = "Indicator of a card entry mode fallback."]
pub fallback_indicator: Option<TrueFalseIndicator>,
#[doc = "Method used to authenticate a cardholder."]
pub authentication_method: Option<CardholderAuthentication2>,
}
impl<'a> PaymentContext3 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let card_present =
reader.parse_optional_element("CardPres", <TrueFalseIndicator>::parse)?;
let cardholder_present =
reader.parse_optional_element("CrdhldrPres", <TrueFalseIndicator>::parse)?;
let on_line_context =
reader.parse_optional_element("OnLineCntxt", <TrueFalseIndicator>::parse)?;
let attendance_context =
reader.parse_optional_element("AttndncCntxt", <AttendanceContext1Code>::parse)?;
let transaction_environment =
reader.parse_optional_element("TxEnvt", <TransactionEnvironment1Code>::parse)?;
let transaction_channel =
reader.parse_optional_element("TxChanl", <TransactionChannel1Code>::parse)?;
let attendant_message_capable =
reader.parse_optional_element("AttndntMsgCpbl", <TrueFalseIndicator>::parse)?;
let attendant_language =
reader.parse_optional_element("AttndntLang", <IsoLanguageCode>::parse)?;
let card_data_entry_mode =
reader.parse_element("CardDataNtryMd", <CardDataReading1Code>::parse)?;
let fallback_indicator =
reader.parse_optional_element("FllbckInd", <TrueFalseIndicator>::parse)?;
let authentication_method =
reader.parse_optional_element("AuthntcnMtd", <CardholderAuthentication2>::parse)?;
Ok(Self {
card_present,
cardholder_present,
on_line_context,
attendance_context,
transaction_environment,
transaction_channel,
attendant_message_capable,
attendant_language,
card_data_entry_mode,
fallback_indicator,
authentication_method,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Data related to the authentication of the cardholder."]
pub struct CardholderAuthentication2 {
#[doc = "Method used to authenticate the cardholder."]
pub authentication_method: AuthenticationMethod1Code,
#[doc = "Entity or object in charge of verifying the cardholder authenticity."]
pub authentication_entity: AuthenticationEntity1Code,
}
impl<'a> CardholderAuthentication2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let authentication_method =
reader.parse_element("AuthntcnMtd", <AuthenticationMethod1Code>::parse)?;
let authentication_entity =
reader.parse_element("AuthntcnNtty", <AuthenticationEntity1Code>::parse)?;
Ok(Self {
authentication_method,
authentication_entity,
})
}
}
pub type AuthenticationEntity1Code = AuthenticationEntityCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Entity or object in charge of verifying the cardholder authenticity."]
pub enum AuthenticationEntityCode {
#[doc = "Application in the chip card (Integrated Circuit Card), for instance an offline PIN verification."]
Icc,
#[doc = "Authorisation agent of the issuer."]
AuthorisedAgent,
#[doc = "Merchant (for example signature verification by the attendant)."]
Merchant,
#[doc = "Acquirer of the transaction."]
Acquirer,
#[doc = "Card issuer."]
Issuer,
#[doc = "Secure application in the terminal."]
Terminal,
}
impl<'a> AuthenticationEntityCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"ICCD" => Self::Icc,
"AGNT" => Self::AuthorisedAgent,
"MERC" => Self::Merchant,
"ACQR" => Self::Acquirer,
"ISSR" => Self::Issuer,
"TRML" => Self::Terminal,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type AuthenticationMethod1Code = AuthenticationMethodCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Method used to authenticate a cardholder."]
pub enum AuthenticationMethodCode {
#[doc = "Authentication method is performed unknown."]
UnknownMethod,
#[doc = "Authentication bypassed by the merchant."]
Bypass,
#[doc = "On-line PIN authentication (Personal Identification Number)."]
OnLinePin,
#[doc = "Off-line PIN authentication (Personal Identification Number)."]
OfflinePin,
#[doc = "Electronic signature capture (handwritten signature)."]
SignatureCapture,
#[doc = "Handwritten paper signature."]
PaperSignature,
#[doc = "Manual verification, for example passport or drivers license."]
ManualVerification,
#[doc = "Merchant-related authentication."]
MerchantAuthentication,
#[doc = "Electronic commerce transaction secured with the X.509 certificate of a customer."]
SecureCertificate,
#[doc = "Secure electronic transaction without cardholder certificate."]
SecureNoCertificate,
#[doc = "Channel-encrypted transaction."]
SecuredChannel,
#[doc = "Authentication by a password."]
Password,
#[doc = "Cardholder billing address verification."]
BillingAddressVerification,
#[doc = "Biometric authentication of the cardholder."]
Biometry,
#[doc = "Cardholder data provided for verification, for instance social security number, driver license number, passport number."]
CardholderIdentificationData,
#[doc = "Verification of a cryptogram generated by a chip card or another device, for instance ARQC (Authorisation Request Cryptogram)."]
CryptogramVerification,
#[doc = "Verification of Card Security Code."]
CscVerification,
#[doc = "Authentication based on statistical cardholder behaviour."]
PassiveAuthentication,
#[doc = "Authentication performed during a secure electronic commerce transaction."]
SecureElectronicCommerce,
#[doc = "Cardholder shipping address verification."]
ShippingAddressVerification,
#[doc = "Cryptogram generated by the token requestor or a customer device to validate the authorised use of a token."]
TokenAuthentication,
#[doc = "Verification or authentication related to the use of a payment token, for instance the validation of the authorised use of a token."]
PaymentToken,
#[doc = "A token is used to verify an already performed authentication."]
AuthenticationToken,
#[doc = "Customer mobile device."]
Mobile,
#[doc = "Other customer authentication."]
Other,
#[doc = "Digits of the address."]
AddressDigits,
#[doc = "Number assigned by a government agency to identify foreign nationals."]
AlienRegistrationNumber,
#[doc = "Verification of a cryptogram generated by a chip card, for instance an ARQC (Authorisation Request Cryptogram)."]
ArqcVerification,
#[doc = "Date of birth of a person."]
BirthDate,
#[doc = "Name of cardholder"]
CardholderName,
#[doc = "City of birth to authenticate a person."]
CityOfBirth,
#[doc = "Customer number used as a mechanism of authentication."]
CustomerIdentification,
#[doc = "Identification of a driver in a fleet of vehicles."]
DriverIdentification,
#[doc = "Number assigned by a driving license authority to a person driving a car."]
DriverLicenseNumber,
#[doc = "Electronic mail address"]
Email,
#[doc = "Number assigned to an employee by an employer."]
EmployeeIdentificationNumber,
#[doc = "Number assigned to an employer by a registration authority."]
EmployerIdentificationNumber,
#[doc = "Number assigned by a national authority to an identity card."]
IdentityCardNumber,
#[doc = "Verification of a one-time password provided by the issuer."]
OneTimePassword,
#[doc = "Other cardholder data provided for identification."]
OtherCardholderIdentification,
#[doc = "Verification of a cryptogram generated by a non-card form factor."]
OtherCryptogram,
#[doc = "Number assigned by a passport authority to a passport."]
PassportNumber,
#[doc = "Verification based on digits of the postal code."]
PostalCode,
#[doc = "Shipping address from verification."]
ShippingAddressFrom,
#[doc = "Shipping address to verification"]
ShippingAddressTo,
#[doc = "Verification whether the address corresponds to the cardholder's one."]
CardholderAddress,
#[doc = "Non visible Card Security Code."]
NonVisibleCsc,
#[doc = "Other type of verification defined at national level."]
OtherNational,
#[doc = "Other type of verification defined at private level"]
OtherPrivate,
#[doc = "Place of birth of a person."]
PlaceOfBirth,
#[doc = "Number assigned by a social security agency."]
SocialSecurityNumber,
#[doc = "Number assigned by a tax authority to an entity."]
TaxIdentificationNumber,
#[doc = "Account-based digital signature authentication."]
AccountDigitalSignature,
#[doc = "Response Card Cryptogram (ARPC) verification."]
ArpcVerification,
#[doc = "Application Transaction Counter"]
Atc,
#[doc = "Biographics authentication in an offline mode."]
OffLineBiographics,
#[doc = "Biometrics authentication in an offline mode"]
OffLineBiometrics,
#[doc = "Authentication of data in an offline mode"]
OffLineDataAuthentication,
#[doc = "Analysis of signature transmitted offline"]
OffLineDigitisedSignatureAnalysis,
#[doc = "PIN generated offline and transmitted encrypted"]
OffLinePinEncrypted,
#[doc = "PIN generated offline and transmitted in clear"]
OffLinePinInClear,
#[doc = "Biographics authentication in an online mode."]
OnLineBiographics,
#[doc = "Customer home phone number."]
PhoneHome,
#[doc = "Customer work phone number"]
PhoneWork,
#[doc = "PKI (Public Key Infrastructure) based digital signature"]
PkiSignature,
#[doc = "QualifiedCertificate"]
QualifiedCertificate,
#[doc = "Authentication performed during a secure electronic commerce transaction."]
ThreeDs,
}
impl<'a> AuthenticationMethodCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"UKNW" => Self::UnknownMethod,
"BYPS" => Self::Bypass,
"NPIN" => Self::OnLinePin,
"FPIN" => Self::OfflinePin,
"CPSG" => Self::SignatureCapture,
"PPSG" => Self::PaperSignature,
"MANU" => Self::ManualVerification,
"MERC" => Self::MerchantAuthentication,
"SCRT" => Self::SecureCertificate,
"SNCT" => Self::SecureNoCertificate,
"SCNL" => Self::SecuredChannel,
"PSWD" => Self::Password,
"ADDB" => Self::BillingAddressVerification,
"BIOM" => Self::Biometry,
"CDHI" => Self::CardholderIdentificationData,
"CRYP" => Self::CryptogramVerification,
"CSCV" => Self::CscVerification,
"PSVE" => Self::PassiveAuthentication,
"CSEC" => Self::SecureElectronicCommerce,
"ADDS" => Self::ShippingAddressVerification,
"TOKN" => Self::TokenAuthentication,
"TOKP" => Self::PaymentToken,
"TOKA" => Self::AuthenticationToken,
"MOBL" => Self::Mobile,
"OTHR" => Self::Other,
"ADVF" => Self::AddressDigits,
"ARNB" => Self::AlienRegistrationNumber,
"ARQC" => Self::ArqcVerification,
"BTHD" => Self::BirthDate,
"CHDN" => Self::CardholderName,
"COFB" => Self::CityOfBirth,
"CUID" => Self::CustomerIdentification,
"DRVI" => Self::DriverIdentification,
"DRLN" => Self::DriverLicenseNumber,
"EMAL" => Self::Email,
"EMIN" => Self::EmployeeIdentificationNumber,
"EMRN" => Self::EmployerIdentificationNumber,
"IDCN" => Self::IdentityCardNumber,
"OTPW" => Self::OneTimePassword,
"OCHI" => Self::OtherCardholderIdentification,
"OTHC" => Self::OtherCryptogram,
"PASN" => Self::PassportNumber,
"PCDV" => Self::PostalCode,
"SHAF" => Self::ShippingAddressFrom,
"SHAT" => Self::ShippingAddressTo,
"CHSA" => Self::CardholderAddress,
"NVSC" => Self::NonVisibleCsc,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
"PLOB" => Self::PlaceOfBirth,
"SSNB" => Self::SocialSecurityNumber,
"TXIN" => Self::TaxIdentificationNumber,
"APKI" => Self::AccountDigitalSignature,
"ARPC" => Self::ArpcVerification,
"ATCC" => Self::Atc,
"FBIG" => Self::OffLineBiographics,
"FBIO" => Self::OffLineBiometrics,
"OLDA" => Self::OffLineDataAuthentication,
"OLDS" => Self::OffLineDigitisedSignatureAnalysis,
"OFPE" => Self::OffLinePinEncrypted,
"FCPN" => Self::OffLinePinInClear,
"NBIG" => Self::OnLineBiographics,
"PHOM" => Self::PhoneHome,
"PWOR" => Self::PhoneWork,
"PKIS" => Self::PkiSignature,
"QWAC" => Self::QualifiedCertificate,
"THDS" => Self::ThreeDs,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type TransactionChannel1Code = TransactionChannelCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the type of communication channel."]
pub enum TransactionChannelCode {
#[doc = "Mail order."]
MailOrder,
#[doc = "Telephone order."]
TelephoneOrder,
#[doc = "Electronic commerce."]
ElectronicCommerce,
#[doc = "Payment on television."]
TelevisionPayment,
#[doc = "Office or branch."]
OfficeOrBranch,
#[doc = "Home banking."]
HomeBanking,
#[doc = "Financial advisor."]
FinancialAdvisor,
#[doc = "Payment performed through a cardholder mobile device."]
MobilePayment,
#[doc = "Electronic commerce with cardholder authentication."]
SecuredElectronicCommerce,
#[doc = "Payment performed through a merchant mobile device."]
MobilePos,
}
impl<'a> TransactionChannelCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"MAIL" => Self::MailOrder,
"TLPH" => Self::TelephoneOrder,
"ECOM" => Self::ElectronicCommerce,
"TVPY" => Self::TelevisionPayment,
"BRAN" => Self::OfficeOrBranch,
"HOBA" => Self::HomeBanking,
"FIAD" => Self::FinancialAdvisor,
"MOBL" => Self::MobilePayment,
"SECM" => Self::SecuredElectronicCommerce,
"MPOS" => Self::MobilePos,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type TransactionEnvironment1Code = TransactionEnvironmentCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Indicates the environment of the transaction."]
pub enum TransactionEnvironmentCode {
#[doc = "Merchant environment."]
Merchant,
#[doc = "Private environment."]
Private,
#[doc = "Public environment."]
Public,
#[doc = "Bank environment."]
Branch,
#[doc = "Other environments, for instance a mall or an airport."]
Other,
}
impl<'a> TransactionEnvironmentCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"MERC" => Self::Merchant,
"PRIV" => Self::Private,
"PUBL" => Self::Public,
"BRCH" => Self::Branch,
"OTHR" => Self::Other,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type AttendanceContext1Code = AttendanceContextCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Human attendance at the POI location during the transaction."]
pub enum AttendanceContextCode {
#[doc = "Attended payment, with an attendant."]
Attended,
#[doc = "Semi-attended, including self checkout. An attendant supervises several payment, and could be called to help the cardholder."]
SemiAttended,
#[doc = "Unattended payment, no attendant present."]
Unattended,
#[doc = "Delivery by an attendant."]
AttendantDelivery,
#[doc = "Delivery by the customer."]
CustomerDelivery,
#[doc = "Delivery by a carrier."]
CarrierDelivery,
#[doc = "Full service for fuel distribution."]
FullServe,
#[doc = "Self service for fuel distribution."]
SelfServe,
}
impl<'a> AttendanceContextCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"ATTD" => Self::Attended,
"SATT" => Self::SemiAttended,
"UATT" => Self::Unattended,
"ATTL" => Self::AttendantDelivery,
"CUST" => Self::CustomerDelivery,
"CARR" => Self::CarrierDelivery,
"FULL" => Self::FullServe,
"SELF" => Self::SelfServe,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 1025 characters."]
pub struct Max1025Text<'a>(Cow<'a, str>);
impl<'a> Max1025Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=1025usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Deposit of an amount of money defined in cash notes and/or coins."]
pub struct CashDeposit1<'a> {
#[doc = "Specifies the note or coin denomination, including the currency, such as a 50 euro note."]
pub note_denomination: ActiveCurrencyAndAmount,
#[doc = "Specifies the number of notes of the same denomination in the deposit."]
pub number_of_notes: Max15NumericText<'a>,
#[doc = "Specifies the total amount of money in the cash deposit, that is the note denomination times the number of notes."]
pub amount: ActiveCurrencyAndAmount,
}
impl<'a> CashDeposit1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let note_denomination =
reader.parse_element("NoteDnmtn", <ActiveCurrencyAndAmount>::parse)?;
let number_of_notes = reader.parse_element("NbOfNotes", <Max15NumericText<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveCurrencyAndAmount>::parse)?;
Ok(Self {
note_denomination,
number_of_notes,
amount,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "A number of monetary units specified in an active currency where the unit of currency is explicit and compliant with ISO 4217."]
pub struct ActiveCurrencyAndAmount {
amount: Decimal,
pub currency: CurrencyCode,
}
impl<'a> ActiveCurrencyAndAmount {
pub(crate) fn parse(reader: &mut XmlReader<'a>, start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let amount = Decimal::from_str(&text).unwrap();
let currency = {
let currency = start
.try_get_attribute(b"Ccy")?
.ok_or_else(|| -> XmlError { todo!() })?;
let currency = currency.unescape_value()?;
CurrencyCode::from_str(&*currency)?
};
Ok(Self { amount, currency })
}
}
#[derive(Clone, Debug)]
#[doc = "Account to or from which a securities entry is made."]
pub struct SecuritiesAccount19<'a> {
#[doc = "Unambiguous identification for the account between the account owner and the account servicer."]
pub identification: Max35Text<'a>,
#[doc = "Specifies the type of securities account."]
pub r#type: Option<GenericIdentification30<'a>>,
#[doc = "Description of the account."]
pub name: Option<Max70Text<'a>>,
}
impl<'a> SecuritiesAccount19<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <GenericIdentification30<'a>>::parse)?;
let name = reader.parse_optional_element("Nm", <Max70Text<'a>>::parse)?;
Ok(Self {
identification,
r#type,
name,
})
}
}
#[derive(Clone, Debug)]
#[doc = "An event determined by a corporation's board of directors, that changes the existing corporate capital structure or financial condition."]
pub struct CorporateAction9<'a> {
#[doc = "Type of corporate action event, in a free-text format."]
pub event_type: Max35Text<'a>,
#[doc = "Identification of a corporate action assigned by an official central body/entity within a given market."]
pub event_identification: Max35Text<'a>,
}
impl<'a> CorporateAction9<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let event_type = reader.parse_element("EvtTp", <Max35Text<'a>>::parse)?;
let event_identification = reader.parse_element("EvtId", <Max35Text<'a>>::parse)?;
Ok(Self {
event_type,
event_identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details on the reason of the return of the transaction."]
pub struct PaymentReturnReason5<'a> {
#[doc = "Bank transaction code included in the original entry for the transaction."]
pub original_bank_transaction_code: Option<BankTransactionCodeStructure4<'a>>,
#[doc = "Party that issues the return."]
pub originator: Option<PartyIdentification135<'a>>,
#[doc = "Specifies the reason for the return."]
pub reason: Option<ReturnReason5Choice<'a>>,
#[doc = "Further details on the return reason."]
pub additional_information: Vec<Max105Text<'a>>,
}
impl<'a> PaymentReturnReason5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let original_bank_transaction_code = reader
.parse_optional_element("OrgnlBkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let originator =
reader.parse_optional_element("Orgtr", <PartyIdentification135<'a>>::parse)?;
let reason = reader.parse_optional_element("Rsn", <ReturnReason5Choice<'a>>::parse)?;
let additional_information = reader.parse_list("AddtlInf", <Max105Text<'a>>::parse)?;
Ok(Self {
original_bank_transaction_code,
originator,
reason,
additional_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Details about tax paid, or to be paid, to the government in accordance with the law, including pre-defined parameters such as thresholds and type of account."]
pub struct TaxInformation8<'a> {
#[doc = "Party on the credit side of the transaction to which the tax applies."]
pub creditor: Option<TaxParty1<'a>>,
#[doc = "Party on the debit side of the transaction to which the tax applies."]
pub debtor: Option<TaxParty2<'a>>,
#[doc = "Territorial part of a country to which the tax payment is related."]
pub administration_zone: Option<Max35Text<'a>>,
#[doc = "Tax reference information that is specific to a taxing agency."]
pub reference_number: Option<Max140Text<'a>>,
#[doc = "Method used to indicate the underlying business or how the tax is paid."]
pub method: Option<Max35Text<'a>>,
#[doc = "Total amount of money on which the tax is based."]
pub total_taxable_base_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Total amount of money as result of the calculation of the tax."]
pub total_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Date by which tax is due."]
pub date: Option<IsoDate>,
#[doc = "Sequential number of the tax report."]
pub sequence_number: Option<Number>,
#[doc = "Record of tax details."]
pub record: Vec<TaxRecord2<'a>>,
}
impl<'a> TaxInformation8<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let creditor = reader.parse_optional_element("Cdtr", <TaxParty1<'a>>::parse)?;
let debtor = reader.parse_optional_element("Dbtr", <TaxParty2<'a>>::parse)?;
let administration_zone =
reader.parse_optional_element("AdmstnZone", <Max35Text<'a>>::parse)?;
let reference_number = reader.parse_optional_element("RefNb", <Max140Text<'a>>::parse)?;
let method = reader.parse_optional_element("Mtd", <Max35Text<'a>>::parse)?;
let total_taxable_base_amount = reader.parse_optional_element(
"TtlTaxblBaseAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let total_tax_amount = reader
.parse_optional_element("TtlTaxAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let date = reader.parse_optional_element("Dt", <IsoDate>::parse)?;
let sequence_number = reader.parse_optional_element("SeqNb", <Number>::parse)?;
let record = reader.parse_list("Rcrd", <TaxRecord2<'a>>::parse)?;
Ok(Self {
creditor,
debtor,
administration_zone,
reference_number,
method,
total_taxable_base_amount,
total_tax_amount,
date,
sequence_number,
record,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Identification of a security."]
pub struct SecurityIdentification19<'a> {
#[doc = "International Securities Identification Number (ISIN). A numbering system designed by the United Nation's International Organisation for Standardisation (ISO). The ISIN is composed of a 2-character prefix representing the country of issue, followed by the national security number (if one exists), and a check digit. Each country has a national numbering agency that assigns ISIN numbers for securities in that country."]
pub isin: Option<IsinIdentifier>,
#[doc = "Identification of a security by proprietary or domestic identification scheme."]
pub other_identification: Vec<OtherIdentification1<'a>>,
#[doc = "Textual description of a security instrument."]
pub description: Option<Max140Text<'a>>,
}
impl<'a> SecurityIdentification19<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let isin = reader.parse_optional_element("ISIN", <IsinIdentifier>::parse)?;
let other_identification =
reader.parse_list("OthrId", <OtherIdentification1<'a>>::parse)?;
let description = reader.parse_optional_element("Desc", <Max140Text<'a>>::parse)?;
Ok(Self {
isin,
other_identification,
description,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Other accepted financial instrument's identification than ISIN."]
pub struct OtherIdentification1<'a> {
#[doc = "Identification of a security."]
pub identification: Max35Text<'a>,
#[doc = "Identifies the suffix of the security identification."]
pub suffix: Option<Max16Text<'a>>,
#[doc = "Type of the identification."]
pub r#type: IdentificationSource3Choice<'a>,
}
impl<'a> OtherIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let suffix = reader.parse_optional_element("Sfx", <Max16Text<'a>>::parse)?;
let r#type = reader.parse_element("Tp", <IdentificationSource3Choice<'a>>::parse)?;
Ok(Self {
identification,
suffix,
r#type,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between source of identification of a financial instrument."]
pub enum IdentificationSource3Choice<'a> {
#[doc = "Unique and unambiguous identification source, as assigned via a pre-determined code list."]
Code(ExternalFinancialInstrumentIdentificationType1Code),
#[doc = "Unique and unambiguous identification source using a proprietary identification scheme."]
Proprietary(Max35Text<'a>),
}
impl<'a> IdentificationSource3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element(
"Cd",
<ExternalFinancialInstrumentIdentificationType1Code>::parse,
)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalFinancialInstrumentIdentificationType1Code;
#[derive(Clone, Debug)]
#[doc = "Specifies the quantities (such as securities) in the underlying transaction."]
pub enum TransactionQuantities3Choice<'a> {
#[doc = "Specifies the quantity (such as securities) in the underlying transaction."]
Quantity(FinancialInstrumentQuantity1Choice),
#[doc = "Face amount and amortised value of security."]
OriginalAndCurrentFaceAmount(OriginalAndCurrentQuantities1),
#[doc = "Proprietary quantities specification defined in the underlying transaction."]
Proprietary(ProprietaryQuantity1<'a>),
}
impl<'a> TransactionQuantities3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Qty".as_bytes() => {
let inner =
reader.parse_element("Qty", <FinancialInstrumentQuantity1Choice>::parse)?;
Self::Quantity(inner)
}
name if name == "OrgnlAndCurFaceAmt".as_bytes() => {
let inner = reader
.parse_element("OrgnlAndCurFaceAmt", <OriginalAndCurrentQuantities1>::parse)?;
Self::OriginalAndCurrentFaceAmount(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <ProprietaryQuantity1<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Original and current value of an asset-back instrument."]
pub struct OriginalAndCurrentQuantities1 {
#[doc = "Quantity expressed as an amount representing the face amount, that is, the principal of a debt instrument."]
pub face_amount: ImpliedCurrencyAndAmount,
#[doc = "Quantity expressed as an amount representing the current amortised face amount of a bond, for example, a periodic reduction/increase of a bond's principal amount."]
pub amortised_value: ImpliedCurrencyAndAmount,
}
impl<'a> OriginalAndCurrentQuantities1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let face_amount = reader.parse_element("FaceAmt", <ImpliedCurrencyAndAmount>::parse)?;
let amortised_value =
reader.parse_element("AmtsdVal", <ImpliedCurrencyAndAmount>::parse)?;
Ok(Self {
face_amount,
amortised_value,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between formats for the quantity of security."]
pub enum FinancialInstrumentQuantity1Choice {
#[doc = "Quantity expressed as a number, for example, a number of shares."]
Unit(DecimalNumber),
#[doc = "Quantity expressed as an amount representing the face amount, that is, the principal, of a debt instrument."]
FaceAmount(ImpliedCurrencyAndAmount),
#[doc = "Quantity expressed as an amount representing the current amortised face amount of a bond, for example, a periodic reduction/increase of a bond's principal amount."]
AmortisedValue(ImpliedCurrencyAndAmount),
}
impl<'a> FinancialInstrumentQuantity1Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Unit".as_bytes() => {
let inner = reader.parse_element("Unit", <DecimalNumber>::parse)?;
Self::Unit(inner)
}
name if name == "FaceAmt".as_bytes() => {
let inner = reader.parse_element("FaceAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::FaceAmount(inner)
}
name if name == "AmtsdVal".as_bytes() => {
let inner = reader.parse_element("AmtsdVal", <ImpliedCurrencyAndAmount>::parse)?;
Self::AmortisedValue(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the price information related to the underlying transaction."]
pub enum TransactionPrice4Choice<'a> {
#[doc = "Specifies the price of the traded financial instrument.\nThis is the deal price of the individual trade transaction. \nIf there is only one trade transaction for the execution of the trade, then the deal price could equal the executed trade price (unless, for example, the price includes commissions or rounding, or some other factor has been applied to the deal price or the executed trade price, or both)."]
DealPrice(Price7),
#[doc = "Proprietary price specification related to the underlying transaction."]
Proprietary(Vec<ProprietaryPrice2<'a>>),
}
impl<'a> TransactionPrice4Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "DealPric".as_bytes() => {
let inner = reader.parse_element("DealPric", <Price7>::parse)?;
Self::DealPrice(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_list("Prtry", <ProprietaryPrice2<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Type and information about a price."]
pub struct Price7 {
#[doc = "Specification of the price type."]
pub r#type: YieldedOrValueType1Choice,
#[doc = "Value of the price, for example, as a currency and value."]
pub value: PriceRateOrAmount3Choice,
}
impl<'a> Price7 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <YieldedOrValueType1Choice>::parse)?;
let value = reader.parse_element("Val", <PriceRateOrAmount3Choice>::parse)?;
Ok(Self { r#type, value })
}
}
#[derive(Clone, Debug)]
#[doc = "Choice of formats for the price."]
pub enum PriceRateOrAmount3Choice {
#[doc = "Price expressed as a rate, that is percentage."]
Rate(PercentageRate),
#[doc = "Price expressed as a currency and value."]
Amount(ActiveOrHistoricCurrencyAnd13DecimalAmount),
}
impl<'a> PriceRateOrAmount3Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Rate".as_bytes() => {
let inner = reader.parse_element("Rate", <PercentageRate>::parse)?;
Self::Rate(inner)
}
name if name == "Amt".as_bytes() => {
let inner = reader
.parse_element("Amt", <ActiveOrHistoricCurrencyAnd13DecimalAmount>::parse)?;
Self::Amount(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "A number of monetary units specified in an active or a historic currency where the unit of currency is explicit and compliant with ISO 4217. The number of fractional digits (or minor unit of currency) is not checked as per ISO 4217: It must be lesser than or equal to 13.\nNote: The decimal separator is a dot."]
pub struct ActiveOrHistoricCurrencyAnd13DecimalAmount {
amount: Decimal,
pub currency: CurrencyCode,
}
impl<'a> ActiveOrHistoricCurrencyAnd13DecimalAmount {
pub(crate) fn parse(reader: &mut XmlReader<'a>, start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let amount = Decimal::from_str(&text).unwrap();
let currency = {
let currency = start
.try_get_attribute(b"Ccy")?
.ok_or_else(|| -> XmlError { todo!() })?;
let currency = currency.unescape_value()?;
CurrencyCode::from_str(&*currency)?
};
Ok(Self { amount, currency })
}
}
#[derive(Clone, Debug)]
#[doc = "Choice of value type."]
pub enum YieldedOrValueType1Choice {
#[doc = "Indicates whether the price is expressed as a yield."]
Yielded(YesNoIndicator),
#[doc = "Type of value in which the price is expressed."]
ValueType(PriceValueType1Code),
}
impl<'a> YieldedOrValueType1Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Yldd".as_bytes() => {
let inner = reader.parse_element("Yldd", <YesNoIndicator>::parse)?;
Self::Yielded(inner)
}
name if name == "ValTp".as_bytes() => {
let inner = reader.parse_element("ValTp", <PriceValueType1Code>::parse)?;
Self::ValueType(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type PriceValueType1Code = PriceValueTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Price will not be paid."]
pub enum PriceValueTypeCode {
#[doc = "Price expressed as a number of percentage points below par, for example, a discount price of 2.0% equals a price of 98 when par is 100."]
Discount,
#[doc = "Price expressed as a number of percentage points above par, for example, a premium price of 2.0% equals a price of 102 when par is 100."]
Premium,
#[doc = "Price is the face amount."]
Par,
#[doc = "Price expressed as a yield."]
Yield,
#[doc = "Difference between a market maker's bid and asked price."]
Spread,
#[doc = "Price expressed per unit."]
PerUnit,
#[doc = "Price is expressed as absolute."]
Absolute,
#[doc = "Price is expressed as Treasury Euro Dollar price."]
TedPrice,
#[doc = "Price is expressed as Treasury Euro Dollar yield."]
TedYield,
#[doc = "Cabinet trades are used to indicate prices that trade at a price lower than that available on an exchange and they can be fixed or variable (primarily used for listed futures and options)."]
FixedCabinetTrade,
#[doc = "Cabinet trades are used to indicate prices that trade at a price lower than that available on an exchange and they can be fixed or variable (primarily used for listed futures and options)."]
VariableCabinetTrade,
#[doc = "Price expressed as a percentage of par."]
Percentage,
#[doc = "Price is unknown by the sender or has not been established."]
Unknown,
#[doc = "Price has not been established."]
OpenDated,
#[doc = "Price is not required to be specified by account owner."]
Unspecified,
#[doc = "Price to be specified by account owner."]
ToBeSpecified,
#[doc = "Price expressed as a currency and amount per unit or per share."]
ActualAmount,
#[doc = "Price will not be paid."]
NilPayment,
#[doc = "Price must be interpreted as a negative amount of currency per unit or per share."]
NegativeActualAmount,
}
impl<'a> PriceValueTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"DISC" => Self::Discount,
"PREM" => Self::Premium,
"PARV" => Self::Par,
"YIEL" => Self::Yield,
"SPRE" => Self::Spread,
"PEUN" => Self::PerUnit,
"ABSO" => Self::Absolute,
"TEDP" => Self::TedPrice,
"TEDY" => Self::TedYield,
"FICT" => Self::FixedCabinetTrade,
"VACT" => Self::VariableCabinetTrade,
"PRCT" => Self::Percentage,
"UKWN" => Self::Unknown,
"OPEN" => Self::OpenDated,
"UNSP" => Self::Unspecified,
"TBSP" => Self::ToBeSpecified,
"ACTU" => Self::ActualAmount,
"NILP" => Self::NilPayment,
"NEGA" => Self::NegativeActualAmount,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the dates related to the underlying individual transaction."]
pub struct TransactionDates3<'a> {
#[doc = "Point in time when the payment order from the initiating party meets the processing conditions of the account servicing agent. This means that the account servicing agent has received the payment order and has applied checks such as authorisation, availability of funds."]
pub acceptance_date_time: Option<IsoDateTime>,
#[doc = "Identifies when an amount of money should have contractually been credited or debited the account versus when the amount of money was actually settled (debited/credited) on the cash account."]
pub trade_activity_contractual_settlement_date: Option<IsoDate>,
#[doc = "Date on which the trade was executed."]
pub trade_date: Option<IsoDate>,
#[doc = "Date on which the amount of money ceases to be available to the agent that owes it and when the amount of money becomes available to the agent to which it is due."]
pub interbank_settlement_date: Option<IsoDate>,
#[doc = "Start date of the underlying transaction, such as a treasury transaction, an investment plan."]
pub start_date: Option<IsoDate>,
#[doc = "End date of the underlying transaction, such as a treasury transaction, an investment plan."]
pub end_date: Option<IsoDate>,
#[doc = "Date and time of the underlying transaction."]
pub transaction_date_time: Option<IsoDateTime>,
#[doc = "Proprietary date related to the underlying transaction."]
pub proprietary: Vec<ProprietaryDate3<'a>>,
}
impl<'a> TransactionDates3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let acceptance_date_time =
reader.parse_optional_element("AccptncDtTm", <IsoDateTime>::parse)?;
let trade_activity_contractual_settlement_date =
reader.parse_optional_element("TradActvtyCtrctlSttlmDt", <IsoDate>::parse)?;
let trade_date = reader.parse_optional_element("TradDt", <IsoDate>::parse)?;
let interbank_settlement_date =
reader.parse_optional_element("IntrBkSttlmDt", <IsoDate>::parse)?;
let start_date = reader.parse_optional_element("StartDt", <IsoDate>::parse)?;
let end_date = reader.parse_optional_element("EndDt", <IsoDate>::parse)?;
let transaction_date_time =
reader.parse_optional_element("TxDtTm", <IsoDateTime>::parse)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryDate3<'a>>::parse)?;
Ok(Self {
acceptance_date_time,
trade_activity_contractual_settlement_date,
trade_date,
interbank_settlement_date,
start_date,
end_date,
transaction_date_time,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a proprietary date."]
pub struct ProprietaryDate3<'a> {
#[doc = "Specifies the type of date."]
pub r#type: Max35Text<'a>,
#[doc = "Date in ISO format."]
pub date: DateAndDateTime2Choice,
}
impl<'a> ProprietaryDate3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let date = reader.parse_element("Dt", <DateAndDateTime2Choice>::parse)?;
Ok(Self { r#type, date })
}
}
#[derive(Clone, Debug)]
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system."]
pub struct RemittanceInformation16<'a> {
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in an unstructured form."]
pub unstructured: Vec<Max140Text<'a>>,
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in a structured form."]
pub structured: Vec<StructuredRemittanceInformation16<'a>>,
}
impl<'a> RemittanceInformation16<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let unstructured = reader.parse_list("Ustrd", <Max140Text<'a>>::parse)?;
let structured =
reader.parse_list("Strd", <StructuredRemittanceInformation16<'a>>::parse)?;
Ok(Self {
unstructured,
structured,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in a structured form."]
pub struct StructuredRemittanceInformation16<'a> {
#[doc = "Provides the identification and the content of the referred document."]
pub referred_document_information: Vec<ReferredDocumentInformation7<'a>>,
#[doc = "Provides details on the amounts of the referred document."]
pub referred_document_amount: Option<RemittanceAmount2<'a>>,
#[doc = "Reference information provided by the creditor to allow the identification of the underlying documents."]
pub creditor_reference_information: Option<CreditorReferenceInformation2<'a>>,
#[doc = "Identification of the organisation issuing the invoice, when it is different from the creditor or ultimate creditor."]
pub invoicer: Option<PartyIdentification135<'a>>,
#[doc = "Identification of the party to whom an invoice is issued, when it is different from the debtor or ultimate debtor."]
pub invoicee: Option<PartyIdentification135<'a>>,
#[doc = "Provides remittance information about a payment made for tax-related purposes."]
pub tax_remittance: Option<TaxInformation7<'a>>,
#[doc = "Provides remittance information about a payment for garnishment-related purposes."]
pub garnishment_remittance: Option<Garnishment3<'a>>,
#[doc = "Additional information, in free text form, to complement the structured remittance information."]
pub additional_remittance_information: Vec<Max140Text<'a>>,
}
impl<'a> StructuredRemittanceInformation16<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let referred_document_information =
reader.parse_list("RfrdDocInf", <ReferredDocumentInformation7<'a>>::parse)?;
let referred_document_amount =
reader.parse_optional_element("RfrdDocAmt", <RemittanceAmount2<'a>>::parse)?;
let creditor_reference_information = reader
.parse_optional_element("CdtrRefInf", <CreditorReferenceInformation2<'a>>::parse)?;
let invoicer =
reader.parse_optional_element("Invcr", <PartyIdentification135<'a>>::parse)?;
let invoicee =
reader.parse_optional_element("Invcee", <PartyIdentification135<'a>>::parse)?;
let tax_remittance =
reader.parse_optional_element("TaxRmt", <TaxInformation7<'a>>::parse)?;
let garnishment_remittance =
reader.parse_optional_element("GrnshmtRmt", <Garnishment3<'a>>::parse)?;
let additional_remittance_information =
reader.parse_list("AddtlRmtInf", <Max140Text<'a>>::parse)?;
Ok(Self {
referred_document_information,
referred_document_amount,
creditor_reference_information,
invoicer,
invoicee,
tax_remittance,
garnishment_remittance,
additional_remittance_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides remittance information about a payment for garnishment-related purposes."]
pub struct Garnishment3<'a> {
#[doc = "Specifies the type of garnishment."]
pub r#type: GarnishmentType1<'a>,
#[doc = "Ultimate party that owes an amount of money to the (ultimate) creditor, in this case, to the garnisher."]
pub garnishee: Option<PartyIdentification135<'a>>,
#[doc = "Party on the credit side of the transaction who administers the garnishment on behalf of the ultimate beneficiary."]
pub garnishment_administrator: Option<PartyIdentification135<'a>>,
#[doc = "Reference information that is specific to the agency receiving the garnishment."]
pub reference_number: Option<Max140Text<'a>>,
#[doc = "Date of payment which garnishment was taken from."]
pub date: Option<IsoDate>,
#[doc = "Amount of money remitted for the referred document."]
pub remitted_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Indicates if the person to whom the garnishment applies (that is, the ultimate debtor) has family medical insurance coverage available."]
pub family_medical_insurance_indicator: Option<TrueFalseIndicator>,
#[doc = "Indicates if the employment of the person to whom the garnishment applies (that is, the ultimate debtor) has been terminated."]
pub employee_termination_indicator: Option<TrueFalseIndicator>,
}
impl<'a> Garnishment3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <GarnishmentType1<'a>>::parse)?;
let garnishee =
reader.parse_optional_element("Grnshee", <PartyIdentification135<'a>>::parse)?;
let garnishment_administrator =
reader.parse_optional_element("GrnshmtAdmstr", <PartyIdentification135<'a>>::parse)?;
let reference_number = reader.parse_optional_element("RefNb", <Max140Text<'a>>::parse)?;
let date = reader.parse_optional_element("Dt", <IsoDate>::parse)?;
let remitted_amount =
reader.parse_optional_element("RmtdAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let family_medical_insurance_indicator =
reader.parse_optional_element("FmlyMdclInsrncInd", <TrueFalseIndicator>::parse)?;
let employee_termination_indicator =
reader.parse_optional_element("MplyeeTermntnInd", <TrueFalseIndicator>::parse)?;
Ok(Self {
r#type,
garnishee,
garnishment_administrator,
reference_number,
date,
remitted_amount,
family_medical_insurance_indicator,
employee_termination_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of garnishment."]
pub struct GarnishmentType1<'a> {
#[doc = "Provides the type details of the garnishment."]
pub code_or_proprietary: GarnishmentType1Choice<'a>,
#[doc = "Identification of the issuer of the garnishment type."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GarnishmentType1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <GarnishmentType1Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of garnishment."]
pub enum GarnishmentType1Choice<'a> {
#[doc = "Garnishment type in a coded form.\r\nWould suggest this to be an External Code List to contain:\r\nGNCS\u{a0}\u{a0}\u{a0} Garnishment from a third party payer for Child Support\r\nGNDP\u{a0}\u{a0}\u{a0} Garnishment from a Direct Payer for Child Support\r\nGTPP\u{a0}\u{a0}\u{a0}\u{a0} Garnishment from a third party payer to taxing agency."]
Code(ExternalGarnishmentType1Code),
#[doc = "Proprietary identification of the type of garnishment."]
Proprietary(Max35Text<'a>),
}
impl<'a> GarnishmentType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalGarnishmentType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalGarnishmentType1Code;
#[derive(Clone, Debug)]
#[doc = "Details about tax paid, or to be paid, to the government in accordance with the law, including pre-defined parameters such as thresholds and type of account."]
pub struct TaxInformation7<'a> {
#[doc = "Party on the credit side of the transaction to which the tax applies."]
pub creditor: Option<TaxParty1<'a>>,
#[doc = "Identifies the party on the debit side of the transaction to which the tax applies."]
pub debtor: Option<TaxParty2<'a>>,
#[doc = "Ultimate party that owes an amount of money to the (ultimate) creditor, in this case, to the taxing authority."]
pub ultimate_debtor: Option<TaxParty2<'a>>,
#[doc = "Territorial part of a country to which the tax payment is related."]
pub administration_zone: Option<Max35Text<'a>>,
#[doc = "Tax reference information that is specific to a taxing agency."]
pub reference_number: Option<Max140Text<'a>>,
#[doc = "Method used to indicate the underlying business or how the tax is paid."]
pub method: Option<Max35Text<'a>>,
#[doc = "Total amount of money on which the tax is based."]
pub total_taxable_base_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Total amount of money as result of the calculation of the tax."]
pub total_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Date by which tax is due."]
pub date: Option<IsoDate>,
#[doc = "Sequential number of the tax report."]
pub sequence_number: Option<Number>,
#[doc = "Record of tax details."]
pub record: Vec<TaxRecord2<'a>>,
}
impl<'a> TaxInformation7<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let creditor = reader.parse_optional_element("Cdtr", <TaxParty1<'a>>::parse)?;
let debtor = reader.parse_optional_element("Dbtr", <TaxParty2<'a>>::parse)?;
let ultimate_debtor = reader.parse_optional_element("UltmtDbtr", <TaxParty2<'a>>::parse)?;
let administration_zone =
reader.parse_optional_element("AdmstnZone", <Max35Text<'a>>::parse)?;
let reference_number = reader.parse_optional_element("RefNb", <Max140Text<'a>>::parse)?;
let method = reader.parse_optional_element("Mtd", <Max35Text<'a>>::parse)?;
let total_taxable_base_amount = reader.parse_optional_element(
"TtlTaxblBaseAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let total_tax_amount = reader
.parse_optional_element("TtlTaxAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let date = reader.parse_optional_element("Dt", <IsoDate>::parse)?;
let sequence_number = reader.parse_optional_element("SeqNb", <Number>::parse)?;
let record = reader.parse_list("Rcrd", <TaxRecord2<'a>>::parse)?;
Ok(Self {
creditor,
debtor,
ultimate_debtor,
administration_zone,
reference_number,
method,
total_taxable_base_amount,
total_tax_amount,
date,
sequence_number,
record,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the tax record."]
pub struct TaxRecord2<'a> {
#[doc = "High level code to identify the type of tax details."]
pub r#type: Option<Max35Text<'a>>,
#[doc = "Specifies the tax code as published by the tax authority."]
pub category: Option<Max35Text<'a>>,
#[doc = "Provides further details of the category tax code."]
pub category_details: Option<Max35Text<'a>>,
#[doc = "Code provided by local authority to identify the status of the party that has drawn up the settlement document."]
pub debtor_status: Option<Max35Text<'a>>,
#[doc = "Identification number of the tax report as assigned by the taxing authority."]
pub certificate_identification: Option<Max35Text<'a>>,
#[doc = "Identifies, in a coded form, on which template the tax report is to be provided."]
pub forms_code: Option<Max35Text<'a>>,
#[doc = "Set of elements used to provide details on the period of time related to the tax payment."]
pub period: Option<TaxPeriod2>,
#[doc = "Set of elements used to provide information on the amount of the tax record."]
pub tax_amount: Option<TaxAmount2>,
#[doc = "Further details of the tax record."]
pub additional_information: Option<Max140Text<'a>>,
}
impl<'a> TaxRecord2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <Max35Text<'a>>::parse)?;
let category = reader.parse_optional_element("Ctgy", <Max35Text<'a>>::parse)?;
let category_details = reader.parse_optional_element("CtgyDtls", <Max35Text<'a>>::parse)?;
let debtor_status = reader.parse_optional_element("DbtrSts", <Max35Text<'a>>::parse)?;
let certificate_identification =
reader.parse_optional_element("CertId", <Max35Text<'a>>::parse)?;
let forms_code = reader.parse_optional_element("FrmsCd", <Max35Text<'a>>::parse)?;
let period = reader.parse_optional_element("Prd", <TaxPeriod2>::parse)?;
let tax_amount = reader.parse_optional_element("TaxAmt", <TaxAmount2>::parse)?;
let additional_information =
reader.parse_optional_element("AddtlInf", <Max140Text<'a>>::parse)?;
Ok(Self {
r#type,
category,
category_details,
debtor_status,
certificate_identification,
forms_code,
period,
tax_amount,
additional_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the tax amount(s) of tax record."]
pub struct TaxAmount2 {
#[doc = "Rate used to calculate the tax."]
pub rate: Option<PercentageRate>,
#[doc = "Amount of money on which the tax is based."]
pub taxable_base_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Total amount that is the result of the calculation of the tax for the record."]
pub total_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Set of elements used to provide details on the tax period and amount."]
pub details: Vec<TaxRecordDetails2>,
}
impl<'a> TaxAmount2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let rate = reader.parse_optional_element("Rate", <PercentageRate>::parse)?;
let taxable_base_amount = reader
.parse_optional_element("TaxblBaseAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let total_amount =
reader.parse_optional_element("TtlAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let details = reader.parse_list("Dtls", <TaxRecordDetails2>::parse)?;
Ok(Self {
rate,
taxable_base_amount,
total_amount,
details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides information on the individual tax amount(s) per period of the tax record."]
pub struct TaxRecordDetails2 {
#[doc = "Set of elements used to provide details on the period of time related to the tax payment."]
pub period: Option<TaxPeriod2>,
#[doc = "Underlying tax amount related to the specified period."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
}
impl<'a> TaxRecordDetails2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let period = reader.parse_optional_element("Prd", <TaxPeriod2>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { period, amount })
}
}
#[derive(Clone, Debug)]
#[doc = "Period of time details related to the tax payment."]
pub struct TaxPeriod2 {
#[doc = "Year related to the tax payment."]
pub year: Option<IsoDate>,
#[doc = "Identification of the period related to the tax payment."]
pub r#type: Option<TaxRecordPeriod1Code>,
#[doc = "Range of time between a start date and an end date for which the tax report is provided."]
pub from_to_date: Option<DatePeriod2>,
}
impl<'a> TaxPeriod2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let year = reader.parse_optional_element("Yr", <IsoDate>::parse)?;
let r#type = reader.parse_optional_element("Tp", <TaxRecordPeriod1Code>::parse)?;
let from_to_date = reader.parse_optional_element("FrToDt", <DatePeriod2>::parse)?;
Ok(Self {
year,
r#type,
from_to_date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Nature of the amount and currency on a document referred to in the remittance section, typically either the original amount due/payable or the amount actually remitted for the referenced document."]
pub struct RemittanceAmount2<'a> {
#[doc = "Amount specified is the exact amount due and payable to the creditor."]
pub due_payable_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Amount specified for the referred document is the amount of discount to be applied to the amount due and payable to the creditor."]
pub discount_applied_amount: Vec<DiscountAmountAndType1<'a>>,
#[doc = "Amount specified for the referred document is the amount of a credit note."]
pub credit_note_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Quantity of cash resulting from the calculation of the tax."]
pub tax_amount: Vec<TaxAmountAndType1<'a>>,
#[doc = "Specifies detailed information on the amount and reason of the document adjustment."]
pub adjustment_amount_and_reason: Vec<DocumentAdjustment1<'a>>,
#[doc = "Amount of money remitted for the referred document."]
pub remitted_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
}
impl<'a> RemittanceAmount2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let due_payable_amount = reader
.parse_optional_element("DuePyblAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let discount_applied_amount =
reader.parse_list("DscntApldAmt", <DiscountAmountAndType1<'a>>::parse)?;
let credit_note_amount = reader
.parse_optional_element("CdtNoteAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let tax_amount = reader.parse_list("TaxAmt", <TaxAmountAndType1<'a>>::parse)?;
let adjustment_amount_and_reason =
reader.parse_list("AdjstmntAmtAndRsn", <DocumentAdjustment1<'a>>::parse)?;
let remitted_amount =
reader.parse_optional_element("RmtdAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self {
due_payable_amount,
discount_applied_amount,
credit_note_amount,
tax_amount,
adjustment_amount_and_reason,
remitted_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the documents referred to in the remittance information."]
pub struct ReferredDocumentInformation7<'a> {
#[doc = "Specifies the type of referred document."]
pub r#type: Option<ReferredDocumentType4<'a>>,
#[doc = "Unique and unambiguous identification of the referred document."]
pub number: Option<Max35Text<'a>>,
#[doc = "Date associated with the referred document."]
pub related_date: Option<IsoDate>,
#[doc = "Set of elements used to provide the content of the referred document line."]
pub line_details: Vec<DocumentLineInformation1<'a>>,
}
impl<'a> ReferredDocumentInformation7<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <ReferredDocumentType4<'a>>::parse)?;
let number = reader.parse_optional_element("Nb", <Max35Text<'a>>::parse)?;
let related_date = reader.parse_optional_element("RltdDt", <IsoDate>::parse)?;
let line_details = reader.parse_list("LineDtls", <DocumentLineInformation1<'a>>::parse)?;
Ok(Self {
r#type,
number,
related_date,
line_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides document line information.\r\n"]
pub struct DocumentLineInformation1<'a> {
#[doc = "Provides identification of the document line."]
pub identification: Vec<DocumentLineIdentification1<'a>>,
#[doc = "Description associated with the document line."]
pub description: Option<Max2048Text<'a>>,
#[doc = "Provides details on the amounts of the document line."]
pub amount: Option<RemittanceAmount3<'a>>,
}
impl<'a> DocumentLineInformation1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_list("Id", <DocumentLineIdentification1<'a>>::parse)?;
let description = reader.parse_optional_element("Desc", <Max2048Text<'a>>::parse)?;
let amount = reader.parse_optional_element("Amt", <RemittanceAmount3<'a>>::parse)?;
Ok(Self {
identification,
description,
amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Nature of the amount and currency on a document referred to in the remittance section, typically either the original amount due/payable or the amount actually remitted for the referenced document."]
pub struct RemittanceAmount3<'a> {
#[doc = "Amount specified is the exact amount due and payable to the creditor."]
pub due_payable_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Amount of discount to be applied to the amount due and payable to the creditor."]
pub discount_applied_amount: Vec<DiscountAmountAndType1<'a>>,
#[doc = "Amount of a credit note."]
pub credit_note_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Amount of the tax."]
pub tax_amount: Vec<TaxAmountAndType1<'a>>,
#[doc = "Specifies detailed information on the amount and reason of the adjustment."]
pub adjustment_amount_and_reason: Vec<DocumentAdjustment1<'a>>,
#[doc = "Amount of money remitted."]
pub remitted_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
}
impl<'a> RemittanceAmount3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let due_payable_amount = reader
.parse_optional_element("DuePyblAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let discount_applied_amount =
reader.parse_list("DscntApldAmt", <DiscountAmountAndType1<'a>>::parse)?;
let credit_note_amount = reader
.parse_optional_element("CdtNoteAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let tax_amount = reader.parse_list("TaxAmt", <TaxAmountAndType1<'a>>::parse)?;
let adjustment_amount_and_reason =
reader.parse_list("AdjstmntAmtAndRsn", <DocumentAdjustment1<'a>>::parse)?;
let remitted_amount =
reader.parse_optional_element("RmtdAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self {
due_payable_amount,
discount_applied_amount,
credit_note_amount,
tax_amount,
adjustment_amount_and_reason,
remitted_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the amount with a specific type."]
pub struct TaxAmountAndType1<'a> {
#[doc = "Specifies the type of the amount."]
pub r#type: Option<TaxAmountType1Choice<'a>>,
#[doc = "Amount of money, which has been typed."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
}
impl<'a> TaxAmountAndType1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <TaxAmountType1Choice<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { r#type, amount })
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the amount type."]
pub enum TaxAmountType1Choice<'a> {
#[doc = "Specifies the amount type, in a coded form."]
Code(ExternalTaxAmountType1Code),
#[doc = "Specifies the amount type, in a free-text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> TaxAmountType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalTaxAmountType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalTaxAmountType1Code;
#[derive(Clone, Debug)]
#[doc = "Specifies the amount with a specific type."]
pub struct DiscountAmountAndType1<'a> {
#[doc = "Specifies the type of the amount."]
pub r#type: Option<DiscountAmountType1Choice<'a>>,
#[doc = "Amount of money, which has been typed."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
}
impl<'a> DiscountAmountAndType1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <DiscountAmountType1Choice<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { r#type, amount })
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the amount type."]
pub enum DiscountAmountType1Choice<'a> {
#[doc = "Specifies the amount type, in a coded form."]
Code(ExternalDiscountAmountType1Code),
#[doc = "Specifies the amount type, in a free-text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> DiscountAmountType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalDiscountAmountType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalDiscountAmountType1Code;
#[derive(Clone, Debug)]
#[doc = "Identifies the documents referred to in the remittance information."]
pub struct DocumentLineIdentification1<'a> {
#[doc = "Specifies the type of referred document line identification."]
pub r#type: Option<DocumentLineType1<'a>>,
#[doc = "Identification of the type specified for the referred document line."]
pub number: Option<Max35Text<'a>>,
#[doc = "Date associated with the referred document line."]
pub related_date: Option<IsoDate>,
}
impl<'a> DocumentLineIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <DocumentLineType1<'a>>::parse)?;
let number = reader.parse_optional_element("Nb", <Max35Text<'a>>::parse)?;
let related_date = reader.parse_optional_element("RltdDt", <IsoDate>::parse)?;
Ok(Self {
r#type,
number,
related_date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document line identification."]
pub struct DocumentLineType1<'a> {
#[doc = "Provides the type details of the referred document line identification."]
pub code_or_proprietary: DocumentLineType1Choice<'a>,
#[doc = "Identification of the issuer of the reference document line identificationtype."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> DocumentLineType1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <DocumentLineType1Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document line identification."]
pub enum DocumentLineType1Choice<'a> {
#[doc = "Line identification type in a coded form."]
Code(ExternalDocumentLineType1Code),
#[doc = "Proprietary identification of the type of the remittance document."]
Proprietary(Max35Text<'a>),
}
impl<'a> DocumentLineType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalDocumentLineType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalDocumentLineType1Code;
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document referred in the remittance information."]
pub struct ReferredDocumentType4<'a> {
#[doc = "Provides the type details of the referred document."]
pub code_or_proprietary: ReferredDocumentType3Choice<'a>,
#[doc = "Identification of the issuer of the reference document type."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> ReferredDocumentType4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <ReferredDocumentType3Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document referred in the remittance information."]
pub enum ReferredDocumentType3Choice<'a> {
#[doc = "Document type in a coded form."]
Code(DocumentType6Code),
#[doc = "Proprietary identification of the type of the remittance document."]
Proprietary(Max35Text<'a>),
}
impl<'a> ReferredDocumentType3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <DocumentType6Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type DocumentType6Code = DocumentTypeCode;
#[derive(Clone, Debug)]
#[doc = "Provides information on the remittance advice."]
pub struct RemittanceLocation7<'a> {
#[doc = "Unique identification, as assigned by the initiating party, to unambiguously identify the remittance information sent separately from the payment instruction, such as a remittance advice."]
pub remittance_identification: Option<Max35Text<'a>>,
#[doc = "Set of elements used to provide information on the location and/or delivery of the remittance information."]
pub remittance_location_details: Vec<RemittanceLocationData1<'a>>,
}
impl<'a> RemittanceLocation7<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let remittance_identification =
reader.parse_optional_element("RmtId", <Max35Text<'a>>::parse)?;
let remittance_location_details =
reader.parse_list("RmtLctnDtls", <RemittanceLocationData1<'a>>::parse)?;
Ok(Self {
remittance_identification,
remittance_location_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides additional details on the remittance advice."]
pub struct RemittanceLocationData1<'a> {
#[doc = "Method used to deliver the remittance advice information."]
pub method: RemittanceLocationMethod2Code,
#[doc = "Electronic address to which an agent is to send the remittance information."]
pub electronic_address: Option<Max2048Text<'a>>,
#[doc = "Postal address to which an agent is to send the remittance information."]
pub postal_address: Option<NameAndAddress16<'a>>,
}
impl<'a> RemittanceLocationData1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let method = reader.parse_element("Mtd", <RemittanceLocationMethod2Code>::parse)?;
let electronic_address =
reader.parse_optional_element("ElctrncAdr", <Max2048Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <NameAndAddress16<'a>>::parse)?;
Ok(Self {
method,
electronic_address,
postal_address,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a party."]
pub struct NameAndAddress16<'a> {
#[doc = "Name by which a party is known and is usually used to identify that party."]
pub name: Max140Text<'a>,
#[doc = "Postal address of a party."]
pub address: PostalAddress24<'a>,
}
impl<'a> NameAndAddress16<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name = reader.parse_element("Nm", <Max140Text<'a>>::parse)?;
let address = reader.parse_element("Adr", <PostalAddress24<'a>>::parse)?;
Ok(Self { name, address })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements that further identifies the type of local instruments being requested by the initiating party."]
pub enum LocalInstrument2Choice<'a> {
#[doc = "Specifies the local instrument, as published in an external local instrument code list."]
Code(ExternalLocalInstrument1Code),
#[doc = "Specifies the local instrument, as a proprietary code."]
Proprietary(Max35Text<'a>),
}
impl<'a> LocalInstrument2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalLocalInstrument1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalLocalInstrument1Code;
#[derive(Clone, Debug)]
#[doc = "Provides further details on the agents specific to the individual transaction."]
pub struct TransactionAgents5<'a> {
#[doc = "Agent that instructs the next party in the chain to carry out the (set of) instruction(s)."]
pub instructing_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Agent that is instructed by the previous party in the chain to carry out the (set of) instruction(s)."]
pub instructed_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Financial institution servicing an account for the debtor."]
pub debtor_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Financial institution servicing an account for the creditor."]
pub creditor_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If more than one intermediary agent is present, then IntermediaryAgent1 identifies the agent between the DebtorAgent and the IntermediaryAgent2."]
pub intermediary_agent1: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If more than two intermediary agents are present, then IntermediaryAgent2 identifies the agent between the IntermediaryAgent1 and the IntermediaryAgent3."]
pub intermediary_agent2: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If IntermediaryAgent3 is present, then it identifies the agent between the IntermediaryAgent 2 and the CreditorAgent."]
pub intermediary_agent3: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Party that receives securities from the delivering agent at the place of settlement, such as central securities depository.\nCan also be used in the context of treasury operations."]
pub receiving_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Party that delivers securities to the receiving agent at the place of settlement, such as a central securities depository.\nCan also be used in the context of treasury operations."]
pub delivering_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Legal entity that has the right to issue securities."]
pub issuing_agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Place where settlement of the securities takes place.\nUsage: This is typed by a financial institution identification as this is the standard way to identify a securities settlement agent/central system."]
pub settlement_place: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Proprietary agent related to the underlying transaction."]
pub proprietary: Vec<ProprietaryAgent4<'a>>,
}
impl<'a> TransactionAgents5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let instructing_agent = reader.parse_optional_element(
"InstgAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let instructed_agent = reader.parse_optional_element(
"InstdAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let debtor_agent = reader.parse_optional_element(
"DbtrAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let creditor_agent = reader.parse_optional_element(
"CdtrAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let intermediary_agent1 = reader.parse_optional_element(
"IntrmyAgt1",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let intermediary_agent2 = reader.parse_optional_element(
"IntrmyAgt2",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let intermediary_agent3 = reader.parse_optional_element(
"IntrmyAgt3",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let receiving_agent = reader.parse_optional_element(
"RcvgAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let delivering_agent = reader.parse_optional_element(
"DlvrgAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let issuing_agent = reader.parse_optional_element(
"IssgAgt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let settlement_place = reader.parse_optional_element(
"SttlmPlc",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryAgent4<'a>>::parse)?;
Ok(Self {
instructing_agent,
instructed_agent,
debtor_agent,
creditor_agent,
intermediary_agent1,
intermediary_agent2,
intermediary_agent3,
receiving_agent,
delivering_agent,
issuing_agent,
settlement_place,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Identifies a proprietary party."]
pub struct ProprietaryAgent4<'a> {
#[doc = "Specifies the type of proprietary agent."]
pub r#type: Max35Text<'a>,
#[doc = "Organisation established primarily to provide financial services."]
pub agent: BranchAndFinancialInstitutionIdentification6<'a>,
}
impl<'a> ProprietaryAgent4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let agent = reader.parse_element(
"Agt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
Ok(Self { r#type, agent })
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details on the parties specific to the individual transaction."]
pub struct TransactionParties6<'a> {
#[doc = "Party that initiated the payment that is reported in the entry."]
pub initiating_party: Option<Party40Choice<'a>>,
#[doc = "Party that owes an amount of money to the (ultimate) creditor."]
pub debtor: Option<Party40Choice<'a>>,
#[doc = "Unambiguous identification of the account of the debtor."]
pub debtor_account: Option<CashAccount38<'a>>,
#[doc = "Ultimate party that owes an amount of money to the (ultimate) creditor."]
pub ultimate_debtor: Option<Party40Choice<'a>>,
#[doc = "Party to which an amount of money is due."]
pub creditor: Option<Party40Choice<'a>>,
#[doc = "Unambiguous identification of the account of the creditor to which a credit entry has been posted as a result of the payment transaction."]
pub creditor_account: Option<CashAccount38<'a>>,
#[doc = "Ultimate party to which an amount of money is due."]
pub ultimate_creditor: Option<Party40Choice<'a>>,
#[doc = "Party that plays an active role in planning and executing the transactions that create or liquidate investments of the investors assets, or that move the investor's assets from one investment to another. A trading party is a trade instructor, an investment decision-maker, a post trade administrator, or a trader. In the context of treasury, it is the party that negotiates and executes the treasury transaction."]
pub trading_party: Option<Party40Choice<'a>>,
#[doc = "Proprietary party related to the underlying transaction."]
pub proprietary: Vec<ProprietaryParty5<'a>>,
}
impl<'a> TransactionParties6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let initiating_party =
reader.parse_optional_element("InitgPty", <Party40Choice<'a>>::parse)?;
let debtor = reader.parse_optional_element("Dbtr", <Party40Choice<'a>>::parse)?;
let debtor_account =
reader.parse_optional_element("DbtrAcct", <CashAccount38<'a>>::parse)?;
let ultimate_debtor =
reader.parse_optional_element("UltmtDbtr", <Party40Choice<'a>>::parse)?;
let creditor = reader.parse_optional_element("Cdtr", <Party40Choice<'a>>::parse)?;
let creditor_account =
reader.parse_optional_element("CdtrAcct", <CashAccount38<'a>>::parse)?;
let ultimate_creditor =
reader.parse_optional_element("UltmtCdtr", <Party40Choice<'a>>::parse)?;
let trading_party =
reader.parse_optional_element("TradgPty", <Party40Choice<'a>>::parse)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryParty5<'a>>::parse)?;
Ok(Self {
initiating_party,
debtor,
debtor_account,
ultimate_debtor,
creditor,
creditor_account,
ultimate_creditor,
trading_party,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Identifies a proprietary party."]
pub struct ProprietaryParty5<'a> {
#[doc = "Specifies the type of proprietary party."]
pub r#type: Max35Text<'a>,
#[doc = "Proprietary party."]
pub party: Party40Choice<'a>,
}
impl<'a> ProprietaryParty5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let party = reader.parse_element("Pty", <Party40Choice<'a>>::parse)?;
Ok(Self { r#type, party })
}
}
#[derive(Clone, Debug)]
#[doc = "Identification of a person, an organisation or a financial institution."]
pub enum Party40Choice<'a> {
#[doc = "Identification of a person or an organisation."]
Party(PartyIdentification135<'a>),
#[doc = "Identification of a financial institution."]
Agent(BranchAndFinancialInstitutionIdentification6<'a>),
}
impl<'a> Party40Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Pty".as_bytes() => {
let inner = reader.parse_element("Pty", <PartyIdentification135<'a>>::parse)?;
Self::Party(inner)
}
name if name == "Agt".as_bytes() => {
let inner = reader.parse_element(
"Agt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
Self::Agent(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Identifies the underlying transaction."]
pub struct TransactionReferences6<'a> {
#[doc = "Point to point reference, as assigned by the instructing party of the underlying message."]
pub message_identification: Option<Max35Text<'a>>,
#[doc = "Unique reference, as assigned by the account servicing institution, to unambiguously identify the instruction."]
pub account_servicer_reference: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by a sending party, to unambiguously identify the payment information group within the message."]
pub payment_information_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by an instructing party for an instructed party, to unambiguously identify the instruction.\n\nUsage: The instruction identification is a point to point reference that can be used between the instructing party and the instructed party to refer to the individual instruction. It can be included in several messages related to the instruction."]
pub instruction_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by the initiating party, to unambiguously identify the transaction. This identification is passed on, unchanged, throughout the entire end-to-end chain.\n\nUsage: The end-to-end identification can be used for reconciliation or to link tasks relating to the transaction. It can be included in several messages related to the transaction.\n\nUsage: In case there are technical limitations to pass on multiple references, the end-to-end identification must be passed on throughout the entire end-to-end chain."]
pub end_to_end_identification: Option<Max35Text<'a>>,
#[doc = "Universally unique identifier to provide an end-to-end reference of a payment transaction."]
pub uetr: Option<UuidV4Identifier>,
#[doc = "Unique identification, as assigned by the first instructing agent, to unambiguously identify the transaction that is passed on, unchanged, throughout the entire interbank chain. \nUsage: The transaction identification can be used for reconciliation, tracking or to link tasks relating to the transaction on the interbank level. \nUsage: The instructing agent has to make sure that the transaction identification is unique for a pre-agreed period."]
pub transaction_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by the creditor, to unambiguously identify the mandate."]
pub mandate_identification: Option<Max35Text<'a>>,
#[doc = "Unique and unambiguous identifier for a cheque as assigned by the agent."]
pub cheque_number: Option<Max35Text<'a>>,
#[doc = "Unique reference, as assigned by a clearing system, to unambiguously identify the instruction.\nUsage: In case there are technical limitations to pass on multiple references, the end-to-end identification must be passed on throughout the entire end-to-end chain."]
pub clearing_system_reference: Option<Max35Text<'a>>,
#[doc = "Unambiguous identification of the securities transaction as known by the securities account owner (or the instructing party managing the account)."]
pub account_owner_transaction_identification: Option<Max35Text<'a>>,
#[doc = "Unambiguous identification of the securities transaction as known by the securities account servicer."]
pub account_servicer_transaction_identification: Option<Max35Text<'a>>,
#[doc = "Identification of a securities transaction assigned by a market infrastructure other than a central securities depository, for example, Target2-Securities."]
pub market_infrastructure_transaction_identification: Option<Max35Text<'a>>,
#[doc = "Identification of the securities transaction assigned by the processor of the instruction other than the securities account owner, the securities account servicer and the market infrastructure."]
pub processing_identification: Option<Max35Text<'a>>,
#[doc = "Proprietary reference related to the underlying transaction."]
pub proprietary: Vec<ProprietaryReference1<'a>>,
}
impl<'a> TransactionReferences6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification =
reader.parse_optional_element("MsgId", <Max35Text<'a>>::parse)?;
let account_servicer_reference =
reader.parse_optional_element("AcctSvcrRef", <Max35Text<'a>>::parse)?;
let payment_information_identification =
reader.parse_optional_element("PmtInfId", <Max35Text<'a>>::parse)?;
let instruction_identification =
reader.parse_optional_element("InstrId", <Max35Text<'a>>::parse)?;
let end_to_end_identification =
reader.parse_optional_element("EndToEndId", <Max35Text<'a>>::parse)?;
let uetr = reader.parse_optional_element("UETR", <UuidV4Identifier>::parse)?;
let transaction_identification =
reader.parse_optional_element("TxId", <Max35Text<'a>>::parse)?;
let mandate_identification =
reader.parse_optional_element("MndtId", <Max35Text<'a>>::parse)?;
let cheque_number = reader.parse_optional_element("ChqNb", <Max35Text<'a>>::parse)?;
let clearing_system_reference =
reader.parse_optional_element("ClrSysRef", <Max35Text<'a>>::parse)?;
let account_owner_transaction_identification =
reader.parse_optional_element("AcctOwnrTxId", <Max35Text<'a>>::parse)?;
let account_servicer_transaction_identification =
reader.parse_optional_element("AcctSvcrTxId", <Max35Text<'a>>::parse)?;
let market_infrastructure_transaction_identification =
reader.parse_optional_element("MktInfrstrctrTxId", <Max35Text<'a>>::parse)?;
let processing_identification =
reader.parse_optional_element("PrcgId", <Max35Text<'a>>::parse)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryReference1<'a>>::parse)?;
Ok(Self {
message_identification,
account_servicer_reference,
payment_information_identification,
instruction_identification,
end_to_end_identification,
uetr,
transaction_identification,
mandate_identification,
cheque_number,
clearing_system_reference,
account_owner_transaction_identification,
account_servicer_transaction_identification,
market_infrastructure_transaction_identification,
processing_identification,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Card transaction entry."]
pub struct CardEntry4<'a> {
#[doc = "Electronic money product that provides the cardholder with a portable and specialised computer device, which typically contains a microprocessor."]
pub card: Option<PaymentCard4<'a>>,
#[doc = "Physical or logical card payment terminal containing software and hardware components."]
pub poi: Option<PointOfInteraction1<'a>>,
#[doc = "Card entry details, based on card transaction aggregated data performed by the account servicer."]
pub aggregated_entry: Option<CardAggregated2<'a>>,
#[doc = "Prepaid account for the transfer or loading of an amount of money."]
pub pre_paid_account: Option<CashAccount38<'a>>,
}
impl<'a> CardEntry4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let card = reader.parse_optional_element("Card", <PaymentCard4<'a>>::parse)?;
let poi = reader.parse_optional_element("POI", <PointOfInteraction1<'a>>::parse)?;
let aggregated_entry =
reader.parse_optional_element("AggtdNtry", <CardAggregated2<'a>>::parse)?;
let pre_paid_account =
reader.parse_optional_element("PrePdAcct", <CashAccount38<'a>>::parse)?;
Ok(Self {
card,
poi,
aggregated_entry,
pre_paid_account,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Globalised card transaction entry details."]
pub struct CardAggregated2<'a> {
#[doc = "Service in addition to the main service."]
pub additional_service: Option<CardPaymentServiceType2Code>,
#[doc = "Category code conform to ISO 18245, related to the type of services or goods the merchant provides for the transaction."]
pub transaction_category: Option<ExternalCardTransactionCategory1Code>,
#[doc = "Unique identification of the sales reconciliation period between the acceptor and the acquirer. This identification might be linked to the identification of the settlement for further verification by the merchant."]
pub sale_reconciliation_identification: Option<Max35Text<'a>>,
#[doc = "Range of sequence numbers on which the globalisation applies."]
pub sequence_number_range: Option<CardSequenceNumberRange1<'a>>,
#[doc = "Date range on which the globalisation applies."]
pub transaction_date_range: Option<DateOrDateTimePeriod1Choice>,
}
impl<'a> CardAggregated2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let additional_service =
reader.parse_optional_element("AddtlSvc", <CardPaymentServiceType2Code>::parse)?;
let transaction_category = reader
.parse_optional_element("TxCtgy", <ExternalCardTransactionCategory1Code>::parse)?;
let sale_reconciliation_identification =
reader.parse_optional_element("SaleRcncltnId", <Max35Text<'a>>::parse)?;
let sequence_number_range =
reader.parse_optional_element("SeqNbRg", <CardSequenceNumberRange1<'a>>::parse)?;
let transaction_date_range =
reader.parse_optional_element("TxDtRg", <DateOrDateTimePeriod1Choice>::parse)?;
Ok(Self {
additional_service,
transaction_category,
sale_reconciliation_identification,
sequence_number_range,
transaction_date_range,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between a date or a date and time format for a period."]
pub enum DateOrDateTimePeriod1Choice {
#[doc = "Period expressed with dates."]
Date(DatePeriod2),
#[doc = "Period expressed a dates and times."]
DateTime(DateTimePeriod1),
}
impl<'a> DateOrDateTimePeriod1Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Dt".as_bytes() => {
let inner = reader.parse_element("Dt", <DatePeriod2>::parse)?;
Self::Date(inner)
}
name if name == "DtTm".as_bytes() => {
let inner = reader.parse_element("DtTm", <DateTimePeriod1>::parse)?;
Self::DateTime(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Range of time defined by a start date and an end date."]
pub struct DatePeriod2 {
#[doc = "Start date of the range."]
pub from_date: IsoDate,
#[doc = "End date of the range."]
pub to_date: IsoDate,
}
impl<'a> DatePeriod2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_date = reader.parse_element("FrDt", <IsoDate>::parse)?;
let to_date = reader.parse_element("ToDt", <IsoDate>::parse)?;
Ok(Self { from_date, to_date })
}
}
#[derive(Clone, Debug)]
#[doc = "Range of sequence numbers related to card transactions."]
pub struct CardSequenceNumberRange1<'a> {
#[doc = "CardSequenceNumberRange1: FirstTransactionSequenceNumberMessage element to be finalised once feedback from Card SEG has been received."]
pub first_transaction: Option<Max35Text<'a>>,
#[doc = "CardSequenceNumberRange1: LastTransactionSequenceNumberMessage element to be finalised once feedback from Card SEG has been received."]
pub last_transaction: Option<Max35Text<'a>>,
}
impl<'a> CardSequenceNumberRange1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let first_transaction = reader.parse_optional_element("FrstTx", <Max35Text<'a>>::parse)?;
let last_transaction = reader.parse_optional_element("LastTx", <Max35Text<'a>>::parse)?;
Ok(Self {
first_transaction,
last_transaction,
})
}
}
pub type CardPaymentServiceType2Code = CardPaymentServiceTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Service provided by a card payment transaction."]
pub enum CardPaymentServiceTypeCode {
#[doc = "Transfer of funds to and/or from a card account."]
CardsFundTransfer,
#[doc = "Original credit."]
OriginalCredit,
#[doc = "Card payment."]
CardPayment,
#[doc = "Card payment with cash-back."]
CashBack,
#[doc = "Cash advance or withdrawals on a POI (Point Of Interaction), or at a bank counter."]
CashAdvance,
#[doc = "Cash deposit."]
CashDeposit,
#[doc = "Deferred payment."]
DeferredPayment,
#[doc = "Reservation (pre-authorisation)."]
Reservation,
#[doc = "Loading or reloading non-financial account."]
Loading,
#[doc = "Refund transaction."]
Refund,
#[doc = "Quasi-cash."]
QuasiCash,
#[doc = "Balance enquiry."]
Balance,
#[doc = "Card activation."]
CardActivation,
#[doc = "Card verification."]
CardVerification,
#[doc = "PIN (Personal Identification Number) change."]
PinChange,
#[doc = "Card validity check."]
ValidityCheck,
#[doc = "Aggregation of low payments."]
Aggregation,
#[doc = "Dynamic currency conversion (DCC)."]
Dcc,
#[doc = "Card payment with gratuity."]
Gratuity,
#[doc = "Instalment payment."]
Instalment,
#[doc = "Loyalty services."]
Loyalty,
#[doc = "No show after reservation."]
NoShow,
#[doc = "Purchase and corporate data."]
PurchaseCorporate,
#[doc = "Recurring payment."]
RecurringPayment,
#[doc = "Solicited available funds."]
SolicitedAvailableFunds,
#[doc = "Unsolicited available funds."]
UnsolicitedAvailableFunds,
#[doc = "Voice authorisation."]
VoiceAuthorisation,
#[doc = "Initial reservation."]
InitialReservation,
#[doc = "Update reservation."]
UpdateReservation,
#[doc = "Payment after reservation."]
PaymentReservation,
#[doc = "Additional payment after reservation."]
AdditionalPayment,
#[doc = "Initial recurring payment."]
FirstRecurring,
#[doc = "Repeat recurring payment."]
FollowingRecurring,
#[doc = "Card payment transaction transfer from person to business."]
PersonToBusiness,
#[doc = "Card payment transaction transfer from person to person."]
PersonToPerson,
#[doc = "Instalment payment transaction performed by the acceptor or the acquirer."]
AcceptorInstalment,
#[doc = "Instalment payment transaction performed by the card issuer."]
IssuerInstalment,
#[doc = "Unloading non-financial account."]
Unloading,
#[doc = "Transfer of funds to a card or an account."]
CardsFundTransferPush,
#[doc = "Transfer of funds from a card or an account."]
CardsFundTransferPull,
#[doc = "Withdrawal of cash on an ATM."]
CashWithdrawal,
#[doc = "Unblock the cardholder PIN."]
PinUnblock,
#[doc = "Amount and notes values are chosen by the customer."]
ChosenWithdrawal,
#[doc = "Withdrawal transaction was pre-authorised by another channel (amount could be absent)."]
PreAuthorisedWithdrawal,
#[doc = "Amount and Notes Values are pre-defined by the customer profile."]
ProfileWithdrawal,
#[doc = "Customer pressed a button associated with a withdrawal of unique amount and notes mix."]
StandardWithdrawal,
#[doc = "Transfer for payment of bills."]
TransferCardBillPayment,
#[doc = "Transfer from cash deposit."]
TransferFromCash,
#[doc = "Transfer from cheque deposit."]
TransferFromCheque,
#[doc = "Transfer for general disbursement."]
TransferFundsDisbursementGeneral,
#[doc = "Transfer for government disbursement."]
TransferGovernmentDisbursement,
#[doc = "Transfer for merchant disbursement."]
TransferMerchantDisbursement,
#[doc = "Transfer for payroll pension disbursement."]
TransferPayrollPensionDisbursement,
#[doc = "Payment of goods or services which are not refundable, for instance low cost airline tickets."]
NonRefundable,
#[doc = "Instant transaction."]
Instant,
#[doc = "Credit adjustment to a previous transaction."]
CreditAdjustement,
#[doc = "Debit adjustment to a previous transaction."]
DebitAdjustement,
#[doc = "Creation of an X.509 certificate with the public key and the information of the owner of the asymmetric key provided by the requestor."]
CreateCertificate,
#[doc = "Renewal of an X.509 certificate, protected by the certificate to renew."]
RenewCerificate,
#[doc = "Revocation of an active X.509 certificate."]
RevokeCertificate,
#[doc = "Add a POI in the white list of the terminal manager."]
AddWhiteList,
#[doc = "Remove a POI from the white list of the terminal manager."]
RemoveWhiteList,
#[doc = "Direct Debit initiated by Card."]
CardInitiatingDirectDebit,
#[doc = "Acceptor claims for guarantee of payment."]
GuaranteeOfPayment,
}
impl<'a> CardPaymentServiceTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"CAFT" => Self::CardsFundTransfer,
"ORCR" => Self::OriginalCredit,
"CRDP" => Self::CardPayment,
"CSHB" => Self::CashBack,
"CSHW" => Self::CashAdvance,
"CSHD" => Self::CashDeposit,
"DEFR" => Self::DeferredPayment,
"RESA" => Self::Reservation,
"LOAD" => Self::Loading,
"RFND" => Self::Refund,
"QUCH" => Self::QuasiCash,
"BALC" => Self::Balance,
"CACT" => Self::CardActivation,
"CAVR" => Self::CardVerification,
"PINC" => Self::PinChange,
"VALC" => Self::ValidityCheck,
"AGGR" => Self::Aggregation,
"DCCV" => Self::Dcc,
"GRTT" => Self::Gratuity,
"INSP" => Self::Instalment,
"LOYT" => Self::Loyalty,
"NRES" => Self::NoShow,
"PUCO" => Self::PurchaseCorporate,
"RECP" => Self::RecurringPayment,
"SOAF" => Self::SolicitedAvailableFunds,
"UNAF" => Self::UnsolicitedAvailableFunds,
"VCAU" => Self::VoiceAuthorisation,
"IRES" => Self::InitialReservation,
"URES" => Self::UpdateReservation,
"PRES" => Self::PaymentReservation,
"ARES" => Self::AdditionalPayment,
"FREC" => Self::FirstRecurring,
"RREC" => Self::FollowingRecurring,
"TP2B" => Self::PersonToBusiness,
"TP2P" => Self::PersonToPerson,
"INSA" => Self::AcceptorInstalment,
"INSI" => Self::IssuerInstalment,
"UNLD" => Self::Unloading,
"CAFH" => Self::CardsFundTransferPush,
"CAFL" => Self::CardsFundTransferPull,
"CHWD" => Self::CashWithdrawal,
"PINU" => Self::PinUnblock,
"CSWD" => Self::ChosenWithdrawal,
"AUWS" => Self::PreAuthorisedWithdrawal,
"PFWD" => Self::ProfileWithdrawal,
"SDWD" => Self::StandardWithdrawal,
"TFBL" => Self::TransferCardBillPayment,
"TFCS" => Self::TransferFromCash,
"TFCH" => Self::TransferFromCheque,
"TFDB" => Self::TransferFundsDisbursementGeneral,
"TFGD" => Self::TransferGovernmentDisbursement,
"TFMD" => Self::TransferMerchantDisbursement,
"TFPD" => Self::TransferPayrollPensionDisbursement,
"NRFD" => Self::NonRefundable,
"INST" => Self::Instant,
"CADJ" => Self::CreditAdjustement,
"DADJ" => Self::DebitAdjustement,
"CRTC" => Self::CreateCertificate,
"CRTR" => Self::RenewCerificate,
"CRTK" => Self::RevokeCertificate,
"WLSA" => Self::AddWhiteList,
"WLSR" => Self::RemoveWhiteList,
"CIDD" => Self::CardInitiatingDirectDebit,
"GOPT" => Self::GuaranteeOfPayment,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Point of interaction (POI) performing the transaction."]
pub struct PointOfInteraction1<'a> {
#[doc = "Identification of the POI (Point Of Interaction) for the acquirer or its agent."]
pub identification: GenericIdentification32<'a>,
#[doc = "Common name assigned by the acquirer to the POI system."]
pub system_name: Option<Max70Text<'a>>,
#[doc = "Identifier assigned by the merchant identifying a set of POI terminals performing some categories of transactions."]
pub group_identification: Option<Max35Text<'a>>,
#[doc = "Capabilities of the POI performing the transaction."]
pub capabilities: Option<PointOfInteractionCapabilities1<'a>>,
#[doc = "Data related to a component of the POI performing the transaction."]
pub component: Vec<PointOfInteractionComponent1<'a>>,
}
impl<'a> PointOfInteraction1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <GenericIdentification32<'a>>::parse)?;
let system_name = reader.parse_optional_element("SysNm", <Max70Text<'a>>::parse)?;
let group_identification =
reader.parse_optional_element("GrpId", <Max35Text<'a>>::parse)?;
let capabilities = reader
.parse_optional_element("Cpblties", <PointOfInteractionCapabilities1<'a>>::parse)?;
let component = reader.parse_list("Cmpnt", <PointOfInteractionComponent1<'a>>::parse)?;
Ok(Self {
identification,
system_name,
group_identification,
capabilities,
component,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Data related to a component of the POI performing the transaction."]
pub struct PointOfInteractionComponent1<'a> {
#[doc = "Type of component belonging to a POI Terminal."]
pub poi_component_type: PoiComponentType1Code,
#[doc = "Identification of the software, hardware or system provider of the POI component."]
pub manufacturer_identification: Option<Max35Text<'a>>,
#[doc = "Identification of a model of POI component for a given manufacturer."]
pub model: Option<Max35Text<'a>>,
#[doc = "Version of component belonging to a given model."]
pub version_number: Option<Max16Text<'a>>,
#[doc = "Serial number of a component."]
pub serial_number: Option<Max35Text<'a>>,
#[doc = "Unique approval number for a component, delivered by a certification body.\r\nUsage: More than one approval number could be present, when assigned by different bodies. The certification body identification must be provided within the approval number (for example at the beginning of the value)."]
pub approval_number: Vec<Max70Text<'a>>,
}
impl<'a> PointOfInteractionComponent1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let poi_component_type =
reader.parse_element("POICmpntTp", <PoiComponentType1Code>::parse)?;
let manufacturer_identification =
reader.parse_optional_element("ManfctrId", <Max35Text<'a>>::parse)?;
let model = reader.parse_optional_element("Mdl", <Max35Text<'a>>::parse)?;
let version_number = reader.parse_optional_element("VrsnNb", <Max16Text<'a>>::parse)?;
let serial_number = reader.parse_optional_element("SrlNb", <Max35Text<'a>>::parse)?;
let approval_number = reader.parse_list("ApprvlNb", <Max70Text<'a>>::parse)?;
Ok(Self {
poi_component_type,
manufacturer_identification,
model,
version_number,
serial_number,
approval_number,
})
}
}
pub type PoiComponentType1Code = PoiComponentTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Generic component type belonging to a POI (Point of Interaction) Terminal."]
pub enum PoiComponentTypeCode {
#[doc = "Payment or other software application."]
Soft,
#[doc = "EMV application kernel (EMV is the chip card specifications initially defined by Eurocard, Mastercard and Visa)."]
EmvKernel,
#[doc = "EMV physical interface (EMV is the chip card specifications initially defined by Eurocard, Mastercard and Visa)."]
EmvLevel1,
#[doc = "Merchant interface."]
MerchantInterface,
#[doc = "Cardholder Interface."]
CardholderInterface,
#[doc = "Security module."]
SecureModule,
#[doc = "Personal identification number (or PIN) entry device (PED)."]
PinEntryDevice,
#[doc = "Acquirer specific configuration parameters for the point of interaction (POI) system."]
AcquirerParameters,
#[doc = "Merchant configuration parameters for the point of interaction (POI)."]
MerchantParameters,
#[doc = "Point of interaction parameters defined by the manufacturer for instance the PIN verification capabilities."]
VendorParameters,
#[doc = "Parameters for acquirer interface of the point of interaction, including acquirer host configuration parameters."]
AcquirerProtocolParameters,
#[doc = "Parameters of a payment application running on the point of interaction."]
ApplicationParameters,
#[doc = "Device sub-component of a component of the point of interaction."]
Device,
#[doc = "Driver module of the point of interaction."]
Driver,
#[doc = "Software module of the point of interaction."]
Middleware,
#[doc = "Software that manages hardware to provide common services to the applications."]
OperatingSystem,
#[doc = "Payment application software."]
PaymentApplication,
#[doc = "Security parameters of the point of interaction."]
SecurityParameters,
#[doc = "Payment server of a point of interaction system."]
Server,
#[doc = "Payment terminal point of interaction."]
Terminal,
#[doc = "Manufacturer configuration parameters of the point of interaction."]
TerminalParameters,
#[doc = "Certificate provided by a terminal manager."]
CertificateParameters,
#[doc = "Configuration parameters for the TMS protocol."]
TmsProtocolParameters,
#[doc = "Parameters related to the Sale to POI protocol."]
SaleToPoiProtocolParameters,
#[doc = "Component of the Sale system."]
SaleComponent,
#[doc = "Any repository used for recording log traces."]
LogFile,
#[doc = "Media file managed by an application of the POI."]
MediaFile,
#[doc = "Configuration file relevant for the POI."]
ConfigurationFile,
#[doc = "Report file generated by the POI."]
ReportFile,
}
impl<'a> PoiComponentTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"SOFT" => Self::Soft,
"EMVK" => Self::EmvKernel,
"EMVO" => Self::EmvLevel1,
"MRIT" => Self::MerchantInterface,
"CHIT" => Self::CardholderInterface,
"SECM" => Self::SecureModule,
"PEDV" => Self::PinEntryDevice,
"AQPR" => Self::AcquirerParameters,
"MRPR" => Self::MerchantParameters,
"VDPR" => Self::VendorParameters,
"AQPP" => Self::AcquirerProtocolParameters,
"APPR" => Self::ApplicationParameters,
"DVCE" => Self::Device,
"DRVR" => Self::Driver,
"MDWR" => Self::Middleware,
"OPST" => Self::OperatingSystem,
"APLI" => Self::PaymentApplication,
"SCPR" => Self::SecurityParameters,
"SERV" => Self::Server,
"TERM" => Self::Terminal,
"TLPR" => Self::TerminalParameters,
"CRTF" => Self::CertificateParameters,
"TMSP" => Self::TmsProtocolParameters,
"SAPR" => Self::SaleToPoiProtocolParameters,
"SACP" => Self::SaleComponent,
"LOGF" => Self::LogFile,
"MDFL" => Self::MediaFile,
"CONF" => Self::ConfigurationFile,
"RPFL" => Self::ReportFile,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Capabilities of the POI performing the transaction."]
pub struct PointOfInteractionCapabilities1<'a> {
#[doc = "Card reading capabilities of the POI performing the transaction."]
pub card_reading_capabilities: Vec<CardDataReading1Code>,
#[doc = "Cardholder verification capabilities of the POI performing the transaction."]
pub cardholder_verification_capabilities: Vec<CardholderVerificationCapability1Code>,
#[doc = "On-line and off-line capabilities of the POI."]
pub on_line_capabilities: Option<OnLineCapability1Code>,
#[doc = "Capabilities of the display components performing the transaction."]
pub display_capabilities: Vec<DisplayCapabilities1<'a>>,
#[doc = "Number of columns of the printer component."]
pub print_line_width: Option<Max3NumericText<'a>>,
}
impl<'a> PointOfInteractionCapabilities1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let card_reading_capabilities =
reader.parse_list("CardRdngCpblties", <CardDataReading1Code>::parse)?;
let cardholder_verification_capabilities = reader.parse_list(
"CrdhldrVrfctnCpblties",
<CardholderVerificationCapability1Code>::parse,
)?;
let on_line_capabilities =
reader.parse_optional_element("OnLineCpblties", <OnLineCapability1Code>::parse)?;
let display_capabilities =
reader.parse_list("DispCpblties", <DisplayCapabilities1<'a>>::parse)?;
let print_line_width =
reader.parse_optional_element("PrtLineWidth", <Max3NumericText<'a>>::parse)?;
Ok(Self {
card_reading_capabilities,
cardholder_verification_capabilities,
on_line_capabilities,
display_capabilities,
print_line_width,
})
}
}
#[derive(Clone, Debug)]
#[doc = "The capabilities of the display components performing the transaction."]
pub struct DisplayCapabilities1<'a> {
#[doc = "Type of display (for example merchant or cardholder)."]
pub display_type: UserInterface2Code,
#[doc = "Number of lines of the display component."]
pub number_of_lines: Max3NumericText<'a>,
#[doc = "Number of columns of the display component."]
pub line_width: Max3NumericText<'a>,
}
impl<'a> DisplayCapabilities1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let display_type = reader.parse_element("DispTp", <UserInterface2Code>::parse)?;
let number_of_lines = reader.parse_element("NbOfLines", <Max3NumericText<'a>>::parse)?;
let line_width = reader.parse_element("LineWidth", <Max3NumericText<'a>>::parse)?;
Ok(Self {
display_type,
number_of_lines,
line_width,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a maximum length of 3 digits."]
pub struct Max3NumericText<'a>(Cow<'a, str>);
impl<'a> Max3NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
pub type UserInterface2Code = UserInterfaceCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Type of user interface to display or print information."]
pub enum UserInterfaceCode {
#[doc = "Cardholder display or interface."]
CardholderDisplay,
#[doc = "Cardholder receipt."]
CardholderReceipt,
#[doc = "Merchant display or interface."]
MerchantDisplay,
#[doc = "Merchant receipt."]
MerchantReceipt,
#[doc = "Acquirer."]
Acquirer,
#[doc = "Issuer."]
Issuer,
#[doc = "Agent."]
Agent,
#[doc = "Other interface of the cardholder, for instance e-mail or smartphone message."]
OtherCardholderInterface,
#[doc = "Information dedicated to a software application related to a device belonging to the cardholder."]
CardholderApplication,
#[doc = "Data dedicated to an application maintained by a clearing agent."]
ClearingAgentApplication,
#[doc = "Data dedicated to a log maintained by the clearing agent."]
ClearingAgentLog,
#[doc = "Interface used in case of disputes or chargebacks."]
Dispute,
#[doc = "File used to store the message."]
File,
#[doc = "Information dedicated to a log file."]
Log,
#[doc = "Information dedicated to a software application related to a device belonging to the merchant."]
MerchantApplication,
#[doc = "Other type of acquirer interface."]
OtherAcquirerInterface,
#[doc = "Data dedicated to another interface maintained by the clearing agent."]
OtherClearingAgentInterface,
#[doc = "Other type of issuer interface."]
OtherIssuerInterface,
#[doc = "Other interface of the merchant for instance e-mail or smartphone message."]
OtherMerchantInterface,
#[doc = "Other type of interface defined at national level."]
OtherNational,
#[doc = "Other type of interface defined at private level."]
OtherPrivate,
#[doc = "Other settlement agent interface."]
OtherSettlementAgentInterface,
#[doc = "Settlement agent interface."]
SettlementAgent,
#[doc = "Credit information related to a top-up account."]
TopUpCredit,
}
impl<'a> UserInterfaceCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"CDSP" => Self::CardholderDisplay,
"CRCP" => Self::CardholderReceipt,
"MDSP" => Self::MerchantDisplay,
"MRCP" => Self::MerchantReceipt,
"ACQU" => Self::Acquirer,
"ISSR" => Self::Issuer,
"AGNT" => Self::Agent,
"CRDO" => Self::OtherCardholderInterface,
"CHAP" => Self::CardholderApplication,
"CLRA" => Self::ClearingAgentApplication,
"CLRL" => Self::ClearingAgentLog,
"DSPU" => Self::Dispute,
"FILE" => Self::File,
"LOGF" => Self::Log,
"MRAP" => Self::MerchantApplication,
"OTAI" => Self::OtherAcquirerInterface,
"OCAI" => Self::OtherClearingAgentInterface,
"OTII" => Self::OtherIssuerInterface,
"MRIN" => Self::OtherMerchantInterface,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
"OSAI" => Self::OtherSettlementAgentInterface,
"STLI" => Self::SettlementAgent,
"TUCR" => Self::TopUpCredit,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type OnLineCapability1Code = OnLineCapabilityCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "On-line and off-line capabilities of the POI (Point Of Interaction)."]
pub enum OnLineCapabilityCode {
#[doc = "Off-line only capable."]
OffLine,
#[doc = "On-line only capable."]
OnLine,
#[doc = "Off-line capable with possible on-line requests to the acquirer."]
SemiOffLine,
#[doc = "Both online and offline"]
BothOnLineAndOffLine,
}
impl<'a> OnLineCapabilityCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"OFLN" => Self::OffLine,
"ONLN" => Self::OnLine,
"SMON" => Self::SemiOffLine,
"BOTH" => Self::BothOnLineAndOffLine,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type CardholderVerificationCapability1Code = CardholderVerificationCapabilityCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Cardholder verification capabilities of the POI (Personal Identification Number) performing the transaction."]
pub enum CardholderVerificationCapabilityCode {
#[doc = "Manual signature verification."]
ManualSignature,
#[doc = "Online PIN (Personal Identification Number)."]
OnLinePin,
#[doc = "Offline PIN in clear (Personal Identification Number)."]
OfflinePinClear,
#[doc = "Offline PIN encrypted (Personal Identification Number)."]
OfflinePinEncrypted,
#[doc = "Offline digital signature analysis."]
OfflineDigitalSignature,
#[doc = "Offline biometrics."]
OfflineBiometrics,
#[doc = "Other manual verification, for example passport or drivers license."]
ManualVerification,
#[doc = "Offline biographics."]
OfflineBiographics,
#[doc = "Account based digital signature."]
AccountDigitalSignature,
#[doc = "PKI (Public Key Infrastructure) based digital signature."]
PkiSignature,
#[doc = "Cardholder authentication data."]
CardholderData,
#[doc = "Three domain secure (three domain secure authentication of the cardholder)."]
SecureElectronicCommerce,
#[doc = "Unknown cardholder verification capability."]
Unknown,
#[doc = "Personal code of the customer for banking services."]
PersonalCode,
#[doc = "No cardholder verification capability."]
NoCapabilities,
#[doc = "Online biometrics."]
OnLineBiometrics,
#[doc = "Other cardholder verification capabilities."]
Other,
#[doc = "Other type of cardholder verification defined at national level"]
OtherNational,
#[doc = "Other type of cardholder verification defined in a private manner."]
OtherPrivate,
#[doc = "Handwritten signature verification"]
Signature,
#[doc = "Cardholder verification capability unspecified."]
Unspecified,
#[doc = "Recognition by voice."]
VoiceRecognition,
#[doc = "Device has no pin entry capability."]
NoPinEntry,
#[doc = "Device has no online pin entry capability."]
NoOnLinePinEntry,
}
impl<'a> CardholderVerificationCapabilityCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"MNSG" => Self::ManualSignature,
"NPIN" => Self::OnLinePin,
"FCPN" => Self::OfflinePinClear,
"FEPN" => Self::OfflinePinEncrypted,
"FDSG" => Self::OfflineDigitalSignature,
"FBIO" => Self::OfflineBiometrics,
"MNVR" => Self::ManualVerification,
"FBIG" => Self::OfflineBiographics,
"APKI" => Self::AccountDigitalSignature,
"PKIS" => Self::PkiSignature,
"CHDT" => Self::CardholderData,
"SCEC" => Self::SecureElectronicCommerce,
"UNKW" => Self::Unknown,
"PCOD" => Self::PersonalCode,
"NOVF" => Self::NoCapabilities,
"NBIO" => Self::OnLineBiometrics,
"OTHR" => Self::Other,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
"SIGN" => Self::Signature,
"UNSP" => Self::Unspecified,
"VORN" => Self::VoiceRecognition,
"NOPN" => Self::NoPinEntry,
"NOOP" => Self::NoOnLinePinEntry,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
pub type CardDataReading1Code = CardDataReadingCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Type of reading of the card data."]
pub enum CardDataReadingCode {
#[doc = "Tag reading capabilities (RFID, etc.)."]
Tag,
#[doc = "Keyboard entry or OCR reading of embossing or printed data, either at time of transaction or after the event."]
Physical,
#[doc = "Bar code."]
BarCode,
#[doc = "Magnetic stripe."]
MagneticStripe,
#[doc = "ICC (Integrated Circuit Card) with contact containing software applications conform to ISO 7816."]
Icc,
#[doc = "Account data on file."]
AccountData,
#[doc = "Contactless proximity reader."]
ProximityReader,
#[doc = "Contactless proximity reader, with application conform to the standard EMV (standard initiated by Europay, Mastercard and Visa)."]
EmvProximityReader,
#[doc = "Card information are stored on a file."]
CardOnFile,
#[doc = "Unknown card reading capability."]
Unknown,
#[doc = "Synchronous ICC - (Integrated Circuit Card) with contact."]
SynchronousIntegratedCircuitCard,
#[doc = "ICC contact capability"]
IccContact,
#[doc = "ICC contactless proximity"]
IccProximity,
#[doc = "Recognition of magnetic ink characters"]
MagneticInkCharacterRecognition,
#[doc = "Manual, no terminal used."]
ManualEntry,
#[doc = "Magstripe image contactless proximity"]
MsiProximity,
#[doc = "OCR either at time of transaction or after the event."]
OpticalCharacterRecognition,
#[doc = "Optical coded reading capabilities (e.g. barcode, QR code, etc.)"]
OpticalCode,
#[doc = "Other national capability type assigned at national level."]
OtherNational,
#[doc = "Other card reading capability assigned on a private basis."]
OtherPrivate,
#[doc = "Radio Frequency Identification tag capabilities."]
RfidTag,
#[doc = "Unspecified capability."]
Unspecified,
#[doc = "Key entered."]
KeyEntered,
#[doc = "Quick response code."]
QrCode,
}
impl<'a> CardDataReadingCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"TAGC" => Self::Tag,
"PHYS" => Self::Physical,
"BRCD" => Self::BarCode,
"MGST" => Self::MagneticStripe,
"CICC" => Self::Icc,
"DFLE" => Self::AccountData,
"CTLS" => Self::ProximityReader,
"ECTL" => Self::EmvProximityReader,
"CDFL" => Self::CardOnFile,
"UNKW" => Self::Unknown,
"SICC" => Self::SynchronousIntegratedCircuitCard,
"ICCY" => Self::IccContact,
"ICPY" => Self::IccProximity,
"MICR" => Self::MagneticInkCharacterRecognition,
"MLEY" => Self::ManualEntry,
"MSIP" => Self::MsiProximity,
"OCRR" => Self::OpticalCharacterRecognition,
"OPTC" => Self::OpticalCode,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
"RFID" => Self::RfidTag,
"UNSP" => Self::Unspecified,
"KEEN" => Self::KeyEntered,
"QRCD" => Self::QrCode,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Identification of an entity."]
pub struct GenericIdentification32<'a> {
#[doc = "Identification of the entity."]
pub identification: Max35Text<'a>,
#[doc = "Type of identified entity."]
pub r#type: Option<PartyType3Code>,
#[doc = "Entity assigning the identification (for example merchant, acceptor, acquirer, or tax authority)."]
pub issuer: Option<PartyType4Code>,
#[doc = "Name of the entity."]
pub short_name: Option<Max35Text<'a>>,
}
impl<'a> GenericIdentification32<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <PartyType3Code>::parse)?;
let issuer = reader.parse_optional_element("Issr", <PartyType4Code>::parse)?;
let short_name = reader.parse_optional_element("ShrtNm", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
r#type,
issuer,
short_name,
})
}
}
pub type PartyType4Code = PartyTypeCode;
pub type PartyType3Code = PartyTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the entitled party."]
pub enum PartyTypeCode {
#[doc = "Party selling goods and services."]
SaleSystem,
#[doc = "Party component of a POI system or POI terminal (Point of Interaction)."]
PoiComponent,
#[doc = "Issuer is the entitled party."]
Issuer,
#[doc = "Holder is the entitled party."]
Holder,
#[doc = "Party, either an individual or organisation, whose assets are being invested."]
Investor,
#[doc = "Party that identifies an executing / give-up broker."]
ExecutingFirm,
#[doc = "Party that receives the trade credit."]
BrokerOfCredit,
#[doc = "Party that is going to carry the position on their books at another clearinghouse (exchanges)."]
CorrespondentClearingFirm,
#[doc = "Party that is the counterparty in a trade."]
ContraFirm,
#[doc = "Party that is the clearing firm of the counterparty in a trade."]
ContraClearingFirm,
#[doc = "Party (broker or other firm), which is the contra side of the trade for the underlying security."]
UnderlyingContraFirm,
#[doc = "Party to which the trade is given up (carries the position that results from a trade)."]
GiveUpClearingFirm,
#[doc = "Party that originates an order."]
OrderOriginationFirm,
#[doc = "Party (member of an exchange)that is sponsoring an entering firm to send orders directly to the exchange."]
SponsoringFirm,
#[doc = "Party (broker) that settles security transactions from another broker for a fee = take up broker."]
Clearingfirm,
#[doc = "Party that can relay an order directly to the trading floor, or give clients direct access to the floor. The introducing firm delegates the work of the floor operation, trade execution and accounting."]
IntroducingFirm,
#[doc = "Party that has recorded or reported an execution of a trade. When an entering firm that is not a party to a trade enters the trade into a trade recording system, any inquiries can be directed to the appropriate source."]
EnteringFirm,
#[doc = "A client is identified in third party-transactions or for investor in intermediary transactions."]
Client,
#[doc = "Broker to which the investment manager directs the execution of a portion of the trade."]
StepInBroker,
#[doc = "Party (buyer or seller) that positively affirms the details of a previously agreed security trade confirmation."]
AffirmingParty,
#[doc = "Party acting as the Electronic Trade Confirmation (ETC) service provider 1."]
EtcServiceProvider1,
#[doc = "Party acting as the Electronic Trade Confirmation (ETC) service provider 2."]
EtcServiceProvider2,
#[doc = "In a directed order, broker with which the Receiver of the message is requested to execute the order."]
RequestedBroker,
#[doc = "Tax authority."]
TaxAuthority,
#[doc = "Party to whom the card issuer delegates to authorise card payment transactions."]
DelegateIssuer,
#[doc = "Point Of Interaction initiating the card payment transaction."]
OriginatingPoi,
#[doc = "Party that issues cards."]
CardIssuer,
#[doc = "Card acceptor, party accepting the card and presenting transaction data to the acquirer."]
Acceptor,
#[doc = "Merchant providing goods and service in the card payment transaction."]
Merchant,
#[doc = "Entity acquiring card transactions."]
Acquirer,
#[doc = "Party acting on behalf of other parties to process or forward data to other parties."]
IntermediaryAgent,
#[doc = "Responsible for the maintenance of a card payment acceptance terminal."]
MasterTerminalManager,
#[doc = "Responsible for one or several maintenance functions of a card payment acceptance terminal."]
TerminalManager,
#[doc = "Entity providing acquiring card payment processing services on behalf on an acquirer."]
AcquirerProcessor,
#[doc = "Entity providing issuing card payment processing services on behalf on an issuer."]
CardIssuerProcessor,
#[doc = "Entity defining rules and procedures for card payment transactions acting as an intermediary between an acquirer and an issuer."]
CardScheme,
#[doc = "Entity providing card payment processing services acting on behalf of a card scheme."]
CardSchemeProcessor,
#[doc = "Entity managing the ATM."]
AtmManager,
#[doc = "Entity hosting the ATM."]
HostingEntity,
#[doc = "ATM initiating the transaction."]
OriginatingAtm,
#[doc = "Application on the terminal which has initiated the transaction."]
OriginatingTerminal,
#[doc = "Application in the smart card."]
CardApplication,
#[doc = "Configuration to apply to the whole POI system."]
PoiSystem,
#[doc = "Configuration to apply to a subset of the whole POI system."]
PoiGroup,
#[doc = "Configuration to apply to a single POI terminal."]
SinglePoi,
#[doc = "The bank of the source account."]
AccountFromBank,
#[doc = "The bank of the destination account."]
AccountToBank,
#[doc = "Entity providing card payment processing services acting as an intermediary between an acquirer and an issuer."]
Agent,
#[doc = "Holder of a payment card."]
Cardholder,
#[doc = "Agent in charge of clearing payment or related transactions."]
ClearingAgent,
#[doc = "Government organisation investigation unit. "]
GovernmentInvestigationUnit,
#[doc = "Other card payment entity type defined at national level"]
OtherNational,
#[doc = "Other card payment entity type defined at private level"]
OtherPrivate,
#[doc = "Payment Initiation Service Provider (PISP)"]
PaymentInitiationServiceProvider,
#[doc = "Entity provding payments services."]
PaymentServiceProvider,
#[doc = "Party in charge of controlling or supervising a card acceptance Point of Interaction"]
PointOfInteraction,
#[doc = "Agent in charge of the settlement of a payment or related transaction."]
SettlementAgent,
#[doc = "Provider of an electronic wallet"]
WalletProvider,
}
impl<'a> PartyTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"SALE" => Self::SaleSystem,
"PCPT" => Self::PoiComponent,
"ISUR" => Self::Issuer,
"HLDR" => Self::Holder,
"INVE" => Self::Investor,
"EXEC" => Self::ExecutingFirm,
"BROK" => Self::BrokerOfCredit,
"CORR" => Self::CorrespondentClearingFirm,
"COFI" => Self::ContraFirm,
"COCL" => Self::ContraClearingFirm,
"UNDE" => Self::UnderlyingContraFirm,
"GIVE" => Self::GiveUpClearingFirm,
"ORDE" => Self::OrderOriginationFirm,
"SPON" => Self::SponsoringFirm,
"CLEA" => Self::Clearingfirm,
"INTR" => Self::IntroducingFirm,
"ENTE" => Self::EnteringFirm,
"CLIE" => Self::Client,
"STEP" => Self::StepInBroker,
"AFFI" => Self::AffirmingParty,
"ETC1" => Self::EtcServiceProvider1,
"ETC2" => Self::EtcServiceProvider2,
"RQBR" => Self::RequestedBroker,
"TAXH" => Self::TaxAuthority,
"DLIS" => Self::DelegateIssuer,
"OPOI" => Self::OriginatingPoi,
"CISS" => Self::CardIssuer,
"ACCP" => Self::Acceptor,
"MERC" => Self::Merchant,
"ACQR" => Self::Acquirer,
"ITAG" => Self::IntermediaryAgent,
"MTMG" => Self::MasterTerminalManager,
"TMGT" => Self::TerminalManager,
"ACQP" => Self::AcquirerProcessor,
"CISP" => Self::CardIssuerProcessor,
"CSCH" => Self::CardScheme,
"SCHP" => Self::CardSchemeProcessor,
"ATMG" => Self::AtmManager,
"HSTG" => Self::HostingEntity,
"OATM" => Self::OriginatingAtm,
"OTRM" => Self::OriginatingTerminal,
"ICCA" => Self::CardApplication,
"PSYS" => Self::PoiSystem,
"PGRP" => Self::PoiGroup,
"PSNG" => Self::SinglePoi,
"BKAF" => Self::AccountFromBank,
"BKAT" => Self::AccountToBank,
"AGNT" => Self::Agent,
"CRDH" => Self::Cardholder,
"CLRA" => Self::ClearingAgent,
"GVIU" => Self::GovernmentInvestigationUnit,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
"PISP" => Self::PaymentInitiationServiceProvider,
"PASP" => Self::PaymentServiceProvider,
"POOI" => Self::PointOfInteraction,
"SETA" => Self::SettlementAgent,
"WLPR" => Self::WalletProvider,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Electronic money product that provides the cardholder with a portable and specialised computer device, which typically contains a microprocessor."]
pub struct PaymentCard4<'a> {
#[doc = "Sensitive data associated with the card performing the transaction."]
pub plain_card_data: Option<PlainCardData1<'a>>,
#[doc = "Country code assigned to the card by the card issuer."]
pub card_country_code: Option<Exact3NumericText<'a>>,
#[doc = "Brand name of the card."]
pub card_brand: Option<GenericIdentification1<'a>>,
#[doc = "Additional card issuer specific data."]
pub additional_card_data: Option<Max70Text<'a>>,
}
impl<'a> PaymentCard4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let plain_card_data =
reader.parse_optional_element("PlainCardData", <PlainCardData1<'a>>::parse)?;
let card_country_code =
reader.parse_optional_element("CardCtryCd", <Exact3NumericText<'a>>::parse)?;
let card_brand =
reader.parse_optional_element("CardBrnd", <GenericIdentification1<'a>>::parse)?;
let additional_card_data =
reader.parse_optional_element("AddtlCardData", <Max70Text<'a>>::parse)?;
Ok(Self {
plain_card_data,
card_country_code,
card_brand,
additional_card_data,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification, for example party identification or account identification."]
pub struct GenericIdentification1<'a> {
#[doc = "Identification assigned by an institution."]
pub identification: Max35Text<'a>,
#[doc = "Name of the identification scheme."]
pub scheme_name: Option<Max35Text<'a>>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let scheme_name = reader.parse_optional_element("SchmeNm", <Max35Text<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
scheme_name,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Sensible data associated with the payment card performing the transaction."]
pub struct PlainCardData1<'a> {
#[doc = "Primary Account Number (PAN) of the card, or card number."]
pub pan: Min8Max28NumericText<'a>,
#[doc = "Identify a card inside a set of cards with the same card number (PAN)."]
pub card_sequence_number: Option<Min2Max3NumericText<'a>>,
#[doc = "Date as from which the card can be used."]
pub effective_date: Option<IsoYearMonth>,
#[doc = "Expiry date of the card."]
pub expiry_date: IsoYearMonth,
#[doc = "Services attached to the card, as defined in ISO 7813."]
pub service_code: Option<Exact3NumericText<'a>>,
#[doc = "Magnetic track or equivalent payment card data."]
pub track_data: Vec<TrackData1<'a>>,
#[doc = "Card security code (CSC) associated with the card performing the transaction."]
pub card_security_code: Option<CardSecurityInformation1<'a>>,
}
impl<'a> PlainCardData1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let pan = reader.parse_element("PAN", <Min8Max28NumericText<'a>>::parse)?;
let card_sequence_number =
reader.parse_optional_element("CardSeqNb", <Min2Max3NumericText<'a>>::parse)?;
let effective_date = reader.parse_optional_element("FctvDt", <IsoYearMonth>::parse)?;
let expiry_date = reader.parse_element("XpryDt", <IsoYearMonth>::parse)?;
let service_code =
reader.parse_optional_element("SvcCd", <Exact3NumericText<'a>>::parse)?;
let track_data = reader.parse_list("TrckData", <TrackData1<'a>>::parse)?;
let card_security_code =
reader.parse_optional_element("CardSctyCd", <CardSecurityInformation1<'a>>::parse)?;
Ok(Self {
pan,
card_sequence_number,
effective_date,
expiry_date,
service_code,
track_data,
card_security_code,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Card security code (CSC) associated with the card performing the transaction."]
pub struct CardSecurityInformation1<'a> {
#[doc = "Card security code (CSC) management associated with the transaction."]
pub csc_management: CscManagement1Code,
#[doc = "Card security code (CSC)."]
pub csc_value: Option<Min3Max4NumericText<'a>>,
}
impl<'a> CardSecurityInformation1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let csc_management = reader.parse_element("CSCMgmt", <CscManagement1Code>::parse)?;
let csc_value =
reader.parse_optional_element("CSCVal", <Min3Max4NumericText<'a>>::parse)?;
Ok(Self {
csc_management,
csc_value,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a minimum length of 3 digits, and a maximum length of 4 digits."]
pub struct Min3Max4NumericText<'a>(Cow<'a, str>);
impl<'a> Min3Max4NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
pub type CscManagement1Code = CscManagementCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "CSC (Card Security Code) management associated with the transaction."]
pub enum CscManagementCode {
#[doc = "Card security code present."]
CscPresent,
#[doc = "Card security code by-passed or not provided by the merchant."]
CscByPass,
#[doc = "Card security code unreadable."]
CscUnread,
#[doc = "No card security code imprint."]
NoCsc,
}
impl<'a> CscManagementCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"PRST" => Self::CscPresent,
"BYPS" => Self::CscByPass,
"UNRD" => Self::CscUnread,
"NCSC" => Self::NoCsc,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Magnetic track or equivalent payment card data."]
pub struct TrackData1<'a> {
#[doc = "Track number of the card."]
pub track_number: Option<Exact1NumericText<'a>>,
#[doc = "Card track content or equivalent."]
pub track_value: Max140Text<'a>,
}
impl<'a> TrackData1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let track_number =
reader.parse_optional_element("TrckNb", <Exact1NumericText<'a>>::parse)?;
let track_value = reader.parse_element("TrckVal", <Max140Text<'a>>::parse)?;
Ok(Self {
track_number,
track_value,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with an exact length of1digit."]
pub struct Exact1NumericText<'a>(Cow<'a, str>);
impl<'a> Exact1NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with an exact length of 3 digits."]
pub struct Exact3NumericText<'a>(Cow<'a, str>);
impl<'a> Exact3NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Month within a particular calendar year represented by YYYY-MM (ISO 8601)."]
pub struct IsoYearMonth {
pub month: time::Month,
pub year: i32,
}
impl<'a> IsoYearMonth {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let mut parser = time::parsing::Parsed::new();
let rest = parser
.parse_items(
text.as_bytes(),
time::macros::format_description!("[year]-[month]"),
)
.map_err(|_| -> XmlError { todo!() })?;
if !rest.is_empty() {
todo!()
}
let month = parser.month().unwrap();
let year = parser.year().unwrap();
Ok(Self { month, year })
}
}
impl Ord for IsoYearMonth {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.year
.cmp(&other.year)
.then_with(|| u8::from(self.month).cmp(&u8::from(other.month)))
}
}
impl PartialOrd for IsoYearMonth {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a minimum length of 2 digits, and a maximum length of 3 digits."]
pub struct Min2Max3NumericText<'a>(Cow<'a, str>);
impl<'a> Min2Max3NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a minimum length of 8 digits, and a maximum length of 28 digits."]
pub struct Min8Max28NumericText<'a>(Cow<'a, str>);
impl<'a> Min8Max28NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Provide further details on transaction specific interest information that applies to the underlying transaction."]
pub struct TransactionInterest4<'a> {
#[doc = "Total amount of interests and taxes included in the entry amount."]
pub total_interest_and_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Individual interest record."]
pub record: Vec<InterestRecord2<'a>>,
}
impl<'a> TransactionInterest4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let total_interest_and_tax_amount = reader.parse_optional_element(
"TtlIntrstAndTaxAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let record = reader.parse_list("Rcrd", <InterestRecord2<'a>>::parse)?;
Ok(Self {
total_interest_and_tax_amount,
record,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides transaction specific interest information that applies to the underlying transaction."]
pub struct InterestRecord2<'a> {
#[doc = "Amount of interest included in the entry amount."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the interest amount included in the entry is credit or debit amount.\r\nUsage: A zero amount is considered to be a credit."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Specifies the type of interest."]
pub r#type: Option<InterestType1Choice<'a>>,
#[doc = "Set of elements used to qualify the interest rate."]
pub rate: Option<Rate4<'a>>,
#[doc = "Range of time between a start date and an end date for the calculation of the interest."]
pub from_to_date: Option<DateTimePeriod1>,
#[doc = "Specifies the reason for the interest."]
pub reason: Option<Max35Text<'a>>,
#[doc = "Provides details on the tax applied to charges."]
pub tax: Option<TaxCharges2<'a>>,
}
impl<'a> InterestRecord2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let r#type = reader.parse_optional_element("Tp", <InterestType1Choice<'a>>::parse)?;
let rate = reader.parse_optional_element("Rate", <Rate4<'a>>::parse)?;
let from_to_date = reader.parse_optional_element("FrToDt", <DateTimePeriod1>::parse)?;
let reason = reader.parse_optional_element("Rsn", <Max35Text<'a>>::parse)?;
let tax = reader.parse_optional_element("Tax", <TaxCharges2<'a>>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
r#type,
rate,
from_to_date,
reason,
tax,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details on the charges related to the payment transaction."]
pub struct Charges6<'a> {
#[doc = "Total of all charges and taxes applied to the entry."]
pub total_charges_and_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Provides details of the individual charges record."]
pub record: Vec<ChargesRecord3<'a>>,
}
impl<'a> Charges6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let total_charges_and_tax_amount = reader.parse_optional_element(
"TtlChrgsAndTaxAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let record = reader.parse_list("Rcrd", <ChargesRecord3<'a>>::parse)?;
Ok(Self {
total_charges_and_tax_amount,
record,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further individual record details on the charges related to the payment transaction."]
pub struct ChargesRecord3<'a> {
#[doc = "Transaction charges to be paid by the charge bearer."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the charges amount is a credit or a debit amount. \nUsage: A zero amount is considered to be a credit."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Indicates whether the charge should be included in the amount or is added as pre-advice."]
pub charge_included_indicator: Option<ChargeIncludedIndicator>,
#[doc = "Specifies the type of charge."]
pub r#type: Option<ChargeType3Choice<'a>>,
#[doc = "Rate used to calculate the amount of the charge or fee."]
pub rate: Option<PercentageRate>,
#[doc = "Specifies which party/parties will bear the charges associated with the processing of the payment transaction."]
pub bearer: Option<ChargeBearerType1Code>,
#[doc = "Agent that takes the transaction charges or to which the transaction charges are due."]
pub agent: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
#[doc = "Provides details on the tax applied to charges."]
pub tax: Option<TaxCharges2<'a>>,
}
impl<'a> ChargesRecord3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let charge_included_indicator =
reader.parse_optional_element("ChrgInclInd", <ChargeIncludedIndicator>::parse)?;
let r#type = reader.parse_optional_element("Tp", <ChargeType3Choice<'a>>::parse)?;
let rate = reader.parse_optional_element("Rate", <PercentageRate>::parse)?;
let bearer = reader.parse_optional_element("Br", <ChargeBearerType1Code>::parse)?;
let agent = reader.parse_optional_element(
"Agt",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
let tax = reader.parse_optional_element("Tax", <TaxCharges2<'a>>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
charge_included_indicator,
r#type,
rate,
bearer,
agent,
tax,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the charge type."]
pub enum ChargeType3Choice<'a> {
#[doc = "Charge type, in a coded form."]
Code(ExternalChargeType1Code),
#[doc = "Type of charge in a proprietary form, as defined by the issuer."]
Proprietary(GenericIdentification3<'a>),
}
impl<'a> ChargeType3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalChargeType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <GenericIdentification3<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalChargeType1Code;
#[derive(Clone, Debug)]
#[doc = "Indicates whether charges have already been included."]
pub enum ChargeIncludedIndicator {
PreAdvised,
Included,
}
impl<'a> ChargeIncludedIndicator {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = if reader.expect_boolean()? {
Self::Included
} else {
Self::PreAdvised
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the status of an entry on the books of the account servicer."]
pub enum EntryStatus1Choice<'a> {
#[doc = "Entry status, in a coded form."]
Code(ExternalEntryStatus1Code),
#[doc = "Entry status, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> EntryStatus1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalEntryStatus1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalEntryStatus1Code;
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide summary information on entries."]
pub struct TotalTransactions6<'a> {
#[doc = "Specifies the total number and sum of debit and credit entries."]
pub total_entries: Option<NumberAndSumOfTransactions4<'a>>,
#[doc = "Specifies the total number and sum of credit entries."]
pub total_credit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Specifies the total number and sum of debit entries."]
pub total_debit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Specifies the total number and sum of entries per bank transaction code."]
pub total_entries_per_bank_transaction_code: Vec<TotalsPerBankTransactionCode5<'a>>,
}
impl<'a> TotalTransactions6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let total_entries =
reader.parse_optional_element("TtlNtries", <NumberAndSumOfTransactions4<'a>>::parse)?;
let total_credit_entries = reader
.parse_optional_element("TtlCdtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let total_debit_entries = reader
.parse_optional_element("TtlDbtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let total_entries_per_bank_transaction_code = reader.parse_list(
"TtlNtriesPerBkTxCd",
<TotalsPerBankTransactionCode5<'a>>::parse,
)?;
Ok(Self {
total_entries,
total_credit_entries,
total_debit_entries,
total_entries_per_bank_transaction_code,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide the total sum of entries per bank transaction code."]
pub struct TotalsPerBankTransactionCode5<'a> {
#[doc = "Number of individual entries for the bank transaction code."]
pub number_of_entries: Option<Max15NumericText<'a>>,
#[doc = "Total of all individual entries included in the report."]
pub sum: Option<DecimalNumber>,
#[doc = "Total debit or credit amount that is the result of the netted amounts for all debit and credit entries per bank transaction code."]
pub total_net_entry: Option<AmountAndDirection35>,
#[doc = "Number of individual credit entries for the bank transaction code."]
pub credit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Number of individual debit entries for the bank transaction code."]
pub debit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Indicates whether the bank transaction code is related to booked or forecast items."]
pub forecast_indicator: Option<TrueFalseIndicator>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: BankTransactionCodeStructure4<'a>,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest."]
pub availability: Vec<CashAvailability1<'a>>,
#[doc = "Indicates the date (and time) of the transaction summary."]
pub date: Option<DateAndDateTime2Choice>,
}
impl<'a> TotalsPerBankTransactionCode5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_entries =
reader.parse_optional_element("NbOfNtries", <Max15NumericText<'a>>::parse)?;
let sum = reader.parse_optional_element("Sum", <DecimalNumber>::parse)?;
let total_net_entry =
reader.parse_optional_element("TtlNetNtry", <AmountAndDirection35>::parse)?;
let credit_entries =
reader.parse_optional_element("CdtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let debit_entries =
reader.parse_optional_element("DbtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let forecast_indicator =
reader.parse_optional_element("FcstInd", <TrueFalseIndicator>::parse)?;
let bank_transaction_code =
reader.parse_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashAvailability1<'a>>::parse)?;
let date = reader.parse_optional_element("Dt", <DateAndDateTime2Choice>::parse)?;
Ok(Self {
number_of_entries,
sum,
total_net_entry,
credit_entries,
debit_entries,
forecast_indicator,
bank_transaction_code,
availability,
date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements providing the total sum of entries."]
pub struct NumberAndSumOfTransactions4<'a> {
#[doc = "Number of individual entries included in the report."]
pub number_of_entries: Option<Max15NumericText<'a>>,
#[doc = "Total of all individual entries included in the report."]
pub sum: Option<DecimalNumber>,
#[doc = "Resulting debit or credit amount of the netted amounts for all debit and credit entries."]
pub total_net_entry: Option<AmountAndDirection35>,
}
impl<'a> NumberAndSumOfTransactions4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_entries =
reader.parse_optional_element("NbOfNtries", <Max15NumericText<'a>>::parse)?;
let sum = reader.parse_optional_element("Sum", <DecimalNumber>::parse)?;
let total_net_entry =
reader.parse_optional_element("TtlNetNtry", <AmountAndDirection35>::parse)?;
Ok(Self {
number_of_entries,
sum,
total_net_entry,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Resulting debit or credit amount of the netted amounts for all debit and credit entries."]
pub struct AmountAndDirection35 {
#[doc = "Resulting amount of the netted amounts for all debit and credit entries."]
pub amount: NonNegativeDecimalNumber,
#[doc = "Indicates whether the amount is a credit or a debit amount."]
pub credit_debit_indicator: CreditDebitCode,
}
impl<'a> AmountAndDirection35 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <NonNegativeDecimalNumber>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Number of objects represented as a non negative decimal number, for example, 0.75 or 45.6."]
pub struct NonNegativeDecimalNumber(Decimal);
impl<'a> NonNegativeDecimalNumber {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let inner = Decimal::from_str(&text).unwrap();
Ok(Self(inner))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the balance details."]
pub struct CashBalance8<'a> {
#[doc = "Specifies the nature of a balance."]
pub r#type: BalanceType13<'a>,
#[doc = "Set of elements used to provide details on the credit line."]
pub credit_line: Vec<CreditLine3<'a>>,
#[doc = "Amount of money of the cash balance."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the balance is a credit or a debit balance. \nUsage: A zero balance is considered to be a credit balance."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Indicates the date (and time) of the balance."]
pub date: DateAndDateTime2Choice,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashAvailability1<'a>>,
}
impl<'a> CashBalance8<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <BalanceType13<'a>>::parse)?;
let credit_line = reader.parse_list("CdtLine", <CreditLine3<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let date = reader.parse_element("Dt", <DateAndDateTime2Choice>::parse)?;
let availability = reader.parse_list("Avlbty", <CashAvailability1<'a>>::parse)?;
Ok(Self {
r#type,
credit_line,
amount,
credit_debit_indicator,
date,
availability,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Indicates when the amount of money will become available, that is can be accessed and start generating interest."]
pub struct CashAvailability1<'a> {
#[doc = "Indicates when the amount of money will become available."]
pub date: CashAvailabilityDate1Choice<'a>,
#[doc = "Identifies the available amount."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the availability balance is a credit or a debit balance. \nUsage: A zero balance is considered to be a credit balance."]
pub credit_debit_indicator: CreditDebitCode,
}
impl<'a> CashAvailability1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let date = reader.parse_element("Dt", <CashAvailabilityDate1Choice<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
Ok(Self {
date,
amount,
credit_debit_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Indicates when the amount of money will become available."]
pub enum CashAvailabilityDate1Choice<'a> {
#[doc = "Indicates the number of float days attached to the balance."]
NumberOfDays(Max15PlusSignedNumericText<'a>),
#[doc = "Identifies the actual availability date."]
ActualDate(IsoDate),
}
impl<'a> CashAvailabilityDate1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "NbOfDays".as_bytes() => {
let inner =
reader.parse_element("NbOfDays", <Max15PlusSignedNumericText<'a>>::parse)?;
Self::NumberOfDays(inner)
}
name if name == "ActlDt".as_bytes() => {
let inner = reader.parse_element("ActlDt", <IsoDate>::parse)?;
Self::ActualDate(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide details of the credit line."]
pub struct CreditLine3<'a> {
#[doc = "Indicates whether or not the credit line is included in the balance."]
pub included: TrueFalseIndicator,
#[doc = "Type of the credit line provided when multiple credit lines may be provided."]
pub r#type: Option<CreditLineType1Choice<'a>>,
#[doc = "Amount of money of the credit line."]
pub amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Date of the credit line provided when multiple credit lines may be provided."]
pub date: Option<DateAndDateTime2Choice>,
}
impl<'a> CreditLine3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let included = reader.parse_element("Incl", <TrueFalseIndicator>::parse)?;
let r#type = reader.parse_optional_element("Tp", <CreditLineType1Choice<'a>>::parse)?;
let amount =
reader.parse_optional_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let date = reader.parse_optional_element("Dt", <DateAndDateTime2Choice>::parse)?;
Ok(Self {
included,
r#type,
amount,
date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between a date or a date and time format."]
pub enum DateAndDateTime2Choice {
#[doc = "Specified date."]
Date(IsoDate),
#[doc = "Specified date and time."]
DateTime(IsoDateTime),
}
impl<'a> DateAndDateTime2Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Dt".as_bytes() => {
let inner = reader.parse_element("Dt", <IsoDate>::parse)?;
Self::Date(inner)
}
name if name == "DtTm".as_bytes() => {
let inner = reader.parse_element("DtTm", <IsoDateTime>::parse)?;
Self::DateTime(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the credit line provided."]
pub enum CreditLineType1Choice<'a> {
#[doc = "Type of the credit line, as published in an external purpose code list."]
Code(ExternalCreditLineType1Code),
#[doc = "Type of the credit line, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> CreditLineType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalCreditLineType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the balance type and sub-type."]
pub struct BalanceType13<'a> {
#[doc = "Coded or proprietary format balance type."]
pub code_or_proprietary: BalanceType10Choice<'a>,
#[doc = "Specifies the balance sub-type."]
pub sub_type: Option<BalanceSubType1Choice<'a>>,
}
impl<'a> BalanceType13<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <BalanceType10Choice<'a>>::parse)?;
let sub_type =
reader.parse_optional_element("SubTp", <BalanceSubType1Choice<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
sub_type,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the balance type."]
pub enum BalanceType10Choice<'a> {
#[doc = "Balance type, in a coded format."]
Code(ExternalBalanceType1Code),
#[doc = "Balance type, in a proprietary format."]
Proprietary(Max35Text<'a>),
}
impl<'a> BalanceType10Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalBalanceType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalBalanceType1Code;
#[derive(Clone, Debug)]
#[doc = "Provides further details on the interest that applies to the account at a particular moment in time."]
pub struct AccountInterest4<'a> {
#[doc = "Specifies the type of interest."]
pub r#type: Option<InterestType1Choice<'a>>,
#[doc = "Set of elements used to qualify the interest rate."]
pub rate: Vec<Rate4<'a>>,
#[doc = "Range of time between a start date and an end date for the calculation of the interest."]
pub from_to_date: Option<DateTimePeriod1>,
#[doc = "Specifies the reason for the interest."]
pub reason: Option<Max35Text<'a>>,
#[doc = "Provides details on the tax applied to charges."]
pub tax: Option<TaxCharges2<'a>>,
}
impl<'a> AccountInterest4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <InterestType1Choice<'a>>::parse)?;
let rate = reader.parse_list("Rate", <Rate4<'a>>::parse)?;
let from_to_date = reader.parse_optional_element("FrToDt", <DateTimePeriod1>::parse)?;
let reason = reader.parse_optional_element("Rsn", <Max35Text<'a>>::parse)?;
let tax = reader.parse_optional_element("Tax", <TaxCharges2<'a>>::parse)?;
Ok(Self {
r#type,
rate,
from_to_date,
reason,
tax,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to qualify the interest rate."]
pub struct Rate4<'a> {
#[doc = "Specifies the type of interest rate."]
pub r#type: RateType4Choice<'a>,
#[doc = "An amount range where the interest rate is applicable."]
pub validity_range: Option<ActiveOrHistoricCurrencyAndAmountRange2>,
}
impl<'a> Rate4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <RateType4Choice<'a>>::parse)?;
let validity_range = reader
.parse_optional_element("VldtyRg", <ActiveOrHistoricCurrencyAndAmountRange2>::parse)?;
Ok(Self {
r#type,
validity_range,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Range of amount values."]
pub struct ActiveOrHistoricCurrencyAndAmountRange2 {
#[doc = "Specified amount or amount range."]
pub amount: ImpliedCurrencyAmountRange1Choice,
#[doc = "Indicates whether the amount is a credited or debited amount."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Medium of exchange of value, used to qualify an amount."]
pub currency: CurrencyCode,
}
impl<'a> ActiveOrHistoricCurrencyAndAmountRange2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ImpliedCurrencyAmountRange1Choice>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let currency = reader.parse_element("Ccy", <CurrencyCode>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
currency,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between ranges of values in which an amount is considered valid or a specified amount value which has to be matched or unmatched to be valid."]
pub enum ImpliedCurrencyAmountRange1Choice {
#[doc = "Lower boundary of a range of amount values."]
FromAmount(AmountRangeBoundary1),
#[doc = "Upper boundary of a range of amount values."]
ToAmount(AmountRangeBoundary1),
#[doc = "Range of valid amount values."]
FromToAmount(FromToAmountRange1),
#[doc = "Exact value an amount must match to be considered valid."]
EqualAmount(ImpliedCurrencyAndAmount),
#[doc = "Value that an amount must not match to be considered valid."]
NotEqualAmount(ImpliedCurrencyAndAmount),
}
impl<'a> ImpliedCurrencyAmountRange1Choice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "FrAmt".as_bytes() => {
let inner = reader.parse_element("FrAmt", <AmountRangeBoundary1>::parse)?;
Self::FromAmount(inner)
}
name if name == "ToAmt".as_bytes() => {
let inner = reader.parse_element("ToAmt", <AmountRangeBoundary1>::parse)?;
Self::ToAmount(inner)
}
name if name == "FrToAmt".as_bytes() => {
let inner = reader.parse_element("FrToAmt", <FromToAmountRange1>::parse)?;
Self::FromToAmount(inner)
}
name if name == "EQAmt".as_bytes() => {
let inner = reader.parse_element("EQAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::EqualAmount(inner)
}
name if name == "NEQAmt".as_bytes() => {
let inner = reader.parse_element("NEQAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::NotEqualAmount(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Range of amount values."]
pub struct FromToAmountRange1 {
#[doc = "Lower boundary of a range of amount values."]
pub from_amount: AmountRangeBoundary1,
#[doc = "Upper boundary of a range of amount values."]
pub to_amount: AmountRangeBoundary1,
}
impl<'a> FromToAmountRange1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_amount = reader.parse_element("FrAmt", <AmountRangeBoundary1>::parse)?;
let to_amount = reader.parse_element("ToAmt", <AmountRangeBoundary1>::parse)?;
Ok(Self {
from_amount,
to_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides the details to identify an account."]
pub struct CashAccount38<'a> {
#[doc = "Unique and unambiguous identification for the account between the account owner and the account servicer."]
pub identification: AccountIdentification4Choice<'a>,
#[doc = "Specifies the nature, or use of the account."]
pub r#type: Option<CashAccountType2Choice<'a>>,
#[doc = "Identification of the currency in which the account is held. \n\nUsage: Currency should only be used in case one and the same account number covers several currencies\nand the initiating party needs to identify which currency needs to be used for settlement on the account."]
pub currency: Option<CurrencyCode>,
#[doc = "Name of the account, as assigned by the account servicing institution, in agreement with the account owner in order to provide an additional means of identification of the account.\n\nUsage: The account name is different from the account owner name. The account name is used in certain user communities to provide a means of identifying the account, in addition to the account owner's identity and the account number."]
pub name: Option<Max70Text<'a>>,
#[doc = "Specifies an alternate assumed name for the identification of the account. "]
pub proxy: Option<ProxyAccountIdentification1<'a>>,
}
impl<'a> CashAccount38<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification =
reader.parse_element("Id", <AccountIdentification4Choice<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <CashAccountType2Choice<'a>>::parse)?;
let currency = reader.parse_optional_element("Ccy", <CurrencyCode>::parse)?;
let name = reader.parse_optional_element("Nm", <Max70Text<'a>>::parse)?;
let proxy =
reader.parse_optional_element("Prxy", <ProxyAccountIdentification1<'a>>::parse)?;
Ok(Self {
identification,
r#type,
currency,
name,
proxy,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides the details to identify an account."]
pub struct CashAccount39<'a> {
#[doc = "Unique and unambiguous identification for the account between the account owner and the account servicer."]
pub identification: AccountIdentification4Choice<'a>,
#[doc = "Specifies the nature, or use of the account."]
pub r#type: Option<CashAccountType2Choice<'a>>,
#[doc = "Identification of the currency in which the account is held."]
pub currency: Option<CurrencyCode>,
#[doc = "Name of the account, as assigned by the account servicing institution, in agreement with the account owner in order to provide an additional means of identification of the account.\n\nUsage: The account name is different from the account owner name. The account name is used in certain user communities to provide a means of identifying the account, in addition to the account owner's identity and the account number."]
pub name: Option<Max70Text<'a>>,
#[doc = "Specifies an alternate assumed name for the identification of the account. "]
pub proxy: Option<ProxyAccountIdentification1<'a>>,
#[doc = "Party that legally owns the account."]
pub owner: Option<PartyIdentification135<'a>>,
#[doc = "Party that manages the account on behalf of the account owner, that is manages the registration and booking of entries on the account, calculates balances on the account and provides information about the account."]
pub servicer: Option<BranchAndFinancialInstitutionIdentification6<'a>>,
}
impl<'a> CashAccount39<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification =
reader.parse_element("Id", <AccountIdentification4Choice<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <CashAccountType2Choice<'a>>::parse)?;
let currency = reader.parse_optional_element("Ccy", <CurrencyCode>::parse)?;
let name = reader.parse_optional_element("Nm", <Max70Text<'a>>::parse)?;
let proxy =
reader.parse_optional_element("Prxy", <ProxyAccountIdentification1<'a>>::parse)?;
let owner = reader.parse_optional_element("Ownr", <PartyIdentification135<'a>>::parse)?;
let servicer = reader.parse_optional_element(
"Svcr",
<BranchAndFinancialInstitutionIdentification6<'a>>::parse,
)?;
Ok(Self {
identification,
r#type,
currency,
name,
proxy,
owner,
servicer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Unique and unambiguous identification of a financial institution or a branch of a financial institution."]
pub struct BranchAndFinancialInstitutionIdentification6<'a> {
#[doc = "Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme."]
pub financial_institution_identification: FinancialInstitutionIdentification18<'a>,
#[doc = "Identifies a specific branch of a financial institution.\n\nUsage: This component should be used in case the identification information in the financial institution component does not provide identification up to branch level."]
pub branch_identification: Option<BranchData3<'a>>,
}
impl<'a> BranchAndFinancialInstitutionIdentification6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let financial_institution_identification = reader.parse_element(
"FinInstnId",
<FinancialInstitutionIdentification18<'a>>::parse,
)?;
let branch_identification =
reader.parse_optional_element("BrnchId", <BranchData3<'a>>::parse)?;
Ok(Self {
financial_institution_identification,
branch_identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a specific branch of a financial institution."]
pub struct BranchData3<'a> {
#[doc = "Unique and unambiguous identification of a branch of a financial institution."]
pub identification: Option<Max35Text<'a>>,
#[doc = "Legal entity identification for the branch of the financial institution."]
pub lei: Option<LeiIdentifier>,
#[doc = "Name by which an agent is known and which is usually used to identify that agent."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress24<'a>>,
}
impl<'a> BranchData3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_optional_element("Id", <Max35Text<'a>>::parse)?;
let lei = reader.parse_optional_element("LEI", <LeiIdentifier>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress24<'a>>::parse)?;
Ok(Self {
identification,
lei,
name,
postal_address,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the details to identify a financial institution."]
pub struct FinancialInstitutionIdentification18<'a> {
#[doc = "Code allocated to a financial institution by the ISO 9362 Registration Authority as described in ISO 9362 \"Banking - Banking telecommunication messages - Business identifier code (BIC)\"."]
pub bicfi: Option<BicIdentifier<'a>>,
#[doc = "Information used to identify a member within a clearing system."]
pub clearing_system_member_identification: Option<ClearingSystemMemberIdentification2<'a>>,
#[doc = "Legal entity identifier of the financial institution."]
pub lei: Option<LeiIdentifier>,
#[doc = "Name by which an agent is known and which is usually used to identify that agent."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress24<'a>>,
#[doc = "Unique identification of an agent, as assigned by an institution, using an identification scheme."]
pub other: Option<GenericFinancialIdentification1<'a>>,
}
impl<'a> FinancialInstitutionIdentification18<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let bicfi = reader.parse_optional_element("BICFI", <BicIdentifier<'a>>::parse)?;
let clearing_system_member_identification = reader.parse_optional_element(
"ClrSysMmbId",
<ClearingSystemMemberIdentification2<'a>>::parse,
)?;
let lei = reader.parse_optional_element("LEI", <LeiIdentifier>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress24<'a>>::parse)?;
let other =
reader.parse_optional_element("Othr", <GenericFinancialIdentification1<'a>>::parse)?;
Ok(Self {
bicfi,
clearing_system_member_identification,
lei,
name,
postal_address,
other,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to a proxy identification of the account."]
pub struct ProxyAccountIdentification1<'a> {
#[doc = "Type of the proxy identification."]
pub r#type: Option<ProxyAccountType1Choice<'a>>,
#[doc = "Identification used to indicate the account identification under another specified name."]
pub identification: Max2048Text<'a>,
}
impl<'a> ProxyAccountIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <ProxyAccountType1Choice<'a>>::parse)?;
let identification = reader.parse_element("Id", <Max2048Text<'a>>::parse)?;
Ok(Self {
r#type,
identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the scheme used for the identification of an account alias."]
pub enum ProxyAccountType1Choice<'a> {
#[doc = "Name of the identification scheme, in a coded form as published in an external list."]
Code(ExternalProxyAccountType1Code),
#[doc = "Name of the identification scheme, in a free text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> ProxyAccountType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalProxyAccountType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalProxyAccountType1Code;
#[derive(Clone, Debug)]
#[doc = "Nature or use of the account."]
pub enum CashAccountType2Choice<'a> {
#[doc = "Account type, in a coded form."]
Code(ExternalCashAccountType1Code),
#[doc = "Nature or use of the account in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> CashAccountType2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalCashAccountType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalCashAccountType1Code;
#[derive(Clone, Debug)]
#[doc = "Time span defined by a start date and time, and an end date and time."]
pub struct DateTimePeriod1 {
#[doc = "Date and time at which the period starts."]
pub from_date_time: IsoDateTime,
#[doc = "Date and time at which the period ends."]
pub to_date_time: IsoDateTime,
}
impl<'a> DateTimePeriod1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_date_time = reader.parse_element("FrDtTm", <IsoDateTime>::parse)?;
let to_date_time = reader.parse_element("ToDtTm", <IsoDateTime>::parse)?;
Ok(Self {
from_date_time,
to_date_time,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies a choice of sequences."]
pub enum SequenceRange1Choice<'a> {
#[doc = "Start sequence of the range."]
FromSequence(Max35Text<'a>),
#[doc = "End sequence of the range."]
ToSequence(Max35Text<'a>),
#[doc = "Particular sequence range specified between a start sequence and an end sequence."]
FromToSequence(Vec<SequenceRange1<'a>>),
#[doc = "Specified sequence to match."]
EqualSequence(Vec<Max35Text<'a>>),
#[doc = "Specified sequence to be excluded."]
NotEqualSequence(Vec<Max35Text<'a>>),
}
impl<'a> SequenceRange1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "FrSeq".as_bytes() => {
let inner = reader.parse_element("FrSeq", <Max35Text<'a>>::parse)?;
Self::FromSequence(inner)
}
name if name == "ToSeq".as_bytes() => {
let inner = reader.parse_element("ToSeq", <Max35Text<'a>>::parse)?;
Self::ToSequence(inner)
}
name if name == "FrToSeq".as_bytes() => {
let inner = reader.parse_list("FrToSeq", <SequenceRange1<'a>>::parse)?;
Self::FromToSequence(inner)
}
name if name == "EQSeq".as_bytes() => {
let inner = reader.parse_list("EQSeq", <Max35Text<'a>>::parse)?;
Self::EqualSequence(inner)
}
name if name == "NEQSeq".as_bytes() => {
let inner = reader.parse_list("NEQSeq", <Max35Text<'a>>::parse)?;
Self::NotEqualSequence(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies a range of sequences from a start sequence to an end sequence."]
pub struct SequenceRange1<'a> {
#[doc = "Start sequence of the range."]
pub from_sequence: Max35Text<'a>,
#[doc = "End sequence of the range."]
pub to_sequence: Max35Text<'a>,
}
impl<'a> SequenceRange1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_sequence = reader.parse_element("FrSeq", <Max35Text<'a>>::parse)?;
let to_sequence = reader.parse_element("ToSeq", <Max35Text<'a>>::parse)?;
Ok(Self {
from_sequence,
to_sequence,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides further details on the message."]
pub struct GroupHeader81<'a> {
#[doc = "Point to point reference, as assigned by the account servicing institution, and sent to the account owner or the party authorised to receive the message, to unambiguously identify the message.\nUsage: The account servicing institution has to make sure that MessageIdentification is unique per account owner for a pre-agreed period."]
pub message_identification: Max35Text<'a>,
#[doc = "Date and time at which the message was created."]
pub creation_date_time: IsoDateTime,
#[doc = "Party authorised by the account owner to receive information about movements on the account.\nUsage: MessageRecipient should only be identified when different from the account owner."]
pub message_recipient: Option<PartyIdentification135<'a>>,
#[doc = "Provides details on the page number of the message.\n\nUsage: The pagination of the message is only allowed when agreed between the parties."]
pub message_pagination: Option<Pagination1<'a>>,
#[doc = "Unique identification, as assigned by the original requestor, to unambiguously identify the business query message."]
pub original_business_query: Option<OriginalBusinessQuery1<'a>>,
#[doc = "Further details of the message."]
pub additional_information: Option<Max500Text<'a>>,
}
impl<'a> GroupHeader81<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification = reader.parse_element("MsgId", <Max35Text<'a>>::parse)?;
let creation_date_time = reader.parse_element("CreDtTm", <IsoDateTime>::parse)?;
let message_recipient =
reader.parse_optional_element("MsgRcpt", <PartyIdentification135<'a>>::parse)?;
let message_pagination =
reader.parse_optional_element("MsgPgntn", <Pagination1<'a>>::parse)?;
let original_business_query =
reader.parse_optional_element("OrgnlBizQry", <OriginalBusinessQuery1<'a>>::parse)?;
let additional_information =
reader.parse_optional_element("AddtlInf", <Max500Text<'a>>::parse)?;
Ok(Self {
message_identification,
creation_date_time,
message_recipient,
message_pagination,
original_business_query,
additional_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Unique identification, as assigned by the original requestor, to unambiguously identify the business query message."]
pub struct OriginalBusinessQuery1<'a> {
#[doc = "Point to point reference, as assigned by the original initiating party, to unambiguously identify the original query message."]
pub message_identification: Max35Text<'a>,
#[doc = "Specifies the query message name identifier to which the message refers."]
pub message_name_identification: Option<Max35Text<'a>>,
#[doc = "Date and time at which the message was created."]
pub creation_date_time: Option<IsoDateTime>,
}
impl<'a> OriginalBusinessQuery1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification = reader.parse_element("MsgId", <Max35Text<'a>>::parse)?;
let message_name_identification =
reader.parse_optional_element("MsgNmId", <Max35Text<'a>>::parse)?;
let creation_date_time = reader.parse_optional_element("CreDtTm", <IsoDateTime>::parse)?;
Ok(Self {
message_identification,
message_name_identification,
creation_date_time,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Number used to sequence pages when it is not possible for data to be conveyed in a single message and the data has to be split across several pages (messages)."]
pub struct Pagination1<'a> {
#[doc = "Page number."]
pub page_number: Max5NumericText<'a>,
#[doc = "Indicates the last page."]
pub last_page_indicator: YesNoIndicator,
}
impl<'a> Pagination1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let page_number = reader.parse_element("PgNb", <Max5NumericText<'a>>::parse)?;
let last_page_indicator = reader.parse_element("LastPgInd", <YesNoIndicator>::parse)?;
Ok(Self {
page_number,
last_page_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the identification of a person or an organisation."]
pub struct PartyIdentification135<'a> {
#[doc = "Name by which a party is known and which is usually used to identify that party."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress24<'a>>,
#[doc = "Unique and unambiguous identification of a party."]
pub identification: Option<Party38Choice<'a>>,
#[doc = "Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed."]
pub country_of_residence: Option<CountryCode>,
#[doc = "Set of elements used to indicate how to contact the party."]
pub contact_details: Option<Contact4<'a>>,
}
impl<'a> PartyIdentification135<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress24<'a>>::parse)?;
let identification = reader.parse_optional_element("Id", <Party38Choice<'a>>::parse)?;
let country_of_residence =
reader.parse_optional_element("CtryOfRes", <CountryCode>::parse)?;
let contact_details = reader.parse_optional_element("CtctDtls", <Contact4<'a>>::parse)?;
Ok(Self {
name,
postal_address,
identification,
country_of_residence,
contact_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the details of the contact person."]
pub struct Contact4<'a> {
#[doc = "Specifies the terms used to formally address a person."]
pub name_prefix: Option<NamePrefix2Code>,
#[doc = "Name by which a party is known and which is usually used to identify that party."]
pub name: Option<Max140Text<'a>>,
#[doc = "Collection of information that identifies a phone number, as defined by telecom services."]
pub phone_number: Option<PhoneNumber<'a>>,
#[doc = "Collection of information that identifies a mobile phone number, as defined by telecom services."]
pub mobile_number: Option<PhoneNumber<'a>>,
#[doc = "Collection of information that identifies a FAX number, as defined by telecom services."]
pub fax_number: Option<PhoneNumber<'a>>,
#[doc = "Address for electronic mail (e-mail)."]
pub email_address: Option<Max2048Text<'a>>,
#[doc = "Purpose for which an email address may be used."]
pub email_purpose: Option<Max35Text<'a>>,
#[doc = "Title of the function."]
pub job_title: Option<Max35Text<'a>>,
#[doc = "Role of a person in an organisation."]
pub responsibility: Option<Max35Text<'a>>,
#[doc = "Identification of a division of a large organisation or building."]
pub department: Option<Max70Text<'a>>,
#[doc = "Contact details in another form."]
pub other: Vec<OtherContact1<'a>>,
#[doc = "Preferred method used to reach the contact."]
pub preferred_method: Option<PreferredContactMethod1Code>,
}
impl<'a> Contact4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name_prefix = reader.parse_optional_element("NmPrfx", <NamePrefix2Code>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let phone_number = reader.parse_optional_element("PhneNb", <PhoneNumber<'a>>::parse)?;
let mobile_number = reader.parse_optional_element("MobNb", <PhoneNumber<'a>>::parse)?;
let fax_number = reader.parse_optional_element("FaxNb", <PhoneNumber<'a>>::parse)?;
let email_address = reader.parse_optional_element("EmailAdr", <Max2048Text<'a>>::parse)?;
let email_purpose = reader.parse_optional_element("EmailPurp", <Max35Text<'a>>::parse)?;
let job_title = reader.parse_optional_element("JobTitl", <Max35Text<'a>>::parse)?;
let responsibility = reader.parse_optional_element("Rspnsblty", <Max35Text<'a>>::parse)?;
let department = reader.parse_optional_element("Dept", <Max70Text<'a>>::parse)?;
let other = reader.parse_list("Othr", <OtherContact1<'a>>::parse)?;
let preferred_method =
reader.parse_optional_element("PrefrdMtd", <PreferredContactMethod1Code>::parse)?;
Ok(Self {
name_prefix,
name,
phone_number,
mobile_number,
fax_number,
email_address,
email_purpose,
job_title,
responsibility,
department,
other,
preferred_method,
})
}
}
pub type PreferredContactMethod1Code = PreferredContactMethodCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Preferred method used to reach the individual contact within an organisation."]
pub enum PreferredContactMethodCode {
#[doc = "Preferred method used to reach the contact is per letter."]
Letter,
#[doc = "Preferred method used to reach the contact is per email."]
Email,
#[doc = "Preferred method used to reach the contact is per phone."]
Phone,
#[doc = "Preferred method used to reach the contact is per fax."]
Fax,
#[doc = "Preferred method used to reach the contact is per mobile or cell phone."]
MobileOrCellPhone,
}
impl<'a> PreferredContactMethodCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"LETT" => Self::Letter,
"MAIL" => Self::Email,
"PHON" => Self::Phone,
"FAXX" => Self::Fax,
"CELL" => Self::MobileOrCellPhone,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Communication device number or electronic address used for communication."]
pub struct OtherContact1<'a> {
#[doc = "Method used to contact the financial institution’s contact for the specific tax region."]
pub channel_type: Max4Text<'a>,
#[doc = "Communication value such as phone number or email address."]
pub identification: Option<Max128Text<'a>>,
}
impl<'a> OtherContact1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let channel_type = reader.parse_element("ChanlTp", <Max4Text<'a>>::parse)?;
let identification = reader.parse_optional_element("Id", <Max128Text<'a>>::parse)?;
Ok(Self {
channel_type,
identification,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 128 characters."]
pub struct Max128Text<'a>(Cow<'a, str>);
impl<'a> Max128Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=128usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
pub type NamePrefix2Code = NamePrefixCode;
#[derive(Clone, Debug)]
#[doc = "Nature or use of the account."]
pub enum Party38Choice<'a> {
#[doc = "Unique and unambiguous way to identify an organisation."]
OrganisationIdentification(OrganisationIdentification29<'a>),
#[doc = "Unique and unambiguous identification of a person, for example a passport."]
PrivateIdentification(PersonIdentification13<'a>),
}
impl<'a> Party38Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "OrgId".as_bytes() => {
let inner =
reader.parse_element("OrgId", <OrganisationIdentification29<'a>>::parse)?;
Self::OrganisationIdentification(inner)
}
name if name == "PrvtId".as_bytes() => {
let inner = reader.parse_element("PrvtId", <PersonIdentification13<'a>>::parse)?;
Self::PrivateIdentification(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Unique and unambiguous way to identify a person."]
pub struct PersonIdentification13<'a> {
#[doc = "Date and place of birth of a person."]
pub date_and_place_of_birth: Option<DateAndPlaceOfBirth1<'a>>,
#[doc = "Unique identification of a person, as assigned by an institution, using an identification scheme."]
pub other: Vec<GenericPersonIdentification1<'a>>,
}
impl<'a> PersonIdentification13<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let date_and_place_of_birth =
reader.parse_optional_element("DtAndPlcOfBirth", <DateAndPlaceOfBirth1<'a>>::parse)?;
let other = reader.parse_list("Othr", <GenericPersonIdentification1<'a>>::parse)?;
Ok(Self {
date_and_place_of_birth,
other,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Date and place of birth of a person."]
pub struct DateAndPlaceOfBirth1<'a> {
#[doc = "Date on which a person is born."]
pub birth_date: IsoDate,
#[doc = "Province where a person was born."]
pub province_of_birth: Option<Max35Text<'a>>,
#[doc = "City where a person was born."]
pub city_of_birth: Max35Text<'a>,
#[doc = "Country where a person was born."]
pub country_of_birth: CountryCode,
}
impl<'a> DateAndPlaceOfBirth1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let birth_date = reader.parse_element("BirthDt", <IsoDate>::parse)?;
let province_of_birth =
reader.parse_optional_element("PrvcOfBirth", <Max35Text<'a>>::parse)?;
let city_of_birth = reader.parse_element("CityOfBirth", <Max35Text<'a>>::parse)?;
let country_of_birth = reader.parse_element("CtryOfBirth", <CountryCode>::parse)?;
Ok(Self {
birth_date,
province_of_birth,
city_of_birth,
country_of_birth,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Unique and unambiguous way to identify an organisation."]
pub struct OrganisationIdentification29<'a> {
#[doc = "Business identification code of the organisation."]
pub any_bic: Option<BicIdentifier<'a>>,
#[doc = "Legal entity identification as an alternate identification for a party."]
pub lei: Option<LeiIdentifier>,
#[doc = "Unique identification of an organisation, as assigned by an institution, using an identification scheme."]
pub other: Vec<GenericOrganisationIdentification1<'a>>,
}
impl<'a> OrganisationIdentification29<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let any_bic = reader.parse_optional_element("AnyBIC", <BicIdentifier<'a>>::parse)?;
let lei = reader.parse_optional_element("LEI", <LeiIdentifier>::parse)?;
let other = reader.parse_list("Othr", <GenericOrganisationIdentification1<'a>>::parse)?;
Ok(Self {
any_bic,
lei,
other,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub struct PostalAddress24<'a> {
#[doc = "Identifies the nature of the postal address."]
pub address_type: Option<AddressType3Choice<'a>>,
#[doc = "Identification of a division of a large organisation or building."]
pub department: Option<Max70Text<'a>>,
#[doc = "Identification of a sub-division of a large organisation or building."]
pub sub_department: Option<Max70Text<'a>>,
#[doc = "Name of a street or thoroughfare."]
pub street_name: Option<Max70Text<'a>>,
#[doc = "Number that identifies the position of a building on a street."]
pub building_number: Option<Max16Text<'a>>,
#[doc = "Name of the building or house."]
pub building_name: Option<Max35Text<'a>>,
#[doc = "Floor or storey within a building."]
pub floor: Option<Max70Text<'a>>,
#[doc = "Numbered box in a post office, assigned to a person or organisation, where letters are kept until called for."]
pub post_box: Option<Max16Text<'a>>,
#[doc = "Building room number."]
pub room: Option<Max70Text<'a>>,
#[doc = "Identifier consisting of a group of letters and/or numbers that is added to a postal address to assist the sorting of mail."]
pub post_code: Option<Max16Text<'a>>,
#[doc = "Name of a built-up area, with defined boundaries, and a local government."]
pub town_name: Option<Max35Text<'a>>,
#[doc = "Specific location name within the town."]
pub town_location_name: Option<Max35Text<'a>>,
#[doc = "Identifies a subdivision within a country sub-division."]
pub district_name: Option<Max35Text<'a>>,
#[doc = "Identifies a subdivision of a country such as state, region, county."]
pub country_sub_division: Option<Max35Text<'a>>,
#[doc = "Nation with its own government."]
pub country: Option<CountryCode>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services, presented in free format text."]
pub address_line: Vec<Max70Text<'a>>,
}
impl<'a> PostalAddress24<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let address_type =
reader.parse_optional_element("AdrTp", <AddressType3Choice<'a>>::parse)?;
let department = reader.parse_optional_element("Dept", <Max70Text<'a>>::parse)?;
let sub_department = reader.parse_optional_element("SubDept", <Max70Text<'a>>::parse)?;
let street_name = reader.parse_optional_element("StrtNm", <Max70Text<'a>>::parse)?;
let building_number = reader.parse_optional_element("BldgNb", <Max16Text<'a>>::parse)?;
let building_name = reader.parse_optional_element("BldgNm", <Max35Text<'a>>::parse)?;
let floor = reader.parse_optional_element("Flr", <Max70Text<'a>>::parse)?;
let post_box = reader.parse_optional_element("PstBx", <Max16Text<'a>>::parse)?;
let room = reader.parse_optional_element("Room", <Max70Text<'a>>::parse)?;
let post_code = reader.parse_optional_element("PstCd", <Max16Text<'a>>::parse)?;
let town_name = reader.parse_optional_element("TwnNm", <Max35Text<'a>>::parse)?;
let town_location_name =
reader.parse_optional_element("TwnLctnNm", <Max35Text<'a>>::parse)?;
let district_name = reader.parse_optional_element("DstrctNm", <Max35Text<'a>>::parse)?;
let country_sub_division =
reader.parse_optional_element("CtrySubDvsn", <Max35Text<'a>>::parse)?;
let country = reader.parse_optional_element("Ctry", <CountryCode>::parse)?;
let address_line = reader.parse_list("AdrLine", <Max70Text<'a>>::parse)?;
Ok(Self {
address_type,
department,
sub_department,
street_name,
building_number,
building_name,
floor,
post_box,
room,
post_code,
town_name,
town_location_name,
district_name,
country_sub_division,
country,
address_line,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice of formats for the type of address."]
pub enum AddressType3Choice<'a> {
#[doc = "Type of address expressed as a code."]
Code(AddressType2Code),
#[doc = "Type of address expressed as a proprietary code."]
Proprietary(GenericIdentification30<'a>),
}
impl<'a> AddressType3Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <AddressType2Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <GenericIdentification30<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification, for example, party identification or account identification."]
pub struct GenericIdentification30<'a> {
#[doc = "Proprietary information, often a code, issued by the data source scheme issuer."]
pub identification: Exact4AlphaNumericText<'a>,
#[doc = "Entity that assigns the identification."]
pub issuer: Max35Text<'a>,
#[doc = "Short textual description of the scheme."]
pub scheme_name: Option<Max35Text<'a>>,
}
impl<'a> GenericIdentification30<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Exact4AlphaNumericText<'a>>::parse)?;
let issuer = reader.parse_element("Issr", <Max35Text<'a>>::parse)?;
let scheme_name = reader.parse_optional_element("SchmeNm", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
issuer,
scheme_name,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies an alphanumeric string with a length of 4 characters."]
pub struct Exact4AlphaNumericText<'a>(Cow<'a, str>);
impl<'a> Exact4AlphaNumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Scope\r\nThe BankToCustomerAccountReport message is sent by the account servicer to an account owner or to a party authorised by the account owner to receive the message. It can be used to inform the account owner, or authorised party, of the entries reported to the account, and/or to provide the owner with balance information on the account at a given point in time.\r\nUsage\r\nThe BankToCustomerAccountReport message can contain reports for more than one account. It provides information for cash management and/or reconciliation. It can be used to:\r\n- report pending and booked items;\r\n- provide balance information.\r\nIt can include underlying details of transactions that have been included in the entry.\r\nIt is possible that the receiver of the message is not the account owner, but a party entitled by the account owner to receive the account information (also known as recipient).\r\nFor a statement, the Bank-to-Customer Account Statement message should be used."]
pub struct BankToCustomerAccountReportV02<'a> {
#[doc = "Common information for the message."]
pub group_header: GroupHeader42<'a>,
#[doc = "Reports on a cash account."]
pub report: Vec<AccountReport11<'a>>,
}
impl<'a> BankToCustomerAccountReportV02<'a> {
pub fn from_str(document: &'a str) -> XmlResult<Self> {
let mut reader = XmlReader::from_str(document);
reader.try_declaration()?;
reader.parse_element("Document", |reader, _| {
reader.parse_element("BkToCstmrAcctRpt", Self::parse)
})
}
}
impl<'a> BankToCustomerAccountReportV02<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let group_header = reader.parse_element("GrpHdr", <GroupHeader42<'a>>::parse)?;
let report = reader.parse_list("Rpt", <AccountReport11<'a>>::parse)?;
Ok(Self {
group_header,
report,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide details of the account report."]
pub struct AccountReport11<'a> {
#[doc = "Unique identification, as assigned by the account servicer, to unambiguously identify the account report."]
pub identification: Max35Text<'a>,
#[doc = "Sequential number of the report, as assigned by the account servicer. \nUsage: The sequential number is increased incrementally for each report sent electronically."]
pub electronic_sequence_number: Option<Number>,
#[doc = "Legal sequential number of the report, as assigned by the account servicer. It is increased incrementally for each report sent."]
pub legal_sequence_number: Option<Number>,
#[doc = "Date and time at which the message was created."]
pub creation_date_time: IsoDateTime,
#[doc = "Range of time between a start date and an end date for which the account report is issued."]
pub from_to_date: Option<DateTimePeriodDetails>,
#[doc = "Indicates whether the document is a copy, a duplicate, or a duplicate of a copy."]
pub copy_duplicate_indicator: Option<CopyDuplicate1Code>,
#[doc = "Specifies the application used to generate the reporting."]
pub reporting_source: Option<ReportingSource1Choice<'a>>,
#[doc = "Unambiguous identification of the account to which credit and debit entries are made."]
pub account: CashAccount20<'a>,
#[doc = "Identifies the parent account of the account for which the report has been issued."]
pub related_account: Option<CashAccount16<'a>>,
#[doc = "Set of elements used to provide general interest information that applies to the account at a particular moment in time."]
pub interest: Vec<AccountInterest2<'a>>,
#[doc = "Set of elements used to define the balance as a numerical representation of the net increases and decreases in an account at a specific point in time."]
pub balance: Vec<CashBalance3<'a>>,
#[doc = "Set of elements used to provide summary information on entries."]
pub transactions_summary: Option<TotalTransactions2<'a>>,
#[doc = "Set of elements used to specify an entry in the report.\nUsage: At least one reference must be provided to identify the entry and its underlying transaction(s)."]
pub entry: Vec<ReportEntry2<'a>>,
#[doc = "Further details of the account report."]
pub additional_report_information: Option<Max500Text<'a>>,
}
impl<'a> AccountReport11<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let electronic_sequence_number =
reader.parse_optional_element("ElctrncSeqNb", <Number>::parse)?;
let legal_sequence_number = reader.parse_optional_element("LglSeqNb", <Number>::parse)?;
let creation_date_time = reader.parse_element("CreDtTm", <IsoDateTime>::parse)?;
let from_to_date =
reader.parse_optional_element("FrToDt", <DateTimePeriodDetails>::parse)?;
let copy_duplicate_indicator =
reader.parse_optional_element("CpyDplctInd", <CopyDuplicate1Code>::parse)?;
let reporting_source =
reader.parse_optional_element("RptgSrc", <ReportingSource1Choice<'a>>::parse)?;
let account = reader.parse_element("Acct", <CashAccount20<'a>>::parse)?;
let related_account =
reader.parse_optional_element("RltdAcct", <CashAccount16<'a>>::parse)?;
let interest = reader.parse_list("Intrst", <AccountInterest2<'a>>::parse)?;
let balance = reader.parse_list("Bal", <CashBalance3<'a>>::parse)?;
let transactions_summary =
reader.parse_optional_element("TxsSummry", <TotalTransactions2<'a>>::parse)?;
let entry = reader.parse_list("Ntry", <ReportEntry2<'a>>::parse)?;
let additional_report_information =
reader.parse_optional_element("AddtlRptInf", <Max500Text<'a>>::parse)?;
Ok(Self {
identification,
electronic_sequence_number,
legal_sequence_number,
creation_date_time,
from_to_date,
copy_duplicate_indicator,
reporting_source,
account,
related_account,
interest,
balance,
transactions_summary,
entry,
additional_report_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on an entry in the report."]
pub struct ReportEntry2<'a> {
#[doc = "Unique reference for the entry."]
pub entry_reference: Option<Max35Text<'a>>,
#[doc = "Amount of money in the cash entry."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the entry is a credit or a debit entry."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Indicates whether or not the entry is the result of a reversal.\nUsage: This element should only be present if the entry is the result of a reversal.\nIf the CreditDebitIndicator is CRDT and ReversalIndicator is Yes, the original operation was a debit entry.\nIf the CreditDebitIndicator is DBIT and ReversalIndicator is Yes, the original operation was a credit entry."]
pub reversal_indicator: Option<TrueFalseIndicator>,
#[doc = "Status of an entry on the books of the account servicer."]
pub status: EntryStatus2Code,
#[doc = "Date and time when an entry is posted to an account on the account servicer's books.\n\nUsage: Booking date is the expected booking date, unless the status is booked, in which case it is the actual booking date."]
pub booking_date: Option<DateAndDateTimeChoice>,
#[doc = "Date and time at which assets become available to the account owner in case of a credit entry, or cease to be available to the account owner in case of a debit entry.\nUsage: If entry status is pending and value date is present, then the value date refers to an expected/requested value date.\nFor entries subject to availability/float and for which availability information is provided, the value date must not be used. In this case the availability component identifies the number of availability days."]
pub value_date: Option<DateAndDateTimeChoice>,
#[doc = "Unique reference as assigned by the account servicing institution to unambiguously identify the entry."]
pub account_servicer_reference: Option<Max35Text<'a>>,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashBalanceAvailability2<'a>>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: BankTransactionCodeStructure4<'a>,
#[doc = "Indicates whether the transaction is exempt from commission."]
pub commission_waiver_indicator: Option<YesNoIndicator>,
#[doc = "Indicates whether the underlying transaction details are provided through a separate message, as in the case of aggregate bookings."]
pub additional_information_indicator: Option<MessageIdentification2<'a>>,
#[doc = "Set of elements providing information on the original amount.\n\nUsage: This component (on entry level) should be used when a total original batch or aggregate amount has to be provided. If required, the individual original amounts can be included in the same component on transaction details level."]
pub amount_details: Option<AmountAndCurrencyExchange3<'a>>,
#[doc = "Provides information on the charges included in the entry amount.\n\nUsage: This component is used on entry level in case of batch or aggregate bookings."]
pub charges: Vec<ChargesInformation6<'a>>,
#[doc = "Channel used to technically input the instruction related to the entry."]
pub technical_input_channel: Option<TechnicalInputChannel1Choice<'a>>,
#[doc = "Set of elements used to provide details of the interest amount included in the entry amount.\n\nUsage: This component is used on entry level in the case of batch or aggregate bookings."]
pub interest: Vec<TransactionInterest2<'a>>,
#[doc = "Set of elements used to provide details on the entry."]
pub entry_details: Vec<EntryDetails1<'a>>,
#[doc = "Further details of the entry."]
pub additional_entry_information: Option<Max500Text<'a>>,
}
impl<'a> ReportEntry2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let entry_reference = reader.parse_optional_element("NtryRef", <Max35Text<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let reversal_indicator =
reader.parse_optional_element("RvslInd", <TrueFalseIndicator>::parse)?;
let status = reader.parse_element("Sts", <EntryStatus2Code>::parse)?;
let booking_date =
reader.parse_optional_element("BookgDt", <DateAndDateTimeChoice>::parse)?;
let value_date = reader.parse_optional_element("ValDt", <DateAndDateTimeChoice>::parse)?;
let account_servicer_reference =
reader.parse_optional_element("AcctSvcrRef", <Max35Text<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashBalanceAvailability2<'a>>::parse)?;
let bank_transaction_code =
reader.parse_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let commission_waiver_indicator =
reader.parse_optional_element("ComssnWvrInd", <YesNoIndicator>::parse)?;
let additional_information_indicator =
reader.parse_optional_element("AddtlInfInd", <MessageIdentification2<'a>>::parse)?;
let amount_details =
reader.parse_optional_element("AmtDtls", <AmountAndCurrencyExchange3<'a>>::parse)?;
let charges = reader.parse_list("Chrgs", <ChargesInformation6<'a>>::parse)?;
let technical_input_channel = reader
.parse_optional_element("TechInptChanl", <TechnicalInputChannel1Choice<'a>>::parse)?;
let interest = reader.parse_list("Intrst", <TransactionInterest2<'a>>::parse)?;
let entry_details = reader.parse_list("NtryDtls", <EntryDetails1<'a>>::parse)?;
let additional_entry_information =
reader.parse_optional_element("AddtlNtryInf", <Max500Text<'a>>::parse)?;
Ok(Self {
entry_reference,
amount,
credit_debit_indicator,
reversal_indicator,
status,
booking_date,
value_date,
account_servicer_reference,
availability,
bank_transaction_code,
commission_waiver_indicator,
additional_information_indicator,
amount_details,
charges,
technical_input_channel,
interest,
entry_details,
additional_entry_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the underlying transaction(s) and/or batched entries."]
pub struct EntryDetails1<'a> {
#[doc = "Set of elements used to provide details on batched transactions."]
pub batch: Option<BatchInformation2<'a>>,
#[doc = "Set of elements used to provide information on the underlying transaction(s)."]
pub transaction_details: Vec<EntryTransaction2<'a>>,
}
impl<'a> EntryDetails1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let batch = reader.parse_optional_element("Btch", <BatchInformation2<'a>>::parse)?;
let transaction_details = reader.parse_list("TxDtls", <EntryTransaction2<'a>>::parse)?;
Ok(Self {
batch,
transaction_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the underlying transaction."]
pub struct EntryTransaction2<'a> {
#[doc = "Set of elements used to provide the identification of the underlying transaction."]
pub references: Option<TransactionReferences2<'a>>,
#[doc = "Set of elements providing detailed information on the original amount.\n\nUsage: This component (on transaction level) should be used in case booking is for a single transaction and the original amount is different from the entry amount. It can also be used in case individual original amounts are provided in case of a batch or aggregate booking."]
pub amount_details: Option<AmountAndCurrencyExchange3<'a>>,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashBalanceAvailability2<'a>>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: Option<BankTransactionCodeStructure4<'a>>,
#[doc = "Provides information on the charges included in the entry amount.\n\nUsage: This component (on transaction level) can be used in case the booking is for a single transaction, and charges are included in the entry amount. It can also be used in case individual charge amounts are applied to individual transactions in case of a batch or aggregate amount booking."]
pub charges: Vec<ChargesInformation6<'a>>,
#[doc = "Set of elements used to provide details of the interest amount included in the entry amount.\n\nUsage: This component (on transaction level) can be used if the booking is for a single transaction, and interest amount is included in the entry amount. It can also be used if individual interest amounts are applied to individual transactions in the case of a batch or aggregate amount booking."]
pub interest: Vec<TransactionInterest2<'a>>,
#[doc = "Set of elements used to identify the parties related to the underlying transaction."]
pub related_parties: Option<TransactionParty2<'a>>,
#[doc = "Set of elements used to identify the agents related to the underlying transaction."]
pub related_agents: Option<TransactionAgents2<'a>>,
#[doc = "Underlying reason for the payment transaction.\nUsage: Purpose is used by the end-customers, that is initiating party, (ultimate) debtor, (ultimate) creditor to provide information concerning the nature of the payment. Purpose is a content element, which is not used for processing by any of the agents involved in the payment chain."]
pub purpose: Option<Purpose2Choice<'a>>,
#[doc = "Set of elements used to provide information related to the handling of the remittance information by any of the agents in the transaction processing chain."]
pub related_remittance_information: Vec<RemittanceLocation2<'a>>,
#[doc = "Structured information that enables the matching, ie, reconciliation, of a payment with the items that the payment is intended to settle, such as commercial invoices in an account receivable system."]
pub remittance_information: Option<RemittanceInformation5<'a>>,
#[doc = "Set of elements used to identify the dates related to the underlying transactions."]
pub related_dates: Option<TransactionDates2<'a>>,
#[doc = "Set of elements used to identify the price information related to the underlying transaction."]
pub related_price: Option<TransactionPrice2Choice<'a>>,
#[doc = "Set of elements used to identify the related quantities, such as securities, in the underlying transaction."]
pub related_quantities: Vec<TransactionQuantities1Choice<'a>>,
#[doc = "Identification of a security, as assigned under a formal or proprietary identification scheme."]
pub financial_instrument_identification: Option<SecurityIdentification4Choice<'a>>,
#[doc = "Set of elements used to provide details on the tax."]
pub tax: Option<TaxInformation3<'a>>,
#[doc = "Set of elements used to provide the return information."]
pub return_information: Option<ReturnReasonInformation10<'a>>,
#[doc = "Set of elements used to identify the underlying corporate action."]
pub corporate_action: Option<CorporateAction1<'a>>,
#[doc = "Safekeeping or investment account. A safekeeping account is an account on which a securities entry is made. An investment account is an account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family."]
pub safekeeping_account: Option<CashAccount16<'a>>,
#[doc = "Further details of the transaction."]
pub additional_transaction_information: Option<Max500Text<'a>>,
}
impl<'a> EntryTransaction2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let references =
reader.parse_optional_element("Refs", <TransactionReferences2<'a>>::parse)?;
let amount_details =
reader.parse_optional_element("AmtDtls", <AmountAndCurrencyExchange3<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashBalanceAvailability2<'a>>::parse)?;
let bank_transaction_code =
reader.parse_optional_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let charges = reader.parse_list("Chrgs", <ChargesInformation6<'a>>::parse)?;
let interest = reader.parse_list("Intrst", <TransactionInterest2<'a>>::parse)?;
let related_parties =
reader.parse_optional_element("RltdPties", <TransactionParty2<'a>>::parse)?;
let related_agents =
reader.parse_optional_element("RltdAgts", <TransactionAgents2<'a>>::parse)?;
let purpose = reader.parse_optional_element("Purp", <Purpose2Choice<'a>>::parse)?;
let related_remittance_information =
reader.parse_list("RltdRmtInf", <RemittanceLocation2<'a>>::parse)?;
let remittance_information =
reader.parse_optional_element("RmtInf", <RemittanceInformation5<'a>>::parse)?;
let related_dates =
reader.parse_optional_element("RltdDts", <TransactionDates2<'a>>::parse)?;
let related_price =
reader.parse_optional_element("RltdPric", <TransactionPrice2Choice<'a>>::parse)?;
let related_quantities =
reader.parse_list("RltdQties", <TransactionQuantities1Choice<'a>>::parse)?;
let financial_instrument_identification = reader
.parse_optional_element("FinInstrmId", <SecurityIdentification4Choice<'a>>::parse)?;
let tax = reader.parse_optional_element("Tax", <TaxInformation3<'a>>::parse)?;
let return_information =
reader.parse_optional_element("RtrInf", <ReturnReasonInformation10<'a>>::parse)?;
let corporate_action =
reader.parse_optional_element("CorpActn", <CorporateAction1<'a>>::parse)?;
let safekeeping_account =
reader.parse_optional_element("SfkpgAcct", <CashAccount16<'a>>::parse)?;
let additional_transaction_information =
reader.parse_optional_element("AddtlTxInf", <Max500Text<'a>>::parse)?;
Ok(Self {
references,
amount_details,
availability,
bank_transaction_code,
charges,
interest,
related_parties,
related_agents,
purpose,
related_remittance_information,
remittance_information,
related_dates,
related_price,
related_quantities,
financial_instrument_identification,
tax,
return_information,
corporate_action,
safekeeping_account,
additional_transaction_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "An event determined by a corporation's board of directors, that changes the existing corporate capital structure or financial condition."]
pub struct CorporateAction1<'a> {
#[doc = "Specifies the code of corporate action event, in free-text format."]
pub code: Option<Max35Text<'a>>,
#[doc = "Reference assigned by the account servicer to unambiguously identify a corporate action event."]
pub number: Option<Max35Text<'a>>,
#[doc = "Proprietary corporate action event information."]
pub proprietary: Option<Max35Text<'a>>,
}
impl<'a> CorporateAction1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code = reader.parse_optional_element("Cd", <Max35Text<'a>>::parse)?;
let number = reader.parse_optional_element("Nb", <Max35Text<'a>>::parse)?;
let proprietary = reader.parse_optional_element("Prtry", <Max35Text<'a>>::parse)?;
Ok(Self {
code,
number,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the reason of the return of the transaction."]
pub struct ReturnReasonInformation10<'a> {
#[doc = "Bank transaction code included in the original entry for the transaction."]
pub original_bank_transaction_code: Option<BankTransactionCodeStructure4<'a>>,
#[doc = "Party that issues the return."]
pub originator: Option<PartyIdentification32<'a>>,
#[doc = "Specifies the reason for the return."]
pub reason: Option<ReturnReason5Choice<'a>>,
#[doc = "Further details on the return reason."]
pub additional_information: Vec<Max105Text<'a>>,
}
impl<'a> ReturnReasonInformation10<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let original_bank_transaction_code = reader
.parse_optional_element("OrgnlBkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let originator =
reader.parse_optional_element("Orgtr", <PartyIdentification32<'a>>::parse)?;
let reason = reader.parse_optional_element("Rsn", <ReturnReason5Choice<'a>>::parse)?;
let additional_information = reader.parse_list("AddtlInf", <Max105Text<'a>>::parse)?;
Ok(Self {
original_bank_transaction_code,
originator,
reason,
additional_information,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 105 characters."]
pub struct Max105Text<'a>(Cow<'a, str>);
impl<'a> Max105Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=105usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the reason for the return of the transaction."]
pub enum ReturnReason5Choice<'a> {
#[doc = "Reason for the return, as published in an external reason code list."]
Code(ExternalReturnReason1Code),
#[doc = "Reason for the return, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> ReturnReason5Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalReturnReason1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalReturnReason1Code;
#[derive(Clone, Debug)]
#[doc = "Details about tax paid, or to be paid, to the government in accordance with the law, including pre-defined parameters such as thresholds and type of account."]
pub struct TaxInformation3<'a> {
#[doc = "Party on the credit side of the transaction to which the tax applies."]
pub creditor: Option<TaxParty1<'a>>,
#[doc = "Set of elements used to identify the party on the debit side of the transaction to which the tax applies."]
pub debtor: Option<TaxParty2<'a>>,
#[doc = "Territorial part of a country to which the tax payment is related."]
pub administration_zone: Option<Max35Text<'a>>,
#[doc = "Tax reference information that is specific to a taxing agency."]
pub reference_number: Option<Max140Text<'a>>,
#[doc = "Method used to indicate the underlying business or how the tax is paid."]
pub method: Option<Max35Text<'a>>,
#[doc = "Total amount of money on which the tax is based."]
pub total_taxable_base_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Total amount of money as result of the calculation of the tax."]
pub total_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Date by which tax is due."]
pub date: Option<IsoDate>,
#[doc = "Sequential number of the tax report."]
pub sequence_number: Option<Number>,
#[doc = "Record of tax details."]
pub record: Vec<TaxRecord1<'a>>,
}
impl<'a> TaxInformation3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let creditor = reader.parse_optional_element("Cdtr", <TaxParty1<'a>>::parse)?;
let debtor = reader.parse_optional_element("Dbtr", <TaxParty2<'a>>::parse)?;
let administration_zone =
reader.parse_optional_element("AdmstnZn", <Max35Text<'a>>::parse)?;
let reference_number = reader.parse_optional_element("RefNb", <Max140Text<'a>>::parse)?;
let method = reader.parse_optional_element("Mtd", <Max35Text<'a>>::parse)?;
let total_taxable_base_amount = reader.parse_optional_element(
"TtlTaxblBaseAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let total_tax_amount = reader
.parse_optional_element("TtlTaxAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let date = reader.parse_optional_element("Dt", <IsoDate>::parse)?;
let sequence_number = reader.parse_optional_element("SeqNb", <Number>::parse)?;
let record = reader.parse_list("Rcrd", <TaxRecord1<'a>>::parse)?;
Ok(Self {
creditor,
debtor,
administration_zone,
reference_number,
method,
total_taxable_base_amount,
total_tax_amount,
date,
sequence_number,
record,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the tax record."]
pub struct TaxRecord1<'a> {
#[doc = "High level code to identify the type of tax details."]
pub r#type: Option<Max35Text<'a>>,
#[doc = "Specifies the tax code as published by the tax authority."]
pub category: Option<Max35Text<'a>>,
#[doc = "Provides further details of the category tax code."]
pub category_details: Option<Max35Text<'a>>,
#[doc = "Code provided by local authority to identify the status of the party that has drawn up the settlement document."]
pub debtor_status: Option<Max35Text<'a>>,
#[doc = "Identification number of the tax report as assigned by the taxing authority."]
pub certificate_identification: Option<Max35Text<'a>>,
#[doc = "Identifies, in a coded form, on which template the tax report is to be provided."]
pub forms_code: Option<Max35Text<'a>>,
#[doc = "Set of elements used to provide details on the period of time related to the tax payment."]
pub period: Option<TaxPeriod1>,
#[doc = "Set of elements used to provide information on the amount of the tax record."]
pub tax_amount: Option<TaxAmount1>,
#[doc = "Further details of the tax record."]
pub additional_information: Option<Max140Text<'a>>,
}
impl<'a> TaxRecord1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <Max35Text<'a>>::parse)?;
let category = reader.parse_optional_element("Ctgy", <Max35Text<'a>>::parse)?;
let category_details = reader.parse_optional_element("CtgyDtls", <Max35Text<'a>>::parse)?;
let debtor_status = reader.parse_optional_element("DbtrSts", <Max35Text<'a>>::parse)?;
let certificate_identification =
reader.parse_optional_element("CertId", <Max35Text<'a>>::parse)?;
let forms_code = reader.parse_optional_element("FrmsCd", <Max35Text<'a>>::parse)?;
let period = reader.parse_optional_element("Prd", <TaxPeriod1>::parse)?;
let tax_amount = reader.parse_optional_element("TaxAmt", <TaxAmount1>::parse)?;
let additional_information =
reader.parse_optional_element("AddtlInf", <Max140Text<'a>>::parse)?;
Ok(Self {
r#type,
category,
category_details,
debtor_status,
certificate_identification,
forms_code,
period,
tax_amount,
additional_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the tax amount(s) of tax record."]
pub struct TaxAmount1 {
#[doc = "Rate used to calculate the tax."]
pub rate: Option<PercentageRate>,
#[doc = "Amount of money on which the tax is based."]
pub taxable_base_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Total amount that is the result of the calculation of the tax for the record."]
pub total_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Set of elements used to provide details on the tax period and amount."]
pub details: Vec<TaxRecordDetails1>,
}
impl<'a> TaxAmount1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let rate = reader.parse_optional_element("Rate", <PercentageRate>::parse)?;
let taxable_base_amount = reader
.parse_optional_element("TaxblBaseAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let total_amount =
reader.parse_optional_element("TtlAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let details = reader.parse_list("Dtls", <TaxRecordDetails1>::parse)?;
Ok(Self {
rate,
taxable_base_amount,
total_amount,
details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Provides information on the individual tax amount(s) per period of the tax record."]
pub struct TaxRecordDetails1 {
#[doc = "Set of elements used to provide details on the period of time related to the tax payment."]
pub period: Option<TaxPeriod1>,
#[doc = "Underlying tax amount related to the specified period."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
}
impl<'a> TaxRecordDetails1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let period = reader.parse_optional_element("Prd", <TaxPeriod1>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { period, amount })
}
}
#[derive(Clone, Debug)]
#[doc = "Period of time details related to the tax payment."]
pub struct TaxPeriod1 {
#[doc = "Year related to the tax payment."]
pub year: Option<IsoDate>,
#[doc = "Identification of the period related to the tax payment."]
pub r#type: Option<TaxRecordPeriod1Code>,
#[doc = "Range of time between a start date and an end date for which the tax report is provided."]
pub from_to_date: Option<DatePeriodDetails>,
}
impl<'a> TaxPeriod1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let year = reader.parse_optional_element("Yr", <IsoDate>::parse)?;
let r#type = reader.parse_optional_element("Tp", <TaxRecordPeriod1Code>::parse)?;
let from_to_date = reader.parse_optional_element("FrToDt", <DatePeriodDetails>::parse)?;
Ok(Self {
year,
r#type,
from_to_date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Range of time defined by a start date and an end date."]
pub struct DatePeriodDetails {
#[doc = "Start date of the range."]
pub from_date: IsoDate,
#[doc = "End date of the range."]
pub to_date: IsoDate,
}
impl<'a> DatePeriodDetails {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_date = reader.parse_element("FrDt", <IsoDate>::parse)?;
let to_date = reader.parse_element("ToDt", <IsoDate>::parse)?;
Ok(Self { from_date, to_date })
}
}
pub type TaxRecordPeriod1Code = TaxRecordPeriodCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the period related to the tax payment."]
pub enum TaxRecordPeriodCode {
#[doc = "Tax is related to the second month of the period."]
FirstMonth,
#[doc = "Tax is related to the first month of the period."]
SecondMonth,
#[doc = "Tax is related to the third month of the period."]
ThirdMonth,
#[doc = "Tax is related to the fourth month of the period."]
FourthMonth,
#[doc = "Tax is related to the fifth month of the period."]
FifthMonth,
#[doc = "Tax is related to the sixth month of the period."]
SixthMonth,
#[doc = "Tax is related to the seventh month of the period."]
SeventhMonth,
#[doc = "Tax is related to the eighth month of the period."]
EighthMonth,
#[doc = "Tax is related to the ninth month of the period."]
NinthMonth,
#[doc = "Tax is related to the tenth month of the period."]
TenthMonth,
#[doc = "Tax is related to the eleventh month of the period."]
EleventhMonth,
#[doc = "Tax is related to the twelfth month of the period."]
TwelfthMonth,
#[doc = "Tax is related to the first quarter of the period."]
FirstQuarter,
#[doc = "Tax is related to the second quarter of the period."]
SecondQuarter,
#[doc = "Tax is related to the third quarter of the period."]
ThirdQuarter,
#[doc = "Tax is related to the forth quarter of the period."]
FourthQuarter,
#[doc = "Tax is related to the first half of the period."]
FirstHalf,
#[doc = "Tax is related to the second half of the period."]
SecondHalf,
}
impl<'a> TaxRecordPeriodCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"MM01" => Self::FirstMonth,
"MM02" => Self::SecondMonth,
"MM03" => Self::ThirdMonth,
"MM04" => Self::FourthMonth,
"MM05" => Self::FifthMonth,
"MM06" => Self::SixthMonth,
"MM07" => Self::SeventhMonth,
"MM08" => Self::EighthMonth,
"MM09" => Self::NinthMonth,
"MM10" => Self::TenthMonth,
"MM11" => Self::EleventhMonth,
"MM12" => Self::TwelfthMonth,
"QTR1" => Self::FirstQuarter,
"QTR2" => Self::SecondQuarter,
"QTR3" => Self::ThirdQuarter,
"QTR4" => Self::FourthQuarter,
"HLF1" => Self::FirstHalf,
"HLF2" => Self::SecondHalf,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Details about the entity involved in the tax paid or to be paid."]
pub struct TaxParty2<'a> {
#[doc = "Tax identification number of the debtor."]
pub tax_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by an organisation, to unambiguously identify a party."]
pub registration_identification: Option<Max35Text<'a>>,
#[doc = "Type of tax payer."]
pub tax_type: Option<Max35Text<'a>>,
#[doc = "Details of the authorised tax paying party."]
pub authorisation: Option<TaxAuthorisation1<'a>>,
}
impl<'a> TaxParty2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let tax_identification = reader.parse_optional_element("TaxId", <Max35Text<'a>>::parse)?;
let registration_identification =
reader.parse_optional_element("RegnId", <Max35Text<'a>>::parse)?;
let tax_type = reader.parse_optional_element("TaxTp", <Max35Text<'a>>::parse)?;
let authorisation =
reader.parse_optional_element("Authstn", <TaxAuthorisation1<'a>>::parse)?;
Ok(Self {
tax_identification,
registration_identification,
tax_type,
authorisation,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Details of the authorised tax paying party."]
pub struct TaxAuthorisation1<'a> {
#[doc = "Title or position of debtor or the debtor's authorised representative."]
pub title: Option<Max35Text<'a>>,
#[doc = "Name of the debtor or the debtor's authorised representative."]
pub name: Option<Max140Text<'a>>,
}
impl<'a> TaxAuthorisation1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let title = reader.parse_optional_element("Titl", <Max35Text<'a>>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
Ok(Self { title, name })
}
}
#[derive(Clone, Debug)]
#[doc = "Details about the entity involved in the tax paid or to be paid."]
pub struct TaxParty1<'a> {
#[doc = "Tax identification number of the creditor."]
pub tax_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by an organisation, to unambiguously identify a party."]
pub registration_identification: Option<Max35Text<'a>>,
#[doc = "Type of tax payer."]
pub tax_type: Option<Max35Text<'a>>,
}
impl<'a> TaxParty1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let tax_identification = reader.parse_optional_element("TaxId", <Max35Text<'a>>::parse)?;
let registration_identification =
reader.parse_optional_element("RegnId", <Max35Text<'a>>::parse)?;
let tax_type = reader.parse_optional_element("TaxTp", <Max35Text<'a>>::parse)?;
Ok(Self {
tax_identification,
registration_identification,
tax_type,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between formats for the identification of a financial instrument."]
pub enum SecurityIdentification4Choice<'a> {
#[doc = "International Securities Identification Number (ISIN). A numbering system designed by the United Nation's International Organisation for Standardisation (ISO). The ISIN is composed of a 2-character prefix representing the country of issue, followed by the national security number (if one exists), and a check digit. Each country has a national numbering agency that assigns ISIN numbers for securities in that country."]
Isin(IsinIdentifier),
#[doc = "Proprietary identification of an underlying financial instrument."]
Proprietary(AlternateSecurityIdentification2<'a>),
}
impl<'a> SecurityIdentification4Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "ISIN".as_bytes() => {
let inner = reader.parse_element("ISIN", <IsinIdentifier>::parse)?;
Self::Isin(inner)
}
name if name == "Prtry".as_bytes() => {
let inner =
reader.parse_element("Prtry", <AlternateSecurityIdentification2<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Proprietary or domestic identification scheme that uniquely identifies a security."]
pub struct AlternateSecurityIdentification2<'a> {
#[doc = "Identifies the type of financial instrument identifier type."]
pub r#type: Max35Text<'a>,
#[doc = "Unique and unambiguous identifier of a security."]
pub identification: Max35Text<'a>,
}
impl<'a> AlternateSecurityIdentification2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
Ok(Self {
r#type,
identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the quantities (eg of securities) in the underlying transaction."]
pub enum TransactionQuantities1Choice<'a> {
#[doc = "Specifies the quantity (eg of securities) in the underlying transaction."]
Quantity(FinancialInstrumentQuantityChoice),
#[doc = "Proprietary quantities specification defined in the underlying transaction."]
Proprietary(ProprietaryQuantity1<'a>),
}
impl<'a> TransactionQuantities1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Qty".as_bytes() => {
let inner =
reader.parse_element("Qty", <FinancialInstrumentQuantityChoice>::parse)?;
Self::Quantity(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <ProprietaryQuantity1<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements to identify a proprietary quantity."]
pub struct ProprietaryQuantity1<'a> {
#[doc = "Identifies the type of proprietary quantity reported."]
pub r#type: Max35Text<'a>,
#[doc = "Provides the proprietary quantity in free format."]
pub quantity: Max35Text<'a>,
}
impl<'a> ProprietaryQuantity1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let quantity = reader.parse_element("Qty", <Max35Text<'a>>::parse)?;
Ok(Self { r#type, quantity })
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between formats for the quantity of security."]
pub enum FinancialInstrumentQuantityChoice {
#[doc = "Quantity expressed as a number, eg, a number of shares."]
Unit(DecimalNumber),
#[doc = "Quantity expressed as an amount representing the face amount, ie, the principal, of a debt instrument."]
FaceAmount(ImpliedCurrencyAndAmount),
#[doc = "Quantity expressed as an amount representing the current amortised face amount of a bond, eg, a periodic reduction of a bond's principal amount."]
AmortisedValue(ImpliedCurrencyAndAmount),
}
impl<'a> FinancialInstrumentQuantityChoice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Unit".as_bytes() => {
let inner = reader.parse_element("Unit", <DecimalNumber>::parse)?;
Self::Unit(inner)
}
name if name == "FaceAmt".as_bytes() => {
let inner = reader.parse_element("FaceAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::FaceAmount(inner)
}
name if name == "AmtsdVal".as_bytes() => {
let inner = reader.parse_element("AmtsdVal", <ImpliedCurrencyAndAmount>::parse)?;
Self::AmortisedValue(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the price information related to the underlying transaction."]
pub enum TransactionPrice2Choice<'a> {
#[doc = "Specifies the price of the traded financial instrument.\nThis is the deal price of the individual trade transaction. \nIf there is only one trade transaction for the execution of the trade, then the deal price could equal the executed trade price (unless, for example, the price includes commissions or rounding, or some other factor has been applied to the deal price or the executed trade price, or both)."]
DealPrice(ActiveOrHistoricCurrencyAndAmount),
#[doc = "Proprietary price specification related to the underlying transaction."]
Proprietary(Vec<ProprietaryPrice2<'a>>),
}
impl<'a> TransactionPrice2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "DealPric".as_bytes() => {
let inner =
reader.parse_element("DealPric", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Self::DealPrice(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_list("Prtry", <ProprietaryPrice2<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a proprietary price."]
pub struct ProprietaryPrice2<'a> {
#[doc = "Specifies the type of price."]
pub r#type: Max35Text<'a>,
#[doc = "Proprietary price specification related to the underlying transaction."]
pub price: ActiveOrHistoricCurrencyAndAmount,
}
impl<'a> ProprietaryPrice2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let price = reader.parse_element("Pric", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { r#type, price })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the dates related to the underlying individual transaction."]
pub struct TransactionDates2<'a> {
#[doc = "Point in time when the payment order from the initiating party meets the processing conditions of the account servicing agent. This means that the account servicing agent has received the payment order and has applied checks such as authorisation, availability of funds."]
pub acceptance_date_time: Option<IsoDateTime>,
#[doc = "Identifies when an amount of money should have contractually been credited or debited the account versus when the amount of money was actually settled (debited/credited) on the cash account."]
pub trade_activity_contractual_settlement_date: Option<IsoDate>,
#[doc = "Date on which the trade was executed."]
pub trade_date: Option<IsoDate>,
#[doc = "Date on which the amount of money ceases to be available to the agent that owes it and when the amount of money becomes available to the agent to which it is due."]
pub interbank_settlement_date: Option<IsoDate>,
#[doc = "Start date of the underlying transaction, such as a treasury transaction, an investment plan."]
pub start_date: Option<IsoDate>,
#[doc = "End date of the underlying transaction, such as a treasury transaction, an investment plan."]
pub end_date: Option<IsoDate>,
#[doc = "Date and time of the underlying transaction."]
pub transaction_date_time: Option<IsoDateTime>,
#[doc = "Proprietary date related to the underlying transaction."]
pub proprietary: Vec<ProprietaryDate2<'a>>,
}
impl<'a> TransactionDates2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let acceptance_date_time =
reader.parse_optional_element("AccptncDtTm", <IsoDateTime>::parse)?;
let trade_activity_contractual_settlement_date =
reader.parse_optional_element("TradActvtyCtrctlSttlmDt", <IsoDate>::parse)?;
let trade_date = reader.parse_optional_element("TradDt", <IsoDate>::parse)?;
let interbank_settlement_date =
reader.parse_optional_element("IntrBkSttlmDt", <IsoDate>::parse)?;
let start_date = reader.parse_optional_element("StartDt", <IsoDate>::parse)?;
let end_date = reader.parse_optional_element("EndDt", <IsoDate>::parse)?;
let transaction_date_time =
reader.parse_optional_element("TxDtTm", <IsoDateTime>::parse)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryDate2<'a>>::parse)?;
Ok(Self {
acceptance_date_time,
trade_activity_contractual_settlement_date,
trade_date,
interbank_settlement_date,
start_date,
end_date,
transaction_date_time,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a proprietary date."]
pub struct ProprietaryDate2<'a> {
#[doc = "Specifies the type of date."]
pub r#type: Max35Text<'a>,
#[doc = "Date in ISO format."]
pub date: DateAndDateTimeChoice,
}
impl<'a> ProprietaryDate2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let date = reader.parse_element("Dt", <DateAndDateTimeChoice>::parse)?;
Ok(Self { r#type, date })
}
}
#[derive(Clone, Debug)]
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system."]
pub struct RemittanceInformation5<'a> {
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in an unstructured form."]
pub unstructured: Vec<Max140Text<'a>>,
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in a structured form."]
pub structured: Vec<StructuredRemittanceInformation7<'a>>,
}
impl<'a> RemittanceInformation5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let unstructured = reader.parse_list("Ustrd", <Max140Text<'a>>::parse)?;
let structured =
reader.parse_list("Strd", <StructuredRemittanceInformation7<'a>>::parse)?;
Ok(Self {
unstructured,
structured,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in a structured form."]
pub struct StructuredRemittanceInformation7<'a> {
#[doc = "Set of elements used to identify the documents referred to in the remittance information."]
pub referred_document_information: Vec<ReferredDocumentInformation3<'a>>,
#[doc = "Set of elements used to provide details on the amounts of the referred document."]
pub referred_document_amount: Option<RemittanceAmount1<'a>>,
#[doc = "Reference information provided by the creditor to allow the identification of the underlying documents."]
pub creditor_reference_information: Option<CreditorReferenceInformation2<'a>>,
#[doc = "Identification of the organisation issuing the invoice, when it is different from the creditor or ultimate creditor."]
pub invoicer: Option<PartyIdentification32<'a>>,
#[doc = "Identification of the party to whom an invoice is issued, when it is different from the debtor or ultimate debtor."]
pub invoicee: Option<PartyIdentification32<'a>>,
#[doc = "Additional information, in free text form, to complement the structured remittance information."]
pub additional_remittance_information: Vec<Max140Text<'a>>,
}
impl<'a> StructuredRemittanceInformation7<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let referred_document_information =
reader.parse_list("RfrdDocInf", <ReferredDocumentInformation3<'a>>::parse)?;
let referred_document_amount =
reader.parse_optional_element("RfrdDocAmt", <RemittanceAmount1<'a>>::parse)?;
let creditor_reference_information = reader
.parse_optional_element("CdtrRefInf", <CreditorReferenceInformation2<'a>>::parse)?;
let invoicer =
reader.parse_optional_element("Invcr", <PartyIdentification32<'a>>::parse)?;
let invoicee =
reader.parse_optional_element("Invcee", <PartyIdentification32<'a>>::parse)?;
let additional_remittance_information =
reader.parse_list("AddtlRmtInf", <Max140Text<'a>>::parse)?;
Ok(Self {
referred_document_information,
referred_document_amount,
creditor_reference_information,
invoicer,
invoicee,
additional_remittance_information,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Reference information provided by the creditor to allow the identification of the underlying documents."]
pub struct CreditorReferenceInformation2<'a> {
#[doc = "Specifies the type of creditor reference."]
pub r#type: Option<CreditorReferenceType2<'a>>,
#[doc = "Unique reference, as assigned by the creditor, to unambiguously refer to the payment transaction.\n\nUsage: If available, the initiating party should provide this reference in the structured remittance information, to enable reconciliation by the creditor upon receipt of the amount of money.\n\nIf the business context requires the use of a creditor reference or a payment remit identification, and only one identifier can be passed through the end-to-end chain, the creditor's reference or payment remittance identification should be quoted in the end-to-end transaction identification."]
pub reference: Option<Max35Text<'a>>,
}
impl<'a> CreditorReferenceInformation2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <CreditorReferenceType2<'a>>::parse)?;
let reference = reader.parse_optional_element("Ref", <Max35Text<'a>>::parse)?;
Ok(Self { r#type, reference })
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of creditor reference."]
pub struct CreditorReferenceType2<'a> {
#[doc = "Coded or proprietary format creditor reference type."]
pub code_or_proprietary: CreditorReferenceType1Choice<'a>,
#[doc = "Entity that assigns the credit reference type."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> CreditorReferenceType2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <CreditorReferenceType1Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of document referred by the creditor."]
pub enum CreditorReferenceType1Choice<'a> {
#[doc = "Type of creditor reference, in a coded form."]
Code(DocumentType3Code),
#[doc = "Creditor reference type, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> CreditorReferenceType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <DocumentType3Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type DocumentType3Code = DocumentTypeCode;
#[derive(Clone, Debug)]
#[doc = "Nature of the amount and currency on a document referred to in the remittance section, typically either the original amount due/payable or the amount actually remitted for the referenced document."]
pub struct RemittanceAmount1<'a> {
#[doc = "Amount specified is the exact amount due and payable to the creditor."]
pub due_payable_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Amount of money that results from the application of an agreed discount to the amount due and payable to the creditor."]
pub discount_applied_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Amount specified for the referred document is the amount of a credit note."]
pub credit_note_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Quantity of cash resulting from the calculation of the tax."]
pub tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Set of elements used to provide information on the amount and reason of the document adjustment."]
pub adjustment_amount_and_reason: Vec<DocumentAdjustment1<'a>>,
#[doc = "Amount of money remitted for the referred document."]
pub remitted_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
}
impl<'a> RemittanceAmount1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let due_payable_amount = reader
.parse_optional_element("DuePyblAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let discount_applied_amount = reader
.parse_optional_element("DscntApldAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_note_amount = reader
.parse_optional_element("CdtNoteAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let tax_amount =
reader.parse_optional_element("TaxAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let adjustment_amount_and_reason =
reader.parse_list("AdjstmntAmtAndRsn", <DocumentAdjustment1<'a>>::parse)?;
let remitted_amount =
reader.parse_optional_element("RmtdAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self {
due_payable_amount,
discount_applied_amount,
credit_note_amount,
tax_amount,
adjustment_amount_and_reason,
remitted_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the amount and reason of the document adjustment."]
pub struct DocumentAdjustment1<'a> {
#[doc = "Amount of money of the document adjustment."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Specifies whether the adjustment must be subtracted or added to the total amount."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Specifies the reason for the adjustment."]
pub reason: Option<Max4Text<'a>>,
#[doc = "Provides further details on the document adjustment."]
pub additional_information: Option<Max140Text<'a>>,
}
impl<'a> DocumentAdjustment1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let reason = reader.parse_optional_element("Rsn", <Max4Text<'a>>::parse)?;
let additional_information =
reader.parse_optional_element("AddtlInf", <Max140Text<'a>>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
reason,
additional_information,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 4 characters."]
pub struct Max4Text<'a>(Cow<'a, str>);
impl<'a> Max4Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=4usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the documents referred to in the remittance information."]
pub struct ReferredDocumentInformation3<'a> {
#[doc = "Specifies the type of referred document."]
pub r#type: Option<ReferredDocumentType2<'a>>,
#[doc = "Unique and unambiguous identification of the referred document."]
pub number: Option<Max35Text<'a>>,
#[doc = "Date associated with the referred document."]
pub related_date: Option<IsoDate>,
}
impl<'a> ReferredDocumentInformation3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <ReferredDocumentType2<'a>>::parse)?;
let number = reader.parse_optional_element("Nb", <Max35Text<'a>>::parse)?;
let related_date = reader.parse_optional_element("RltdDt", <IsoDate>::parse)?;
Ok(Self {
r#type,
number,
related_date,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document referred in the remittance information."]
pub struct ReferredDocumentType2<'a> {
#[doc = "Provides the type details of the referred document."]
pub code_or_proprietary: ReferredDocumentType1Choice<'a>,
#[doc = "Identification of the issuer of the reference document type."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> ReferredDocumentType2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <ReferredDocumentType1Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the type of the document referred in the remittance information."]
pub enum ReferredDocumentType1Choice<'a> {
#[doc = "Document type in a coded form."]
Code(DocumentType5Code),
#[doc = "Proprietary identification of the type of the remittance document."]
Proprietary(Max35Text<'a>),
}
impl<'a> ReferredDocumentType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <DocumentType5Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type DocumentType5Code = DocumentTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies a type of financial or commercial document."]
pub enum DocumentTypeCode {
#[doc = "Document is an invoice claiming payment for the supply of metered services, for example gas or electricity supplied to a fixed meter."]
MeteredServiceInvoice,
#[doc = "Document is a credit note for the final amount settled for a commercial transaction."]
CreditNoteRelatedToFinancialAdjustment,
#[doc = "Document is a debit note for the final amount settled for a commercial transaction."]
DebitNoteRelatedToFinancialAdjustment,
#[doc = "Document is an invoice."]
CommercialInvoice,
#[doc = "Document is a credit note."]
CreditNote,
#[doc = "Document is a debit note."]
DebitNote,
#[doc = "Document is an invoice for the hiring of human resources or renting goods or equipment."]
HireInvoice,
#[doc = "Document is an invoice issued by the debtor."]
SelfBilledInvoice,
#[doc = "Document is a remittance advice sent separately from the current transaction."]
RemittanceAdviceMessage,
#[doc = "Document is a linked payment instruction to which the current payment instruction is related, for example, in a cover scenario."]
RelatedPaymentInstruction,
#[doc = "Document is an agreement between the parties, stipulating the terms and conditions of the delivery of goods or services."]
CommercialContract,
#[doc = "Document is a pre-agreed or pre-arranged foreign exchange transaction to which the payment transaction refers."]
ForeignExchangeDealReference,
#[doc = "Document is a statement of the transactions posted to the debtor's account at the supplier."]
StatementOfAccount,
#[doc = "Document is a dispatch advice."]
DispatchAdvice,
#[doc = "Document is a purchase order."]
PurchaseOrder,
#[doc = "Document is a structured communication reference provided by the creditor to identify the referred transaction."]
StructuredCommunicationReference,
#[doc = "Document is a shipping notice."]
BillOfLading,
#[doc = "Document is an electronic payment document."]
Voucher,
#[doc = "Document is a payment that applies to a specific source document."]
AccountReceivableOpenItem,
#[doc = "Document is a transaction identifier as assigned by the Trade Services Utility."]
TradeServicesUtilityTransaction,
#[doc = "When the Sale system print the Cashier copy of the Payment receipt."]
CashierReceipt,
#[doc = "When the Sale System requires\tthe POI system to print the Customer receipt."]
CustomerReceipt,
#[doc = "When the POI or the Sale System wants to store a message on the journal printer or electronic journal of the Sale Terminal (it is sometimes a Sale Logging/Journal Printer)."]
Journal,
#[doc = "When the Sale System requires the POI system to print the Sale receipt."]
SaleReceipt,
}
impl<'a> DocumentTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"MSIN" => Self::MeteredServiceInvoice,
"CNFA" => Self::CreditNoteRelatedToFinancialAdjustment,
"DNFA" => Self::DebitNoteRelatedToFinancialAdjustment,
"CINV" => Self::CommercialInvoice,
"CREN" => Self::CreditNote,
"DEBN" => Self::DebitNote,
"HIRI" => Self::HireInvoice,
"SBIN" => Self::SelfBilledInvoice,
"RADM" => Self::RemittanceAdviceMessage,
"RPIN" => Self::RelatedPaymentInstruction,
"CMCN" => Self::CommercialContract,
"FXDR" => Self::ForeignExchangeDealReference,
"SOAC" => Self::StatementOfAccount,
"DISP" => Self::DispatchAdvice,
"PUOR" => Self::PurchaseOrder,
"SCOR" => Self::StructuredCommunicationReference,
"BOLD" => Self::BillOfLading,
"VCHR" => Self::Voucher,
"AROI" => Self::AccountReceivableOpenItem,
"TSUT" => Self::TradeServicesUtilityTransaction,
"HRCP" => Self::CashierReceipt,
"CRCP" => Self::CustomerReceipt,
"JNRL" => Self::Journal,
"SRCP" => Self::SaleReceipt,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the remittance advice."]
pub struct RemittanceLocation2<'a> {
#[doc = "Unique identification, as assigned by the initiating party, to unambiguously identify the remittance information sent separately from the payment instruction, such as a remittance advice."]
pub remittance_identification: Option<Max35Text<'a>>,
#[doc = "Method used to deliver the remittance advice information."]
pub remittance_location_method: Option<RemittanceLocationMethod2Code>,
#[doc = "Electronic address to which an agent is to send the remittance information."]
pub remittance_location_electronic_address: Option<Max2048Text<'a>>,
#[doc = "Postal address to which an agent is to send the remittance information."]
pub remittance_location_postal_address: Option<NameAndAddress10<'a>>,
}
impl<'a> RemittanceLocation2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let remittance_identification =
reader.parse_optional_element("RmtId", <Max35Text<'a>>::parse)?;
let remittance_location_method =
reader.parse_optional_element("RmtLctnMtd", <RemittanceLocationMethod2Code>::parse)?;
let remittance_location_electronic_address =
reader.parse_optional_element("RmtLctnElctrncAdr", <Max2048Text<'a>>::parse)?;
let remittance_location_postal_address =
reader.parse_optional_element("RmtLctnPstlAdr", <NameAndAddress10<'a>>::parse)?;
Ok(Self {
remittance_identification,
remittance_location_method,
remittance_location_electronic_address,
remittance_location_postal_address,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a party."]
pub struct NameAndAddress10<'a> {
#[doc = "Name by which a party is known and is usually used to identify that party."]
pub name: Max140Text<'a>,
#[doc = "Postal address of a party."]
pub address: PostalAddress6<'a>,
}
impl<'a> NameAndAddress10<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name = reader.parse_element("Nm", <Max140Text<'a>>::parse)?;
let address = reader.parse_element("Adr", <PostalAddress6<'a>>::parse)?;
Ok(Self { name, address })
}
}
pub type RemittanceLocationMethod2Code = RemittanceLocationMethodCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the method used to deliver the remittance advice information."]
pub enum RemittanceLocationMethodCode {
#[doc = "Remittance advice information must be faxed."]
Fax,
#[doc = "Remittance advice information must be sent through Electronic Data Interchange (EDI)."]
ElectronicDataInterchange,
#[doc = "Remittance advice information needs to be sent to a Uniform Resource Identifier (URI). URI is a compact string of characters that uniquely identify an abstract or physical resource. URI's are the super-set of identifiers, such as URLs, email addresses, ftp sites, etc, and as such, provide the syntax for all of the identification schemes."]
UniformResourceIdentifier,
#[doc = "Remittance advice information must be sent through e-mail."]
EMail,
#[doc = "Remittance advice information must be sent through postal services."]
Post,
#[doc = "Remittance advice information must be sent through by phone as a short message service (SMS)."]
Sms,
}
impl<'a> RemittanceLocationMethodCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"FAXI" => Self::Fax,
"EDIC" => Self::ElectronicDataInterchange,
"URID" => Self::UniformResourceIdentifier,
"EMAL" => Self::EMail,
"POST" => Self::Post,
"SMSM" => Self::Sms,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the underlying reason for the payment transaction.\nUsage: Purpose is used by the end-customers, that is initiating party, (ultimate) debtor, (ultimate) creditor to provide information concerning the nature of the payment. Purpose is a content element, which is not used for processing by any of the agents involved in the payment chain."]
pub enum Purpose2Choice<'a> {
#[doc = "Underlying reason for the payment transaction, as published in an external purpose code list."]
Code(ExternalPurpose1Code),
#[doc = "Purpose, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> Purpose2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalPurpose1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalPurpose1Code;
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the agents specific to the individual transaction."]
pub struct TransactionAgents2<'a> {
#[doc = "Financial institution servicing an account for the debtor."]
pub debtor_agent: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Financial institution servicing an account for the creditor."]
pub creditor_agent: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If more than one intermediary agent is present, then IntermediaryAgent1 identifies the agent between the DebtorAgent and the IntermediaryAgent2."]
pub intermediary_agent1: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If more than two intermediary agents are present, then IntermediaryAgent2 identifies the agent between the IntermediaryAgent1 and the IntermediaryAgent3."]
pub intermediary_agent2: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Agent between the debtor's agent and the creditor's agent.\n\nUsage: If IntermediaryAgent3 is present, then it identifies the agent between the IntermediaryAgent 2 and the CreditorAgent."]
pub intermediary_agent3: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Party that receives securities from the delivering agent at the place of settlement, such as central securities depository.\nCan also be used in the context of treasury operations."]
pub receiving_agent: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Party that delivers securities to the receiving agent at the place of settlement, such as a central securities depository.\nCan also be used in the context of treasury operations."]
pub delivering_agent: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Legal entity that has the right to issue securities."]
pub issuing_agent: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Place where settlement of the securities takes place.\nUsage: This is typed by a financial institution identification as this is the standard way to identify a securities settlement agent/central system."]
pub settlement_place: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Proprietary agent related to the underlying transaction."]
pub proprietary: Vec<ProprietaryAgent2<'a>>,
}
impl<'a> TransactionAgents2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let debtor_agent = reader.parse_optional_element(
"DbtrAgt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let creditor_agent = reader.parse_optional_element(
"CdtrAgt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let intermediary_agent1 = reader.parse_optional_element(
"IntrmyAgt1",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let intermediary_agent2 = reader.parse_optional_element(
"IntrmyAgt2",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let intermediary_agent3 = reader.parse_optional_element(
"IntrmyAgt3",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let receiving_agent = reader.parse_optional_element(
"RcvgAgt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let delivering_agent = reader.parse_optional_element(
"DlvrgAgt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let issuing_agent = reader.parse_optional_element(
"IssgAgt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let settlement_place = reader.parse_optional_element(
"SttlmPlc",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryAgent2<'a>>::parse)?;
Ok(Self {
debtor_agent,
creditor_agent,
intermediary_agent1,
intermediary_agent2,
intermediary_agent3,
receiving_agent,
delivering_agent,
issuing_agent,
settlement_place,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a proprietary party."]
pub struct ProprietaryAgent2<'a> {
#[doc = "Specifies the type of proprietary agent."]
pub r#type: Max35Text<'a>,
#[doc = "Organisation established primarily to provide financial services."]
pub agent: BranchAndFinancialInstitutionIdentification4<'a>,
}
impl<'a> ProprietaryAgent2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let agent = reader.parse_element(
"Agt",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
Ok(Self { r#type, agent })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the parties specific to the individual transaction."]
pub struct TransactionParty2<'a> {
#[doc = "Party that initiated the payment that is reported in the entry."]
pub initiating_party: Option<PartyIdentification32<'a>>,
#[doc = "Party that owes an amount of money to the (ultimate) creditor."]
pub debtor: Option<PartyIdentification32<'a>>,
#[doc = "Unambiguous identification of the account of the debtor."]
pub debtor_account: Option<CashAccount16<'a>>,
#[doc = "Ultimate party that owes an amount of money to the (ultimate) creditor."]
pub ultimate_debtor: Option<PartyIdentification32<'a>>,
#[doc = "Party to which an amount of money is due."]
pub creditor: Option<PartyIdentification32<'a>>,
#[doc = "Unambiguous identification of the account of the creditor to which a credit entry has been posted as a result of the payment transaction."]
pub creditor_account: Option<CashAccount16<'a>>,
#[doc = "Ultimate party to which an amount of money is due."]
pub ultimate_creditor: Option<PartyIdentification32<'a>>,
#[doc = "Party that plays an active role in planning and executing the transactions that create or liquidate investments of the investors assets, or that move the investor's assets from one investment to another. A trading party is a trade instructor, an investment decision-maker, a post trade administrator, or a trader. In the context of treasury, it is the party that negotiates and executes the treasury transaction."]
pub trading_party: Option<PartyIdentification32<'a>>,
#[doc = "Proprietary party related to the underlying transaction."]
pub proprietary: Vec<ProprietaryParty2<'a>>,
}
impl<'a> TransactionParty2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let initiating_party =
reader.parse_optional_element("InitgPty", <PartyIdentification32<'a>>::parse)?;
let debtor = reader.parse_optional_element("Dbtr", <PartyIdentification32<'a>>::parse)?;
let debtor_account =
reader.parse_optional_element("DbtrAcct", <CashAccount16<'a>>::parse)?;
let ultimate_debtor =
reader.parse_optional_element("UltmtDbtr", <PartyIdentification32<'a>>::parse)?;
let creditor = reader.parse_optional_element("Cdtr", <PartyIdentification32<'a>>::parse)?;
let creditor_account =
reader.parse_optional_element("CdtrAcct", <CashAccount16<'a>>::parse)?;
let ultimate_creditor =
reader.parse_optional_element("UltmtCdtr", <PartyIdentification32<'a>>::parse)?;
let trading_party =
reader.parse_optional_element("TradgPty", <PartyIdentification32<'a>>::parse)?;
let proprietary = reader.parse_list("Prtry", <ProprietaryParty2<'a>>::parse)?;
Ok(Self {
initiating_party,
debtor,
debtor_account,
ultimate_debtor,
creditor,
creditor_account,
ultimate_creditor,
trading_party,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a proprietary party."]
pub struct ProprietaryParty2<'a> {
#[doc = "Specifies the type of proprietary party."]
pub r#type: Max35Text<'a>,
#[doc = "Proprietary party."]
pub party: PartyIdentification32<'a>,
}
impl<'a> ProprietaryParty2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let party = reader.parse_element("Pty", <PartyIdentification32<'a>>::parse)?;
Ok(Self { r#type, party })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the underlying transaction."]
pub struct TransactionReferences2<'a> {
#[doc = "Point to point reference, as assigned by the instructing party of the underlying message."]
pub message_identification: Option<Max35Text<'a>>,
#[doc = "Unique reference, as assigned by the account servicing institution, to unambiguously identify the instruction."]
pub account_servicer_reference: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by a sending party, to unambiguously identify the payment information group within the message."]
pub payment_information_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by an instructing party for an instructed party, to unambiguously identify the instruction.\n\nUsage: The instruction identification is a point to point reference that can be used between the instructing party and the instructed party to refer to the individual instruction. It can be included in several messages related to the instruction."]
pub instruction_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by the initiating party, to unambiguously identify the transaction. This identification is passed on, unchanged, throughout the entire end-to-end chain.\n\nUsage: The end-to-end identification can be used for reconciliation or to link tasks relating to the transaction. It can be included in several messages related to the transaction.\n\nUsage: In case there are technical limitations to pass on multiple references, the end-to-end identification must be passed on throughout the entire end-to-end chain."]
pub end_to_end_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by the first instructing agent, to unambiguously identify the transaction that is passed on, unchanged, throughout the entire interbank chain. \nUsage: The transaction identification can be used for reconciliation, tracking or to link tasks relating to the transaction on the interbank level. \nUsage: The instructing agent has to make sure that the transaction identification is unique for a pre-agreed period."]
pub transaction_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by the creditor, to unambiguously identify the mandate."]
pub mandate_identification: Option<Max35Text<'a>>,
#[doc = "Unique and unambiguous identifier for a cheque as assigned by the agent."]
pub cheque_number: Option<Max35Text<'a>>,
#[doc = "Unique reference, as assigned by a clearing system, to unambiguously identify the instruction.\nUsage: In case there are technical limitations to pass on multiple references, the end-to-end identification must be passed on throughout the entire end-to-end chain."]
pub clearing_system_reference: Option<Max35Text<'a>>,
#[doc = "Proprietary reference related to the underlying transaction."]
pub proprietary: Option<ProprietaryReference1<'a>>,
}
impl<'a> TransactionReferences2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification =
reader.parse_optional_element("MsgId", <Max35Text<'a>>::parse)?;
let account_servicer_reference =
reader.parse_optional_element("AcctSvcrRef", <Max35Text<'a>>::parse)?;
let payment_information_identification =
reader.parse_optional_element("PmtInfId", <Max35Text<'a>>::parse)?;
let instruction_identification =
reader.parse_optional_element("InstrId", <Max35Text<'a>>::parse)?;
let end_to_end_identification =
reader.parse_optional_element("EndToEndId", <Max35Text<'a>>::parse)?;
let transaction_identification =
reader.parse_optional_element("TxId", <Max35Text<'a>>::parse)?;
let mandate_identification =
reader.parse_optional_element("MndtId", <Max35Text<'a>>::parse)?;
let cheque_number = reader.parse_optional_element("ChqNb", <Max35Text<'a>>::parse)?;
let clearing_system_reference =
reader.parse_optional_element("ClrSysRef", <Max35Text<'a>>::parse)?;
let proprietary =
reader.parse_optional_element("Prtry", <ProprietaryReference1<'a>>::parse)?;
Ok(Self {
message_identification,
account_servicer_reference,
payment_information_identification,
instruction_identification,
end_to_end_identification,
transaction_identification,
mandate_identification,
cheque_number,
clearing_system_reference,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements to identify a proprietary reference."]
pub struct ProprietaryReference1<'a> {
#[doc = "Identifies the type of reference reported."]
pub r#type: Max35Text<'a>,
#[doc = "Proprietary reference specification related to the underlying transaction."]
pub reference: Max35Text<'a>,
}
impl<'a> ProprietaryReference1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let reference = reader.parse_element("Ref", <Max35Text<'a>>::parse)?;
Ok(Self { r#type, reference })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the underlying batches."]
pub struct BatchInformation2<'a> {
#[doc = "Point to point reference, as assigned by the sending party, to unambiguously identify the batch of transactions."]
pub message_identification: Option<Max35Text<'a>>,
#[doc = "Unique identification, as assigned by a sending party, to unambiguously identify the payment information group within the message."]
pub payment_information_identification: Option<Max35Text<'a>>,
#[doc = "Number of individual transactions included in the batch."]
pub number_of_transactions: Option<Max15NumericText<'a>>,
#[doc = "Total amount of money reported in the batch entry."]
pub total_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Indicates whether the batch entry is a credit or a debit entry."]
pub credit_debit_indicator: Option<CreditDebitCode>,
}
impl<'a> BatchInformation2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification =
reader.parse_optional_element("MsgId", <Max35Text<'a>>::parse)?;
let payment_information_identification =
reader.parse_optional_element("PmtInfId", <Max35Text<'a>>::parse)?;
let number_of_transactions =
reader.parse_optional_element("NbOfTxs", <Max15NumericText<'a>>::parse)?;
let total_amount =
reader.parse_optional_element("TtlAmt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
Ok(Self {
message_identification,
payment_information_identification,
number_of_transactions,
total_amount,
credit_debit_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide transaction specific interest information that applies to the underlying transaction."]
pub struct TransactionInterest2<'a> {
#[doc = "Amount of interest included in the entry amount."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the interest amount included in the entry is credit or debit amount."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Specifies the type of interest."]
pub r#type: Option<InterestType1Choice<'a>>,
#[doc = "Set of elements used to qualify the interest rate."]
pub rate: Vec<Rate3<'a>>,
#[doc = "Range of time between a start date and an end date for the calculation of the interest."]
pub from_to_date: Option<DateTimePeriodDetails>,
#[doc = "Specifies the reason for the interest."]
pub reason: Option<Max35Text<'a>>,
}
impl<'a> TransactionInterest2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let r#type = reader.parse_optional_element("Tp", <InterestType1Choice<'a>>::parse)?;
let rate = reader.parse_list("Rate", <Rate3<'a>>::parse)?;
let from_to_date =
reader.parse_optional_element("FrToDt", <DateTimePeriodDetails>::parse)?;
let reason = reader.parse_optional_element("Rsn", <Max35Text<'a>>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
r#type,
rate,
from_to_date,
reason,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the technical input channel."]
pub enum TechnicalInputChannel1Choice<'a> {
#[doc = "Technical input channel, as published in an external technical input channel code list."]
Code(ExternalTechnicalInputChannel1Code),
#[doc = "Technical channel used to input the instruction, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> TechnicalInputChannel1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner =
reader.parse_element("Cd", <ExternalTechnicalInputChannel1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalTechnicalInputChannel1Code;
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the charges related to the payment transaction."]
pub struct ChargesInformation6<'a> {
#[doc = "Total of all charges and taxes applied to the entry."]
pub total_charges_and_tax_amount: Option<ActiveOrHistoricCurrencyAndAmount>,
#[doc = "Transaction charges to be paid by the charge bearer."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the charges amount is a credit or a debit amount. \nUsage: A zero amount is considered to be a credit."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Specifies the type of charge."]
pub r#type: Option<ChargeType2Choice<'a>>,
#[doc = "Rate used to calculate the amount of the charge or fee."]
pub rate: Option<PercentageRate>,
#[doc = "Specifies which party/parties will bear the charges associated with the processing of the payment transaction."]
pub bearer: Option<ChargeBearerType1Code>,
#[doc = "Party that takes the transaction charges or to which the transaction charges are due."]
pub party: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
#[doc = "Set of elements used to provide details on the tax applied to charges."]
pub tax: Option<TaxCharges2<'a>>,
}
impl<'a> ChargesInformation6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let total_charges_and_tax_amount = reader.parse_optional_element(
"TtlChrgsAndTaxAmt",
<ActiveOrHistoricCurrencyAndAmount>::parse,
)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let r#type = reader.parse_optional_element("Tp", <ChargeType2Choice<'a>>::parse)?;
let rate = reader.parse_optional_element("Rate", <PercentageRate>::parse)?;
let bearer = reader.parse_optional_element("Br", <ChargeBearerType1Code>::parse)?;
let party = reader.parse_optional_element(
"Pty",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
let tax = reader.parse_optional_element("Tax", <TaxCharges2<'a>>::parse)?;
Ok(Self {
total_charges_and_tax_amount,
amount,
credit_debit_indicator,
r#type,
rate,
bearer,
party,
tax,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Amount of money due to the government or tax authority, according to various pre-defined parameters such as thresholds or income."]
pub struct TaxCharges2<'a> {
#[doc = "Unique reference to unambiguously identify the nature of the tax levied, such as Value Added Tax (VAT)."]
pub identification: Option<Max35Text<'a>>,
#[doc = "Rate used to calculate the tax."]
pub rate: Option<PercentageRate>,
#[doc = "Amount of money resulting from the calculation of the tax."]
pub amount: Option<ActiveOrHistoricCurrencyAndAmount>,
}
impl<'a> TaxCharges2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_optional_element("Id", <Max35Text<'a>>::parse)?;
let rate = reader.parse_optional_element("Rate", <PercentageRate>::parse)?;
let amount =
reader.parse_optional_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self {
identification,
rate,
amount,
})
}
}
pub type ChargeBearerType1Code = ChargeBearerTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies which party(ies) will pay charges due for processing of the instruction."]
pub enum ChargeBearerTypeCode {
#[doc = "All transaction charges are to be borne by the debtor."]
BorneByDebtor,
#[doc = "All transaction charges are to be borne by the creditor."]
BorneByCreditor,
#[doc = "In a credit transfer context, means that transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor. In a direct debit context, means that transaction charges on the sender side are to be borne by the creditor, transaction charges on the receiver side are to be borne by the debtor."]
Shared,
#[doc = "Charges are to be applied following the rules agreed in the service level and/or scheme."]
FollowingServiceLevel,
}
impl<'a> ChargeBearerTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"DEBT" => Self::BorneByDebtor,
"CRED" => Self::BorneByCreditor,
"SHAR" => Self::Shared,
"SLEV" => Self::FollowingServiceLevel,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the charge type."]
pub enum ChargeType2Choice<'a> {
#[doc = "Charge type, in a coded form."]
Code(ChargeType1Code),
#[doc = "Type of charge in a proprietary form, as defined by the issuer."]
Proprietary(GenericIdentification3<'a>),
}
impl<'a> ChargeType2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ChargeType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <GenericIdentification3<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification, for example, party identification or account identification."]
pub struct GenericIdentification3<'a> {
#[doc = "Name or number assigned by an entity to enable recognition of that entity, for example, account identifier."]
pub identification: Max35Text<'a>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericIdentification3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
issuer,
})
}
}
pub type ChargeType1Code = ChargeTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Type of service for which a charge is asked or paid."]
pub enum ChargeTypeCode {
#[doc = "Fee paid to a broker for services provided."]
BrokerageFee,
#[doc = "Fee paid for services provided."]
Commission,
#[doc = "Sales charge paid by the investor when redeeming an investment such as an investment fund."]
BackEndLoad,
#[doc = "Sales charge paid immediately by the investor when subscribing to an investment such as an investment fund."]
FrontEndLoad,
#[doc = "In investment funds, charge related to a switch transaction."]
Switch,
#[doc = "In investment funds, a charge payable by the investor covering bid-offer spreads and dealing charges for the underlying investments. The dilution levy is paid to the fund for the benefit of other unit holders."]
DilutionLevy,
#[doc = "Charge that has been reduced from the standard initial charge levied by a fund, eg, during a launch period or as negotiated by a funds supermarket / discount broker."]
Discount,
#[doc = "Fee paid to an investment manager for services. The fee usually includes fund administration costs and investor relationship management. Typically, the amount paid is a percentage of the assets under management."]
ManagementFee,
#[doc = "In investment funds, a fee charged for the transfer of ownership of an investment fund."]
TransferFee,
#[doc = "Fee charged for matching and/or confirmation."]
MatchingFees,
#[doc = "Charge paid for the postage."]
PostageCharge,
#[doc = "Fee charged by a regulatory authority, eg, Securities and Exchange fees."]
RegulatoryFee,
#[doc = "Charge for shipping, including the insurance of securities."]
ShippingCharge,
#[doc = "Fee paid for the provision of financial services."]
ServiceProvisionFee,
#[doc = "Charges, drawdown, or other reduction from or in addition to the deal price."]
SpecialConcessions,
#[doc = "Portion of charge that the fund is entitled to receive, that cannot be reduced by an intermediary."]
PartAcquis,
#[doc = "Fee charged to the investor for early redemption of the fund."]
Penalty,
#[doc = "Deferred sales charge."]
ContingencyDeferredSalesCharge,
#[doc = "Another type of charge."]
Other,
#[doc = "The part of an investor's subscription amount that is held by the fund in order to pay incentive or performance fees at the end of the fiscal year."]
Equalisation,
#[doc = "In investment funds, the charge of the correspondent bank for transferring money."]
CorrespondentBankCharge,
#[doc = "In investment funds, pre-arranged addition to the trade amount based on the published net asset value."]
Premium,
#[doc = "Charge paid at the time of the first subscription."]
Initial,
#[doc = "Fee paid for advisory services rendered."]
AdvisoryFee,
#[doc = "Fee paid to a custodian in respect of custodial services."]
CustodyFee,
#[doc = "Fee paid in respect of publications made."]
PublicationFee,
#[doc = "Fee paid for accounting services rendered."]
AccountingFee,
#[doc = "Charge is for signature services."]
SignatureService,
#[doc = "Charge is for storage of goods at destination."]
StorageAtDestination,
#[doc = "Charge is for storage of goods at origin."]
StorageAtOrigin,
#[doc = "Charge is for packaging of goods."]
Packaging,
#[doc = "Charge is for pick-up of goods."]
PickUp,
#[doc = "Charge is for dangerous goods."]
DangerousGoodsFee,
#[doc = "Charge is for security."]
SecurityCharge,
#[doc = "Charge is a premium for insurance."]
InsurancePremium,
#[doc = "Charge is for the collection of the freight."]
CollectFreight,
#[doc = "Charge is for clearance and handling of goods at origin."]
ClearanceAndHandlingAtOrigin,
#[doc = "Charge is for clearance and handling of goods at destination."]
ClearanceAndHandlingAtDestination,
#[doc = "Charge is an airway bill fee."]
AirWayBillFee,
#[doc = "Charge is for transport."]
TransportCharges,
#[doc = "Charges paid by the investor to the Fund Company for subscription and redemption orders."]
UcitsCommission,
#[doc = "Specially agreed front-end load."]
SpeciallyAgreedFrontEndLoad,
#[doc = "Charge linked to an ADR (American Depositary Receipt)."]
AdrFee,
#[doc = "Fee linked to the cancellation of an issuance."]
IssuanceCancellationFee,
#[doc = "Miscellaneous fee."]
MiscellaneousFee,
#[doc = "Charge linked to the issuance of security."]
IssuanceFee,
}
impl<'a> ChargeTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"BRKF" => Self::BrokerageFee,
"COMM" => Self::Commission,
"BEND" => Self::BackEndLoad,
"FEND" => Self::FrontEndLoad,
"SWIT" => Self::Switch,
"DLEV" => Self::DilutionLevy,
"DISC" => Self::Discount,
"MANF" => Self::ManagementFee,
"TRAN" => Self::TransferFee,
"MACO" => Self::MatchingFees,
"POST" => Self::PostageCharge,
"REGF" => Self::RegulatoryFee,
"SHIP" => Self::ShippingCharge,
"CHAR" => Self::ServiceProvisionFee,
"SPCN" => Self::SpecialConcessions,
"PACQ" => Self::PartAcquis,
"PENA" => Self::Penalty,
"CDSC" => Self::ContingencyDeferredSalesCharge,
"OTHR" => Self::Other,
"EQUL" => Self::Equalisation,
"CBCH" => Self::CorrespondentBankCharge,
"PREM" => Self::Premium,
"INIT" => Self::Initial,
"ADVI" => Self::AdvisoryFee,
"CUST" => Self::CustodyFee,
"PUBL" => Self::PublicationFee,
"ACCT" => Self::AccountingFee,
"SIGN" => Self::SignatureService,
"STDE" => Self::StorageAtDestination,
"STOR" => Self::StorageAtOrigin,
"PACK" => Self::Packaging,
"PICK" => Self::PickUp,
"DNGR" => Self::DangerousGoodsFee,
"SECU" => Self::SecurityCharge,
"INSU" => Self::InsurancePremium,
"COLF" => Self::CollectFreight,
"CHOR" => Self::ClearanceAndHandlingAtOrigin,
"CHDE" => Self::ClearanceAndHandlingAtDestination,
"AIRF" => Self::AirWayBillFee,
"TRPT" => Self::TransportCharges,
"UCIC" => Self::UcitsCommission,
"SFEN" => Self::SpeciallyAgreedFrontEndLoad,
"ADRF" => Self::AdrFee,
"ISSC" => Self::IssuanceCancellationFee,
"MISC" => Self::MiscellaneousFee,
"ISSU" => Self::IssuanceFee,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the original amount."]
pub struct AmountAndCurrencyExchange3<'a> {
#[doc = "Identifies the amount of money to be moved between the debtor and creditor, before deduction of charges, expressed in the currency as ordered by the initiating party and provides currency exchange information in case the instructed amount and/or currency is/are different from the entry amount and/or currency."]
pub instructed_amount: Option<AmountAndCurrencyExchangeDetails3<'a>>,
#[doc = "Amount of the underlying transaction."]
pub transaction_amount: Option<AmountAndCurrencyExchangeDetails3<'a>>,
#[doc = "Set of elements used to provide the countervalue amount and currency exchange information. \nUsage: This can be either the counter amount quoted in an FX deal, or the result of the currency information applied to an instructed amount, before deduction of charges."]
pub counter_value_amount: Option<AmountAndCurrencyExchangeDetails3<'a>>,
#[doc = "Amount of money, based on terms of corporate action event and balance of underlying securities, entitled to/from the account owner.\nIn some situations, this amount may alternatively be called entitled amount."]
pub announced_posting_amount: Option<AmountAndCurrencyExchangeDetails3<'a>>,
#[doc = "Set of elements used to provide information on the original amount and currency exchange."]
pub proprietary_amount: Vec<AmountAndCurrencyExchangeDetails4<'a>>,
}
impl<'a> AmountAndCurrencyExchange3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let instructed_amount = reader
.parse_optional_element("InstdAmt", <AmountAndCurrencyExchangeDetails3<'a>>::parse)?;
let transaction_amount = reader
.parse_optional_element("TxAmt", <AmountAndCurrencyExchangeDetails3<'a>>::parse)?;
let counter_value_amount = reader
.parse_optional_element("CntrValAmt", <AmountAndCurrencyExchangeDetails3<'a>>::parse)?;
let announced_posting_amount = reader.parse_optional_element(
"AnncdPstngAmt",
<AmountAndCurrencyExchangeDetails3<'a>>::parse,
)?;
let proprietary_amount =
reader.parse_list("PrtryAmt", <AmountAndCurrencyExchangeDetails4<'a>>::parse)?;
Ok(Self {
instructed_amount,
transaction_amount,
counter_value_amount,
announced_posting_amount,
proprietary_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the original amount and currency exchange."]
pub struct AmountAndCurrencyExchangeDetails4<'a> {
#[doc = "Specifies the type of amount."]
pub r#type: Max35Text<'a>,
#[doc = "Amount of money to be exchanged against another amount of money in the counter currency."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Set of elements used to provide details on the currency exchange."]
pub currency_exchange: Option<CurrencyExchange5<'a>>,
}
impl<'a> AmountAndCurrencyExchangeDetails4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <Max35Text<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let currency_exchange =
reader.parse_optional_element("CcyXchg", <CurrencyExchange5<'a>>::parse)?;
Ok(Self {
r#type,
amount,
currency_exchange,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide information on the original amount and currency exchange."]
pub struct AmountAndCurrencyExchangeDetails3<'a> {
#[doc = "Amount of money to be moved between the debtor and creditor, before deduction of charges, expressed in the currency as ordered by the initiating party."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Set of elements used to provide details on the currency exchange."]
pub currency_exchange: Option<CurrencyExchange5<'a>>,
}
impl<'a> AmountAndCurrencyExchangeDetails3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let currency_exchange =
reader.parse_optional_element("CcyXchg", <CurrencyExchange5<'a>>::parse)?;
Ok(Self {
amount,
currency_exchange,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide details of the currency exchange."]
pub struct CurrencyExchange5<'a> {
#[doc = "Currency from which an amount is to be converted in a currency conversion."]
pub source_currency: CurrencyCode,
#[doc = "Currency into which an amount is to be converted in a currency conversion."]
pub target_currency: Option<CurrencyCode>,
#[doc = "Currency in which the rate of exchange is expressed in a currency exchange. In the example 1GBP = xxxCUR, the unit currency is GBP."]
pub unit_currency: Option<CurrencyCode>,
#[doc = "Factor used to convert an amount from one currency into another. This reflects the price at which one currency was bought with another currency.\n\nUsage: ExchangeRate expresses the ratio between UnitCurrency and QuotedCurrency (ExchangeRate = UnitCurrency/QuotedCurrency)."]
pub exchange_rate: BaseOneRate,
#[doc = "Unique identification to unambiguously identify the foreign exchange contract."]
pub contract_identification: Option<Max35Text<'a>>,
#[doc = "Date and time at which an exchange rate is quoted."]
pub quotation_date: Option<IsoDateTime>,
}
impl<'a> CurrencyExchange5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let source_currency = reader.parse_element("SrcCcy", <CurrencyCode>::parse)?;
let target_currency = reader.parse_optional_element("TrgtCcy", <CurrencyCode>::parse)?;
let unit_currency = reader.parse_optional_element("UnitCcy", <CurrencyCode>::parse)?;
let exchange_rate = reader.parse_element("XchgRate", <BaseOneRate>::parse)?;
let contract_identification =
reader.parse_optional_element("CtrctId", <Max35Text<'a>>::parse)?;
let quotation_date = reader.parse_optional_element("QtnDt", <IsoDateTime>::parse)?;
Ok(Self {
source_currency,
target_currency,
unit_currency,
exchange_rate,
contract_identification,
quotation_date,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Rate expressed as a decimal, for example, 0.7 is 7/10 and 70%."]
pub struct BaseOneRate(Decimal);
impl<'a> BaseOneRate {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
const BASE: Decimal = Decimal::from_parts(1410065408u32, 2u32, 0u32, false, 10u32);
let text = reader.expect_text()?;
let inner = Decimal::from_str(&text).unwrap() / BASE;
Ok(Self(inner))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements providing the identification of a message."]
pub struct MessageIdentification2<'a> {
#[doc = "Specifies the message name identifier of the message that will be used to provide additional details."]
pub message_name_identification: Option<Max35Text<'a>>,
#[doc = "Specifies the identification of the message that will be used to provide additional details."]
pub message_identification: Option<Max35Text<'a>>,
}
impl<'a> MessageIdentification2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_name_identification =
reader.parse_optional_element("MsgNmId", <Max35Text<'a>>::parse)?;
let message_identification =
reader.parse_optional_element("MsgId", <Max35Text<'a>>::parse)?;
Ok(Self {
message_name_identification,
message_identification,
})
}
}
pub type EntryStatus2Code = EntryStatusCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the status of an entry."]
pub enum EntryStatusCode {
#[doc = "Booked means that the transfer of money has been completed between account servicer and account owner\n\nUsage: \nStatus Booked does not necessarily imply finality of money as this depends on other factors such as the payment system used, the completion of the end-to-end transaction and the terms agreed between account servicer and owner.\nStatus Booked is the only status that can be reversed."]
Booked,
#[doc = "Booking on the account owner's account in the account servicer's ledger has not been completed.\n\nUsage: this can be used for expected items, or for items for which some conditions still need to be fulfilled before they can be booked. If booking takes place, the entry will be included with status Booked in subsequent account report or statement. Status Pending cannot be reversed."]
Pending,
#[doc = "Entry is only provided for information, and no booking on the account owner's account in the account servicer's ledger has been performed."]
Information,
#[doc = "Entry is on the books of the account servicer and value will be applied to the account owner at a future date and time."]
Future,
}
impl<'a> EntryStatusCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"BOOK" => Self::Booked,
"PDNG" => Self::Pending,
"INFO" => Self::Information,
"FUTR" => Self::Future,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide summary information on entries."]
pub struct TotalTransactions2<'a> {
#[doc = "Specifies the total number and sum of debit and credit entries."]
pub total_entries: Option<NumberAndSumOfTransactions2<'a>>,
#[doc = "Specifies the total number and sum of credit entries."]
pub total_credit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Specifies the total number and sum of debit entries."]
pub total_debit_entries: Option<NumberAndSumOfTransactions1<'a>>,
#[doc = "Specifies the total number and sum of entries per bank transaction code."]
pub total_entries_per_bank_transaction_code: Vec<TotalsPerBankTransactionCode2<'a>>,
}
impl<'a> TotalTransactions2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let total_entries =
reader.parse_optional_element("TtlNtries", <NumberAndSumOfTransactions2<'a>>::parse)?;
let total_credit_entries = reader
.parse_optional_element("TtlCdtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let total_debit_entries = reader
.parse_optional_element("TtlDbtNtries", <NumberAndSumOfTransactions1<'a>>::parse)?;
let total_entries_per_bank_transaction_code = reader.parse_list(
"TtlNtriesPerBkTxCd",
<TotalsPerBankTransactionCode2<'a>>::parse,
)?;
Ok(Self {
total_entries,
total_credit_entries,
total_debit_entries,
total_entries_per_bank_transaction_code,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide the total sum of entries per bank transaction code."]
pub struct TotalsPerBankTransactionCode2<'a> {
#[doc = "Number of individual entries for the bank transaction code."]
pub number_of_entries: Option<Max15NumericText<'a>>,
#[doc = "Total of all individual entries included in the report."]
pub sum: Option<DecimalNumber>,
#[doc = "Total amount that is the result of the netted amounts for all debit and credit entries per bank transaction code."]
pub total_net_entry_amount: Option<DecimalNumber>,
#[doc = "Indicates whether the total net entry amount is a credit or a debit amount."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Indicates whether the bank transaction code is related to booked or forecast items."]
pub forecast_indicator: Option<TrueFalseIndicator>,
#[doc = "Set of elements used to fully identify the type of underlying transaction resulting in an entry."]
pub bank_transaction_code: BankTransactionCodeStructure4<'a>,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest."]
pub availability: Vec<CashBalanceAvailability2<'a>>,
}
impl<'a> TotalsPerBankTransactionCode2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_entries =
reader.parse_optional_element("NbOfNtries", <Max15NumericText<'a>>::parse)?;
let sum = reader.parse_optional_element("Sum", <DecimalNumber>::parse)?;
let total_net_entry_amount =
reader.parse_optional_element("TtlNetNtryAmt", <DecimalNumber>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let forecast_indicator =
reader.parse_optional_element("FcstInd", <TrueFalseIndicator>::parse)?;
let bank_transaction_code =
reader.parse_element("BkTxCd", <BankTransactionCodeStructure4<'a>>::parse)?;
let availability = reader.parse_list("Avlbty", <CashBalanceAvailability2<'a>>::parse)?;
Ok(Self {
number_of_entries,
sum,
total_net_entry_amount,
credit_debit_indicator,
forecast_indicator,
bank_transaction_code,
availability,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the type or operations code of a transaction entry."]
pub struct BankTransactionCodeStructure4<'a> {
#[doc = "Set of elements used to provide the domain, the family and the sub-family of the bank transaction code, in a structured and hierarchical format.\n\nUsage: If a specific family or sub-family code cannot be provided, the generic family code defined for the domain or the generic sub-family code defined for the family should be provided."]
pub domain: Option<BankTransactionCodeStructure5>,
#[doc = "Bank transaction code in a proprietary form, as defined by the issuer."]
pub proprietary: Option<ProprietaryBankTransactionCodeStructure1<'a>>,
}
impl<'a> BankTransactionCodeStructure4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let domain =
reader.parse_optional_element("Domn", <BankTransactionCodeStructure5>::parse)?;
let proprietary = reader.parse_optional_element(
"Prtry",
<ProprietaryBankTransactionCodeStructure1<'a>>::parse,
)?;
Ok(Self {
domain,
proprietary,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements to fully identify a proprietary bank transaction code."]
pub struct ProprietaryBankTransactionCodeStructure1<'a> {
#[doc = "Proprietary bank transaction code to identify the underlying transaction."]
pub code: Max35Text<'a>,
#[doc = "Identification of the issuer of the proprietary bank transaction code."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> ProprietaryBankTransactionCodeStructure1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code = reader.parse_element("Cd", <Max35Text<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self { code, issuer })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the type or operations code of a transaction entry."]
pub struct BankTransactionCodeStructure5 {
#[doc = "Specifies the business area of the underlying transaction."]
pub code: ExternalBankTransactionDomain1Code,
#[doc = "Specifies the family and the sub-family of the bank transaction code, within a specific domain, in a structured and hierarchical format."]
pub family: BankTransactionCodeStructure6,
}
impl<'a> BankTransactionCodeStructure5 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code = reader.parse_element("Cd", <ExternalBankTransactionDomain1Code>::parse)?;
let family = reader.parse_element("Fmly", <BankTransactionCodeStructure6>::parse)?;
Ok(Self { code, family })
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify the type or operations code of a transaction entry."]
pub struct BankTransactionCodeStructure6 {
#[doc = "Specifies the family within a domain."]
pub code: ExternalBankTransactionFamily1Code,
#[doc = "Specifies the sub-product family within a specific family."]
pub sub_family_code: ExternalBankTransactionSubFamily1Code,
}
impl<'a> BankTransactionCodeStructure6 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code = reader.parse_element("Cd", <ExternalBankTransactionFamily1Code>::parse)?;
let sub_family_code =
reader.parse_element("SubFmlyCd", <ExternalBankTransactionSubFamily1Code>::parse)?;
Ok(Self {
code,
sub_family_code,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements providing the total sum of entries."]
pub struct NumberAndSumOfTransactions1<'a> {
#[doc = "Number of individual entries included in the report."]
pub number_of_entries: Option<Max15NumericText<'a>>,
#[doc = "Total of all individual entries included in the report."]
pub sum: Option<DecimalNumber>,
}
impl<'a> NumberAndSumOfTransactions1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_entries =
reader.parse_optional_element("NbOfNtries", <Max15NumericText<'a>>::parse)?;
let sum = reader.parse_optional_element("Sum", <DecimalNumber>::parse)?;
Ok(Self {
number_of_entries,
sum,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements providing the total sum of entries."]
pub struct NumberAndSumOfTransactions2<'a> {
#[doc = "Number of individual entries included in the report."]
pub number_of_entries: Option<Max15NumericText<'a>>,
#[doc = "Total of all individual entries included in the report."]
pub sum: Option<DecimalNumber>,
#[doc = "Resulting amount of the netted amounts for all debit and credit entries."]
pub total_net_entry_amount: Option<DecimalNumber>,
#[doc = "Indicates whether the total net entry amount is a credit or a debit amount."]
pub credit_debit_indicator: Option<CreditDebitCode>,
}
impl<'a> NumberAndSumOfTransactions2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_entries =
reader.parse_optional_element("NbOfNtries", <Max15NumericText<'a>>::parse)?;
let sum = reader.parse_optional_element("Sum", <DecimalNumber>::parse)?;
let total_net_entry_amount =
reader.parse_optional_element("TtlNetNtryAmt", <DecimalNumber>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
Ok(Self {
number_of_entries,
sum,
total_net_entry_amount,
credit_debit_indicator,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Number of objects represented as a decimal number, for example 0.75 or 45.6."]
pub struct DecimalNumber(Decimal);
impl<'a> DecimalNumber {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let inner = Decimal::from_str(&text).unwrap();
Ok(Self(inner))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a maximum length of 15 digits."]
pub struct Max15NumericText<'a>(Cow<'a, str>);
impl<'a> Max15NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the balance details."]
pub struct CashBalance3<'a> {
#[doc = "Specifies the nature of a balance."]
pub r#type: BalanceType12<'a>,
#[doc = "Set of elements used to provide details on the credit line."]
pub credit_line: Option<CreditLine2>,
#[doc = "Amount of money of the cash balance."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the balance is a credit or a debit balance. \nUsage: A zero balance is considered to be a credit balance."]
pub credit_debit_indicator: CreditDebitCode,
#[doc = "Indicates the date (and time) of the balance."]
pub date: DateAndDateTimeChoice,
#[doc = "Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest. \n\nUsage: This type of information is used in the US and is linked to particular instruments such as cheques.\nExample: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations)."]
pub availability: Vec<CashBalanceAvailability2<'a>>,
}
impl<'a> CashBalance3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <BalanceType12<'a>>::parse)?;
let credit_line = reader.parse_optional_element("CdtLine", <CreditLine2>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let date = reader.parse_element("Dt", <DateAndDateTimeChoice>::parse)?;
let availability = reader.parse_list("Avlbty", <CashBalanceAvailability2<'a>>::parse)?;
Ok(Self {
r#type,
credit_line,
amount,
credit_debit_indicator,
date,
availability,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Indicates when the amount of money will become available, ie can be accessed and start generating interest."]
pub struct CashBalanceAvailability2<'a> {
#[doc = "Indicates when the amount of money will become available."]
pub date: CashBalanceAvailabilityDate1<'a>,
#[doc = "Identifies the available amount."]
pub amount: ActiveOrHistoricCurrencyAndAmount,
#[doc = "Indicates whether the availability balance is a credit or a debit balance. \nUsage: A zero balance is considered to be a credit balance."]
pub credit_debit_indicator: CreditDebitCode,
}
impl<'a> CashBalanceAvailability2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let date = reader.parse_element("Dt", <CashBalanceAvailabilityDate1<'a>>::parse)?;
let amount = reader.parse_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
let credit_debit_indicator = reader.parse_element("CdtDbtInd", <CreditDebitCode>::parse)?;
Ok(Self {
date,
amount,
credit_debit_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Indicates when the amount of money will become available."]
pub struct CashBalanceAvailabilityDate1<'a> {
#[doc = "Indicates the number of float days attached to the balance."]
pub number_of_days: Max15PlusSignedNumericText<'a>,
#[doc = "Identifies the actual availability date."]
pub actual_date: IsoDate,
}
impl<'a> CashBalanceAvailabilityDate1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let number_of_days =
reader.parse_element("NbOfDays", <Max15PlusSignedNumericText<'a>>::parse)?;
let actual_date = reader.parse_element("ActlDt", <IsoDate>::parse)?;
Ok(Self {
number_of_days,
actual_date,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a maximum length of 15 digits and may be prefixed with a plus sign."]
pub struct Max15PlusSignedNumericText<'a>(Cow<'a, str>);
impl<'a> Max15PlusSignedNumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between a date or a date and time format."]
pub enum DateAndDateTimeChoice {
#[doc = "Specified date."]
Date(IsoDate),
#[doc = "Specified date and time."]
DateTime(IsoDateTime),
}
impl<'a> DateAndDateTimeChoice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Dt".as_bytes() => {
let inner = reader.parse_element("Dt", <IsoDate>::parse)?;
Self::Date(inner)
}
name if name == "DtTm".as_bytes() => {
let inner = reader.parse_element("DtTm", <IsoDateTime>::parse)?;
Self::DateTime(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide details of the credit line."]
pub struct CreditLine2 {
#[doc = "Indicates whether or not the credit line is included in the balance.\n\nUsage: If not present, credit line is not included in the balance amount."]
pub included: TrueFalseIndicator,
#[doc = "Amount of money of the credit line."]
pub amount: Option<ActiveOrHistoricCurrencyAndAmount>,
}
impl<'a> CreditLine2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let included = reader.parse_element("Incl", <TrueFalseIndicator>::parse)?;
let amount =
reader.parse_optional_element("Amt", <ActiveOrHistoricCurrencyAndAmount>::parse)?;
Ok(Self { included, amount })
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "A number of monetary units specified in an active or a historic currency where the unit of currency is explicit and compliant with ISO 4217."]
pub struct ActiveOrHistoricCurrencyAndAmount {
amount: Decimal,
pub currency: CurrencyCode,
}
impl<'a> ActiveOrHistoricCurrencyAndAmount {
pub(crate) fn parse(reader: &mut XmlReader<'a>, start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let amount = Decimal::from_str(&text).unwrap();
let currency = {
let currency = start
.try_get_attribute(b"Ccy")?
.ok_or_else(|| -> XmlError { todo!() })?;
let currency = currency.unescape_value()?;
CurrencyCode::from_str(&*currency)?
};
Ok(Self { amount, currency })
}
}
#[derive(Clone, Debug)]
#[doc = "A flag indicating a True or False value."]
pub enum TrueFalseIndicator {
False,
True,
}
impl<'a> TrueFalseIndicator {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = if reader.expect_boolean()? {
Self::True
} else {
Self::False
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to define the balance type and sub-type."]
pub struct BalanceType12<'a> {
#[doc = "Coded or proprietary format balance type."]
pub code_or_proprietary: BalanceType5Choice<'a>,
#[doc = "Specifies the balance sub-type."]
pub sub_type: Option<BalanceSubType1Choice<'a>>,
}
impl<'a> BalanceType12<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code_or_proprietary =
reader.parse_element("CdOrPrtry", <BalanceType5Choice<'a>>::parse)?;
let sub_type =
reader.parse_optional_element("SubTp", <BalanceSubType1Choice<'a>>::parse)?;
Ok(Self {
code_or_proprietary,
sub_type,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the balance subtype."]
pub enum BalanceSubType1Choice<'a> {
#[doc = "Balance sub-type, as published in an external balance sub-type code list."]
Code(ExternalBalanceSubType1Code),
#[doc = "Specifies a proprietary code for the balance type."]
Proprietary(Max35Text<'a>),
}
impl<'a> BalanceSubType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalBalanceSubType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalBalanceSubType1Code;
#[derive(Clone, Debug)]
#[doc = "Specifies the balance type."]
pub enum BalanceType5Choice<'a> {
#[doc = "Balance type, in a coded form."]
Code(BalanceType12Code),
#[doc = "Balance type, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> BalanceType5Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <BalanceType12Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type BalanceType12Code = BalanceTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the nature of the balance."]
pub enum BalanceTypeCode {
#[doc = "Balance attributed to receivables."]
Receivables,
#[doc = "Balance attributed to payables."]
Payables,
#[doc = "Balance attributed according to a different classification, which is not explictly defined."]
Other,
#[doc = "Balance attributed to expenses."]
Expenses,
#[doc = "Balance attributed to cash and cash equivalents."]
CashAndCashEquivalents,
#[doc = "Balance attributed to investor inflow/outflow (creations, cancellations, income distributions)."]
InvestorInflowOutflow,
#[doc = "Balance attributed to revenues; including dividends, interest, net realised gains/losses etc."]
Revenues,
#[doc = "Balance attributed to borrowings."]
Borrowings,
#[doc = "Balance attributed to investments at value."]
Investments,
#[doc = "Book balance of the account at the beginning of the account servicer's business day. It always equals the closing book balance from the previous business day. Note: the available balance at the beginning of the account servicer's business day may be different from the closing book balance from the previous business day."]
Opening,
#[doc = "Balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
Interim,
#[doc = "Balance of the account at the end of the account servicer's business day. It is the sum of the opening balance at the beginning of the day and all entries booked to the account during the account servicer's business day."]
Closing,
#[doc = "Balance that is registered in the books of the account servicer."]
Book,
#[doc = "Balance of the account at a precise moment in time."]
Current,
#[doc = "Balance of securities pending delivery, eg, orders to sell securities have been executed but settlement of the open transactions has not been confirmed."]
Pending,
#[doc = "Balance of a specific limit value, eg, a bilateral balance is calculated in relation to a given bilateral limit."]
LimitRelated,
#[doc = "Balance of money or securities that is at the disposal of the account owner on the date specified."]
Available,
#[doc = "Balance composed of the sum of all liquidity transfers made to or from an account."]
LiquidityTransfer,
#[doc = "Balance representing the sum of all credit entries booked to an account."]
Credit,
#[doc = "Balance representing the potential loan a Central Bank would make in cash if the collateral is pledged, eg, securities available and eligible as collateral with the Central Bank."]
EligibleAssets,
#[doc = "Balance representing the sum of entries as a result of payments processing. Entries relating to fees, interest, or other movements not a result of payments sent or received by the account owner are not included."]
Payment,
#[doc = "Balance representing the regulatory reserve that a financial institution must have with the account servicing institution, eg, the minimum credit balance a financial institution is to keep with its Central Bank for mandatory reserve purposes. In some countries, a blocked balance is known as a 'reserve' balance."]
Blocked,
#[doc = "Balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day balance if everything is booked on the account and no other entry is posted."]
Expected,
#[doc = "Balance representing the intra day overdraft granted by the Central Bank to financial institutions participating in a RTGS system. This balance may vary over time and shall be offset at the end of the day."]
DaylightOverdraft,
#[doc = "Balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day credit balance if everything books to the account and no other credit entry is posted."]
ExpectedCredit,
#[doc = "Balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day debit balance if everything books to the account and no other debit entry is posted."]
ExpectedDebit,
#[doc = "Balance to be held in the settlement account in order to comply with the average reserve due, in the event that the bank's balance is equal to the reserve due during the remaining days of the maintenance period."]
Adjustment,
#[doc = "Average of the daily balances on the account used to fulfil the reserve requirements calculated from the beginning of the maintenance period."]
ProgressiveAverage,
#[doc = "Balance representing the sum of all debit entries booked to an account."]
Debit,
#[doc = "Balance representing the amount that will be destined for investment. Difference between available balance and threshold for investment limit."]
Threshold,
#[doc = "Balance representing the amount that a financial institution has set aside for a specific reason and which is therefore not available."]
Noted,
#[doc = "Balance of the account identified (as opposed to Master Balance)."]
_Self,
#[doc = "Balance of the identified account plus the balance of all of its subaccounts."]
Master,
#[doc = "Balance representing the forecast of total of all cash legs for trades that are ready to settle via CSD. Amounts shown are still subject to processing of the securities settlement."]
ForecastSettlement,
#[doc = "Balance representing the projected total of all cash legs for trades settling via CSD that have been matched but blocked in order to not settle. These blocked trades are included in the calculation for settlement (eg, to avoid overdrafts).\nUsage rule: Blocking can be done by account owner or its counterparties. Usually this is done to chain transactions or to prioritise other trades. Blocked trades have an indicator that prevents the transactions from settling. Once matched, they can settle whenever the freeze is lifted. In this case they will move to FSET. Lifting the freeze can happen anytime during the day and the transaction will be settling in the next settlement cycle which can be the same day if the (I)CSD's operates several settlements cycles per day."]
BlockedTrades,
#[doc = "Balance representing the projected total of all cash legs for trades settling via CSD that have been matched but blocked in order to not settle. These blocked transactions are not included in the calculation for settlement."]
OtherBlockedTrades,
#[doc = "Balance representing the projected total of all asset servicing transactions such as dividends, income corporate actions equivalents, tax returns, etc."]
Custody,
#[doc = "Balance representing the total of all balance types representing transactions to settle, blocked items and custody transactions."]
CashForecast,
#[doc = "Balance representing the projected total amount of all payment obligations to the participant (bank), based on their role as main paying agent."]
DividendsCollection,
#[doc = "Balance representing the net amount to be funded resulting from all transactions which have an impact on the funding requirement."]
NetFunding,
#[doc = "Balance representing the fictive forecast of automated direct debits or payment based on standing arrangements between the CSD and the user.\n\nUsage: Pay-Ins and Pay-Outs can be different based on individual payment instructions or available funds."]
PayInPayOut,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions traded in exchanges."]
ExchangeForecast,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions traded in exchanges that operate a central counterparty functionality."]
CentralCounterparty,
#[doc = "Balance representing the total of the payments that were put on hold because the limits have been exceeded."]
TotalOnHold,
#[doc = "Balance representing the total incoming payments that were put on hold because the credit limit has been exceeded."]
CreditOnHold,
#[doc = "Balance representing the total outgoing payments that were put on hold because the debit limit has been exceeded."]
DebitOnHold,
#[doc = "Balance representing the total of the payments that have been processed and are waiting for settlement during the day."]
TotalProcessed,
#[doc = "Balance representing the total incoming payments that have been processed and are waiting for settlement."]
CreditProcessed,
#[doc = "Balance representing the total outgoing payments that have been processed and are waiting for settlement."]
DebitProcessed,
#[doc = "Balance representing the total of the payments with a processing date in the future."]
TotalFuture,
#[doc = "Balance representing the total of the payments that have been rejected."]
TotalRejected,
#[doc = "Opening balance of amount of money that is at the disposal of the account owner on the date specified."]
OpeningAvailable,
#[doc = "Available balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
InterimAvailable,
#[doc = "Closing balance of amount of money that is at the disposal of the account owner on the date specified."]
ClosingAvailable,
#[doc = "Forward available balance of money that is at the disposal of the account owner on the date specified."]
ForwardAvailable,
#[doc = "Balance of the account at the end of the pre-agreed account reporting period. It is the sum of the opening booked balance at the beginning of the period and all entries booked to the account during the pre-agreed account reporting period."]
ClosingBooked,
#[doc = "Balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
InterimBooked,
#[doc = "Book balance of the account at the beginning of the account reporting period. It always equals the closing book balance from the previous report."]
OpeningBooked,
#[doc = "Balance of the account at the previously closed account reporting period. The opening booked balance for the new period has to be equal to this balance. \n\nUsage: the previously booked closing balance should equal (inclusive date) the booked closing balance of the date it references and equal the actual booked opening balance of the current date."]
PreviouslyClosedBooked,
#[doc = "Investment opening balance of amount of money that is at the disposal of the account owner on the date specified."]
InvestmentOpeningAvailable,
#[doc = "Investment available balance for calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
InvestmentInterimAvailable,
#[doc = "Investment closing balance of an amount of money that is at the disposal of the account owner on the date specified."]
InvestmentClosingAvailable,
#[doc = "Investment forward available balance of money that is at the disposal of the account owner on the date specified."]
InvestmentForwardAvailable,
#[doc = "Investment (mutual funds) balance of the account at the end of the pre-agreed account reporting period. It is the sum of the opening booked balance at the beginning of the period and all entries booked to the account during the pre-agreed account reporting period."]
InvestmentClosingBooked,
#[doc = "Investment balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
InvestmentInterimBooked,
#[doc = "Investment book balance of the account at the beginning of the account reporting period. It always equals the closing book balance from the previous report."]
InvestmentOpeningBooked,
#[doc = "Investment balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day balance if everything is booked on the account and no other entry is posted."]
InvestmentExpected,
#[doc = "Disbursement opening balance of amount of money that is at the disposal of the account owner on the date specified."]
DisbursementOpeningAvailable,
#[doc = "Disbursement available balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
DisbursementInterimAvailable,
#[doc = "Disbursement closing balance of amount of money that is at the disposal of the account owner on the date specified."]
DisbursementClosingAvailable,
#[doc = "Disbursement forward available balance of money that is at the disposal of the account owner on the date specified."]
DisbursementForwardAvailable,
#[doc = "Disbursement balance of the account at the end of the pre-agreed account reporting period. It is the sum of the opening booked balance at the beginning of the period and all entries booked to the account during the pre-agreed account reporting period."]
DisbursementClosingBooked,
#[doc = "Disbursement balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
DisbursementInterimBooked,
#[doc = "Disbursement book balance of the account at the beginning of the account reporting period. It always equals the closing book balance from the previous report."]
DisbursementOpeningBooked,
#[doc = "Disbursement balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day balance if everything is booked on the account and no other entry is posted."]
DisbursementExpected,
#[doc = "Collection opening balance of amount of money that is at the disposal of the account owner on the date specified."]
CollectionOpeningAvailable,
#[doc = "Collection available balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
CollectionInterimAvailable,
#[doc = "Collection closing balance of amount of money that is at the disposal of the account owner on the date specified."]
CollectionClosingAvailable,
#[doc = "Collection forward available balance of money that is at the disposal of the account owner on the date specified."]
CollectionForwardAvailable,
#[doc = "Collection balance of the account at the end of the pre-agreed account reporting period. It is the sum of the opening booked balance at the beginning of the period and all entries booked to the account during the pre-agreed account reporting period."]
CollectionClosingBooked,
#[doc = "Collection balance calculated in the course of the account servicer's business day, at the time specified, and subject to further changes during the business day. The interim balance is calculated on the basis of booked credit and debit items during the calculation time/period specified."]
CollectionInterimBooked,
#[doc = "Collection book balance of the account at the beginning of the account reporting period. It always equals the closing book balance from the previous report."]
CollectionOpeningBooked,
#[doc = "Collection balance, composed of booked entries and pending items known at the time of calculation, which projects the end of day balance if everything is booked on the account and no other entry is posted."]
CollectionExpected,
#[doc = "Balance representing the forecast of the cash-equivalent resulting from evaluation of existing holdings at CSD that are qualified to serve as collateral."]
FirmCollateralisation,
#[doc = "Balance representing the cash equivalent resulting from evaluation of existing holdings at CSD that are qualified to serve as collateral and have been used as collateral."]
UsedAmountsFirmCollateralisation,
#[doc = "Balance representing the forecast of the cash-equivalent resulting from evaluation of the net incoming balance of securities qualified to serve as collateral for which settlement instructions are held at."]
SelfCollateralisation,
#[doc = "Balance representing the cash-equivalent resulting from evaluation of incoming securities, qualified to serve as collateral and actually used as collateral, which have been settled during the settlement process."]
UsedAmountsSelfCollateralisation,
#[doc = "Balance representing the actual total of all asset servicing transactions such as dividends, income corporate actions equivalents, tax returns, redemptions, etc."]
CustodyActual,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions in exchanges, going through CCP functions."]
CcpGuaranteedForecasting,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions traded in exchanges not going through CCP functions."]
NonCcpGuaranteedForecasting,
#[doc = "Balance representing the cash equivalent of all settled securities transactions."]
DefinitiveSettledSecurities,
#[doc = "Balance representing the cash equivalent of transactions with a lack of holdings."]
LackOfHoldingsTransactions,
#[doc = "Balance representing the cash equivalent of all non-settled securities transactions."]
NonSettledSecurities,
#[doc = "Balance representing the Forecast of the total of all cash-legs of transactions 'over the counter' (OTC), going through CCP functions."]
CcpGuaranteedOtcTransactions,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions traded 'over the counter' (OTC)."]
ForecastOtcTransactions,
#[doc = "Balance representing the forecast of the total of all cash legs of transactions traded 'over the counter' (OTC) not going through CCP functions."]
NonCcpGuaranteedOtcTransactions,
#[doc = "Balance represents the settlement account processor direct debit amount."]
SapDirectDebitAmount,
#[doc = "Balance represents the settlement account processor direct credit amount."]
SapDirectCreditAmount,
#[doc = "Balance represents the total of the central moneymarkets unit processor repo debits."]
CmupRepoDebit,
#[doc = "Balance represents the total of the central moneymarkets unit processor repo credits."]
CmupRepoCredit,
#[doc = "Balance represents the total of the bulk settlement and central moneymarkets unit processor debit."]
BulkSettlementCmupDebit,
#[doc = "Balance represents the total of the bulk settlement and central moneymarkets unit processor credit."]
BulkSettlementCmupCredit,
#[doc = "Balance represents the settlement account processor queue amount."]
SapQueueAmount,
#[doc = "Balance represents the intraday repo limit."]
IntradayRepoLimit,
#[doc = "Balance represents the intraday repo drawings."]
IntradayRepoDrawings,
#[doc = "Balance represents the discount window repo drawings."]
DiscountWindowRepoDrawings,
#[doc = "Balance represents the available discounted market value for discount window repo."]
AvailableDmvForDiscountWindowRepo,
#[doc = "Balance represents the available discounted market value for intraday repo."]
AvailableDmvForIntradayRepo,
#[doc = "Balance of instructed position."]
Elected,
#[doc = "Balance of financial instruments that are reserved for the distribution of the proceeds."]
ReservedForDistribution,
#[doc = "Balance of securities which are reserved temporarily in the SPA account before they will effectively be exchanged."]
ReservedForRemoval,
#[doc = "Balance of cash that may only be used under certain conditions.\n\nBalance type is used to block securities/cash in the client account e.g., in relation to elections relating to certain corporate actions. The holding is under the direct control of the system paying agent, who us the only one who can transfer securities out of this balance type.\nAlso known as the \"escrow balance\" or \"sequestered balance\"."]
Restricted,
#[doc = "Total quantity of financial instruments entitled to the account owner based on the terms of the corporate action event."]
TotalEntitled,
#[doc = "Balance of uninstructed position."]
Unelected,
#[doc = "Balance for informational purposes."]
Information,
#[doc = "Amount of money due."]
AmountDue,
#[doc = "Amount put on hold."]
AmountOnHold,
#[doc = "Amount of money owed"]
AmountOwing,
#[doc = "Cleared items balance. "]
ClearedItem,
#[doc = "Credit line available."]
CreditLine,
#[doc = "Ledger balance refers to posted transactions (e.g. limit authorisation amount - posted transactions)."]
Ledger,
#[doc = "Other type of balance defined at national level"]
OtherNational,
#[doc = "Other type of balance defined at private level."]
OtherPrivate,
}
impl<'a> BalanceTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"RECE" => Self::Receivables,
"PAYA" => Self::Payables,
"OTHR" => Self::Other,
"EXPN" => Self::Expenses,
"CASE" => Self::CashAndCashEquivalents,
"IIOF" => Self::InvestorInflowOutflow,
"REVE" => Self::Revenues,
"BORR" => Self::Borrowings,
"INVE" => Self::Investments,
"OPNG" => Self::Opening,
"INTM" => Self::Interim,
"CLSG" => Self::Closing,
"BOOK" => Self::Book,
"CRRT" => Self::Current,
"PDNG" => Self::Pending,
"LRLD" => Self::LimitRelated,
"AVLB" => Self::Available,
"LTSF" => Self::LiquidityTransfer,
"CRDT" => Self::Credit,
"EAST" => Self::EligibleAssets,
"PYMT" => Self::Payment,
"BLCK" => Self::Blocked,
"XPCD" => Self::Expected,
"DLOD" => Self::DaylightOverdraft,
"XCRD" => Self::ExpectedCredit,
"XDBT" => Self::ExpectedDebit,
"ADJT" => Self::Adjustment,
"PRAV" => Self::ProgressiveAverage,
"DBIT" => Self::Debit,
"THRE" => Self::Threshold,
"NOTE" => Self::Noted,
"SELF" => Self::_Self,
"MSTR" => Self::Master,
"FSET" => Self::ForecastSettlement,
"BLOC" => Self::BlockedTrades,
"OTHB" => Self::OtherBlockedTrades,
"CUST" => Self::Custody,
"FORC" => Self::CashForecast,
"COLC" => Self::DividendsCollection,
"FUND" => Self::NetFunding,
"PIPO" => Self::PayInPayOut,
"XCHG" => Self::ExchangeForecast,
"CCPS" => Self::CentralCounterparty,
"TOHB" => Self::TotalOnHold,
"COHB" => Self::CreditOnHold,
"DOHB" => Self::DebitOnHold,
"TPBL" => Self::TotalProcessed,
"CPBL" => Self::CreditProcessed,
"DPBL" => Self::DebitProcessed,
"FUTB" => Self::TotalFuture,
"REJB" => Self::TotalRejected,
"OPAV" => Self::OpeningAvailable,
"ITAV" => Self::InterimAvailable,
"CLAV" => Self::ClosingAvailable,
"FWAV" => Self::ForwardAvailable,
"CLBD" => Self::ClosingBooked,
"ITBD" => Self::InterimBooked,
"OPBD" => Self::OpeningBooked,
"PRCD" => Self::PreviouslyClosedBooked,
"IOPA" => Self::InvestmentOpeningAvailable,
"IITA" => Self::InvestmentInterimAvailable,
"ICLA" => Self::InvestmentClosingAvailable,
"IFWA" => Self::InvestmentForwardAvailable,
"ICLB" => Self::InvestmentClosingBooked,
"IITB" => Self::InvestmentInterimBooked,
"IOPB" => Self::InvestmentOpeningBooked,
"IXPC" => Self::InvestmentExpected,
"DOPA" => Self::DisbursementOpeningAvailable,
"DITA" => Self::DisbursementInterimAvailable,
"DCLA" => Self::DisbursementClosingAvailable,
"DFWA" => Self::DisbursementForwardAvailable,
"DCLB" => Self::DisbursementClosingBooked,
"DITB" => Self::DisbursementInterimBooked,
"DOPB" => Self::DisbursementOpeningBooked,
"DXPC" => Self::DisbursementExpected,
"COPA" => Self::CollectionOpeningAvailable,
"CITA" => Self::CollectionInterimAvailable,
"CCLA" => Self::CollectionClosingAvailable,
"CFWA" => Self::CollectionForwardAvailable,
"CCLB" => Self::CollectionClosingBooked,
"CITB" => Self::CollectionInterimBooked,
"COPB" => Self::CollectionOpeningBooked,
"CXPC" => Self::CollectionExpected,
"FCOL" => Self::FirmCollateralisation,
"FCOU" => Self::UsedAmountsFirmCollateralisation,
"SCOL" => Self::SelfCollateralisation,
"SCOU" => Self::UsedAmountsSelfCollateralisation,
"CUSA" => Self::CustodyActual,
"XCHC" => Self::CcpGuaranteedForecasting,
"XCHN" => Self::NonCcpGuaranteedForecasting,
"DSET" => Self::DefinitiveSettledSecurities,
"LACK" => Self::LackOfHoldingsTransactions,
"NSET" => Self::NonSettledSecurities,
"OTCC" => Self::CcpGuaranteedOtcTransactions,
"OTCG" => Self::ForecastOtcTransactions,
"OTCN" => Self::NonCcpGuaranteedOtcTransactions,
"SAPD" => Self::SapDirectDebitAmount,
"SAPC" => Self::SapDirectCreditAmount,
"REPD" => Self::CmupRepoDebit,
"REPC" => Self::CmupRepoCredit,
"BSCD" => Self::BulkSettlementCmupDebit,
"BSCC" => Self::BulkSettlementCmupCredit,
"SAPP" => Self::SapQueueAmount,
"IRLT" => Self::IntradayRepoLimit,
"IRDR" => Self::IntradayRepoDrawings,
"DWRD" => Self::DiscountWindowRepoDrawings,
"ADWR" => Self::AvailableDmvForDiscountWindowRepo,
"AIDR" => Self::AvailableDmvForIntradayRepo,
"ELEC" => Self::Elected,
"RDIS" => Self::ReservedForDistribution,
"RREM" => Self::ReservedForRemoval,
"REST" => Self::Restricted,
"TENT" => Self::TotalEntitled,
"UNEL" => Self::Unelected,
"INFO" => Self::Information,
"AMTD" => Self::AmountDue,
"AMOH" => Self::AmountOnHold,
"AMTO" => Self::AmountOwing,
"CLRI" => Self::ClearedItem,
"CRDL" => Self::CreditLine,
"LDGR" => Self::Ledger,
"OTHN" => Self::OtherNational,
"OTHP" => Self::OtherPrivate,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide details of the interest that applies to the account at a particular moment in time."]
pub struct AccountInterest2<'a> {
#[doc = "Specifies the type of interest."]
pub r#type: Option<InterestType1Choice<'a>>,
#[doc = "Set of elements used to qualify the interest rate."]
pub rate: Vec<Rate3<'a>>,
#[doc = "Range of time between a start date and an end date for the calculation of the interest."]
pub from_to_date: Option<DateTimePeriodDetails>,
#[doc = "Specifies the reason for the interest."]
pub reason: Option<Max35Text<'a>>,
}
impl<'a> AccountInterest2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_optional_element("Tp", <InterestType1Choice<'a>>::parse)?;
let rate = reader.parse_list("Rate", <Rate3<'a>>::parse)?;
let from_to_date =
reader.parse_optional_element("FrToDt", <DateTimePeriodDetails>::parse)?;
let reason = reader.parse_optional_element("Rsn", <Max35Text<'a>>::parse)?;
Ok(Self {
r#type,
rate,
from_to_date,
reason,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to qualify the interest rate."]
pub struct Rate3<'a> {
#[doc = "Specifies the type of interest rate."]
pub r#type: RateType4Choice<'a>,
#[doc = "An amount range where the interest rate is applicable."]
pub validity_range: Option<CurrencyAndAmountRange2>,
}
impl<'a> Rate3<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let r#type = reader.parse_element("Tp", <RateType4Choice<'a>>::parse)?;
let validity_range =
reader.parse_optional_element("VldtyRg", <CurrencyAndAmountRange2>::parse)?;
Ok(Self {
r#type,
validity_range,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Range of amount values."]
pub struct CurrencyAndAmountRange2 {
#[doc = "Specified amount or amount range."]
pub amount: ImpliedCurrencyAmountRangeChoice,
#[doc = "Indicates whether the amount is a credited or debited amount."]
pub credit_debit_indicator: Option<CreditDebitCode>,
#[doc = "Medium of exchange of value, used to qualify an amount."]
pub currency: CurrencyCode,
}
impl<'a> CurrencyAndAmountRange2 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let amount = reader.parse_element("Amt", <ImpliedCurrencyAmountRangeChoice>::parse)?;
let credit_debit_indicator =
reader.parse_optional_element("CdtDbtInd", <CreditDebitCode>::parse)?;
let currency = reader.parse_element("Ccy", <CurrencyCode>::parse)?;
Ok(Self {
amount,
credit_debit_indicator,
currency,
})
}
}
pub type CreditDebitCode = AmountDirectionCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies if an operation is an increase or a decrease or the result of a reversal operation."]
pub enum AmountDirectionCode {
#[doc = "Operation is a decrease."]
Debit,
#[doc = "Operation is an increase."]
Credit,
#[doc = "Credit entry used to reverse a previously booked debit entry."]
ReversalDebit,
#[doc = "Debit entry used to reverse a previously booked credit entry."]
ReversalCredit,
}
impl<'a> AmountDirectionCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"DBIT" => Self::Debit,
"CRDT" => Self::Credit,
"RVDB" => Self::ReversalDebit,
"RVCD" => Self::ReversalCredit,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Choice between ranges of values in which an amount is considered valid or a specified amount value which has to be matched or unmatched to be valid."]
pub enum ImpliedCurrencyAmountRangeChoice {
#[doc = "Lower boundary of a range of amount values."]
FromAmount(AmountRangeBoundary1),
#[doc = "Upper boundary of a range of amount values."]
ToAmount(AmountRangeBoundary1),
#[doc = "Range of valid amount values."]
FromToAmount(FromToAmountRange),
#[doc = "Exact value an amount must match to be considered valid."]
EqualAmount(ImpliedCurrencyAndAmount),
#[doc = "Value that an amount must not match to be considered valid."]
NotEqualAmount(ImpliedCurrencyAndAmount),
}
impl<'a> ImpliedCurrencyAmountRangeChoice {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "FrAmt".as_bytes() => {
let inner = reader.parse_element("FrAmt", <AmountRangeBoundary1>::parse)?;
Self::FromAmount(inner)
}
name if name == "ToAmt".as_bytes() => {
let inner = reader.parse_element("ToAmt", <AmountRangeBoundary1>::parse)?;
Self::ToAmount(inner)
}
name if name == "FrToAmt".as_bytes() => {
let inner = reader.parse_element("FrToAmt", <FromToAmountRange>::parse)?;
Self::FromToAmount(inner)
}
name if name == "EQAmt".as_bytes() => {
let inner = reader.parse_element("EQAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::EqualAmount(inner)
}
name if name == "NEQAmt".as_bytes() => {
let inner = reader.parse_element("NEQAmt", <ImpliedCurrencyAndAmount>::parse)?;
Self::NotEqualAmount(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Range of amount values."]
pub struct FromToAmountRange {
#[doc = "Lower boundary of a range of amount values."]
pub from_amount: AmountRangeBoundary1,
#[doc = "Upper boundary of a range of amount values."]
pub to_amount: AmountRangeBoundary1,
}
impl<'a> FromToAmountRange {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_amount = reader.parse_element("FrAmt", <AmountRangeBoundary1>::parse)?;
let to_amount = reader.parse_element("ToAmt", <AmountRangeBoundary1>::parse)?;
Ok(Self {
from_amount,
to_amount,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Limit for an amount range."]
pub struct AmountRangeBoundary1 {
#[doc = "Amount value of the range limit."]
pub boundary_amount: ImpliedCurrencyAndAmount,
#[doc = "Indicates whether the boundary amount is included in the range of amount values."]
pub included: YesNoIndicator,
}
impl<'a> AmountRangeBoundary1 {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let boundary_amount = reader.parse_element("BdryAmt", <ImpliedCurrencyAndAmount>::parse)?;
let included = reader.parse_element("Incl", <YesNoIndicator>::parse)?;
Ok(Self {
boundary_amount,
included,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Number of monetary units specified in a currency where the unit of currency is implied by the context and compliant with ISO 4217. The decimal separator is a dot.\nNote: a zero amount is considered a positive amount."]
pub struct ImpliedCurrencyAndAmount {
amount: Decimal,
}
impl<'a> ImpliedCurrencyAndAmount {
pub(crate) fn parse(reader: &mut XmlReader<'a>, start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let amount = Decimal::from_str(&text).unwrap();
Ok(Self { amount })
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the rate as a percentage or a text."]
pub enum RateType4Choice<'a> {
#[doc = "Ratio of the amount of interest paid during a certain period of time compared to the principal amount of the interest bearing financial instrument."]
Percentage(PercentageRate),
#[doc = "Rate type expressed, in an other form."]
Other(Max35Text<'a>),
}
impl<'a> RateType4Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Pctg".as_bytes() => {
let inner = reader.parse_element("Pctg", <PercentageRate>::parse)?;
Self::Percentage(inner)
}
name if name == "Othr".as_bytes() => {
let inner = reader.parse_element("Othr", <Max35Text<'a>>::parse)?;
Self::Other(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Rate expressed as a percentage, that is, in hundredths, for example, 0.7 is 7/10 of a percent, and 7.0 is 7%."]
pub struct PercentageRate(Decimal);
impl<'a> PercentageRate {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
const BASE: Decimal = Decimal::from_parts(3567587328u32, 232u32, 0u32, false, 10u32);
let text = reader.expect_text()?;
let inner = Decimal::from_str(&text).unwrap() / BASE;
Ok(Self(inner))
}
}
#[derive(Clone, Debug)]
#[doc = "Interest type is expressed as a code or a text."]
pub enum InterestType1Choice<'a> {
#[doc = "Specifies the type of interest."]
Code(InterestType1Code),
#[doc = "Specifies the type of interest in uncoded form."]
Proprietary(Max35Text<'a>),
}
impl<'a> InterestType1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <InterestType1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub type InterestType1Code = InterestCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Indicates which type of interest is applied to a balance left on an account."]
pub enum InterestCode {
#[doc = "During or within a business day."]
IntraDay,
#[doc = "Period of time between the end of a business day and the start of the next business day (usually the day after)."]
OverNight,
}
impl<'a> InterestCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"INDY" => Self::IntraDay,
"OVRN" => Self::OverNight,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify an account."]
pub struct CashAccount16<'a> {
#[doc = "Unique and unambiguous identification for the account between the account owner and the account servicer."]
pub identification: AccountIdentification4Choice<'a>,
#[doc = "Specifies the nature, or use of the account."]
pub r#type: Option<CashAccountType2<'a>>,
#[doc = "Identification of the currency in which the account is held. \n\nUsage: Currency should only be used in case one and the same account number covers several currencies\nand the initiating party needs to identify which currency needs to be used for settlement on the account."]
pub currency: Option<CurrencyCode>,
#[doc = "Name of the account, as assigned by the account servicing institution, in agreement with the account owner in order to provide an additional means of identification of the account.\n\nUsage: The account name is different from the account owner name. The account name is used in certain user communities to provide a means of identifying the account, in addition to the account owner's identity and the account number."]
pub name: Option<Max70Text<'a>>,
}
impl<'a> CashAccount16<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification =
reader.parse_element("Id", <AccountIdentification4Choice<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <CashAccountType2<'a>>::parse)?;
let currency = reader.parse_optional_element("Ccy", <CurrencyCode>::parse)?;
let name = reader.parse_optional_element("Nm", <Max70Text<'a>>::parse)?;
Ok(Self {
identification,
r#type,
currency,
name,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify an account."]
pub struct CashAccount20<'a> {
#[doc = "Unique and unambiguous identification for the account between the account owner and the account servicer."]
pub identification: AccountIdentification4Choice<'a>,
#[doc = "Specifies the nature, or use of the account."]
pub r#type: Option<CashAccountType2<'a>>,
#[doc = "Identification of the currency in which the account is held."]
pub currency: Option<CurrencyCode>,
#[doc = "Name of the account, as assigned by the account servicing institution, in agreement with the account owner in order to provide an additional means of identification of the account.\n\nUsage: The account name is different from the account owner name. The account name is used in certain user communities to provide a means of identifying the account, in addition to the account owner's identity and the account number."]
pub name: Option<Max70Text<'a>>,
#[doc = "Party that legally owns the account."]
pub owner: Option<PartyIdentification32<'a>>,
#[doc = "Party that manages the account on behalf of the account owner, that is manages the registration and booking of entries on the account, calculates balances on the account and provides information about the account."]
pub servicer: Option<BranchAndFinancialInstitutionIdentification4<'a>>,
}
impl<'a> CashAccount20<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification =
reader.parse_element("Id", <AccountIdentification4Choice<'a>>::parse)?;
let r#type = reader.parse_optional_element("Tp", <CashAccountType2<'a>>::parse)?;
let currency = reader.parse_optional_element("Ccy", <CurrencyCode>::parse)?;
let name = reader.parse_optional_element("Nm", <Max70Text<'a>>::parse)?;
let owner = reader.parse_optional_element("Ownr", <PartyIdentification32<'a>>::parse)?;
let servicer = reader.parse_optional_element(
"Svcr",
<BranchAndFinancialInstitutionIdentification4<'a>>::parse,
)?;
Ok(Self {
identification,
r#type,
currency,
name,
owner,
servicer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to uniquely and unambiguously identify a financial institution or a branch of a financial institution."]
pub struct BranchAndFinancialInstitutionIdentification4<'a> {
#[doc = "Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme."]
pub financial_institution_identification: FinancialInstitutionIdentification7<'a>,
#[doc = "Identifies a specific branch of a financial institution.\n\nUsage: This component should be used in case the identification information in the financial institution component does not provide identification up to branch level."]
pub branch_identification: Option<BranchData2<'a>>,
}
impl<'a> BranchAndFinancialInstitutionIdentification4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let financial_institution_identification = reader.parse_element(
"FinInstnId",
<FinancialInstitutionIdentification7<'a>>::parse,
)?;
let branch_identification =
reader.parse_optional_element("BrnchId", <BranchData2<'a>>::parse)?;
Ok(Self {
financial_institution_identification,
branch_identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a specific branch of a financial institution."]
pub struct BranchData2<'a> {
#[doc = "Unique and unambiguous identification of a branch of a financial institution."]
pub identification: Option<Max35Text<'a>>,
#[doc = "Name by which an agent is known and which is usually used to identify that agent."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress6<'a>>,
}
impl<'a> BranchData2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_optional_element("Id", <Max35Text<'a>>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress6<'a>>::parse)?;
Ok(Self {
identification,
name,
postal_address,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a financial institution."]
pub struct FinancialInstitutionIdentification7<'a> {
#[doc = "Code allocated to a financial institution by the ISO 9362 Registration Authority as described in ISO 9362 \"Banking - Banking telecommunication messages - Business identifier code (BIC)\"."]
pub bic: Option<BicIdentifier<'a>>,
#[doc = "Information used to identify a member within a clearing system."]
pub clearing_system_member_identification: Option<ClearingSystemMemberIdentification2<'a>>,
#[doc = "Name by which an agent is known and which is usually used to identify that agent."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress6<'a>>,
#[doc = "Unique identification of an agent, as assigned by an institution, using an identification scheme."]
pub other: Option<GenericFinancialIdentification1<'a>>,
}
impl<'a> FinancialInstitutionIdentification7<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let bic = reader.parse_optional_element("BIC", <BicIdentifier<'a>>::parse)?;
let clearing_system_member_identification = reader.parse_optional_element(
"ClrSysMmbId",
<ClearingSystemMemberIdentification2<'a>>::parse,
)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress6<'a>>::parse)?;
let other =
reader.parse_optional_element("Othr", <GenericFinancialIdentification1<'a>>::parse)?;
Ok(Self {
bic,
clearing_system_member_identification,
name,
postal_address,
other,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification of a financial institution."]
pub struct GenericFinancialIdentification1<'a> {
#[doc = "Unique and unambiguous identification of a person."]
pub identification: Max35Text<'a>,
#[doc = "Name of the identification scheme."]
pub scheme_name: Option<FinancialIdentificationSchemeName1Choice<'a>>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericFinancialIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let scheme_name = reader.parse_optional_element(
"SchmeNm",
<FinancialIdentificationSchemeName1Choice<'a>>::parse,
)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
scheme_name,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Sets of elements to identify a name of the organisation identification scheme."]
pub enum FinancialIdentificationSchemeName1Choice<'a> {
#[doc = "Name of the identification scheme, in a coded form as published in an external list."]
Code(ExternalFinancialInstitutionIdentification1Code),
#[doc = "Name of the identification scheme, in a free text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> FinancialIdentificationSchemeName1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element(
"Cd",
<ExternalFinancialInstitutionIdentification1Code>::parse,
)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Unique identification, as assigned by a clearing system, to unambiguously identify a member of the clearing system."]
pub struct ClearingSystemMemberIdentification2<'a> {
#[doc = "Specification of a pre-agreed offering between clearing agents or the channel through which the payment instruction is processed."]
pub clearing_system_identification: Option<ClearingSystemIdentification2Choice<'a>>,
#[doc = "Identification of a member of a clearing system."]
pub member_identification: Max35Text<'a>,
}
impl<'a> ClearingSystemMemberIdentification2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let clearing_system_identification = reader
.parse_optional_element("ClrSysId", <ClearingSystemIdentification2Choice<'a>>::parse)?;
let member_identification = reader.parse_element("MmbId", <Max35Text<'a>>::parse)?;
Ok(Self {
clearing_system_identification,
member_identification,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Choice of a clearing system identifier."]
pub enum ClearingSystemIdentification2Choice<'a> {
#[doc = "Identification of a clearing system, in a coded form as published in an external list."]
Code(ExternalClearingSystemIdentification1Code),
#[doc = "Identification code for a clearing system, that has not yet been identified in the list of clearing systems."]
Proprietary(Max35Text<'a>),
}
impl<'a> ClearingSystemIdentification2Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader
.parse_element("Cd", <ExternalClearingSystemIdentification1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalClearingSystemIdentification1Code;
#[derive(Clone, Debug)]
#[doc = "Nature or use of the account."]
pub struct CashAccountType2<'a> {
#[doc = "Account type, in a coded form."]
pub code: CashAccountType4Code,
#[doc = "Nature or use of the account in a proprietary form."]
pub proprietary: Max35Text<'a>,
}
impl<'a> CashAccountType2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let code = reader.parse_element("Cd", <CashAccountType4Code>::parse)?;
let proprietary = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Ok(Self { code, proprietary })
}
}
pub type CashAccountType4Code = CashAccountTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the nature, or use, of the cash account."]
pub enum CashAccountTypeCode {
#[doc = "Account used for the payment of cash."]
CashPayment,
#[doc = "Account used for charges if different from the account for payment."]
Charges,
#[doc = "Account used for commission if different from the account for payment."]
Commission,
#[doc = "Account used for taxes if different from the account for payment."]
Tax,
#[doc = "Account used for payment of income if different from the current cash account."]
CashIncome,
#[doc = "Account used for trading if different from the current cash account."]
CashTrading,
#[doc = "Account used to post debit and credit entries, as a result of transactions cleared and settled through a specific clearing and settlement system."]
Settlement,
#[doc = "Account used to post debits and credits when no specific account has been nominated."]
Current,
#[doc = "Account used for savings."]
Savings,
#[doc = "Account used for overnight deposits."]
OverNightDeposit,
#[doc = "Account used for a marginal lending facility."]
MarginalLending,
#[doc = "Account used for non-resident external."]
NonResidentExternal,
#[doc = "Account used for money markets if different from the cash account."]
MoneyMarket,
#[doc = "Account used for loans."]
Loan,
#[doc = "Accounts used for salary payments."]
Salary,
#[doc = "Account is used for overdrafts."]
Overdraft,
#[doc = "Account is for the coverage of lending."]
Lending,
#[doc = "Account is for collateral."]
Collateral,
#[doc = "Account is for financial settlements."]
FinancialSettlement,
#[doc = "Account is for margin returns."]
MarginReturn,
#[doc = "Account is an segregated account."]
Segregated,
}
impl<'a> CashAccountTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"CASH" => Self::CashPayment,
"CHAR" => Self::Charges,
"COMM" => Self::Commission,
"TAXE" => Self::Tax,
"CISH" => Self::CashIncome,
"TRAS" => Self::CashTrading,
"SACC" => Self::Settlement,
"CACC" => Self::Current,
"SVGS" => Self::Savings,
"ONDP" => Self::OverNightDeposit,
"MGLD" => Self::MarginalLending,
"NREX" => Self::NonResidentExternal,
"MOMA" => Self::MoneyMarket,
"LOAN" => Self::Loan,
"SLRY" => Self::Salary,
"ODFT" => Self::Overdraft,
"LEND" => Self::Lending,
"COLL" => Self::Collateral,
"SETT" => Self::FinancialSettlement,
"MARR" => Self::MarginReturn,
"SEGT" => Self::Segregated,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the unique identification of an account as assigned by the account servicer."]
pub enum AccountIdentification4Choice<'a> {
#[doc = "International Bank Account Number (IBAN) - identifier used internationally by financial institutions to uniquely identify the account of a customer. Further specifications of the format and content of the IBAN can be found in the standard ISO 13616 \"Banking and related financial services - International Bank Account Number (IBAN)\" version 1997-10-01, or later revisions."]
Iban(IbanIdentifier),
#[doc = "Unique identification of an account, as assigned by the account servicer, using an identification scheme."]
Other(GenericAccountIdentification1<'a>),
}
impl<'a> AccountIdentification4Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "IBAN".as_bytes() => {
let inner = reader.parse_element("IBAN", <IbanIdentifier>::parse)?;
Self::Iban(inner)
}
name if name == "Othr".as_bytes() => {
let inner =
reader.parse_element("Othr", <GenericAccountIdentification1<'a>>::parse)?;
Self::Other(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to a generic account identification."]
pub struct GenericAccountIdentification1<'a> {
#[doc = "Identification assigned by an institution."]
pub identification: Max34Text<'a>,
#[doc = "Name of the identification scheme."]
pub scheme_name: Option<AccountSchemeName1Choice<'a>>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericAccountIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max34Text<'a>>::parse)?;
let scheme_name =
reader.parse_optional_element("SchmeNm", <AccountSchemeName1Choice<'a>>::parse)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
scheme_name,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Sets of elements to identify a name of the identification scheme."]
pub enum AccountSchemeName1Choice<'a> {
#[doc = "Name of the identification scheme, in a coded form as published in an external list."]
Code(ExternalAccountIdentification1Code),
#[doc = "Name of the identification scheme, in a free text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> AccountSchemeName1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner =
reader.parse_element("Cd", <ExternalAccountIdentification1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalAccountIdentification1Code;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 34 characters."]
pub struct Max34Text<'a>(Cow<'a, str>);
impl<'a> Max34Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=34usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Specifies the source used to generate the reporting."]
pub enum ReportingSource1Choice<'a> {
#[doc = "Reporting source, as published in an external reporting source code list."]
Code(ExternalReportingSource1Code),
#[doc = "Reporting source, in a proprietary form."]
Proprietary(Max35Text<'a>),
}
impl<'a> ReportingSource1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner = reader.parse_element("Cd", <ExternalReportingSource1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalReportingSource1Code;
pub type CopyDuplicate1Code = CopyDuplicateCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies if this document is a copy, a duplicate, or a duplicate of a copy."]
pub enum CopyDuplicateCode {
#[doc = "Message is being sent as a copy to a party other than the account owner, for information purposes and the message is a duplicate of a message previously sent."]
CopyDuplicate,
#[doc = "Message is being sent as a copy to a party other than the account owner, for information purposes."]
Copy,
#[doc = "Message is for information/confirmation purposes. It is a duplicate of a message previously sent."]
Duplicate,
}
impl<'a> CopyDuplicateCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"CODU" => Self::CopyDuplicate,
"COPY" => Self::Copy,
"DUPL" => Self::Duplicate,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Time span defined by a start date and time, and an end date and time."]
pub struct DateTimePeriodDetails {
#[doc = "Date and time at which the range starts."]
pub from_date_time: IsoDateTime,
#[doc = "Date and time at which the range ends."]
pub to_date_time: IsoDateTime,
}
impl<'a> DateTimePeriodDetails {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let from_date_time = reader.parse_element("FrDtTm", <IsoDateTime>::parse)?;
let to_date_time = reader.parse_element("ToDtTm", <IsoDateTime>::parse)?;
Ok(Self {
from_date_time,
to_date_time,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Number of objects represented as an integer."]
pub struct Number(Decimal);
impl<'a> Number {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let inner = Decimal::from_str(&text).unwrap();
Ok(Self(inner))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to provide further details of the message."]
pub struct GroupHeader42<'a> {
#[doc = "Point to point reference, as assigned by the account servicing institution, and sent to the account owner or the party authorised to receive the message, to unambiguously identify the message.\nUsage: The account servicing institution has to make sure that MessageIdentification is unique per account owner for a pre-agreed period."]
pub message_identification: Max35Text<'a>,
#[doc = "Date and time at which the message was created."]
pub creation_date_time: IsoDateTime,
#[doc = "Party authorised by the account owner to receive information about movements on the account.\nUsage: MessageRecipient should only be identified when different from the account owner."]
pub message_recipient: Option<PartyIdentification32<'a>>,
#[doc = "Set of elements used to provide details on the page number of the message.\n\nUsage: The pagination of the message is only allowed when agreed between the parties."]
pub message_pagination: Option<Pagination<'a>>,
#[doc = "Further details of the message."]
pub additional_information: Option<Max500Text<'a>>,
}
impl<'a> GroupHeader42<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let message_identification = reader.parse_element("MsgId", <Max35Text<'a>>::parse)?;
let creation_date_time = reader.parse_element("CreDtTm", <IsoDateTime>::parse)?;
let message_recipient =
reader.parse_optional_element("MsgRcpt", <PartyIdentification32<'a>>::parse)?;
let message_pagination =
reader.parse_optional_element("MsgPgntn", <Pagination<'a>>::parse)?;
let additional_information =
reader.parse_optional_element("AddtlInf", <Max500Text<'a>>::parse)?;
Ok(Self {
message_identification,
creation_date_time,
message_recipient,
message_pagination,
additional_information,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 500 characters."]
pub struct Max500Text<'a>(Cow<'a, str>);
impl<'a> Max500Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=500usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Number used to sequence pages when it is not possible for data to be conveyed in a single message and the data has to be split across several pages (messages)."]
pub struct Pagination<'a> {
#[doc = "Page number."]
pub page_number: Max5NumericText<'a>,
#[doc = "Indicates the last page."]
pub last_page_indicator: YesNoIndicator,
}
impl<'a> Pagination<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let page_number = reader.parse_element("PgNb", <Max5NumericText<'a>>::parse)?;
let last_page_indicator = reader.parse_element("LastPgInd", <YesNoIndicator>::parse)?;
Ok(Self {
page_number,
last_page_indicator,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Indicates a \"Yes\" or \"No\" type of answer for an element."]
pub enum YesNoIndicator {
No,
Yes,
}
impl<'a> YesNoIndicator {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = if reader.expect_boolean()? {
Self::Yes
} else {
Self::No
};
Ok(value)
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a numeric string with a maximum length of 5 digits."]
pub struct Max5NumericText<'a>(Cow<'a, str>);
impl<'a> Max5NumericText<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
#[derive(Clone, Debug)]
#[doc = "Set of elements used to identify a person or an organisation."]
pub struct PartyIdentification32<'a> {
#[doc = "Name by which a party is known and which is usually used to identify that party."]
pub name: Option<Max140Text<'a>>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub postal_address: Option<PostalAddress6<'a>>,
#[doc = "Unique and unambiguous identification of a party."]
pub identification: Option<Party6Choice<'a>>,
#[doc = "Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed."]
pub country_of_residence: Option<CountryCode>,
#[doc = "Set of elements used to indicate how to contact the party."]
pub contact_details: Option<ContactDetails2<'a>>,
}
impl<'a> PartyIdentification32<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let postal_address =
reader.parse_optional_element("PstlAdr", <PostalAddress6<'a>>::parse)?;
let identification = reader.parse_optional_element("Id", <Party6Choice<'a>>::parse)?;
let country_of_residence =
reader.parse_optional_element("CtryOfRes", <CountryCode>::parse)?;
let contact_details =
reader.parse_optional_element("CtctDtls", <ContactDetails2<'a>>::parse)?;
Ok(Self {
name,
postal_address,
identification,
country_of_residence,
contact_details,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Communication device number or electronic address used for communication."]
pub struct ContactDetails2<'a> {
#[doc = "Specifies the terms used to formally address a person."]
pub name_prefix: Option<NamePrefix1Code>,
#[doc = "Name by which a party is known and which is usually used to identify that party."]
pub name: Option<Max140Text<'a>>,
#[doc = "Collection of information that identifies a phone number, as defined by telecom services."]
pub phone_number: Option<PhoneNumber<'a>>,
#[doc = "Collection of information that identifies a mobile phone number, as defined by telecom services."]
pub mobile_number: Option<PhoneNumber<'a>>,
#[doc = "Collection of information that identifies a FAX number, as defined by telecom services."]
pub fax_number: Option<PhoneNumber<'a>>,
#[doc = "Address for electronic mail (e-mail)."]
pub email_address: Option<Max2048Text<'a>>,
#[doc = "Contact details in another form."]
pub other: Option<Max35Text<'a>>,
}
impl<'a> ContactDetails2<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let name_prefix = reader.parse_optional_element("NmPrfx", <NamePrefix1Code>::parse)?;
let name = reader.parse_optional_element("Nm", <Max140Text<'a>>::parse)?;
let phone_number = reader.parse_optional_element("PhneNb", <PhoneNumber<'a>>::parse)?;
let mobile_number = reader.parse_optional_element("MobNb", <PhoneNumber<'a>>::parse)?;
let fax_number = reader.parse_optional_element("FaxNb", <PhoneNumber<'a>>::parse)?;
let email_address = reader.parse_optional_element("EmailAdr", <Max2048Text<'a>>::parse)?;
let other = reader.parse_optional_element("Othr", <Max35Text<'a>>::parse)?;
Ok(Self {
name_prefix,
name,
phone_number,
mobile_number,
fax_number,
email_address,
other,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 2048 characters."]
pub struct Max2048Text<'a>(Cow<'a, str>);
impl<'a> Max2048Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=2048usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "The collection of information which identifies a specific phone or FAX number as defined by telecom services.\nIt consists of a \"+\" followed by the country code (from 1 to 3 characters) then a \"-\" and finally, any combination of numbers, \"(\", \")\", \"+\" and \"-\" (up to 30 characters)."]
pub struct PhoneNumber<'a>(Cow<'a, str>);
impl<'a> PhoneNumber<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
Ok(Self(text))
}
}
pub type NamePrefix1Code = NamePrefixCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the terms used to formally address a person."]
pub enum NamePrefixCode {
#[doc = "Title of the person is Doctor or Dr."]
Doctor,
#[doc = "Title of the person is Mister or Mr."]
Mister,
#[doc = "Title of the person is Miss."]
Miss,
#[doc = "Title of the person is Madam."]
Madam,
#[doc = "Title of the person is gender neutral (Mx)."]
GenderNeutral,
}
impl<'a> NamePrefixCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"DOCT" => Self::Doctor,
"MIST" => Self::Mister,
"MISS" => Self::Miss,
"MADM" => Self::Madam,
"MIKS" => Self::GenderNeutral,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Nature or use of the account."]
pub enum Party6Choice<'a> {
#[doc = "Unique and unambiguous way to identify an organisation."]
OrganisationIdentification(OrganisationIdentification4<'a>),
#[doc = "Unique and unambiguous identification of a person, for example a passport."]
PrivateIdentification(PersonIdentification5<'a>),
}
impl<'a> Party6Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "OrgId".as_bytes() => {
let inner =
reader.parse_element("OrgId", <OrganisationIdentification4<'a>>::parse)?;
Self::OrganisationIdentification(inner)
}
name if name == "PrvtId".as_bytes() => {
let inner = reader.parse_element("PrvtId", <PersonIdentification5<'a>>::parse)?;
Self::PrivateIdentification(inner)
}
_ => todo!(),
};
Ok(value)
}
}
#[derive(Clone, Debug)]
#[doc = "Unique and unambiguous way to identify a person."]
pub struct PersonIdentification5<'a> {
#[doc = "Date and place of birth of a person."]
pub date_and_place_of_birth: Option<DateAndPlaceOfBirth<'a>>,
#[doc = "Unique identification of a person, as assigned by an institution, using an identification scheme."]
pub other: Vec<GenericPersonIdentification1<'a>>,
}
impl<'a> PersonIdentification5<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let date_and_place_of_birth =
reader.parse_optional_element("DtAndPlcOfBirth", <DateAndPlaceOfBirth<'a>>::parse)?;
let other = reader.parse_list("Othr", <GenericPersonIdentification1<'a>>::parse)?;
Ok(Self {
date_and_place_of_birth,
other,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification of a person."]
pub struct GenericPersonIdentification1<'a> {
#[doc = "Unique and unambiguous identification of a person."]
pub identification: Max35Text<'a>,
#[doc = "Name of the identification scheme."]
pub scheme_name: Option<PersonIdentificationSchemeName1Choice<'a>>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericPersonIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let scheme_name = reader.parse_optional_element(
"SchmeNm",
<PersonIdentificationSchemeName1Choice<'a>>::parse,
)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
scheme_name,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Sets of elements to identify a name of the identification scheme."]
pub enum PersonIdentificationSchemeName1Choice<'a> {
#[doc = "Name of the identification scheme, in a coded form as published in an external list."]
Code(ExternalPersonIdentification1Code),
#[doc = "Name of the identification scheme, in a free text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> PersonIdentificationSchemeName1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner =
reader.parse_element("Cd", <ExternalPersonIdentification1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalPersonIdentification1Code;
#[derive(Clone, Debug)]
#[doc = "Date and place of birth of a person."]
pub struct DateAndPlaceOfBirth<'a> {
#[doc = "Date on which a person is born."]
pub birth_date: IsoDate,
#[doc = "Province where a person was born."]
pub province_of_birth: Option<Max35Text<'a>>,
#[doc = "City where a person was born."]
pub city_of_birth: Max35Text<'a>,
#[doc = "Country where a person was born."]
pub country_of_birth: CountryCode,
}
impl<'a> DateAndPlaceOfBirth<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let birth_date = reader.parse_element("BirthDt", <IsoDate>::parse)?;
let province_of_birth =
reader.parse_optional_element("PrvcOfBirth", <Max35Text<'a>>::parse)?;
let city_of_birth = reader.parse_element("CityOfBirth", <Max35Text<'a>>::parse)?;
let country_of_birth = reader.parse_element("CtryOfBirth", <CountryCode>::parse)?;
Ok(Self {
birth_date,
province_of_birth,
city_of_birth,
country_of_birth,
})
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "A particular point in the progression of time in a calendar year expressed in the YYYY-MM-DD format. This representation is defined in \"XML Schema Part 2: Datatypes Second Edition - W3C Recommendation 28 October 2004\" which is aligned with ISO 8601."]
pub struct IsoDate(Date);
impl<'a> IsoDate {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let inner = Date::parse(
&text,
&time::format_description::well_known::Iso8601::PARSING,
)
.unwrap();
Ok(Self(inner))
}
}
#[derive(Clone, Debug)]
#[doc = "Unique and unambiguous way to identify an organisation."]
pub struct OrganisationIdentification4<'a> {
#[doc = "Code allocated to a financial institution or non financial institution by the ISO 9362 Registration Authority as described in ISO 9362 \"Banking - Banking telecommunication messages - Business identifier code (BIC)\"."]
pub bic_or_bei: Option<BicIdentifier<'a>>,
#[doc = "Unique identification of an organisation, as assigned by an institution, using an identification scheme."]
pub other: Vec<GenericOrganisationIdentification1<'a>>,
}
impl<'a> OrganisationIdentification4<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let bic_or_bei = reader.parse_optional_element("BICOrBEI", <BicIdentifier<'a>>::parse)?;
let other = reader.parse_list("Othr", <GenericOrganisationIdentification1<'a>>::parse)?;
Ok(Self { bic_or_bei, other })
}
}
#[derive(Clone, Debug)]
#[doc = "Information related to an identification of an organisation."]
pub struct GenericOrganisationIdentification1<'a> {
#[doc = "Identification assigned by an institution."]
pub identification: Max35Text<'a>,
#[doc = "Name of the identification scheme."]
pub scheme_name: Option<OrganisationIdentificationSchemeName1Choice<'a>>,
#[doc = "Entity that assigns the identification."]
pub issuer: Option<Max35Text<'a>>,
}
impl<'a> GenericOrganisationIdentification1<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let identification = reader.parse_element("Id", <Max35Text<'a>>::parse)?;
let scheme_name = reader.parse_optional_element(
"SchmeNm",
<OrganisationIdentificationSchemeName1Choice<'a>>::parse,
)?;
let issuer = reader.parse_optional_element("Issr", <Max35Text<'a>>::parse)?;
Ok(Self {
identification,
scheme_name,
issuer,
})
}
}
#[derive(Clone, Debug)]
#[doc = "Sets of elements to identify a name of the organisation identification scheme."]
pub enum OrganisationIdentificationSchemeName1Choice<'a> {
#[doc = "Name of the identification scheme, in a coded form as published in an external list."]
Code(ExternalOrganisationIdentification1Code),
#[doc = "Name of the identification scheme, in a free text form."]
Proprietary(Max35Text<'a>),
}
impl<'a> OrganisationIdentificationSchemeName1Choice<'a> {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'a>) -> XmlResult<Self> {
let value = match reader.peek_start_name()?.into_inner() {
name if name == "Cd".as_bytes() => {
let inner =
reader.parse_element("Cd", <ExternalOrganisationIdentification1Code>::parse)?;
Self::Code(inner)
}
name if name == "Prtry".as_bytes() => {
let inner = reader.parse_element("Prtry", <Max35Text<'a>>::parse)?;
Self::Proprietary(inner)
}
_ => todo!(),
};
Ok(value)
}
}
pub use self::external_code_sets::ExternalOrganisationIdentification1Code;
#[derive(Clone, Debug)]
#[doc = "Information that locates and identifies a specific address, as defined by postal services."]
pub struct PostalAddress6<'a> {
#[doc = "Identifies the nature of the postal address."]
pub address_type: Option<AddressType2Code>,
#[doc = "Identification of a division of a large organisation or building."]
pub department: Option<Max70Text<'a>>,
#[doc = "Identification of a sub-division of a large organisation or building."]
pub sub_department: Option<Max70Text<'a>>,
#[doc = "Name of a street or thoroughfare."]
pub street_name: Option<Max70Text<'a>>,
#[doc = "Number that identifies the position of a building on a street."]
pub building_number: Option<Max16Text<'a>>,
#[doc = "Identifier consisting of a group of letters and/or numbers that is added to a postal address to assist the sorting of mail."]
pub post_code: Option<Max16Text<'a>>,
#[doc = "Name of a built-up area, with defined boundaries, and a local government."]
pub town_name: Option<Max35Text<'a>>,
#[doc = "Identifies a subdivision of a country such as state, region, county."]
pub country_sub_division: Option<Max35Text<'a>>,
#[doc = "Nation with its own government."]
pub country: Option<CountryCode>,
#[doc = "Information that locates and identifies a specific address, as defined by postal services, presented in free format text."]
pub address_line: Vec<Max70Text<'a>>,
}
impl<'a> PostalAddress6<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let address_type = reader.parse_optional_element("AdrTp", <AddressType2Code>::parse)?;
let department = reader.parse_optional_element("Dept", <Max70Text<'a>>::parse)?;
let sub_department = reader.parse_optional_element("SubDept", <Max70Text<'a>>::parse)?;
let street_name = reader.parse_optional_element("StrtNm", <Max70Text<'a>>::parse)?;
let building_number = reader.parse_optional_element("BldgNb", <Max16Text<'a>>::parse)?;
let post_code = reader.parse_optional_element("PstCd", <Max16Text<'a>>::parse)?;
let town_name = reader.parse_optional_element("TwnNm", <Max35Text<'a>>::parse)?;
let country_sub_division =
reader.parse_optional_element("CtrySubDvsn", <Max35Text<'a>>::parse)?;
let country = reader.parse_optional_element("Ctry", <CountryCode>::parse)?;
let address_line = reader.parse_list("AdrLine", <Max70Text<'a>>::parse)?;
Ok(Self {
address_type,
department,
sub_department,
street_name,
building_number,
post_code,
town_name,
country_sub_division,
country,
address_line,
})
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 16 characters."]
pub struct Max16Text<'a>(Cow<'a, str>);
impl<'a> Max16Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=16usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 70characters."]
pub struct Max70Text<'a>(Cow<'a, str>);
impl<'a> Max70Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=70usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
pub type AddressType2Code = AddressTypeCode;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc = "Specifies the type of address."]
pub enum AddressTypeCode {
#[doc = "Address is the home address."]
Residential,
#[doc = "Address is the business address."]
Business,
#[doc = "Address is the complete postal address."]
Postal,
#[doc = "Address is a postal office (PO) box."]
PoBox,
#[doc = "Address is the address to which mail is sent."]
MailTo,
#[doc = "Address is the address to which delivery is to take place."]
DeliveryTo,
}
impl<'a> AddressTypeCode {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let value = match &*reader.expect_text()? {
"HOME" => Self::Residential,
"BIZZ" => Self::Business,
"ADDR" => Self::Postal,
"PBOX" => Self::PoBox,
"MLTO" => Self::MailTo,
"DLVY" => Self::DeliveryTo,
tag => todo!("handle code {tag:?}"),
};
Ok(value)
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 140 characters."]
pub struct Max140Text<'a>(Cow<'a, str>);
impl<'a> Max140Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=140usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "A particular point in the progression of time defined by a mandatory date and a mandatory time component, expressed in either UTC time format (YYYY-MM-DDThh:mm:ss.sssZ), local time with UTC offset format (YYYY-MM-DDThh:mm:ss.sss+/-hh:mm), or local time format (YYYY-MM-DDThh:mm:ss.sss). These representations are defined in \"XML Schema Part 2: Datatypes Second Edition - W3C Recommendation 28 October 2004\" which is aligned with ISO 8601.\nNote on the time format:\n1) beginning / end of calendar day\n00:00:00 = the beginning of a calendar day\n24:00:00 = the end of a calendar day\n2) fractions of second in time format\nDecimal fractions of seconds may be included. In this case, the involved parties shall agree on the maximum number of digits that are allowed."]
pub struct IsoDateTime(OffsetDateTime);
impl<'a> IsoDateTime {
pub(crate) fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
let inner = OffsetDateTime::parse(
&text,
&time::format_description::well_known::Iso8601::PARSING,
)
.unwrap();
Ok(Self(inner))
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Specifies a character string with a maximum length of 35 characters."]
pub struct Max35Text<'a>(Cow<'a, str>);
impl<'a> Max35Text<'a> {
fn parse(reader: &mut XmlReader<'a>, _start: &BytesStart<'_>) -> XmlResult<Self> {
let text = reader.expect_text()?;
if !(1usize..=35usize).contains(&text.len()) {
todo!()
}
Ok(Self(text))
}
}