/// <summary>
        /// Adds a new transaction to the document
        /// </summary>
        /// <param name="receiver">Object with all the required information about the receiver of the new transaction</param>
        /// <param name="transaction">Object with all the required information about the transaction itself</param>
        public void AddTransaction(Receiver receiver, Transaction transaction)
        {
            CreditTransferTransactionInformation10CH cdtTrfTxInf = new CreditTransferTransactionInformation10CH(); // Index 2.27

            PaymentIdentification1 pmtId = new PaymentIdentification1();                                           // Index 2.28

            cdtTrfTxInf.PmtId = pmtId;
            pmtId.InstrId     = "1-" + pmtInf1.CdtTrfTxInf.Length;                  // Index 2.29
            pmtId.EndToEndId  = transaction.ReferenceIdentification;                // Index 2.30

            PaymentTypeInformation19CH pmtTpInf = new PaymentTypeInformation19CH(); // Index 2.31

            cdtTrfTxInf.PmtTpInf = pmtTpInf;

            AmountType3Choice amt = new AmountType3Choice(); // Index 2.42

            cdtTrfTxInf.Amt = amt;

            ActiveOrHistoricCurrencyAndAmount currencyAndAmount = new ActiveOrHistoricCurrencyAndAmount(); // Index 2.43

            amt.Item = currencyAndAmount;
            currencyAndAmount.Ccy   = transaction.CurrencyCode;
            currencyAndAmount.Value = transaction.Amount;

            BranchAndFinancialInstitutionIdentification4CH cdtrAgt = new BranchAndFinancialInstitutionIdentification4CH(); // Index 2.77

            cdtTrfTxInf.CdtrAgt = cdtrAgt;

            FinancialInstitutionIdentification7CH finInstnIdCdtr = new FinancialInstitutionIdentification7CH(); // Index 2.77 / Financial Institution Identification

            cdtrAgt.FinInstnId = finInstnIdCdtr;

            PartyIdentification32CH_Name cdtr = new PartyIdentification32CH_Name(); // Index 2.79

            cdtTrfTxInf.Cdtr = cdtr;

            cdtr.Nm = receiver.Name;                           // Index 2.79 / Name
            PostalAddress6CH pstlAdr = new PostalAddress6CH(); // Index 2.79 / Postal Address

            cdtr.PstlAdr = pstlAdr;


            pstlAdr.StrtNm = receiver.StreetName; // Index 2.79 / Street Name

            if (!string.IsNullOrWhiteSpace(receiver.StreetNumber))
            {
                pstlAdr.StrtNm = receiver.StreetName + " " + receiver.StreetNumber; // Index 2.79 / Building Number
            }

            pstlAdr.PstCd = receiver.Zip;                           // Index 2.79 / Post Code
            pstlAdr.TwnNm = receiver.City;                          // Index 2.79 / Town Name
            pstlAdr.Ctry  = receiver.CountryCode;                   // Index 2.79 / Country

            CashAccount16CH_Id cdtrAcct = new CashAccount16CH_Id(); // Index 2.80

            cdtTrfTxInf.CdtrAcct = cdtrAcct;

            cdtrAcct.Id      = new AccountIdentification4ChoiceCH(); // Index 2.80 / Identification
            cdtrAcct.Id.Item = transaction.ReceiverIban;             // Index 2.80 / Id / IBAN  Ziel-Konto

            AddNewCreditTransferTransactionInformation(pmtInf1.CdtTrfTxInf, cdtTrfTxInf);
            UpdateLevelA();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new transaction to the document
        /// </summary>
        /// <param name="receiver">Object with all the required information about the receiver of the new transaction</param>
        /// <param name="transaction">Object with all the required information about the transaction itself</param>
        public void AddTransaction(PaymentInstructionInformation3CH pmtInf, Receiver receiver, TransactionBase transaction)
        {
            CreditTransferTransactionInformation10CH cdtTrfTxInf = new CreditTransferTransactionInformation10CH(); // Index 2.27

            PaymentIdentification1 pmtId = new PaymentIdentification1();                                           // Index 2.28

            cdtTrfTxInf.PmtId = pmtId;
            pmtId.InstrId     = "1-" + pmtInf.CdtTrfTxInf.Length;    // Index 2.29
            pmtId.EndToEndId  = transaction.ReferenceIdentification; // Index 2.30

            AmountType3Choice amt = new AmountType3Choice();         // Index 2.42

            cdtTrfTxInf.Amt = amt;

            ActiveOrHistoricCurrencyAndAmount currencyAndAmount = new ActiveOrHistoricCurrencyAndAmount(); // Index 2.43

            amt.Item = currencyAndAmount;
            currencyAndAmount.Ccy   = transaction.CurrencyCode;
            currencyAndAmount.Value = transaction.Amount;

            PartyIdentification32CH_Name cdtr = new PartyIdentification32CH_Name(); // Index 2.79

            cdtTrfTxInf.Cdtr = cdtr;

            cdtr.Nm = receiver.Name;                           // Index 2.79 / Name
            PostalAddress6CH pstlAdr = new PostalAddress6CH(); // Index 2.79 / Postal Address

            cdtr.PstlAdr = pstlAdr;


            pstlAdr.StrtNm = receiver.StreetName; // Index 2.79 / Street Name

            if (!string.IsNullOrWhiteSpace(receiver.StreetNumber))
            {
                pstlAdr.StrtNm = receiver.StreetName + " " + receiver.StreetNumber; // Index 2.79 / Building Number
            }

            pstlAdr.PstCd = receiver.Zip;                                // Index 2.79 / Post Code
            pstlAdr.TwnNm = receiver.City;                               // Index 2.79 / Town Name
            pstlAdr.Ctry  = receiver.CountryCode;                        // Index 2.79 / Country

            CashAccount16CH_Id cdtrAcct = new CashAccount16CH_Id();      // Index 2.80

            cdtrAcct.Id          = new AccountIdentification4ChoiceCH(); // Index 2.80 / Identification
            cdtTrfTxInf.CdtrAcct = cdtrAcct;

            if (transaction.GetType() == typeof(TransactionIBANandQRR))
            {
                TransactionIBANandQRR transactionIbaNandQrr = ((TransactionIBANandQRR)transaction);

                cdtrAcct.Id.Item = transactionIbaNandQrr.ReceiverIban; // Index 2.80 / Id / IBAN  Ziel-Konto

                if (!string.IsNullOrWhiteSpace(transactionIbaNandQrr.ReceiverBIC))
                {
                    BranchAndFinancialInstitutionIdentification4CH cdtrAgt = new BranchAndFinancialInstitutionIdentification4CH(); // Index 2.77
                    cdtTrfTxInf.CdtrAgt = cdtrAgt;

                    FinancialInstitutionIdentification7CH finInstnIdCdtr = new FinancialInstitutionIdentification7CH(); // Index 2.77 / Financial Institution Identification
                    cdtrAgt.FinInstnId = finInstnIdCdtr;
                    finInstnIdCdtr.BIC = transactionIbaNandQrr.ReceiverBIC;                                             // Index 2.21
                }

                // QRR
                if (!string.IsNullOrWhiteSpace(transactionIbaNandQrr.QRReferenceNumber))
                {
                    var rmtInf = new RemittanceInformation5CH(); // Index 2.126
                    cdtTrfTxInf.RmtInf = rmtInf;
                    rmtInf.Strd        = new StructuredRemittanceInformation7
                    {
                        CdtrRefInf = new CreditorReferenceInformation2
                        {
                            Ref = transactionIbaNandQrr.QRReferenceNumber,
                            Tp  = new CreditorReferenceType2
                            {
                                CdOrPrtry = new CreditorReferenceType1Choice
                                {
                                    Item = "QRR"
                                }
                            }
                        }
                    };
                }
            }
            else if (transaction.GetType() == typeof(TransactionESR))
            {
                TransactionESR transactionESR = ((TransactionESR)transaction);

                PaymentTypeInformation19CH pmtTpInf = new PaymentTypeInformation19CH(); // Index 2.31
                cdtTrfTxInf.PmtTpInf = pmtTpInf;
                cdtTrfTxInf.PmtTpInf = new PaymentTypeInformation19CH                   // Index 2.31
                {
                    LclInstrm = new LocalInstrument2Choice                              // Index 2.36
                    {
                        ItemElementName = ItemChoiceType5.Prtry,                        // Index 2.38
                        Item            = transactionESR.PaymentType
                    }
                };

                cdtrAcct.Id.Item = new GenericAccountIdentification1CH() // Index 2.80
                {
                    Id = transactionESR.ReceiverAccount
                };

                var rmtInf = new RemittanceInformation5CH(); // Index 2.98
                cdtTrfTxInf.RmtInf = rmtInf;
                rmtInf.Strd        = new StructuredRemittanceInformation7
                {
                    CdtrRefInf = new CreditorReferenceInformation2
                    {
                        Ref = transactionESR.ESRReferenceNumber
                    }
                };
            }
            else if (transaction.GetType() == typeof(TransactionES))
            {
                TransactionES transactionES = ((TransactionES)transaction);

                PaymentTypeInformation19CH pmtTpInf = new PaymentTypeInformation19CH(); // Index 2.31
                cdtTrfTxInf.PmtTpInf = pmtTpInf;
                cdtTrfTxInf.PmtTpInf = new PaymentTypeInformation19CH                   // Index 2.31
                {
                    LclInstrm = new LocalInstrument2Choice                              // Index 2.36
                    {
                        ItemElementName = ItemChoiceType5.Prtry,                        // Index 2.38
                        Item            = transactionES.PaymentType
                    }
                };

                cdtrAcct.Id.Item = new GenericAccountIdentification1CH() // Index 2.80
                {
                    Id = transactionES.ReceiverAccount
                };
            }

            AddNewCreditTransferTransactionInformation(pmtInf, cdtTrfTxInf);
        }