private static void ZeroiseUtoB(IModulusWeightMapping weightMapping) { for (var i = 0; i < 8; i++) { weightMapping.WeightValues[i] = 0; } }
protected bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails,modulusWeightMapping); var remainder = weightingSum%Modulus; return modulusWeightMapping.Exception == 4 ? bankAccountDetails.AccountNumber.GetExceptionFourCheckValue == remainder : remainder == 0; }
public ModulusWeightMapping(IModulusWeightMapping original) { WeightValues = new int[14]; Array.Copy(original.WeightValues, WeightValues, 14); Algorithm = original.Algorithm; SortCodeStart = original.SortCodeStart; SortCodeEnd = original.SortCodeEnd; Exception = original.Exception; }
protected bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping); var remainder = weightingSum % Modulus; return(modulusWeightMapping.Exception == 4 ? bankAccountDetails.AccountNumber.GetExceptionFourCheckValue == remainder : remainder == 0); }
private bool InitialSecondCheck(BankAccountDetails bankAccountDetails, IModulusWeightMapping mapping) { var alternativeWeightMapping = new ModulusWeightMapping(mapping) { WeightValues = bankAccountDetails .GetExceptionTwoAlternativeWeights( mapping.WeightValues) }; return ProcessWeightingRule(bankAccountDetails, alternativeWeightMapping); }
private bool InitialSecondCheck(BankAccountDetails bankAccountDetails, IModulusWeightMapping mapping) { var alternativeWeightMapping = new ModulusWeightMapping(mapping) { WeightValues = bankAccountDetails .GetExceptionTwoAlternativeWeights( mapping.WeightValues) }; return(ProcessWeightingRule(bankAccountDetails, alternativeWeightMapping)); }
/// For the standard check with exception 5 the checkdigit is g from the original account number. /// • After dividing the result by 11; /// - if the remainder=0 and g=0 the account number is valid /// - if the remainder=1 the account number is invalid /// - for all other remainders, take the remainder away from 11. If the number you get is the same as g /// then the account number is valid. private new bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping); var remainder = weightingSum % Modulus; switch (remainder) { case 0 : return bankAccountDetails.AccountNumber.IntegerAt(6) == 0; case 1 : return false; default : return Modulus - remainder == bankAccountDetails.AccountNumber.IntegerAt(6); } }
public int GetModulusSum(BankAccountDetails bankAccountDetails, IModulusWeightMapping weightMapping) { var combinedValue = bankAccountDetails.ToCombinedString(); if (combinedValue.Length != 14) { throw new Exception( String.Format("Combined SortCode and Account Number should be 14 characters long not {0}: {1}", combinedValue.Length, combinedValue)); } var sum = 0; for (var i = 0; i < 14; i++) { sum += (Int16.Parse(combinedValue[i].ToString(CultureInfo.InvariantCulture)) * weightMapping.WeightValues[i]); } return sum; }
/// For the standard check with exception 5 the checkdigit is g from the original account number. /// • After dividing the result by 11; /// - if the remainder=0 and g=0 the account number is valid /// - if the remainder=1 the account number is invalid /// - for all other remainders, take the remainder away from 11. If the number you get is the same as g /// then the account number is valid. private new bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping); var remainder = weightingSum % Modulus; switch (remainder) { case 0: return(bankAccountDetails.AccountNumber.IntegerAt(6) == 0); case 1: return(false); default: return(Modulus - remainder == bankAccountDetails.AccountNumber.IntegerAt(6)); } }
public int GetModulusSum(BankAccountDetails bankAccountDetails, IModulusWeightMapping weightMapping) { var combinedValue = bankAccountDetails.ToCombinedString(); if (combinedValue.Length != 14) { throw new Exception( string.Format("Combined SortCode and Account Number should be 14 characters long not {0}: {1}", combinedValue.Length, combinedValue)); } var sum = 0; for (var i = 0; i < 14; i++) { sum += (int.Parse(combinedValue[i].ToString(CultureInfo.InvariantCulture)) * weightMapping.WeightValues[i]); } return(sum); }