Skip to content

Commit

Permalink
fixes DragonBe#54 for version 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
krzaczek committed Oct 25, 2018
1 parent faee183 commit f77c228
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Vies/Validator/ValidatorSI.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function validate($vatNumber)
$checksum = (int)$vatNumber[7];
$weights = [8, 7, 6, 5, 4, 3, 2];
$checkval = $this->sumWeights($weights, $vatNumber);
$checkval = ($checkval % 11) == 10 ? 0 : 11 - ($checkval % 11);

if ($checksum != $checkval) {
$mod = 11 - ($checkval % 11);
if ($mod === 11) {
return false;
}
$checkval = ($mod == 10) ? 0 : $mod;

return true;
return $checksum == $checkval;
}
}
2 changes: 1 addition & 1 deletion tests/Vies/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function vatNumberProvider()
'PT' => ['502757191', ['502757192', '12345678']],
'RO' => [['11198699', '14186770'], ['11198698', '1', '12345678902']],
'SE' => ['556188840401', ['556188840400', '1234567890', '556181140401']],
'SI' => ['15012557', ['15012556', '12345670', '01234567', '1234567']],
'SI' => [['15012557', '95796550'], ['15012556', '12345670', '01234567', '1234567', '95736220']],
'SK' => ['4030000007', ['4030000006', '123456789', '0123456789', '4060000007']]
];
}
Expand Down

0 comments on commit f77c228

Please sign in to comment.