本文整理汇总了Golang中github.com/AntoineAugusti/moduluschecking/models.BankAccount类的典型用法代码示例。如果您正苦于以下问题:Golang BankAccount类的具体用法?Golang BankAccount怎么用?Golang BankAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BankAccount类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: FollowsException3
// 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)
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:8,代码来源:exception3.go
示例2: IsValid
// Tell if the bank account is valid
func (e Exception5Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
if !e.Handles(b, sc, attempt) {
panic("Should be exception of type 5")
}
if substitution, hasKey := e.Substitutions[b.SortCode]; hasKey {
b.SortCode = substitution
}
// First attempt
if attempt == 1 {
checkDigit := b.NumberAtPosition("g")
remainder := GeneralChecker{}.RemainderFromRegularCheck(b, sc)
if remainder == 0 && checkDigit == 0 {
return true
}
if remainder == 1 {
return false
}
return (11 - remainder) == checkDigit
}
// Second attempt
checkDigit := b.NumberAtPosition("h")
remainder := GeneralChecker{}.RemainderFromRegularCheck(b, sc)
if remainder == 0 && checkDigit == 0 {
return true
}
return (10 - remainder) == checkDigit
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:33,代码来源:exception5.go
示例3: WeightsForException2Or9
// 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
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:27,代码来源:exception2And9.go
示例4: isForeignCurrency
// Check if a bank account is in a foreign currency
func (e Exception6Checker) isForeignCurrency(b m.BankAccount) bool {
// if a = 4, 5, 6, 7 or 8, and g and h are the same,
// the accounts are for a foreign currency and the checks cannot be used
a := b.NumberAtPosition("a")
g := b.NumberAtPosition("g")
h := b.NumberAtPosition("h")
return a >= 4 && a <= 8 && (g == h)
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:10,代码来源:exception6.go
示例5: IsValid
// Tell if the bank account is valid
func (e Exception4Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
if !e.Handles(b, sc, attempt) {
panic("Should be exception of type 4")
}
g := b.NumberAtPosition("g")
h := b.NumberAtPosition("h")
checkDigit := g*10 + h
return GeneralChecker{}.RemainderFromRegularCheck(b, sc) == checkDigit
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:12,代码来源:exception4.go
示例6: Handles
// 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
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:13,代码来源:exception10.go
示例7: DoubleAlternate
// Perform the double alternate algorithm and return
// the remainder of the operation
func DoubleAlternate(b m.BankAccount, data m.SortCodeData, sum int) (remainder int) {
numbers := b.MergeAccountDetails()
weights := data.Weights
for i, nb := range numbers {
sum += helpers.AddDigits(weights[i] * nb)
}
remainder = sum % 10
return
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:14,代码来源:doubleAlternate.go
示例8: Modulus
// Perform the modulus algorithm with a given modulus
// and return the remainder of the operation
func Modulus(b m.BankAccount, modulus int, data m.SortCodeData) (remainder int) {
numbers := b.MergeAccountDetails()
sum := 0
weights := data.Weights
for i, nb := range numbers {
sum += weights[i] * nb
}
remainder = sum % modulus
return
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:15,代码来源:modulus.go
示例9: IsValid
// Tell if the bank account is valid
func (e Exception14Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
if !e.Handles(b, sc, attempt) {
panic("Should be exception of type 14 at attempt 2")
}
h := b.NumberAtPosition("h")
if h >= 2 && h <= 8 {
return false
}
// Remove the 1st digit from the accout number and insert a 0
// as the 1st digit for check purposes
b.AccountNumber = "0" + b.AccountNumber[0:len(b.AccountNumber)-1]
return GeneralChecker{}.IsValid(b, sc, attempt)
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:16,代码来源:exception14.go
示例10: IsValid
// Tell if the bank account is valid
func (e Exception9Checker) IsValid(b m.BankAccount, sc m.SortCodeData, attempt int) bool {
if !e.Handles(b, sc, attempt) {
panic("Should be exception of type 9")
}
sc.Weights = WeightsForException2Or9(b, sc)
if (GeneralChecker{}.IsValid(b, sc, attempt)) {
return true
}
// Try to replace the sort code
b.SortCode = "309634"
return GeneralChecker{}.IsValid(b, e.Weights[b.SortCode], attempt)
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:16,代码来源:exception9.go
示例11: Handles
// 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
}
开发者ID:AntoineAugusti,项目名称:moduluschecking,代码行数:7,代码来源:exception7.go
注:本文中的github.com/AntoineAugusti/moduluschecking/models.BankAccount类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论