Esempio n. 1
0
        /// <summary>
        /// Returns a List of SummaryHeader information in the BAI file
        /// </summary>
        /// <param name="data">The translated BAI object</param>
        /// <returns>A List of SummaryHeader</returns>
        public static List <SummaryHeader> GetSummaryInformation(TranslatedBaiFile data)
        {
            var ret = new List <SummaryHeader>();

            foreach (var group in data.Groups)
            {
                foreach (var account in group.Accounts)
                {
                    foreach (var fund in account.FundsTypes)
                    {
                        var amount = BaiFileHelpers.GetAmount(fund.Amount, group.CurrencyCode);
                        ret.Add(new SummaryHeader()
                        {
                            Date                     = group.AsOfDateTime,
                            CreationDate             = data.FileCreationDateTime,
                            SenderIdentification     = data.SenderIdentification,
                            ReceiverIndetification   = data.ReceiverIdentification,
                            FileIdentificationNumber = data.FileIdentificationNumber,
                            CurrencyCode             = group.CurrencyCode,
                            CustomerAccountNumber    = account.CustomerAccountNumber,
                            Amount                   = amount,
                            Count                    = fund.ItemCount,
                            FundType                 = fund.FundsType,
                            TypeCode                 = fund.Detail.TypeCode,
                            TypeDescription          = fund.Detail.Description
                        });
                    }
                }
            }
            return(ret);
        }
Esempio n. 2
0
        public Account(BaiAccount data, string currencyCode)
        {
            FundsTypes = new List <FundType>();
            Details    = new List <Detail>();

            var list = new List <string> {
                data.AccountIdentifier
            };

            list.AddRange(data.AccountContinuation);

            var factory = new AccountFundTypeFactory(list);

            IdentifierRecordCode  = factory.RecordCode;
            CustomerAccountNumber = factory.CustomerAccountNumber;
            CurrencyCode          = factory.CurrencyCode;

            var fundType = factory.GetNext();

            while (fundType != null)
            {
                FundsTypes.Add(fundType);
                fundType = factory.GetNext();
            }


            // Time to get the details
            foreach (var detail in data.Details)
            {
                Details.Add(new Detail(detail, currencyCode));
            }

            var fields = data.AccountTrailer.Split(',');

            if (fields.Length != 3)
            {
                throw new NotImplementedException("Bai file does not have proper number of AccountTrailer elements, I don't know how to handle this");
            }
            TrailerRecordCode   = fields[0];
            AccountControlTotal = BaiFileHelpers.GetAmount(fields[1], CurrencyCode);
            NumberOfRecords     = int.Parse(fields[2].Replace("/", ""));
        }
Esempio n. 3
0
        public static FundType GetNext(Stack stack, string currencyCode)
        {
            if (stack.Count < 4)
            {
                return(null);
            }
            var typeCode  = stack.Pop().ToString();
            var amount    = stack.Pop().ToString();
            var itemCount = stack.Pop().ToString();
            var fundsType = stack.Pop().ToString();

            switch (fundsType.ToUpper())
            {
            case "S":
                var immediate = stack.Pop().ToString();
                var oneDay    = stack.Pop().ToString();
                var moreDays  = stack.Pop().ToString();

                return(new FundType(typeCode, amount, itemCount, fundsType, immediate, oneDay, moreDays));

            case "D":
                // next field is the number of distripution pairs
                // number of days, avalible amount
                var info  = new Dictionary <int, decimal>();
                var count = int.Parse(stack.Pop().ToString());
                for (var i = 0; i < count; i++)
                {
                    var key = int.Parse(stack.Pop().ToString());
                    var v   = BaiFileHelpers.GetAmount(stack.Pop().ToString(), currencyCode);
                    info.Add(key, v);
                }
                return(new FundType(typeCode, amount, itemCount, fundsType, count.ToString(), info));

            case "V":
                var date  = stack.Pop().ToString();
                var time  = stack.Pop().ToString();
                var value = BaiFileHelpers.DateTimeFromFields(date, time);
                return(new FundType(typeCode, amount, itemCount, fundsType, value));
            }
            return(new FundType(typeCode, amount, itemCount, fundsType));
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a List of DetailSummary
        /// </summary>
        /// <param name="data">The translated BAI object</param>
        /// <param name="dictionaryKeys">Any Keys in the Detail.TextDictionary (if any) you would like to export</param>
        /// <returns>A List of DetailSummary</returns>
        public static List <DetailSummary> GetDetailInformation(TranslatedBaiFile data, List <string> dictionaryKeys)
        {
            var ret = new List <DetailSummary>();

            foreach (var group in data.Groups)
            {
                foreach (var account in group.Accounts)
                {
                    foreach (var detail in account.Details)
                    {
                        var detailType     = BaiFileHelpers.GetTransactionDetail(detail.TypeCode);
                        var textDictionary = new Dictionary <string, string>();

                        if (dictionaryKeys != null)
                        {
                            foreach (var key in dictionaryKeys)
                            {
                                if (detail.TextDictionary.ContainsKey(key))
                                {
                                    textDictionary.Add(key, detail.TextDictionary[key]);
                                }
                            }
                        }

                        var ds = new DetailSummary()
                        {
                            Date                     = group.AsOfDateTime,
                            CreationDate             = data.FileCreationDateTime,
                            FileIdentificationNumber = data.FileIdentificationNumber,
                            SenderIdentification     = data.SenderIdentification,
                            Amount                   = BaiFileHelpers.GetAmount(detail.Amount, group.CurrencyCode),
                            BankReferenceNumber      = detail.BankReferenceNumber,
                            CustomerReferenceNumber  = detail.CustomerReferenceNumber,
                            CustomerAccountNumber    = account.CustomerAccountNumber,
                            Text                     = detail.Text,
                            TypeCode                 = detailType.TypeCode,
                            TypeDescription          = detailType.Description,
                            FundType                 = detail.FundsType,
                            TextDictionary           = textDictionary
                        };

                        // I don't want to return an optional, I want a blank string
                        if (!string.IsNullOrEmpty(detail.Immediate))
                        {
                            ds.Immediate = BaiFileHelpers.GetAmount(detail.Immediate, group.CurrencyCode).ToString(CultureInfo.CurrentCulture);
                        }
                        if (!string.IsNullOrEmpty(detail.OneDay))
                        {
                            ds.OneDay = BaiFileHelpers.GetAmount(detail.OneDay, group.CurrencyCode).ToString(CultureInfo.CurrentCulture);
                        }
                        if (!string.IsNullOrEmpty(detail.TwoOrMoreDays))
                        {
                            ds.TwoOrMoreDays = BaiFileHelpers.GetAmount(detail.TwoOrMoreDays, group.CurrencyCode).ToString(CultureInfo.CurrentCulture);
                        }

                        ret.Add(ds);
                    }
                }
            }
            return(ret);
        }