예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="cultureInfo">The culture to use</param>
        public TransactionBalance(string data, CultureInfo cultureInfo)
        {
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new ArgumentException("data can not be empty", data);
            }

            if (cultureInfo == null)
            {
                throw new ArgumentNullException(nameof(cultureInfo));
            }

            var regex = new Regex(@"([C|D]{1})([0-9]{2})([0-9]{2})([0-9]{2})([A-Z]{3})(\d.*)");
            var match = regex.Match(data);

            if (match.Groups.Count < 7)
            {
                throw new System.Data.InvalidExpressionException(data);
            }

            DebitCredit = DebitCreditFactory.Create(match.Groups[1].Value);

            EntryDate = ParseDate(match, cultureInfo);

            Currency = new Currency(match.Groups[5].Value);
            Balance  = new Money(match.Groups[6].Value, Currency, cultureInfo);
        }
예제 #2
0
        static DebitCredit ExtractDebitCredit(Match match)
        {
            if (match == null)
            {
                throw new ArgumentNullException(nameof(match));
            }

            string debitCreditCode = match.Groups["creditdebit"].Value;
            var    debitCredit     = DebitCreditFactory.Create(debitCreditCode);

            return(debitCredit);
        }