Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checksum operation #9

Merged
merged 3 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bankbarcode/cuaderno57.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ def checksum(self):
+ int(self.notice) \
+ self.amount100()
decimals = int(Decimal(sum) / 97 % 1 * 100)
if decimals == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO should be better if not decimals

return '00'
return unicode(100 - decimals).zfill(2)

def code(self):
Expand Down
9 changes: 9 additions & 0 deletions spec/cuaderno57_Recibo507_checksum_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@
amount = '37.62'
checksum = '56'
expect(Recibo507(entity, suffix, ref, notice, amount).checksum()).to(equal(checksum))

with it('accomplish another example'):
entity = '22350466'
suffix = '501'
ref = '00000085501'
notice = '130516'
amount = '56.92'
checksum = '00'
expect(Recibo507(entity, suffix, ref, notice, amount).checksum()).to(equal(checksum))