From f3d48246278fa604e498025782108aef51806f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20Juli=C3=A0=20Blasi?= Date: Thu, 5 May 2016 13:38:25 +0200 Subject: [PATCH 1/3] Add failed test --- spec/cuaderno57_Recibo507_checksum_spec.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/cuaderno57_Recibo507_checksum_spec.py b/spec/cuaderno57_Recibo507_checksum_spec.py index 38c5e3a..7ecc89d 100644 --- a/spec/cuaderno57_Recibo507_checksum_spec.py +++ b/spec/cuaderno57_Recibo507_checksum_spec.py @@ -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)) From 9167d5e47fcf29b4164e10a087be105326d5c0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20Juli=C3=A0=20Blasi?= Date: Thu, 5 May 2016 13:41:15 +0200 Subject: [PATCH 2/3] Fix when module 100 is 0 return code 00 --- bankbarcode/cuaderno57.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bankbarcode/cuaderno57.py b/bankbarcode/cuaderno57.py index dea428b..d32795d 100644 --- a/bankbarcode/cuaderno57.py +++ b/bankbarcode/cuaderno57.py @@ -273,6 +273,8 @@ def checksum(self): + int(self.notice) \ + self.amount100() decimals = int(Decimal(sum) / 97 % 1 * 100) + if decimals == 0: + return '00' return unicode(100 - decimals).zfill(2) def code(self): From d273986ed84923e51b4d99636657191f7a0ab793 Mon Sep 17 00:00:00 2001 From: guilleJB Date: Thu, 5 May 2016 13:56:58 +0200 Subject: [PATCH 3/3] Change validation --- bankbarcode/cuaderno57.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bankbarcode/cuaderno57.py b/bankbarcode/cuaderno57.py index d32795d..e6b6594 100644 --- a/bankbarcode/cuaderno57.py +++ b/bankbarcode/cuaderno57.py @@ -273,7 +273,7 @@ def checksum(self): + int(self.notice) \ + self.amount100() decimals = int(Decimal(sum) / 97 % 1 * 100) - if decimals == 0: + if not decimals: return '00' return unicode(100 - decimals).zfill(2)