def __init__(f, inputs={}): super(F1040, f).__init__(inputs) f.must_file = True f.addForm(f) if inputs['status'] == FilingStatus.JOINT: sse = [] for i in [0, 1]: inputs2 = copy.copy(inputs) for j in ['wages', 'wages_ss', 'business_income']: if j in inputs: inputs2[j] = inputs[j][i] x = F1040sse(inputs2) f.addForm(x) sse.append(x) else: sse = F1040sse(inputs) f.addForm(sse) f2441 = F2441(inputs, sse) f.addForm(f2441) f['6d'] = inputs['exemptions'] f['7'] = f.spouseSum(inputs, 'wages') + f2441['26'] f['8a'] = inputs.get('taxable_interest') f['8b'] = inputs.get('tax_exempt_interest') f['9a'] = inputs.get('dividends') f['9b'] = inputs.get('qualified_dividends') f['12'] = f.spouseSum(inputs, 'business_income') sd = F1040sd(inputs) f.addForm(sd) if sd.mustFile(): f['13'] = sd['21'] or sd['16'] else: f['13'] = inputs.get('capital_gain_dist') if 'F8606' in inputs: if inputs['status'] == FilingStatus.JOINT: f8606 = [ f.addForm(F8606(inputs, 0)), f.addForm(F8606(inputs, 1)) ] f['15b'] = (f8606[0]['15c'] + f8606[0]['18'] + f8606[0]['25'] + f8606[1]['15c'] + f8606[1]['18'] + f8606[1]['25']) \ or None else: f8606 = f.addForm(F8606(inputs, None)) f['15b'] = f8606.rowsum(['15c', '18', '25']) f['19'] = inputs.get('unemployment') f['22'] = f.rowsum([ '7', '8a', '9a', '10', '11', '12', '13', '14', '15b', '16b', '17', '18', '19', '20b', '21' ]) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['27'] = ((sse[0]['A6'] or sse[0]['B13'] or 0) + (sse[1]['A6'] or sse[1]['B13'] or 0)) else: if sse.mustFile(): f['27'] = sse['A6'] or sse['B13'] f['36'] = f.rowsum([ '23', '24', '25', '26', '27', '28', '29', '30', '31a', '32', '33', '34', '35' ]) f.comment['37'] = 'AGI' f['37'] = f['22'] - f['36'] f['38'] = f['37'] sa = F1040sa(inputs, f) std = f.STD_DED[inputs['status']] if 'itemize_deductions' in inputs: file_sched_a = inputs['itemize_deductions'] else: file_sched_a = sa['29'] > std if file_sched_a: f.comment['40'] = 'Itemized deductions' f['40'] = sa['29'] f.addForm(sa) else: # TODO: claimed as dependent or born before Jan 2, 1952 or blind f.comment['40'] = 'Standard deduction' f['40'] = std f['41'] = f['38'] - f['40'] f.comment['42'] = 'Exemptions' f['42'] = f.deduction_for_exemptions(inputs['status']) f.comment['43'] = 'Taxable income' f['43'] = max(0, f['41'] - f['42']) # TODO: Schedule D tax worksheet assert (not sd['18'] and not sd['19']) f.comment['44'] = 'Tax' f['44'] = f.div_cap_gain_tax_worksheet(inputs, sd)['27'] # Compute line 46 and 48 now because it's needed by AMT foreign_tax = inputs.get('foreign_tax', 0) assert (foreign_tax < 300 or (foreign_tax < 600 and inputs['status'] == FilingStatus.JOINT)) if foreign_tax: f['48'] = min(foreign_tax, f['44'] + f['46']) f6251 = F6251(inputs, f, sa if file_sched_a else None, sd) f.comment['45'] = 'AMT' f['45'] = f6251.get('35') f.addForm(f6251) f['47'] = f.rowsum(['44', '45', '46']) f['49'] = f2441.part2(f) f['52'] = f.child_tax_credit(inputs) f8801 = F8801(inputs, f, f6251) f['54'] = f8801.get('25') f.addForm(f8801) f.comment['55'] = 'Total credits' f['55'] = f.rowsum(['48', '49', '50', '51', '52', '53', '54']) f['56'] = max(0, f['47'] - f['55']) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['57'] = ((sse[0]['A5'] or sse[0]['B12'] or 0) + (sse[1]['A5'] or sse[1]['B12'] or 0)) else: if sse.mustFile(): f['57'] = sse['A5'] or sse['B12'] f8959 = F8959(inputs, f, sse) f8960 = F8960(inputs, f, sa if file_sched_a else None) f['62'] = f8959['18'] + f8960['17'] or None f.addForm(f8959) f.addForm(f8960) f.comment['63'] = 'Total tax' f['63'] = f.rowsum(['56', '57', '58', '59', '60a', '60b', '61', '62']) f['64'] = inputs.get('withholding', 0) + f8959['24'] f['65'] = inputs.get('estimated_payments') # TODO: EIC if inputs.get('ss_withheld'): if inputs['status'] == FilingStatus.JOINT: if inputs['ss_withheld'][0] > f.SS_MAX: f['71'] = inputs['ss_withheld'][0] - f.SS_MAX if inputs['ss_withheld'][1] > f.SS_MAX: f['71'] += inputs['ss_withheld'][1] - f.SS_MAX else: if inputs['ss_withheld'] > f.SS_MAX: f['71'] = inputs['ss_withheld'] - f.SS_MAX f.comment['74'] = 'Total payments' f['74'] = f.rowsum( ['64', '65', '66a', '67', '68', '69', '70', '71', '72', '73']) if f['74'] > f['63']: f.comment['75'] = 'Refund' f['75'] = f['74'] - f['63'] else: f.comment['78'] = 'Amount you owe' f['78'] = f['63'] - f['74']
def __init__(f, inputs={}): super(F1040, f).__init__(inputs) f.must_file = True f.addForm(f) if inputs['status'] == FilingStatus.JOINT: sse = [] for i in [0, 1]: inputs2 = copy.copy(inputs) for j in ['wages', 'wages_ss', 'business_income']: if j in inputs: inputs2[j] = inputs[j][i] x = F1040sse(inputs2) f.addForm(x) sse.append(x) else: sse = F1040sse(inputs) f.addForm(sse) f2441 = F2441(inputs, sse) f.addForm(f2441) f.comment['1'] = 'Wages' f['1'] = f.spouseSum(inputs, 'wages') + f2441['26'] f['2a'] = inputs.get('tax_exempt_interest') f.comment['2b'] = 'Taxable Interest' f['2b'] = inputs.get('taxable_interest') f['3a'] = inputs.get('qualified_dividends') f.comment['3b'] = 'Dividends' f['3b'] = inputs.get('dividends') if 'F8606' in inputs: if inputs['status'] == FilingStatus.JOINT: f8606 = [ f.addForm(F8606(inputs, 0)), f.addForm(F8606(inputs, 1)) ] f['4b'] = (f8606[0]['15c'] + f8606[0]['18'] + f8606[0]['25c'] + f8606[1]['15c'] + f8606[1]['18'] + f8606[1]['25c']) \ or None else: f8606 = f.addForm(F8606(inputs, None)) f['4b'] = f8606.rowsum(['15c', '18', '25c']) f.comment['6'] = 'Capital Gains' sd = F1040sd(inputs) f.addForm(sd) if sd.mustFile(): f['6'] = sd['21'] or sd['16'] else: f['6'] = inputs.get('capital_gain_dist') f['s1_1'] = inputs.get('state_refund_taxable') f['s1_3'] = f.spouseSum(inputs, 'business_income') f['s1_7'] = inputs.get('unemployment') f['s1_9'] = f.rowsum( ['s1_1', 's1_2a', 's1_3', 's1_4', 's1_5', 's1_6', 's1_7', 's1_8']) f['7a'] = f.get('s1_9') f.comment['7b'] = 'Total Income' f['7b'] = f.rowsum(['1', '2b', '3b', '4b', '4d', '5b', '6', '7a']) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['s1_14'] = ((sse[0]['A6'] or sse[0]['B13'] or 0) + (sse[1]['A6'] or sse[1]['B13'] or 0)) else: if sse.mustFile(): f['s1_14'] = sse['A6'] or sse['B13'] f['s1_22'] = f.rowsum([ 's1_10', 's1_11', 's1_12', 's1_13', 's1_14', 's1_15', 's1_16', 's1_17', 's1_18a', 's1_19', 's1_20', 's1_21' ]) f['8a'] = f.get('s1_22') f.comment['8b'] = 'AGI' f['8b'] = f['7b'] - f['8a'] sa = F1040sa(inputs, f) std = f.STD_DED[inputs['status']] if 'itemize_deductions' in inputs: sa.must_file = inputs['itemize_deductions'] else: sa.must_file = sa['17'] > std f.addForm(sa) if sa.mustFile(): f.comment['9'] = 'Itemized deductions' f['9'] = sa['17'] else: # TODO: claimed as dependent or born before Jan 2, 1955 or blind f.comment['9'] = 'Standard deduction' f['9'] = std # TODO: Qualified Business Income Deduction, form 8995 f['11a'] = f['9'] + f['10'] f.comment['11b'] = 'Taxable Income' f['11b'] = max(0, f['8b'] - f['11a']) # TODO: Schedule D tax worksheet assert (not sd['18'] and not sd['19']) f.comment['12a'] = 'Regular Tax' f['12a'] = f.div_cap_gain_tax_worksheet(inputs, sd)['27'] # Compute line s3_1 now because it's needed by AMT f.comment['s3_1'] = 'Foreign Tax Paid' foreign_tax = inputs.get('foreign_tax', 0) assert (foreign_tax < 300 or (foreign_tax < 600 and inputs['status'] == FilingStatus.JOINT)) if foreign_tax: f['s3_1'] = foreign_tax f6251 = F6251(inputs, f, sa if sa.mustFile() else None, sd, sd) f.comment['s2_1'] = 'AMT' f['s2_1'] = f6251.get('11') f.addForm(f6251) f['s2_3'] = f.rowsum(['s2_1', 's2_2']) f.comment['12b'] = 'Tax' f['12b'] = f['12a'] + f['s2_3'] f.comment['13a'] = 'Child Tax Credit' f['13a'] = f.child_tax_credit(inputs) f.comment['s3_2'] = 'Credit for child care expenses' f['s3_2'] = f2441.part2(f) f8801 = F8801(inputs, f, f6251) f['s3_6'] = f8801.get('25') f.addForm(f8801) f.comment['s3_7'] = 'Nonrefundable credits' f['s3_7'] = f.rowsum(['s3_1', 's3_2', 's3_3', 's3_4', 's3_5', 's3_6']) f.comment['13b'] = 'Total Credits' f['13b'] = f['13a'] + f['s3_7'] f['14'] = max(0, f['12b'] - f['13b']) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['s2_4'] = ((sse[0]['A5'] or sse[0]['B12'] or 0) + (sse[1]['A5'] or sse[1]['B12'] or 0)) else: if sse.mustFile(): f['s2_4'] = sse['A5'] or sse['B12'] f.comment['s2_8'] = 'NIIT and Additional Medicare Tax' f8959 = F8959(inputs, sse) f8960 = F8960(inputs, f, sa if sa.mustFile() else None) f['s2_8'] = f8959['18'] + f8960['17'] or None f.addForm(f8959) f.addForm(f8960) f['s2_10'] = f.rowsum( ['s2_4', 's2_5', 's2_6', 's2_7a', 's2_7b', 's2_8']) f.comment['15'] = 'Other Taxes' f['15'] = f['s2_10'] f.comment['16'] = 'Total Tax' f['16'] = f.rowsum(['14', '15']) f.comment['17'] = 'Withholding' f['17'] = inputs.get('withholding', 0) + f8959['24'] f['s3_8'] = inputs.get('estimated_payments') # TODO: EIC, Additional Child Tax Credit if inputs.get('ss_withheld'): if inputs['status'] == FilingStatus.JOINT: if inputs['ss_withheld'][0] > f.SS_MAX: f['s3_11'] = inputs['ss_withheld'][0] - f.SS_MAX if inputs['ss_withheld'][1] > f.SS_MAX: f['s3_11'] += inputs['ss_withheld'][1] - f.SS_MAX else: if inputs['ss_withheld'] > f.SS_MAX: f['s3_11'] = inputs['ss_withheld'] - f.SS_MAX f['s3_14'] = f.rowsum( ['s3_8', 's3_9', 's3_10', 's3_11', 's3_12', 's3_13']) f['18d'] = f['s3_14'] f.comment['18e'] = 'Refundable Credits' f['18e'] = f.rowsum(['18a', '18b', '18c', '18d']) f.comment['19'] = 'Total payments' f['19'] = f.rowsum(['17', '18e']) if f['19'] > f['16']: f.comment['20'] = 'Refund' f['20'] = f['19'] - f['16'] else: f.comment['23'] = 'Amount you owe' f['23'] = f['16'] - f['19']
def __init__(f, inputs={}): super(F1040, f).__init__(inputs) f.must_file = True f.addForm(f) if inputs['status'] == FilingStatus.JOINT: sse = [] for i in [0, 1]: inputs2 = copy.copy(inputs) for j in ['wages', 'wages_ss', 'business_income']: if j in inputs: inputs2[j] = inputs[j][i] x = F1040sse(inputs2) f.addForm(x) sse.append(x) else: sse = F1040sse(inputs) f.addForm(sse) f2441 = F2441(inputs, sse) f.addForm(f2441) f.comment['1'] = 'Wages' f['1'] = f.spouseSum(inputs, 'wages') + f2441['26'] f['2a'] = inputs.get('tax_exempt_interest') f['2b'] = inputs.get('taxable_interest') f['3a'] = inputs.get('qualified_dividends') f['3b'] = inputs.get('dividends') if 'F8606' in inputs: if inputs['status'] == FilingStatus.JOINT: f8606 = [ f.addForm(F8606(inputs, 0)), f.addForm(F8606(inputs, 1)) ] f['4b'] = (f8606[0]['15c'] + f8606[0]['18'] + f8606[0]['25c'] + f8606[1]['15c'] + f8606[1]['18'] + f8606[1]['25c']) \ or None else: f8606 = f.addForm(F8606(inputs, None)) f['4b'] = f8606.rowsum(['15c', '18', '25c']) f['s12'] = f.spouseSum(inputs, 'business_income') sd = F1040sd(inputs) f.addForm(sd) if sd.mustFile(): f['s13'] = sd['21'] or sd['16'] else: f['s13'] = inputs.get('capital_gain_dist') f['s10'] = inputs.get('state_refund_taxable') f['s19'] = inputs.get('unemployment') f['s22'] = f.rowsum([ 's10', 's11', 's12', 's13', 's14', 's15b', 's16b', 's17', 's18', 's19', 's20b', 's21' ]) f.comment['6'] = 'Total Income' f['6'] = f.rowsum(['1', '2b', '3b', '4b', '5b', 's22']) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['s27'] = ((sse[0]['A6'] or sse[0]['B13'] or 0) + (sse[1]['A6'] or sse[1]['B13'] or 0)) else: if sse.mustFile(): f['s27'] = sse['A6'] or sse['B13'] f['s36'] = f.rowsum([ 's23', 's24', 's25', 's26', 's27', 's28', 's29', 's30', 's31a', 's32', 's33', 's34', 's35' ]) f.comment['7'] = 'AGI' f['7'] = f['6'] - f['s36'] sa = F1040sa(inputs, f) std = f.STD_DED[inputs['status']] if 'itemize_deductions' in inputs: sa.must_file = inputs['itemize_deductions'] else: sa.must_file = sa['17'] > std f.addForm(sa) if sa.mustFile(): f.comment['8'] = 'Itemized deductions' f['8'] = sa['17'] else: # TODO: claimed as dependent or born before Jan 2, 1952 or blind f.comment['8'] = 'Standard deduction' f['8'] = std f.comment['10'] = 'Taxable Income' f['10'] = max(0, f['7'] - f['8'] - f['9']) # TODO: Schedule D tax worksheet assert (not sd['18'] and not sd['19']) f.comment['11a'] = 'Regular Tax' f['11a'] = f.div_cap_gain_tax_worksheet(inputs, sd)['27'] # Compute line s48 now because it's needed by AMT foreign_tax = inputs.get('foreign_tax', 0) assert (foreign_tax < 300 or (foreign_tax < 600 and inputs['status'] == FilingStatus.JOINT)) if foreign_tax: f['s48'] = foreign_tax f6251 = F6251(inputs, f, sa if sa.mustFile() else None, sd, sd) f.comment['s45'] = 'AMT' f['s45'] = f6251.get('11') f.addForm(f6251) f['s47'] = f.rowsum(['s45', 's46']) f.comment['11'] = 'Tax' f['11'] = f['11a'] + f['s47'] f['s49'] = f2441.part2(f) f.comment['12a'] = 'Child Tax Credit' f['12a'] = f.child_tax_credit(inputs) f8801 = F8801(inputs, f, f6251) f['s54'] = f8801.get('25') f.addForm(f8801) f.comment['s55'] = 'Nonrefundable credits' f['s55'] = f.rowsum(['s48', 's49', 's50', 's51', 's52', 's53', 's54']) f.comment['12'] = 'Total Credits' f['12'] = f['12a'] + f['s55'] f['13'] = max(0, f['11'] - f['12']) if inputs['status'] == FilingStatus.JOINT: if sse[0].mustFile() or sse[1].mustFile(): f['s57'] = ((sse[0]['A5'] or sse[0]['B12'] or 0) + (sse[1]['A5'] or sse[1]['B12'] or 0)) else: if sse.mustFile(): f['s57'] = sse['A5'] or sse['B12'] f8959 = F8959(inputs, sse) f8960 = F8960(inputs, f, sa if sa.mustFile() else None) f['s62'] = f8959['18'] + f8960['17'] or None f.addForm(f8959) f.addForm(f8960) f['s64'] = f.rowsum( ['s57', 's58', 's59', 's60a', 's60b', 's61', 's62']) f.comment['14'] = 'Other Taxes' f['14'] = f['s64'] f.comment['15'] = 'Total Tax' f['15'] = f.rowsum(['13', '14']) f.comment['16'] = 'Withholding' f['16'] = inputs.get('withholding', 0) + f8959['24'] f['s66'] = inputs.get('estimated_payments') if inputs.get('ss_withheld'): if inputs['status'] == FilingStatus.JOINT: if inputs['ss_withheld'][0] > f.SS_MAX: f['s72'] = inputs['ss_withheld'][0] - f.SS_MAX if inputs['ss_withheld'][1] > f.SS_MAX: f['s72'] += inputs['ss_withheld'][1] - f.SS_MAX else: if inputs['ss_withheld'] > f.SS_MAX: f['s72'] = inputs['ss_withheld'] - f.SS_MAX f['s75'] = f.rowsum(['s66', 's70', 's71', 's72', 's73', 's74']) # TODO: EIC f.comment['17'] = 'Refundable Credits' f['17'] = f['s75'] f.comment['18'] = 'Total payments' f['18'] = f.rowsum(['16', '17']) if f['18'] > f['15']: f.comment['19'] = 'Refund' f['19'] = f['18'] - f['15'] else: f.comment['22'] = 'Amount you owe' f['22'] = f['15'] - f['18']