From 30376a54f37327f69ecdb4f604d1c697fbad7e2f Mon Sep 17 00:00:00 2001 From: Binh Nguyen Date: Tue, 9 Oct 2012 15:31:35 -0500 Subject: [PATCH] fixed missing field, updated for 2012 --- pyaccuwage/__init__.py | 9 ++++++++- pyaccuwage/model.py | 5 +++-- pyaccuwage/record.py | 12 +++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pyaccuwage/__init__.py b/pyaccuwage/__init__.py index c440872..b3d93a6 100644 --- a/pyaccuwage/__init__.py +++ b/pyaccuwage/__init__.py @@ -16,9 +16,16 @@ RECORD_TYPES = [ def test(): import record, model + from fields import ValidationError for rname in RECORD_TYPES: inst = record.__dict__[rname]() - print type(inst), inst.record_identifier, len(inst.output()) + try: + output_length = len(inst.output()) + except ValidationError, e: + print e.msg, type(inst), inst.record_identifier + continue + + print type(inst), inst.record_identifier, output_length def test_dump(): diff --git a/pyaccuwage/model.py b/pyaccuwage/model.py index bb040b3..9e206db 100644 --- a/pyaccuwage/model.py +++ b/pyaccuwage/model.py @@ -2,7 +2,8 @@ from fields import Field, ValidationError import copy import pdb -class Model(object): + +class Model(object): record_identifier = ' ' required = False @@ -53,7 +54,7 @@ class Model(object): def output(self): result = ''.join([self.record_identifier] + [field.get_data() for field in self.get_sorted_fields()]) if len(result) != 512: - raise ValidationError("Record result length not equal to 512 bytes") + raise ValidationError("Record result length not equal to 512 bytes (%d)" % len(result)) return result def read(self, fp): diff --git a/pyaccuwage/record.py b/pyaccuwage/record.py index 4cd845f..35b6524 100644 --- a/pyaccuwage/record.py +++ b/pyaccuwage/record.py @@ -151,6 +151,7 @@ class EmployeeWageRecord(model.Model): location_address = TextField(max_length=22) delivery_address = TextField(max_length=22) city = TextField(max_length=22) + city = TextField(max_length=22) state = StateField() zipcode = TextField(max_length=5, required=False) zipcode_ext = TextField(max_length=4, required=False) @@ -172,23 +173,24 @@ class EmployeeWageRecord(model.Model): deferred_compensation_408k = MoneyField(max_length=11, required=False) deferred_compensation_457b = MoneyField(max_length=11, required=False) deferred_compensation_501c = MoneyField(max_length=11, required=False) - military_pay = MoneyField(max_length=11, required=False) + blank2 = BlankField(max_length=11) non_qualified_457 = MoneyField(max_length=11, required=False) employer_contrib_to_hsa = MoneyField(max_length=11, required=False) non_qualified_not_457 = MoneyField(max_length=11, required=False) nontaxable_combat_pay = MoneyField(max_length=11, required=False) - blank2 = BlankField(max_length=11) + blank3 = BlankField(max_length=11) cost_of_premiums_for_insurance = MoneyField(max_length=11, required=False) income_nonstatutory_stock_opts = MoneyField(max_length=11, required=False) deferred_compensation_409a = MoneyField(max_length=11, required=False) designated_roth_contrib_401k = MoneyField(max_length=11, required=False) designated_roth_contrib_403b = MoneyField(max_length=11, required=False) - blank3 = BlankField(max_length=12) + employer_sponsored_health = MoneyField(max_length=11, required=False) + blank4 = BlankField(max_length=12) statutory_employee_indicator = BooleanField() - blank4 = BlankField(max_length=1) + blank5 = BlankField(max_length=1) retirement_plan_indicator = BooleanField() third_party_sick_pay = BooleanField() - blank5 = BlankField(max_length=23) + blank6 = BlankField(max_length=23) def validate_ssn(self, f): if str(f.value).startswith('666','9'):