Ejemplo n.º 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 (SortCode.IsCooperativeBankSortCode(sortCode))
                    {
                        accountNumber = accountNumber.Substring(0, 8);
                    }
                    else if (SortCode.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 = AccountNumber.Parse(accountNumber);
        }
 private void ExceptionEightPreProcessing()
 {
     if (WeightMappings.First().Exception == 8)
     {
         SortCode = new SortCode("090126");
     }
 }
Ejemplo n.º 3
0
 private void ExceptionEightPreProcessing(IEnumerable <ModulusWeightMapping> mappings)
 {
     if (mappings.First().Exception == 8)
     {
         SortCode = new SortCode("090126");
     }
 }
        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 (SortCode.IsCooperativeBankSortCode(sortCode))
                {
                    accountNumber = accountNumber.Substring(0, 8);
                }
                else if (SortCode.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 = AccountNumber.Parse(accountNumber);
        }
 public static BankAccountDetails From(SortCode sortCode, AccountNumber accountNumber, IEnumerable <IModulusWeightMapping> weightMappings)
 {
     return(new BankAccountDetails(sortCode.ToString(),
                                   accountNumber.ToString())
     {
         WeightMappings = weightMappings
     });
 }
 public ModulusWeightMapping(
     SortCode sortCodeStart,
     SortCode sortCodeEnd,
     ModulusAlgorithm modulusAlgorithm,
     int[] weightValues,
     int exception)
 {
     SortCodeStart = sortCodeStart;
     SortCodeEnd = sortCodeEnd;
     Algorithm = modulusAlgorithm;
     WeightValues = weightValues;
     Exception = exception;
 }
Ejemplo n.º 7
0
 public ModulusWeightMapping(
     SortCode sortCodeStart,
     SortCode sortCodeEnd,
     ModulusAlgorithm modulusAlgorithm,
     int[] weightValues,
     int exception)
 {
     SortCodeStart = sortCodeStart;
     SortCodeEnd   = sortCodeEnd;
     Algorithm     = modulusAlgorithm;
     WeightValues  = weightValues;
     Exception     = exception;
 }
        public static ModulusWeightMapping From(string row)
        {
            var weightValues = new int[14];
            var items = row.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            var sortCodeStart = new SortCode(items[0]);
            var sortCodeEnd = new SortCode(items[1]);
            var algorithm = (ModulusAlgorithm) Enum.Parse(typeof(ModulusAlgorithm), items[2], true);
            for (var i = 3; i < 17; i++)
            {
                weightValues[i - 3] = int.Parse(items[i]);
            }
            var exception = -1;
            if (items.Length==18)
            {
                exception = int.Parse(items[17]);
            }

            return new ModulusWeightMapping(sortCodeStart, sortCodeEnd, algorithm, weightValues, exception);
        }
 public ModulusWeightMapping(string row)
 {
     WeightValues = new int[14];
     var items = row.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
     SortCodeStart = new SortCode(items[0]);
     SortCodeEnd = new SortCode(items[1]);
     Algorithm = (ModulusAlgorithm) Enum.Parse(typeof(ModulusAlgorithm), items[2], true);
     for (var i = 3; i < 17; i++)
     {
         WeightValues[i - 3] = Int16.Parse(items[i]);
     }
     if (items.Length==18)
     {
         Exception = Int16.Parse(items[17]);
     }
     else
     {
         Exception = -1;
     }
 }
Ejemplo n.º 10
0
        public static ModulusWeightMapping From(string row)
        {
            var weightValues  = new int[14];
            var items         = row.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var sortCodeStart = new SortCode(items[0]);
            var sortCodeEnd   = new SortCode(items[1]);
            var algorithm     = (ModulusAlgorithm)Enum.Parse(typeof(ModulusAlgorithm), items[2], true);

            for (var i = 3; i < 17; i++)
            {
                weightValues[i - 3] = int.Parse(items[i]);
            }
            var exception = -1;

            if (items.Length == 18)
            {
                exception = int.Parse(items[17]);
            }

            return(new ModulusWeightMapping(sortCodeStart, sortCodeEnd, algorithm, weightValues, exception));
        }
        public ModulusWeightMapping(string row)
        {
            WeightValues = new int[14];
            var items = row.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            SortCodeStart = new SortCode(items[0]);
            SortCodeEnd   = new SortCode(items[1]);
            Algorithm     = (ModulusAlgorithm)Enum.Parse(typeof(ModulusAlgorithm), items[2], true);
            for (var i = 3; i < 17; i++)
            {
                WeightValues[i - 3] = int.Parse(items[i]);
            }
            if (items.Length == 18)
            {
                Exception = int.Parse(items[17]);
            }
            else
            {
                Exception = -1;
            }
        }
Ejemplo n.º 12
0
 private bool Equals(SortCode other)
 {
     return _doubleValue.Equals(other._doubleValue);
 }
Ejemplo n.º 13
0
 public static BankAccountDetails From(SortCode sortCode, AccountNumber accountNumber, IEnumerable<IModulusWeightMapping> weightMappings)
 {
     return new BankAccountDetails(sortCode.ToString(),
                                   accountNumber.ToString())
     {
         WeightMappings = weightMappings
     };
 }
Ejemplo n.º 14
0
 private void ExceptionEightPreProcessing(IEnumerable<ModulusWeightMapping> mappings)
 {
     if (mappings.First().Exception == 8)
     {
         SortCode = new SortCode("090126");
     }
 }
Ejemplo n.º 15
0
 private void ExceptionEightPreProcessing()
 {
     if (WeightMappings.First().Exception == 8)
     {
         SortCode = new SortCode("090126");
     }
 }
Ejemplo n.º 16
0
 private bool Equals(SortCode other)
 {
     return(_doubleValue.Equals(other._doubleValue));
 }
Ejemplo n.º 17
0
 public IEnumerable<IModulusWeightMapping> GetRuleMappings(SortCode sortCode)
 {
     return
         RuleMappings.Where(rm => sortCode.DoubleValue >= rm.SortCodeStart.DoubleValue 
                 && sortCode.DoubleValue <= rm.SortCodeEnd.DoubleValue);
 } 
 public String ToCombinedString()
 {
     return(SortCode.ToString() + AccountNumber);
 }
Ejemplo n.º 19
0
 protected bool Equals(SortCode other)
 {
     return _doubleValue.Equals(other._doubleValue);
 }