Пример #1
0
def defaults(form):
    f = form
    f.ssn = ''
    f.name = ''
    f.is_1099_required = False
    f.is_1099_filed = False

    f.Part_I = Form()
    f.Part_II = Form()

    for letter in 'ABC':
        setattr(f.Part_I, letter, Form())
        sub = getattr(f.Part_I, letter)
        sub.address = ''
        sub.type = ''
        sub.fair_rental_days = 0
        sub.personal_use_days = 0
        sub.qjv = ''
        for i in range(3, 20):
            setattr(sub, 'line%d' % i, zero)

    for letter in 'ABCD':
        setattr(f.Part_II, letter, Form())
        sub = getattr(f.Part_II, letter)
        sub.name = ''
        sub.type = ''
        sub.is_foreign = False
        sub.ein = ''
        sub.any_not_at_risk = False
        for col in 'fghij':
            setattr(sub, col, zero)

    f.line40 = zero
    f.line42 = zero
    f.line43 = zero
Пример #2
0
def _build_example_row_2012():
    f = Form()
    f.a = f.b = f.c = ''
    f.d = f.e = zero
    f.f = ''
    f.g = zero
    return f
Пример #3
0
def _build_example_row_2012():
    f = Form()
    f.a = f.b = f.c = ''
    f.d = f.e = zero
    f.f = ''
    f.g = zero
    return f
Пример #4
0
 def test_attributes_remember_their_values(self):
     f = Form()
     f.y = 3
     f.x = 1
     f.z = 2
     assert f.x == 1
     assert f.y == 3
     assert f.z == 2
Пример #5
0
 def test_default_attributes_disappear_from_output(self):
     f = Form()
     f.x = 1
     f._enter_default_mode()
     f.x = -1
     f.y = -2
     f._enter_output_mode()
     f.z = -3
     assert f._inputs == ['x']
     assert f._outputs == ['z']
Пример #6
0
 def test_attributes_are_only_listed_once(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     f.w = 4
     f.w = 8
     f.z = 1
     assert f._inputs == ['y', 'x']
     assert f._outputs == ['z', 'w']
Пример #7
0
 def test_input_attributes_cannot_become_outputs(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     with self.assertRaises(TypeError):
         f.x = 4
Пример #8
0
def defaults(form):
    f = form
    f.name = ''
    f.ssn = ''

    f.carryover_worksheet = Form()

    cw = f.carryover_worksheet
    cw.previous_f1040_line41 = zero
    cw.previous_f1040sd_line7 = zero
    cw.previous_f1040sd_line15 = zero
    cw.previous_f1040sd_line21 = zero

    # Part I: Short-Term Capital Gains and Losses
    # Part II: Long-Term Capital Gains and Losses

    letters = 'efg' if f.form_version < '2012' else 'deg'

    for line in 1, 2, 3:
        for letter in letters:
            setattr(f, 'line{}{}'.format(line, letter), zero)

    f.line4 = f.line5 = zero

    for line in 8, 9, 10:
        for letter in letters:
            setattr(f, 'line{}{}'.format(line, letter), zero)

    f.line11 = f.line12 = f.line13 = zero

    # Part III: Summary

    f.line18 = f.line19 = zero
    f.line22 = None
Пример #9
0
 def test_attribute_assignment_is_ignored_in_default_mode(self):
     f = Form()
     f.x = 1
     f.A = Form()
     f.A.y = 2
     f._enter_default_mode()
     f.x = -1
     f.y = -2
     f.A.x = -3
     f.A.y = -4
     assert f.x == 1
     assert f.y == -2
     assert f.A.x == -3
     assert f.A.y == 2
Пример #10
0
 def test_attributes_remember_their_order(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     assert f._inputs == ['y', 'x']
     assert f._outputs == ['z']
Пример #11
0
 def test_json_output_handles_decimals_in_lists(self):
     f = Form()
     f.line1 = [["First Bank", Decimal('1.23')],
                ["Second Bank", Decimal('4.56')]]
     assert dump_json(f) == dedent(u'''\
         {
          "inputs": {
           "line1": [
            [
             "First Bank",
             "1.23"
            ],
            [
             "Second Bank",
             "4.56"
            ]
           ]
          },
          "outputs": {}
         }
         ''')
Пример #12
0
def defaults(form):
    f = form
    f.name = ''
    f.ssn = ''

    build_example_row = {
        '2011': _build_example_row_2011,
        '2012': _build_example_row_2012
    }[form.form_version]

    f.Part_I = Form()
    f.Part_I.box = 'A'
    f.Part_I.table = [
        build_example_row(),
        build_example_row(),
    ]

    f.Part_II = Form()
    f.Part_II.box = 'A'
    f.Part_II.table = [
        build_example_row(),
        build_example_row(),
    ]
Пример #13
0
def defaults(form):
    f = form
    f.payer = ''
    f.payer_number = ''
    f.recipient_number = ''
    f.recipient_name = ''
    f.recipient_street = ''
    f.recipient_city_state_zip = ''
    f.account_number = ''
    for n in range(1, 9):
        f['line', n] = zero
    f.line9 = False
    f.line10 = zero
    f.line11 = zero
    f.line12 = ''
    f.line13 = zero
    f.line14 = zero
    f.line15a = zero
    f.line15b = zero
    f.states = [Form(), Form()]
    for state in f.states:
        state.line16 = zero
        state.line17 = zero
        state.line18 = zero
Пример #14
0
 def test_dumping_form_includes_output_subforms(self):
     f = load_json('{"inputs": {"A": {"a": 1}}}')
     f._enter_output_mode()
     f.B = Form()
     f.B._enter_output_mode()
     f.B.b = 2
     j = dump_json(f)
     assert j == dedent(u'''\
         {
          "inputs": {
           "A": {
            "a": 1
           }
          },
          "outputs": {
           "B": {
            "b": 2
           }
          }
         }
         ''')
Пример #15
0
 def test_input_attributes_cannot_be_set_twice(self):
     f = Form()
     f.y = 3
     f.x = 1
     with self.assertRaises(TypeError):
         f.y = 5
Пример #16
0
 def empty_line():
     e = Form()
     e.code = ''
     e.amount = zero
     return e
Пример #17
0
def defaults(form):
    f = form
    f.income_beginning = u''
    f.income_ending = u''
    f.net_worth_beginning = u''
    f.net_worth_ending = u''
    f.type = 'original'
    # TODO: Boolean "change" fields
    f.ein = u''
    f.name = u''
    f.incorporation_date = u''
    f.withholding_number = u''
    f.nonresident_withholding_number = u''
    f.address = u''
    f.incorporation_state = u''
    f.sales_tax_number = u''
    f.city = u''
    f.state = u''
    f.zip = u''
    f.date_admitted = u''
    f.naics_code = u''
    f.books_city = u''
    f.books_state = u''
    f.books_phone = u''
    f.kind_of_business = u''
    f.total_shareholders = u''
    f.nonresident_shareholders = u''
    f.federal_ordinary_income = zero
    # TODO: latest taxable year

    f.s1 = s1 = Form()
    # TODO: schedule 2
    f.s3 = s3 = Form()
    f.s4 = s4 = Form()
    # TODO: schedule 5
    # TODO: schedule 6
    # TODO: schedule 7
    f.s8 = s8 = Form()
    f.s9 = s9 = Form()
    # TODO: schedule 10
    # TODO: schedule 11

    s1.line1 = zero

    s3.line1 = zero
    s3.line2 = zero
    s3.line3 = zero
    s3.line5 = Decimal('1.00')
    s3.line7 = zero  # TODO: do tax table lookup automatically

    s4.line2c = zero
    s4.line3c = zero  # TODO: implement Schedule 10?
    s4.line4c = zero

    if f.form_version >= u'2013':
        f.s7 = s7 = Form()
        s7.line1a = dollars(100)
        s7.line1b = dollars(100)

    s8.line1 = zero
    s8.line2 = zero
    s8.line3a = zero
    s8.line3b = zero
    s8.line4a = zero
    s8.line4b = zero
    s8.line4c = zero
    s8.line4d = zero
    s8.line4e = zero
    s8.line4f = zero
    s8.line5 = zero
    s8.line6 = zero

    s9.line2 = zero
    s9.line4 = Decimal('1.00')
    s9.line6 = zero

    # Fields added in 2013:

    f.email = u''
    f.email_authorization = False
    f.title = u''
Пример #18
0
 def empty_line():
     e = Form()
     e.code = ''
     e.amount = zero
     return e
Пример #19
0
 def test_setitem_gets_attributes(self):
     f = Form()
     f['y', 20] = 'Two'
     assert f['y', 20] == 'Two'
     assert f.y20 == 'Two'
Пример #20
0
 def test_getitem_gets_attributes(self):
     f = Form()
     f.x = 1
     f.y20 = 'Two'
     assert f['x'] == 1
     assert f['y', 20] == 'Two'
Пример #21
0
 def test_instantiation(self):
     Form()
Пример #22
0
def defaults(form):
    if form.form_version < u'2018':
        return defaults_pre_2018(form)

    f = form

    f.beginning_date = ''
    f.ending_date = ''
    f.ending_year = ''
    f.ein = ''
    f.name = ''
    f.street = ''
    f.city_state_zip = ''

    f.lineA = f.lineB = ''
    f.lineC = False
    f.lineE = ''
    f.lineF = zero
    f.lineG = False
    f.lineH = '12345'
    f.lineI = 1

    f.line1a = f.line1b = f.line2 = f.line4 = f.line5 = zero
    for n in range(7, 20):
        f['line', n] = zero
    f.line22a = f.line22b = f.line23a = f.line23b = f.line23c = zero
    f.line24 = zero
    f.line27_credited = zero

    f.signer_title = ''
    f.discuss = False

    f.B = Form()
    f.B.line1 = 'a'
    f.B.line2_activity = ''
    f.B.line2_product_or_service = ''
    f.B.line3 = False
    # 4a and 4b tables go here if we ever implement them
    f.B.line4a = []
    f.B.line4b = []
    f.B.line5ai = 0
    f.B.line5aii = 0
    f.B.line5bi = 0
    f.B.line5bii = 0
    f.B.line6 = False
    f.B.line7 = False
    f.B.line8 = zero
    f.B.line9 = False
    f.B.line10 = True if form.form_version < u'2018' else False
    f.B.line11 = True
    f.B.line12 = False
    f.B.line13 = False
    f.B.line14a = False
    f.B.line14b = None
    f.B.line15 = False

    f.K = Form()
    f.K.line2 = zero
    f.K.line3a = f.K.line3b = zero
    f.K.line4 = f.K.line5a = f.K.line5b = f.K.line6 = f.K.line7 = zero
    f.K.line8a = f.K.line8b = f.K.line8c = f.K.line9 = f.K.line10 = zero
    f.K.line10_type = ''
    f.K.line11 = f.K.line12a = f.K.line12b = f.K.line12c = f.K.line12d = zero
    f.K.line12c_type = ''
    f.K.line12d_type = ''
    f.K.line13a = f.K.line13b = f.K.line13c = f.K.line13d = zero
    f.K.line13e = f.K.line13f = f.K.line13g = zero
    f.K.line13d_type = ''
    f.K.line13e_type = ''
    f.K.line13g_type = ''
    for i in range(ord('a'), ord('m') + 1):
        f.K['line14', chr(i)] = zero
    f.K.line14n_accounting = 'a'
    for i in range(ord('a'), ord('f') + 1):
        f.K['line15', chr(i)] = zero
    for i in range(ord('a'), ord('e') + 1):
        f.K['line16', chr(i)] = zero
    f.K.line17a = f.K.line17b = f.K.line17c = zero

    f.M2 = Form()
    f.M2.line1a = zero
    f.M2.line3a = zero
    f.M2.line5a = zero
    f.M2.line7a = zero

    f.M2.line1b = zero
    f.M2.line3b = zero
    f.M2.line5b = zero
    f.M2.line7b = zero

    f.M2.line1c = zero
    f.M2.line7c = zero