Skip to content

Commit 34d4d8f

Browse files
authored
Merge pull request #1 from zgypa/master
add dateutil requirement in setup.py
2 parents e80c8ea + ffb3a0a commit 34d4d8f

File tree

6 files changed

+6144
-4
lines changed

6 files changed

+6144
-4
lines changed

PyFePA/fepa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
TD = ['TD{:0=2d}'.format(td) for td in range(1, 6)]
2828
TR = ['RT01','RT01']
2929
TC = ['TC{:0=2d}'.format(tc) for tc in range(1,22)]
30-
NT = ['NT{:0=2d}'.format(nt) for nt in range(1,7)]
30+
NT = ['N{:0=1d}'.format(nt) for nt in range(1,8)]
3131
TCP = ('SC', 'PR', 'AB', 'AC')
3232
SM = ('SC', 'MG')
3333
TP = ('TP01', 'TP02', 'TP03')

PyFePA/fields.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datetime
1919
import importlib
2020
import dateutil.parser
21+
from decimal import Decimal
2122

2223

2324
class FieldType(object):
@@ -141,7 +142,7 @@ def validate(self, value):
141142
if super(FieldDecimal,self).validate(value):
142143
return value
143144
elif self.minlen <= len('{:.2f}'.format(float(value))) <= self.maxlen:
144-
return float(value)
145+
return Decimal(value).quantize(Decimal('.01'))
145146
except(ValueError, TypeError):
146147
print('DEBUG- ', value)
147148
return False
@@ -155,7 +156,7 @@ def __init__(self, **kwargs):
155156

156157
@classmethod
157158
def tostring(cls,value):
158-
return '{:.2f}'.format(float(value))
159+
return unicode(Decimal(value).quantize(Decimal('.01')))
159160

160161

161162
class FieldDate(FieldType):

PyFePA/serializer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def serializexml(invoice_part,tagname):
146146
for t in taglist[k]['value']:
147147
fe.append(serializexml(t, taglist[k]['tag']))
148148
elif taglist[k]['type'] == 'S' and taglist[k]['value'] is not None:
149+
if type(taglist[k]['value']) != unicode:
150+
taglist[k]['value'] = unicode(taglist[k]['value'])
149151
(ElementTree.SubElement(fe, taglist[k]['tag'])).text = taglist[k]['value']
150152
elif taglist[k]['type'] == 'O' and taglist[k]['value'] is not None:
151153
fe.append(serializexml(taglist[k]['value'],taglist[k]['tag']))

0 commit comments

Comments
 (0)