Skip to content

Commit

Permalink
Merge pull request #14 from codesyntax/fix-control-digit-calculation
Browse files Browse the repository at this point in the history
Fix control digit calculation
  • Loading branch information
erral committed Jun 1, 2018
2 parents 3441355 + 9cc1d64 commit 50b40dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ History
1.0b6 (unreleased)
------------------

- Fix control digit calculation
[erral]

- Document new extra parameters for logos and XSLT template.
[erral]

Expand Down
4 changes: 2 additions & 2 deletions pymipago/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _calculate_reference_number_with_control_digits_notebook_60(sender, referenc
- Divide e by 97 and take the decimal values.
- f: take the first 2 decimal values (add a 0 as a second digit if
the division result creates just one decimal)
- g: deduct f from 100.
- g: deduct f from 99.
- Concatenate the reference number and g and create a 12 digit value
"""
if len(reference_number) != 10:
Expand All @@ -55,7 +55,7 @@ def _calculate_reference_number_with_control_digits_notebook_60(sender, referenc
_, decimals = str(division_result).split('.')

first_two_decimals = '{:0<2}'.format(decimals)[:2]
control_digits = 100 - int(first_two_decimals)
control_digits = 99 - int(first_two_decimals)

return '{reference_number}{control_digits}'.format(
reference_number=reference_number, control_digits=control_digits)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_calculate_reference_number_with_control_digits_notebook_60(self):
else:
first_two_decimals = decimals[:1] + '0'

control_digits = 100 - int(first_two_decimals)
control_digits = 99 - int(first_two_decimals)
value = '{}{}'.format(reference_number, control_digits)

calculated_value = _calculate_reference_number_with_control_digits_notebook_60( # noqa
Expand Down

0 comments on commit 50b40dd

Please sign in to comment.