// Get weights to use for a bank account following the exception 2 or 9.
func WeightsForException2Or9(b m.BankAccount, sc m.SortCodeData) (weights []int) {
	if !(sc.IsException(2) || sc.IsException(9)) {
		panic("Expected exception 2 or exception 9 sort code")
	}

	a := b.NumberAtPosition("a")
	g := b.NumberAtPosition("g")

	// Default weights
	weights = sc.Weights

	switch {
	case a != 0 && g != 9:
		weights = []int{
			0, 0, 1, 2, 5, 3,
			6, 4, 8, 7, 10, 9, 3, 1,
		}
	case a != 0 && g == 9:
		weights = []int{
			0, 0, 0, 0, 0, 0,
			0, 0, 8, 7, 10, 9, 3, 1,
		}
	}

	return
}
Exemplo n.º 2
0
// Check if we follow the criteria of the exception 3
func FollowsException3(b m.BankAccount, scData m.SortCodeData) bool {
	c := b.NumberAtPosition("c")

	hasNextAnd3 := scData.HasNext() && scData.Next.IsException(3)

	return (scData.IsException(3) || hasNextAnd3) && (c == 6 || c == 9)
}
Exemplo n.º 3
0
// Determine if the checker is able to validate the bank account
func (e Exception10Checker) Handles(account m.BankAccount, sc m.SortCodeData, attempt int) bool {
	if !sc.IsException(10) {
		return false
	}

	// if ab = 09 or ab = 99 and g = 9
	a := account.NumberAtPosition("a")
	b := account.NumberAtPosition("b")
	g := account.NumberAtPosition("g")

	return (a == 0 || a == 9) && b == 9 && g == 9
}
Exemplo n.º 4
0
// Determine if the checker is able to validate the bank account
func (e Exception6Checker) Handles(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
	return sc.IsException(6)
}
Exemplo n.º 5
0
// Determine if the checker is able to validate the bank account
func (e Exception7Checker) Handles(account m.BankAccount, sc m.SortCodeData, attempt int) bool {
	// If g=9
	g := account.NumberAtPosition("g")

	return sc.IsException(7) && g == 9
}