Finished up most of the record order validation and also checking
for all required records in a set. Added a controller class but decided to put stuff in __init__ instead, at least for now. Added a DateField which converts datetime.date into the proper string format for EFW2 files (hopefully), this should still be tested next week.
This commit is contained in:
parent
f30237a90d
commit
5781cbf335
4 changed files with 113 additions and 14 deletions
22
fields.py
22
fields.py
|
@ -1,4 +1,4 @@
|
|||
import decimal
|
||||
import decimal, datetime
|
||||
|
||||
class ValidationError(Exception):
|
||||
pass
|
||||
|
@ -123,5 +123,21 @@ class MoneyField(Field):
|
|||
self.value = decimal.Decimal(s) * decimal.Decimal('0.01')
|
||||
|
||||
class DateField(TextField):
|
||||
#FIXME I NEED TO BE WRITTEN!
|
||||
pass
|
||||
def __init__(self, name=None, required=True, value=None):
|
||||
super(TextField, self).__init__(name=name, required=required, max_length=8)
|
||||
if isinstance(value, datetime.date):
|
||||
self._value = value
|
||||
elif value:
|
||||
self._value = datetime.date(*[int(x) for x in value[4:8], value[0:2], value[2:4]])
|
||||
else:
|
||||
self._value = None
|
||||
|
||||
def get_data(self):
|
||||
if self._value:
|
||||
return self._value.strftime('%m%d%Y')
|
||||
return '0' * self.max_length
|
||||
|
||||
def parse(self, s):
|
||||
self.value = datetime.date(*[int(x) for x in s[4:8], s[0:2], s[2:4]])
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue