Skip to content

Commit

Permalink
Caixa validation was not considering when the digit is 10
Browse files Browse the repository at this point in the history
when the calculated value is 10, the digit should be 10
  • Loading branch information
americodls committed Apr 13, 2015
1 parent 4bdf723 commit 7b077d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/banking_data_validator/bank/caixa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Caixa < Base
private

def checksum
"#{raw_checksum % 11}"
"#{raw_checksum % 10}"
end

def raw_checksum
@raw_checksum ||= multiply_factors * 10
@raw_checksum ||= multiply_factors * 10 % 11
end

def factors
Expand Down
2 changes: 2 additions & 0 deletions spec/banking_data_validator/bank/caixa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module Bank
expect(Caixa.valid_account?("1314", "01300169300", "1")).to eq(true)
expect(Caixa.valid_account?(268, "00100030339", "5")).to eq(true)
expect(Caixa.valid_account?("3498", "00100021718", "8")).to eq(true)
expect(Caixa.valid_account?("0821", "00100020502", "0")).to eq(true)
expect(Caixa.valid_account?("0008", "01300060386", "0")).to eq(true)
end

it "returns false when is given an account_number with an invalid digit" do
Expand Down

0 comments on commit 7b077d8

Please sign in to comment.