Пример #1
0
        public BankAccountDetails(string sortCode, string accountNumber)
        {
            accountNumber = PrepareString(accountNumber);
            sortCode = PrepareString(sortCode);

            switch (accountNumber.Length)
            {
                case 9:
                    var chars = sortCode.ToCharArray();
                    chars[5] = accountNumber[0];
                    sortCode = new string(chars);
                    accountNumber = accountNumber.Substring(1);
                    break;
                case 10:
                    if (IsCooperativeBankSortCode(sortCode))
                    {
                        accountNumber = accountNumber.Substring(0, 8);
                    }
                    else if (IsNatWestSortCode(sortCode))
                    {
                        accountNumber = accountNumber.Substring(2);
                    } else
                    {
                        throw new ArgumentException(string.Format("Ten Digit Account Numbers can only come from Natwest or Coop sortcodes. {0} does not appear to be either",sortCode));
                    }
                    break;
            }

            SortCode = new SortCode(sortCode);
            AccountNumber = new AccountNumber(accountNumber);
        }
 public int[] GetExceptionTwoAlternativeWeights(int[] originalWeights)
 {
     if (AccountNumber.IntegerAt(0) != 0)
     {
         return(AccountNumber.IntegerAt(6) == 9
                                       ? AisNotZeroAndGisNineWeights
                                       : AisNotZeroAndGisNotNineWeights);
     }
     return(originalWeights);
 }
 private void ExceptionSevenPreprocessing()
 {
     if (WeightMappings.First().Exception != 7)
     {
         return;
     }
     if (AccountNumber.IntegerAt(6) != 9)
     {
         return;
     }
     ZeroiseUtoB(WeightMappings.First());
 }
        private IList <ModulusWeightMapping> ExceptionSevenPreprocessing(IList <ModulusWeightMapping> mappings)
        {
            if (mappings.First().Exception != 7)
            {
                return(mappings);
            }
            if (AccountNumber.IntegerAt(6) != 9)
            {
                return(mappings);
            }

            return(mappings.Select((m, index) => index == 0 ? ZeroiseUtoB(m) : m).ToList());
        }
Пример #5
0
 public static BankAccountDetails From(SortCode sortCode, AccountNumber accountNumber, IEnumerable<IModulusWeightMapping> weightMappings)
 {
     return new BankAccountDetails(sortCode.ToString(),
                                   accountNumber.ToString())
     {
         WeightMappings = weightMappings
     };
 }