Ejemplo n.º 1
0
        public static pain00100103_ct_data Create(libfintx.pain_001_001_03.Document xml)
        {
            var result = new pain00100103_ct_data();

            result.Initiator            = xml.CstmrCdtTrfInitn?.GrpHdr?.InitgPty?.Nm;
            result.NumberOfTransactions = Convert.ToInt32(xml.CstmrCdtTrfInitn?.GrpHdr?.NbOfTxs);
            result.ControlSum           = xml.CstmrCdtTrfInitn?.GrpHdr?.CtrlSum;

            foreach (var pmtInf in xml.CstmrCdtTrfInitn.PmtInf)
            {
                if (result.Payments == null)
                {
                    result.Payments = new List <PaymentInfo>();
                }

                var paymentInfo = new PaymentInfo();
                paymentInfo.RequestedExecutionDate = pmtInf.ReqdExctnDt;
                paymentInfo.Debtor        = pmtInf.Dbtr?.Nm;
                paymentInfo.DebtorAccount = pmtInf.DbtrAcct?.Id?.Item?.ToString();
                paymentInfo.DebtorAgent   = pmtInf.DbtrAgt?.FinInstnId?.BIC;
                result.Payments.Add(paymentInfo);

                foreach (var cdtTrfTxInf in pmtInf.CdtTrfTxInf)
                {
                    if (paymentInfo.CreditTxInfos == null)
                    {
                        paymentInfo.CreditTxInfos = new List <CreditTransferTransactionInfo>();
                    }

                    var creditTxInfo = new CreditTransferTransactionInfo();
                    creditTxInfo.Amount          = ((libfintx.pain_001_001_03.ActiveOrHistoricCurrencyAndAmount)cdtTrfTxInf.Amt?.Item).Value;
                    creditTxInfo.Creditor        = cdtTrfTxInf.Cdtr?.Nm;
                    creditTxInfo.CreditorAccount = cdtTrfTxInf.CdtrAcct?.Id?.Item?.ToString();
                    creditTxInfo.CreditorAgent   = cdtTrfTxInf.CdtrAgt?.FinInstnId?.BIC;
                    if (cdtTrfTxInf.RmtInf?.Ustrd != null)
                    {
                        creditTxInfo.RemittanceInformation = string.Join(", ", cdtTrfTxInf.RmtInf?.Ustrd);
                    }
                    paymentInfo.CreditTxInfos.Add(creditTxInfo);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void Test_BankersOrders_1()
        {
            libfintx.pain_001_001_03.Document xml;
            XmlSerializer ser = new XmlSerializer(typeof(libfintx.pain_001_001_03.Document), new XmlRootAttribute
            {
                ElementName = "Document",
                Namespace   = "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03",
            });

            using (var fileStream = new FileStream("Resources/get-bankers-orders-1.xml", FileMode.Open))
            {
                xml = (libfintx.pain_001_001_03.Document)ser.Deserialize(fileStream);
            }

            libfintx.pain00100103_ct_data data = libfintx.pain00100103_ct_data.Create(xml);

            Assert.AreEqual(1, data.NumberOfTransactions);
            Assert.AreEqual(100.00m, data.ControlSum);
        }