Exemple #1
0
        /// <summary>
        /// Generate a Payment Information node for a Sequence Type.
        /// </summary>
        /// <param name="xml">The XML object to write</param>
        /// <param name="sqType">The Sequence Type</param>
        /// <param name="seqTransactions">The transactions of the specified type</param>
        private XmlElement GeneratePaymentInformation(XmlDocument xml, SepaSequenceType sqType, IEnumerable <SepaDebitTransferTransaction> seqTransactions)
        {
            int     controlNumber = 0;
            decimal controlSum    = 0;

            // We check the number of transaction to write and the sum due to the Sequence Type.
            foreach (var transfer in seqTransactions)
            {
                controlNumber += 1;
                controlSum    += transfer.Amount;
            }

            // If there is no transaction, we end the method here.
            if (controlNumber == 0)
            {
                return(null);
            }

            var pmtInf = XmlUtils.GetFirstElement(xml, "CstmrDrctDbtInitn").NewElement("PmtInf");

            pmtInf.NewElement("PmtInfId", PaymentInfoId ?? MessageIdentification);
            if (CategoryPurposeCode != null)
            {
                pmtInf.NewElement("CtgyPurp").NewElement("Cd", CategoryPurposeCode);
            }

            pmtInf.NewElement("PmtMtd", Constant.DebitTransfertPaymentMethod);
            pmtInf.NewElement("NbOfTxs", controlNumber);
            pmtInf.NewElement("CtrlSum", StringUtils.FormatAmount(controlSum));

            var pmtTpInf = pmtInf.NewElement("PmtTpInf");

            pmtTpInf.NewElement("SvcLvl").NewElement("Cd", "SEPA");
            pmtTpInf.NewElement("LclInstrm").NewElement("Cd", LocalInstrumentCode);
            pmtTpInf.NewElement("SeqTp", SepaSequenceTypeUtils.SepaSequenceTypeToString(sqType));

            pmtInf.NewElement("ReqdColltnDt", StringUtils.FormatDate(RequestedExecutionDate));
            pmtInf.NewElement("Cdtr").NewElement("Nm", Creditor.Name);

            var dbtrAcct = pmtInf.NewElement("CdtrAcct");

            dbtrAcct.NewElement("Id").NewElement("IBAN", Creditor.Iban);
            dbtrAcct.NewElement("Ccy", CreditorAccountCurrency);

            pmtInf.NewElement("CdtrAgt").NewElement("FinInstnId").NewElement("BIC", Creditor.Bic);
            pmtInf.NewElement("ChrgBr", "SLEV");

            var othr = pmtInf.NewElement("CdtrSchmeId").NewElement("Id")
                       .NewElement("PrvtId")
                       .NewElement("Othr");

            othr.NewElement("Id", PersonId);
            othr.NewElement("SchmeNm").NewElement("Prtry", "SEPA");

            return(pmtInf);
        }
 /// <summary>
 ///     Get awaited XML string from Enum value
 /// </summary>
 /// <param name="seqTp">Enum value</param>
 /// <returns>Awaited XML string</returns>
 public static string SepaSequenceTypeToString(SepaSequenceType seqTp)
 {
     switch (seqTp)
     {
         case SepaSequenceType.OOFF:
             return "OOFF";
         case SepaSequenceType.FIRST:
             return "FRST";
         case SepaSequenceType.RCUR:
             return "RCUR";
         case SepaSequenceType.FINAL:
             return "FNAL";
         default:
             throw new ArgumentException("Unknown Sequence Type : " + seqTp);
     }
 }
        /// <summary>
        ///     Get awaited XML string from Enum value
        /// </summary>
        /// <param name="seqTp">Enum value</param>
        /// <returns>Awaited XML string</returns>
        public static string SepaSequenceTypeToString(SepaSequenceType seqTp)
        {
            switch (seqTp)
            {
            case SepaSequenceType.OOFF:
                return("OOFF");

            case SepaSequenceType.FIRST:
                return("FRST");

            case SepaSequenceType.RCUR:
                return("RCUR");

            case SepaSequenceType.FINAL:
                return("FNAL");

            default:
                throw new ArgumentException("Unknown Sequence Type : " + seqTp);
            }
        }