int main( int argc, char *argv[] ) { int j, k, argk; char word[1000], outfname[1000], it201_xfdf_outfname[1000], it201d_xfdf_outfname[1000]; time_t now; int Dependent, Exemptions, nyc_resident; double itemized_ded, std_ded=0.0, LTC=0, AddAdj=0.0, CollegeDed=0.0; Lmap ded_sched; char prelim_1040_outfilename[5000]; /* Intercept any command-line arguments. */ printf("NY-IT201 - 2011 - v%3.1f\n", thisversion); argk = 1; k=1; while (argk < argc) { if (strcmp(argv[argk],"-verbose")==0) verbose = 1; else if (k==1) { infile = fopen(argv[argk],"r"); if (infile==0) {printf("ERROR: Parameter file '%s' could not be opened.\n", argv[argk]); exit(1);} k = 2; /* Base name of output file on input file. */ strcpy(outfname,argv[argk]); strcpy(it201_xfdf_outfname,argv[argk]); strcpy(it201d_xfdf_outfname,argv[argk]); j = strlen(outfname)-1; while ((j>=0) && (outfname[j]!='.')) j--; if (j<0) { strcat(outfname,"_out.txt"); strcat(it201_xfdf_outfname,"_it201.xfdf"); strcat(it201d_xfdf_outfname,"_it201d.xfdf"); } else { strcpy(&(outfname[j]),"_out.txt"); strcpy(&(it201_xfdf_outfname[j]),"_it201.xfdf"); strcpy(&(it201d_xfdf_outfname[j]),"_it201d.xfdf"); } outfile = fopen(outfname,"w"); if (outfile==0) {printf("ERROR: Output file '%s' could not be opened.\n", outfname); exit(1);} printf("Writing results to file: %s\n", outfname); } else {printf("Unknown command-line parameter '%s'\n", argv[argk]); exit(1);} argk = argk + 1; } if (infile==0) {printf("Error: No input file on command line.\n"); exit(1);} /* Pre-initialize all lines to zeros. */ for (j=0; j<MAX_LINES; j++) { L[j] = 0.0; ded_sched[j] = 0.0; } /* Accept parameters from input file. */ /* Expect NY IT200 form lines, something like: Title: NY IT-200 1999 Return L1 ; {Wages} L2 ; {Interest} L3 ; {Dividends} ... */ /* Accept Form's "Title" line, and put out with date-stamp for records. */ read_line( infile, word ); now = time(0); fprintf(outfile,"\n%s %s\n", word, ctime( &now )); get_parameter( infile, 's', word, "FileName" ); /* Preliminary Return Output File-name. */ get_word(infile, prelim_1040_outfilename ); if (ImportFederalReturnData( prelim_1040_outfilename, &PrelimFedReturn ) == 0) { fclose(infile); fclose(outfile); Display_File( outfname ); exit(1); } /* get_parameter(infile, kind, x, emssg ) */ // get_parameter( infile, 's', word, "Status" ); // get_parameter( infile, 'l', word, "Status?"); // if (strncasecmp(word,"Single",4)==0) status = SINGLE; else // if (strncasecmp(word,"Married/Joint",13)==0) status = MARRIED_FILLING_JOINTLY; else // if (strncasecmp(word,"Married/Sep",11)==0) status = MARRIED_FILLING_SEPARAT; else // if (strncasecmp(word,"Head_of_House",4)==0) status = HEAD_OF_HOUSEHOLD; else // if (strncasecmp(word,"Widow",4)==0) status = WIDOW; // else { printf("Error: unrecognized status '%s'. Exiting.\n", word); exit(1); } if (PrelimFedReturn.Itemized) L["itemized"] = 1; else L["did_not_itemize"] = 1; switch (status) { case SINGLE: L["Single"] = 1; break; case MARRIED_FILLING_SEPARAT: L["MFS"] = 1; break; case HEAD_OF_HOUSEHOLD: L["HOH"] = 1;; break; case MARRIED_FILLING_JOINTLY: L["MFJ"] = 1; break; case WIDOW: L["QW"] = 1; break; } fprintf(outfile,"Status = %s (%d)\n", statusnames[status], status); get_parameter( infile, 's', word, "Dependent" ); get_parameter( infile, 'b', &Dependent, "Dependent?"); if (Dependent==1) { fprintf(outfile," Check box C = Yes\n"); L["dependent"] = 1; } else { fprintf(outfile," Check box C = No\n"); L["not_dependent"] = 1; } // GetLineF( "L1", &L[1] ); /* Wages. */ L[1] = PrelimFedReturn.fedline[7]; showline(1); // GetLineF( "L2", &L[2] ); /* Taxable Interest. */ L[2] = PrelimFedReturn.fedline[8]; showline(2); // GetLineF( "L3", &L[3] ); /* Ordinary Dividends. */ L[3] = PrelimFedReturn.fedline[9]; showline(3); // GetLineF( "L4", &L[4] ); /* Taxable refunds, credits, offsets */ L[4] = PrelimFedReturn.fedline[10]; showline(4); // GetLineF( "L5", &L[5] ); /* Alimony received */ L[5] = PrelimFedReturn.fedline[11]; showline(5); // GetLineF( "L6", &L[6] ); /* Business income/loss (fed sched C) */ L[6] = PrelimFedReturn.fedline[12]; showline(6); // GetLineF( "L7", &L[7] ); /* Capital gains/losses (fed sched D) */ L[7] = PrelimFedReturn.fedline[13]; showline(7); // GetLineF( "L8", &L[8] ); /* Other gains/losses (fed form 4794) */ L[8] = PrelimFedReturn.fedline[14]; showline(8); // GetLineF( "L9", &L[9] ); /* Taxable IRA distributions */ L[9] = PrelimFedReturn.fedline[15]; showline(9); // GetLineF( "L10", &L[10] ); /* Taxable pension/annuity amounts */ L[10] = PrelimFedReturn.fedline[16]; showline(10); // GetLineF( "L11", &L[11] ); /* Rental, royalties, partnership, S corp, (fed sched E) */ L[11] = PrelimFedReturn.fedline[17]; showline(11); // GetLineF( "L13", &L[13] ); /* Farm income (fed sched F) */ L[13] = PrelimFedReturn.fedline[18]; showline(13); // GetLineF( "L14", &L[14] ); /* Unemployment compensation */ L[14] = PrelimFedReturn.fedline[19]; showline(14); // GetLineF( "L15", &L[15] ); /* Taxable Social Sec. benefits */ L[15] = PrelimFedReturn.fedline[20]; showline(15); L[27] = L[15]; // GetLineF( "L16", &L[16] ); /* Other income (pg. 14) */ L[16] = PrelimFedReturn.fedline[21]; showline(16); for (j = 1; j <= 11; j++) L[17] = L[17] + L[j]; for (j=13; j <= 16; j++) L[17] = L[17] + L[j]; showline(17); if (absolutev( L[17] - PrelimFedReturn.fedline[22]) > 0.1) { printf(" Warning: L[17] = %6.2f, while Fed-line[22] = %6.2f\n", L[17], PrelimFedReturn.fedline[22] ); fprintf(outfile," Warning: L[17] = %6.2f, while Fed-line[22] = %6.2f\n", L[17], PrelimFedReturn.fedline[22] ); } // GetLineF( "L18", &L[18] ); /* Total federal adjustments to income (pg 14) */ L[18] = PrelimFedReturn.fedline[36]; showline(18); L[19] = L[17] - L[18]; showline_wmsg( 19, "Federal adjusted gross income" ); if (absolutev(L[19] - PrelimFedReturn.fedline[38]) > 0.1) { printf(" Warning: L[19] = %6.2f, while Fed-line[38] = %6.2f\n", L[19], PrelimFedReturn.fedline[38] ); fprintf(outfile," Warning: L[19] = %6.2f, while Fed-line[38] = %6.2f\n", L[19], PrelimFedReturn.fedline[38] ); } GetLineF( "L20", &L[20] ); /* Interest income from non-NY state or local bonds */ GetLineF( "L21", &L[21] ); /* Public employee retirement contributions (pg 15) */ GetLineF( "L22", &L[22] ); /* College choice tuition saving distributions */ GetLineF( "L23", &L[23] ); /* Other (pg 16) */ for (j = 19; j <= 23; j++) L[24] = L[24] + L[j]; showline(24); L[25] = L[4]; /* Taxable refunds, credits, offsets */ showline(25); GetLineF( "L26", &L[26] ); /* Pensions of NYS and local governments and the federal government (see page 16) */ L[27] = L[14]; /* Taxable amount of social security benefits */ showline(27); GetLineF( "L28", &L[28] ); /* Interest income on U.S. government bonds */ GetLine( "L29", &L[29] ); /* Pension and annuity income exclusion */ if (L[29] > 20000.0) { L[29] = 20000.0; showline_wmsg( 29, "(Limited to 20,000.)" ); } else showline(29); GetLineF( "L30", &L[30] ); /* College choice tuition savings deduction / earnings distributions */ GetLineF( "L31", &L[31] ); /* Other (see page 21) */ for (j=25; j <= 31; j++) L[32] = L[32] + L[j]; showline(32); L[33] = L[24] - L[32]; showline_wmsg(33,"New York adjusted gross income (AGI)"); /* NYS Itemized Deductions Schedule, pg. 38 */ GetLine( "LTcare%", <C ); GetLine( "AddAdj", &AddAdj ); GetLine( "CollegeDed", &CollegeDed ); ded_sched[1] = PrelimFedReturn.schedA[4]; ded_sched[2] = PrelimFedReturn.schedA[9]; ded_sched[3] = PrelimFedReturn.schedA[15]; ded_sched[4] = PrelimFedReturn.schedA[19]; ded_sched[5] = PrelimFedReturn.schedA[20]; ded_sched[6] = PrelimFedReturn.schedA[27]; ded_sched[7] = PrelimFedReturn.schedA[28]; ded_sched[8] = PrelimFedReturn.schedA[29]; ded_sched[9] = PrelimFedReturn.schedA[5] + PrelimFedReturn.schedA[8] + LTC * PrelimFedReturn.schedA[4]; ded_sched[10] = ded_sched[8] - ded_sched[9]; ded_sched[11] = AddAdj; ded_sched[12] = ded_sched[10] + ded_sched[11]; if (L[33] <= 100000.0) ded_sched[13] = 0.0; else { /*L33_morethan_100000*/ double ws[50]; if (L[33] <= 475000.0) { /* Worksheet 3 pg 40 */ ws[1] = L[33]; switch (status) { case SINGLE: case MARRIED_FILLING_SEPARAT: ws[2] = 100000.0; break; case HEAD_OF_HOUSEHOLD: ws[2] = 150000.0; break; case MARRIED_FILLING_JOINTLY: case WIDOW: ws[2] = 200000.0; break; default: ws[2] = 0.0; } ws[3] = ws[1] - ws[2]; if (ws[3] < 0.0) ded_sched[13] = 0.0; else { ws[4] = smallerof( ws[3], 50000.0 ); ws[5] = 0.0001 * Round( 10000.0 * (ws[4] / 50000) ); ws[6] = 0.25 * ded_sched[1]; ws[7] = ws[5] * ws[6]; ded_sched[13] = ws[7]; } } else if (L[33] <= 525000.0) { /* Worksheet 4 pg 40 */ ws[1] = L[33] - 475000.0; ws[2] = 0.0001 * Round( 10000.0 * (ws[1] / 50000) ); ws[3] = 0.25 * ded_sched[1]; ws[4] = ws[2] * ws[3]; ws[5] = ws[3] + ws[4]; ded_sched[13] = ws[5]; } else if (L[33] <= 1000000.0) ded_sched[13] = 0.5 * ded_sched[12]; else if (L[33] <= 10000000.0) { /* Worksheet 5 pg 40 */ ws[1] = L[33]; ws[2] = 0.5 * ded_sched[4]; ws[3] = ws[1] - ws[2]; ded_sched[13] = ws[3]; } else { /* Worksheet 6 pg 40 */ ws[1] = L[33]; ws[2] = 0.25 * ded_sched[4]; ws[3] = ws[1] - ws[2]; ded_sched[13] = ws[3]; } } /*L33_morethan_100000*/ ded_sched[14] = ded_sched[12] - ded_sched[13]; ded_sched[15] = CollegeDed; ded_sched[16] = ded_sched[14] + ded_sched[15]; itemized_ded = ded_sched[16]; // GetLine( "Itemized_Deduction", &itemized_ded ); /* Form IT-201-ATT or 0.0 if std ded. */ switch (status) /* Determine the Std. Deduction. Pg. 18. */ { case SINGLE: if (Dependent) std_ded = 3100.0; else std_ded = 7800.0; break; case MARRIED_FILLING_JOINTLY: std_ded = 15650.0; break; case MARRIED_FILLING_SEPARAT: std_ded = 7800.0; break; case HEAD_OF_HOUSEHOLD: std_ded = 10950.0; break; case WIDOW: std_ded = 15650.0; break; } if (std_ded > itemized_ded) { L[34] = std_ded; L["ny_standard"] = 1; showline_wmsg(34,"(Mark Std-deduction)"); } else { L[34] = itemized_ded; L["ny_itemized"] = 1; showline_wmsg(34,"(Mark Itemized-deduction)"); } L[35] = L[33] - L[34]; if (L[35] < 0.0) L[35] = 0.0; else showline(35); get_parameter( infile, 's', word, "L36" ); /* Number of Dependent Exemptions (Pg 76, line e) */ get_parameters( infile, 'i', &k, "L36" ); L[36] = 1000.0 * (double)k; showline(36); L[37] = L[35] - L[36]; if (L[37] < 0.0) L[37] = 0.0; showline_wmsg(37,"taxable income"); L[38] = L[37]; showline(38); if (L[33] <= 104600.0) L[39] = TaxRateLookup( L[38], status ); else tax_computation_worksheet( status ); showline(39); /* Household credit. */ get_parameter( infile, 's', word, "Exemptions" ); /* NY dependent exemptions, Pg 19. */ get_parameter( infile, 'i', &Exemptions, "Exemptions" ); if (Dependent) L[40] = 0.0; else /* From tables starting on page 25. */ if (status==SINGLE) { if (L[19] < 5000.0) L[40] = 75.0; else if (L[19] < 6000.0) L[40] = 60.0; else if (L[19] < 7000.0) L[40] = 50.0; else if (L[19] < 20000.0) L[40] = 45.0; else if (L[19] < 25000.0) L[40] = 40.0; else if (L[19] < 28000.0) L[40] = 20.0; else L[40] = 0.0; } else /* Status = MARRIED_FILLING_JOINTLY, MARRIED_FILLING_SEPARAT, Head_of_house, Widow */ if (status!=MARRIED_FILLING_SEPARAT) { if (L[19] < 5000.0) L[40] = 90.0 + 15.0 * (Exemptions-1); else if (L[19] < 6000.0) L[40] = 75.0 + 15.0 * (Exemptions-1); else if (L[19] < 7000.0) L[40] = 65.0 + 15.0 * (Exemptions-1); else if (L[19] < 20000.0) L[40] = 60.0 + 15.0 * (Exemptions-1); else if (L[19] < 22000.0) L[40] = 60.0 + 10.0 * (Exemptions-1); else if (L[19] < 25000.0) L[40] = 50.0 + 10.0 * (Exemptions-1); else if (L[19] < 28000.0) L[40] = 40.0 + 5.0 * (Exemptions-1); else if (L[19] < 32000.0) L[40] = 20.0 + 5.0 * (Exemptions-1); else L[40] = 0.0; } else { if (L[19] < 5000.0) L[40] = 45.0 + 8.0 * (Exemptions-1); else if (L[19] < 6000.0) L[40] = 37.5 + 8.0 * (Exemptions-1); else if (L[19] < 7000.0) L[40] = 32.5 + 8.0 * (Exemptions-1); else if (L[19] < 20000.0) L[40] = 30.0 + 8.0 * (Exemptions-1); else if (L[19] < 22000.0) L[40] = 30.0 + 5.0 * (Exemptions-1); else if (L[19] < 25000.0) L[40] = 25.0 + 5.0 * (Exemptions-1); else if (L[19] < 28000.0) L[40] = 20.0 + 3.0 * (Exemptions-1); else if (L[19] < 32000.0) L[40] = 10.0 + 3.0 * (Exemptions-1); else L[40] = 0.0; } showline_wmsg(40,"NY state household credit"); /* NY state household credit, (pg 29). */ GetLineF( "L41", &L[41] ); /* Resident credit, Form IT-112-R or IT-112-C, pg 98 */ GetLineF( "L42", &L[42] ); /* Other New York State nonrefundable credits */ L[43] = L[40] + L[41] + L[42]; showline(43); L[44] = L[39] - L[43]; if (L[44] < 0.0) L[44] = 0.0; else showline(44); GetLineF( "L45", &L[45] ); /* Net Other New York State taxes, Form IT-201-ATT, line 30 */ L[46] = L[44] + L[45]; showline_wmsg(46,"Total New York State taxes"); get_parameter( infile, 's', word, "NYC_Resident" ); get_parameters( infile, 'b', &nyc_resident, "NYC_Resident (yes/no) ?"); GetLine( "L50", &L[50] ); /* Part-year New York City resident tax */ GetLine( "L51", &L[51] ); /* Other New York City taxes */ GetLine( "L53", &L[53] ); /* NY City nonrefundable credits */ if (nyc_resident) { /*NYC*/ L[47] = NYcityTaxRateFunction( L[38], status ); showline(47); /* NYC Household credit. */ if (Dependent) L[48] = 0.0; else if (status==SINGLE) /* From table 4, 5, or 6 on page 30. */ { if (L[19] < 10000.0) L[48] = 15.0; else if (L[19] < 12500.0) L[48] = 10.0; else L[48] = 0.0; } else /* Status = 2, 4, or 5. */ if (status!=MARRIED_FILLING_SEPARAT) { if (L[19] < 15000.0) L[48] = 30.0 * Exemptions; else if (L[19] < 17500.0) L[48] = 25.0 * Exemptions; else if (L[19] < 20000.0) L[48] = 15.0 * Exemptions; else if (L[19] < 22500.0) L[48] = 10.0 * Exemptions; else L[48] = 0.0; } else { if (L[19] < 15000.0) L[48] = 15.0 * Exemptions; else if (L[19] < 17500.0) L[48] = 13.0 * Exemptions; else if (L[19] < 20000.0) L[48] = 8.0 * Exemptions; else if (L[19] < 22500.0) L[48] = 5.0 * Exemptions; else L[48] = 0.0; } showline_wmsg(48,"NY City household credit"); /* NY City household credit, (pg 34). */ L[49] = L[47] - L[48]; if (L[49] > 0.0) showline(49); else L[49] = 0.0; showline(50); showline(51); L[52] = L[49] + L[50] + L[51]; showline(52); showline(53); L[54] = L[52] - L[53]; if (L[54] > 0.0) showline(54); else L[54] = 0.0; /* Yonkers case not added. */ L[58] = L[54] + L[55] + L[56] + L[57]; showline_wmsg(58,"NYC taxes"); } /*NYC*/ GetLineF( "L59", &L[59] ); /* Sales or use tax, see pg 29. */ GetLineF( "L60", &L[60] ); /* Voluntary Gift contibutions (pgs 30). */ L[61] = L[46] + L[58] + L[59] + L[60]; showline(61); L[62] = L[61]; showline(62); GetLineF( "L63", &L[63] ); /* Empire State child credit (attach new Form IT-213) */ GetLineF( "L64", &L[64] ); /* NYS/NYC Child care/dependent credit. Form IT-216. */ GetLineF( "L65", &L[65] ); /* NYS Earned income credit. Form IT-213. */ GetLineF( "L66", &L[66] ); /* NYS State noncustodial parent EIC (attach new Form IT-209) */ GetLineF( "L67", &L[67] ); /* Real property credit. Form IT-214. */ GetLineF( "L68", &L[68] ); /* College tution credit. Form IT-272. */ if (nyc_resident) /* City of NY school taxcredit. (pg 26) */ { /*NYC*/ if (Dependent) L[69] = 0.0; else if (L[37] < 250000) { if ((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT) || (status==HEAD_OF_HOUSEHOLD)) L[69] = 63.0; else if ((status==MARRIED_FILLING_JOINTLY) || (status==WIDOW)) L[69] = 125.0; } else L[69] = 0.0; showline(69); /* L[70] = earned_income_credit; */ /* showline(70); */ } /*NYC*/ GetLineF( "L71", &L[71] ); /* Other refundable credits, IT-201-ATT line 18) */ GetLineF( "L72", &L[72] ); /* Total NY State tax withheld. */ GetLineF( "L73", &L[73] ); /* Total City of NY tax withheld. */ GetLineF( "L74", &L[74] ); /* Yonkers tax withheld. */ GetLineF( "L75", &L[75] ); /* Total estimated tax payments (from IT-370)*/ for (j = 63; j <= 75; j++) L[76] = L[76] + L[j]; showline(76); if (L[76] > L[62]) { L[77] = L[76] - L[62]; fprintf(outfile,"L77 = %6.2f REFUND !!!\n", L[77] ); L[78] = L[77]; showline(78); } else { L[80] = L[62] - L[76]; fprintf(outfile,"L80 = %6.2f YOU OWE !!!\n", L[80] ); } fclose(infile); fclose(outfile); outfile = fopen(it201_xfdf_outfname,"w"); output_xfdf_form_data(outfile, it201_2014, L); fclose(outfile); if (std_ded < itemized_ded) { outfile = fopen(it201d_xfdf_outfname,"w"); output_xfdf_form_data(outfile, it201d_2014, ded_sched); fclose(outfile); } printf("\nListing results from file: %s\n\n", outfname); Display_File( outfname ); return 0; }
int main( int argc, char *argv[] ) { int i, j, k; char word[1000], outfname[4000], nj1040_outfname[4000], nj1040_sched_a_outfname[4000]; int status=0; time_t now; int L12a=0, L12b=0; double L27a=0.0, L27b=0.0, L29a=0.0, L29b=0.0, L37a=0.0; double Ab[10], A9a=0.0, proptxcredit; double F[10], Fb[10]; /* Schedule F, added by BWB. */ double I[10], Ib[10]; /* Schedule I. */ /* Intercept any command-line arguments. */ printf("NJ 1040 2014 - v%3.1f\n", thisversion); i = 1; k=1; while (i < argc) { if (strcmp(argv[i],"-verbose")==0) verbose = 1; else if (k==1) { infile = fopen(argv[i],"r"); if (infile==0) { printf("ERROR: Parameter file '%s' could not be opened.\n", argv[i]); exit(1); } k = 2; /* Base name of output file on input file. */ strcpy(outfname,argv[i]); strcpy(nj1040_outfname,argv[i]); strcpy(nj1040_sched_a_outfname,argv[i]); j = strlen(outfname)-1; while ((j>=0) && (outfname[j]!='.')) j--; if (j<0) { strcat(outfname,"_out.txt"); strcat(nj1040_outfname,"_nj1040.xfdf"); strcat(nj1040_sched_a_outfname,"nj1040abc.xfdf"); } else { strcpy(&(outfname[j]),"_out.txt"); strcpy(&(nj1040_outfname[j]),"_nj1040.xfdf"); strcpy(&(nj1040_sched_a_outfname[j]),"_nj1040abc.xfdf"); } outfile = fopen(outfname,"w"); if (outfile==0) { printf("ERROR: Output file '%s' could not be opened.\n", outfname); exit(1); } printf("Writing results to file: %s\n", outfname); } else { printf("Unknown command-line parameter '%s'\n", argv[i]); exit(1); } i = i + 1; } if (infile==0) { printf("Error: No input file on command line.\n"); exit(1); } /* Pre-initialize all lines to zeros. */ for (i=0; i<MAX_LINES; i++) { L[i] = 0.0; A[i] = 0.0; S[i] = 0.0; E[i] = 0.0; } /* Accept parameters from input file. */ /* Expect NJ-1040 lines, something like: Title: NJ 1040 1999 Return L14 {Wages} L15a {Interest} L16 {Dividends} L18 {Capital Gains} S1 {Property Tax} L42 {Witheld tax, from W-2} */ /* Accept Form's "Title" line, and put out with date-stamp for records. */ read_line( infile, word ); now = time(0); fprintf(outfile,"\n%s %s\n", word, ctime( &now )); /* get_parameter(infile, kind, x, mesage ) */ get_parameter( infile, 's', word, "Status" ); get_parameter( infile, 'l', word, "Status ?"); if (strncasecmp(word,"Single",4)==0) { status = SINGLE; L["Single"] = 1; } else if (strncasecmp(word,"Married/Joint",13)==0) { status = MARRIED_FILLING_JOINTLY; L["MFJ"] = 1; } else if (strncasecmp(word,"Married/Sep",11)==0) { status = MARRIED_FILLING_SEPARAT; L["MFS"] = 1; } else if (strncasecmp(word,"Head_of_House",4)==0) { status = HEAD_OF_HOUSEHOLD; L["HOH"] = 1; } else if (strncasecmp(word,"Widow",4)==0) { status = WIDOW; L["QW"] = 1; } else { printf("Error: unrecognized status '%s'. Must be: Single, Married/joint, Married/sep, Head_of_house, Widow(er)\nExiting.\n", word); fprintf(outfile,"Error: unrecognized status '%s'. Must be: Single, Married/joint, Married/sep, Head_of_house, Widow(er)\nExiting.\n", word); exit(1); } switch (status) { case SINGLE: fprintf(outfile,"Status = Single (%d)\n", status); break; case MARRIED_FILLING_JOINTLY: fprintf(outfile,"Status = Married/Joint (%d)\n", status); break; case MARRIED_FILLING_SEPARAT: fprintf(outfile,"Status = Married/Sep (%d)\n", status); break; case HEAD_OF_HOUSEHOLD: fprintf(outfile,"Status = Head_of_Household (%d)\n", status); break; case WIDOW: fprintf(outfile,"Status = Widow(er) (%d)\n", status); break; } get_parameter( infile, 's', word, "L6" ); /* Exemptions, self/spouse. */ get_parameter( infile, 'i', &j, "L6"); L[6] = j; shownum(6); get_parameter( infile, 's', word, "L7" ); /* Exemptions, Over 65. */ get_parameter( infile, 'i', &j, "L7"); L[7] = j; shownum(7); get_parameter( infile, 's', word, "L8" ); /* Exemptions, Blind/disabled. */ get_parameter( infile, 'i', &j, "L8"); L[8] = j; shownum(8); get_parameter( infile, 's', word, "L9" ); /* Exemptions, children. */ get_parameter( infile, 'i', &j, "L9"); L[9] = j; shownum(9); get_parameter( infile, 's', word, "L10" ); /* Exemptions, other dependents. */ get_parameter( infile, 'i', &j, "L10"); L[10] = j; shownum(10); get_parameter( infile, 's', word, "L11" ); /* Exemptions, college kids. */ get_parameter( infile, 'i', &j, "L11"); L[11] = j; shownum(11); L12a = L[6] + L[7] + L[8] + L[11]; L["12a"] = L12a; fprintf(outfile,"L12a = %d\n", L12a); L12b = L[9] + L[10]; L["12b"] = L12b; fprintf(outfile,"L12b = %d\n", L12b); GetLineF( "L14", &L[14] ); /* Wages. */ GetLineF( "L15a", &L[15] ); /* Taxable Interest. */ /* Form asks for tax-exempt income, but does not use it. */ GetLineF( "L16", &L[16] ); /* Dividends. */ GetLine( "L17", &L[17] ); /* Business profits, Fed Sched C. */ if (L[17] < 0.0) L[17] = 0.0; showline(17); GetLine( "L18", &L[18] ); /* Capital Gains . */ if (L[18] < 0.0) L[18] = 0.0; showline(18); GetLineF( "L19", &L[19] ); /* Pensions, Annuities, and IRA Withdrawals (pg 20). */ GetLineF( "L20", &L[20] ); /* Partnership income. (See pg 24.) */ GetLineF( "L21", &L[21] ); /* S Corporation income. (See pg 24.) */ GetLineF( "L22", &L[22] ); /* Rent, royalty, patents income. (Sched NJ-BUS-1, Part IV, Line 4.) */ GetLineF( "L23", &L[23] ); /* Net gambling winnings. */ GetLineF( "L24", &L[24] ); /* Alimony and maintenance payments RECEIVED. */ GetLineF( "L25", &L[25] ); /* Other (See pg 24). */ L[26] = L[14] + L[15] + L[16] + L[17] + L[18] + L[19] + L[20] + L[21] + L[22] + L[23] + L[24] + L[25]; showline_wmsg(26,"Total Income"); /* Total Income. */ GetLineF( "L27a", &L27a ); /* Pension Exclusion (See pg 26). */ GetLineF( "L27b", &L27b ); /* Other Retirement Income Exclusion (See worksheet pg 26). */ L["27a"] = L27a; L["27b"] = L27b; L[27] = L27a + L27b; L["27c"] = L[27]; showline(27); L[28] = L[26] - L[27]; showline_wmsg(28,"NJ Gross Income"); if ((status == SINGLE) || (status == MARRIED_FILLING_SEPARAT)) { if (L[28] < 10000.0) fprintf(outfile," --- You do not need to file, (except to get refund). Income < $10,000. ---\n"); } else { if (L[28] < 20000.0) fprintf(outfile," --- You do not need to file, (except to get refund). Income < $20,000. ---\n"); } L29a = L12a * 1000.0; fprintf(outfile," L29a = %6.2f\n", L29a ); L29b = L12b * 1500.0; fprintf(outfile," L29b = %6.2f\n", L29b ); L[29] = L29a + L29b; fprintf(outfile,"L29c = %6.2f Total Exemption Amount\n", L[29] ); fprintf(outfile,"\n"); GetLine( "E1", &E[1] ); /* Medical Expenses (See pg 27). */ showline_wrksht('E',1,E); E[2] = 0.02 * L[28]; showline_wrksht('E',2,E); E[3] = NotLessThanZero( E[1] - E[2] ); showline_wrksht('E',3,E); GetLine( "E4", &E[4] ); /* Qualified Archer MSA contributions from Federal Form 8853 */ showline_wrksht('E',4,E); GetLine( "E5", &E[5] ); /* Amount of self-employed health insurance deduction */ showline_wrksht('E',5,E); E[6] = NotLessThanZero( E[3] + E[4] + E[5] ); showline_wrksht('E',6,E); fprintf(outfile,"\n"); L[30] = E[6]; if (L[30] != 0.0) showline_wmsg(30," Medical Expenses Worksheet E (See pg 27)"); /* end of Worksheet E */ GetLineF( "L31", &L[31] ); /* Alimony and maintenance payments PAYED. */ GetLineF( "L32", &L[32] ); /* Qualified Conservation Contribution. */ GetLineF( "L33", &L[33] ); /* Health Enterprise Zone Deduction. */ GetLineF( "L34", &L[34] ); /* Alternative Business Calc Adj (Sched NJ-BUS-2, Line 11). */ L[35] = L[29] + L[30] + L[31] + L[32] + L[33] + L[34]; showline_wmsg(35,"Total Exemptions and Deductions"); /* Taxable income. */ L[36] = L[28] - L[35]; if (L[36] > 0.0) showline_wmsg(36, "(Taxable Income)"); GetLineF( "L37a", &L37a ); /* Property Tax Paid. */ L[37] = L37a; GetLine( "A1", &A[1] ); /* Income taxed by other jurisdictions, if any. */ GetLine( "A9a", &A9a ); /* Tax paid to other jurisdictions on that income, if any. */ fprintf(outfile,"\n"); /* Tax deduction worksheet F (pg 34). */ F[1] = L37a; showline_wrksht('F',1,F); if (status != MARRIED_FILLING_SEPARAT) F[2] = smallerof( F[1], 10000.0 ); else F[2] = smallerof( F[1], 5000.0 ); showline_wrksht('F',2,F); if (status != MARRIED_FILLING_SEPARAT) proptxcredit = 50.0; else proptxcredit = 25.0; if (A9a == 0.0) { /*Worksheet-F*/ F[3] = L[36]; Fb[3] = L[36]; fprintf(outfile," F3a = %6.2f F3b = %6.2f\n", F[3], Fb[3]); F[4] = F[2]; Fb[4] = 0.0; fprintf(outfile," F4a = %6.2f F4b = %6.2f\n", F[4], Fb[4]); F[5] = F[3] - F[4]; Fb[5] = Fb[3] - Fb[4]; fprintf(outfile," F5a = %6.2f F5b = %6.2f\n", F[5], Fb[5]); F[6] = TaxRateFunction( F[5], status ); Fb[6] = TaxRateFunction( Fb[5], status ); fprintf(outfile," F6a = %6.2f F6b = %6.2f\n", F[6], Fb[6]); F[7] = Fb[6] - F[6]; showline_wrksht('F',7,F); if (F[7] >= proptxcredit) { /*yes*/ fprintf(outfile," F8. Yes. (Take Property Tax Deduction.)\n"); L[38] = F[4]; L[39] = F[5]; L[40] = F[6]; L[49] = 0.0; } /*yes*/ else { /*no*/ fprintf(outfile," F8. No. (Take Property Tax Credit.)\n"); L[38] = 0.0; L[39] = Fb[5]; L[40] = Fb[6]; L[49] = proptxcredit; } /*no*/ } /*Worksheet-F*/ else { /*SchedA+Worksheet-I*/ fprintf(outfile,"\nSchedule A:\n"); fprintf(outfile," %c%d = %6.2f\n", 'A', 1, A[1]); A[2] = L[28]; fprintf(outfile," %c%d = %6.2f\n", 'A', 2, A[2]); A[3] = smallerof( 1.0, (A[1] / A[2]) ); fprintf(outfile," A3 = %6.2f %%\n", 100.0 * A[3] ); A["3p"] = 100.0*A[3]; A[4] = L[36]; A["4a"] = L[36]; A["4b"] = L[36]; fprintf(outfile," A4a = %6.2f A4b = %6.2f\n", A[4], A[4] ); fprintf(outfile," (5a = %6.2f)\n", F[1] ); A["5a"] = F[1]; A[5] = F[2]; A["5aa"] = F[2]; fprintf(outfile," A5a = %6.2f A5b = %6.2f\n", A[5], 0.0); A[6] = A[4] - A[5]; A["6a"] = A[6]; Ab[6] = A[4] - 0.0; A["6b"] = Ab[6]; fprintf(outfile," A6a = %6.2f A6b = %6.2f\n", A[6], Ab[6]); A[7] = TaxRateFunction( A[6], status ); A["7a"] = A[7]; Ab[7] = TaxRateFunction( Ab[6], status ); A["7b"] = Ab[7]; fprintf(outfile," A7a = %6.2f A7b = %6.2f\n", A[7], Ab[7] ); A[8] = A[3] * A[7]; A["8a"] = A[8]; Ab[8] = A[3] * Ab[7]; A["8b"] = Ab[8]; fprintf(outfile," A8a = %6.2f A8b = %6.2f\n", A[8], Ab[8] ); fprintf(outfile," (9a = %6.2f)\n", A9a ); A["9a"] = A9a; A[9] = smallerof( smallerof( A9a, A[8] ), A[7] ); A["9aa"] = A[8]; Ab[9] = smallerof( smallerof( A9a, Ab[8] ), Ab[7] ); A["9ab"] = Ab[9]; fprintf(outfile," A9a = %6.2f A9b = %6.2f\n", A[9], Ab[9] ); fprintf(outfile,"\nWorksheet I:\n"); I[1] = A[7]; Ib[1] = Ab[7]; fprintf(outfile," I1a = %6.2f I1b = %6.2f\n", I[1], Ib[1] ); I[2] = A[9]; Ib[2] = Ab[9]; fprintf(outfile," I2a = %6.2f I2b = %6.2f\n", I[2], Ib[2] ); I[3] = I[1] - I[2]; Ib[3] = Ib[1] - Ib[2]; fprintf(outfile," I3a = %6.2f I3b = %6.2f\n", I[3], Ib[3] ); Ib[4] = Ib[3] - I[3]; showline_wrksht('I', 4, Ib); if (Ib[4] >= proptxcredit) { fprintf(outfile," Sched-I, Yes: Take PropTax Deduction\n\n"); L[38] = A[5]; // fprintf(outfile,"L36c = %6.2f\n", L[36]); L[39] = A[6]; L[40] = A[7]; L[41] = I[2]; L[49] = 0.0; } else { fprintf(outfile," Sched-I, No: Take PropTax Credit\n\n"); L[38] = 0.0; L[39] = Ab[6]; L[40] = Ab[7]; L[41] = Ib[2]; L[49] = proptxcredit; } } /*SchedA+Worksheet-I*/ /* If no property tax was paid, ensure prop.tax credit is set to 0 */ if ( L37a == 0.0 ) L[49] = 0.0; if (L[37] > 0.0) fprintf(outfile, "L37c = %6.2f\n", L[37]); showline(39); fprintf(outfile,"\n"); /* NJ Taxable Income.*/ // L[39] = L[36] - L[38]; /* Handled above in Sched-1. */ if (L[39] > 0.0) showline_wmsg(39, "NJ Taxable Income"); // L[40] = TaxRateFunction( L[39], status ); /* Handled above in Schedules+Worksheets, A, F, H. */ showline_wmsg(40, "TAX"); if (A[1] > 0.0) showline_wmsg(41, "( Credit for Taxes paid to other jurisdictions. )\n"); L[42] = L[40] - L[41]; showline_wmsg(42, "( Balance of Tax )"); GetLineF( "L43", &L[43] ); /* Sheltered Workshop Tax Credit. */ L[44] = L[42] - L[43]; showline(44); GetLineF( "L45", &L[45] ); /* Use Tax Due on Out-of-State Purchases (pg 35). */ GetLineF( "L46", &L[46] ); /* Penalty for underpayment of estimated tax. */ L[47] = L[44] + L[45] + L[46]; showline(47); /* Total Tax + Penalty. */ GetLine( "L48", &L[48] ); showline_wmsg(48, "Total NJ Income Tax Withheld"); showline_wmsg(49, "Property tax Credit"); GetLineF( "L50", &L[50] ); /* NJ Estimated Tax Payments/Credit from last year's return. */ GetLineF( "L51", &L[51] ); /* NJ Earned Income Tax Credit. (See Sched pg 38.) */ GetLineF( "L52", &L[52] ); /* EXCESS NJ UI/HC/WD Withheld, (See pg 38.) */ GetLineF( "L53", &L[53] ); /* EXCESS NJ Disability Insurance Withheld, (See pg 38.) */ GetLineF( "L54", &L[54] ); /* EXCESS NJ Family Leave Insurance Withheld, (See pg 38.) */ L[55] = L[48] + L[49] + L[50] + L[51] + L[52] + L[53] + L[54]; showline_wmsg(55,"Total Payments/Credits"); if (L[55] < L[47]) { L[56] = L[47] - L[55]; fprintf(outfile, "L56 = %6.2f YOU OWE !!!\n", L[56] ); } else { L[57] = L[55] - L[47]; fprintf(outfile, "L57 = %6.2f Overpayment\n", L[57] ); L[65] = 0.0; showline_wmsg(65, "( Total Contributions from overpayment )"); L[66] = L[57] - L[65]; showline_wmsg(66, "Refund !!!"); } fclose(infile); fclose(outfile); outfile = fopen(nj1040_outfname,"w"); output_xfdf_form_data(outfile, nj1040_2014, L); fclose(outfile); outfile = fopen(nj1040_sched_a_outfname,"w"); output_xfdf_form_data(outfile, nj_schedule_a_2014, A); fclose(outfile); Display_File( outfname ); printf("\nResults written to file: %s\n", outfname); return 0; }
int main( int argc, char *argv[] ) { int i, j, k; char word[1000], outfname[1000], it1040_xfdf_outfname[1000]; int status=0, exemptions=0, qualify_jfc=0; time_t now; double factor62, factor67, limit; double L35a=0.0, L35b=0.0, L35c=0.0, L35d=0.0, L35e=0.0, L35f=0.0, L35g=0.0; double L37a=0.0, L37b=0.0, L39a=0.0, L39b=0.0; double L40a=0.0, L40b=0.0, L40c=0.0; double L44a=0.0, L44b=0.0; double L46a=0.0, L46b=0.0, L46c=0.0; double L72a=0.0, L72b=0.0, L72c=0.0, L72d=0.0, L72e=0.0; double jfc, exemption_amnt; /* Intercept any command-line arguments. */ printf("OH IT1040 2014 - v%3.1f\n", thisversion); i = 1; k=1; while (i < argc) { if (strcmp(argv[i],"-verbose")==0) verbose = 1; else if (k==1) { infile = fopen(argv[i],"r"); if (infile==0) {printf("ERROR: Parameter file '%s' could not be opened.\n", argv[i]); exit(1);} k = 2; /* Base name of output file on input file. */ strcpy(outfname,argv[i]); strcpy(it1040_xfdf_outfname,argv[i]); j = strlen(outfname)-1; while ((j>=0) && (outfname[j]!='.')) j--; if (j<0) { strcat(outfname,"_out.txt"); strcat(it1040_xfdf_outfname,"_it1040.xfdf"); } else { strcpy(&(outfname[j]),"_out.txt"); strcpy(&(it1040_xfdf_outfname[j]),"_it1040.xfdf"); } outfile = fopen(outfname,"w"); if (outfile==0) {printf("ERROR: Output file '%s' could not be opened.\n", outfname); exit(1);} printf("Writing results to file: %s\n", outfname); } else {printf("Unknown command-line parameter '%s'\n", argv[i]); exit(1);} i = i + 1; } if (infile==0) {printf("Error: No input file on command line.\n"); exit(1);} /* Pre-initialize all lines to zeros. */ for (i=0; i<MAX_LINES; i++) { L[i] = 0.0; } /* Accept parameters from input file. */ /* Expect OH IT1040 lines, something like: Title: OH IT1040 1999 Return L1 {Wages} */ /* Accept Form's "Title" line, and put out with date-stamp for records. */ read_line( infile, word ); now = time(0); fprintf(outfile,"\n%s %s\n", word, ctime( &now )); /* get_parameter(infile, kind, x, emssg ) */ get_parameter( infile, 's', word, "Status" ); get_parameter( infile, 'l', word, "Status ?"); if (strncasecmp(word,"Single",4)==0) { status = SINGLE; L["Single"] = 1; } else if (strncasecmp(word,"Married/Joint",11)==0) { status = MARRIED_FILLING_JOINTLY; L["MFJ"] = 1; }else if (strncasecmp(word,"Married/Sep",11)==0) { status = MARRIED_FILLING_SEPARAT; L["MFS"] = 1; }else if (strncasecmp(word,"Head_of_House",4)==0) { status = HEAD_OF_HOUSEHOLD; L["HOH"] = 1; } else { printf("Error: unrecognized status '%s'. Must be: Single, Married/joint, Married/sep, Head_of_house.\nExiting.\n", word); fprintf(outfile,"Error: unrecognized status '%s'. Must be: Single, Married/joint, Married/sep, Head_of_house.\nExiting.\n", word); exit(1); } fprintf(outfile,"Status = %s (%d)\n", word, status); GetLine( "L1", &L[1] ); /* Federal Adjusted Gross Income */ get_parameter( infile, 's', word, "Exemptions" ); /* Exemptions, self/depend. */ get_parameters( infile, 'i', &exemptions, "Exemptions"); /* Answer YES only if Married Filing Jointly, and you and your spouse */ /* each have qualifying Ohio adjusted gross income of at least $500. */ get_parameter( infile, 's', word, "JointCredit" ); get_parameter( infile, 'b', &qualify_jfc, "JointCredit ?"); GetLine( "L14", &L[14] ); /* Earned income credit (see the worksheet on page 20). */ GetLine( "L15", &L[15] ); /* Ohio adoption credit ($1,500 per child adopted during the year). */ GetLine( "L16", &L[16] ); /* Manufacturing equipment grant. */ GetLine( "L19", &L[19] ); /* Unpaid Ohio Use Tax */ GetLine( "L21", &L[21] ); /* Ohio Tax Withheld (box 17 on your W-2) */ GetLine( "L22", &L[22] ); /* 1040ES payments, IT 40P extension payments for 2014, 2013 overpayments ... */ /* Additions - add to extent not included in fed adjusted gross income (line 1). */ GetLine( "L33", &L[33] ); /* Non-Ohio state or local gov't interest, dividends. */ GetLine( "L34", &L[34] ); /* Pass-through Entity addback. */ GetLine( "L35a", &L35a ); /* Fed int+div subject to state tax & misc. fed adj. */ L["35a"] = L35a; GetLine( "L35b", &L35b ); /* Reimbursed college tuit. fees deducted prev yrs. */ L["35b"] = L35b; GetLine( "L35c", &L35c ); /* Losses, sale of Ohio Public Obligations. */ L["35c"] = L35c; GetLine( "L35d", &L35d ); /* Nonmedical withdrawals OH Med. Savings Acct. */ L["35d"] = L35d; GetLine( "L35e", &L35e ); /* Reimb. exp. prev. deducted, if reimb. not in FAGI .*/ L["35e"] = L35e; GetLine( "L35f", &L35f ); /* Lump sum distribution add-back + misc. fed income tax adjustments */ L["35f"] = L35f; GetLine( "L35g", &L35g ); /* Adjustment for IRC section 168(k) and 179 depreciation expense */ L["35g"] = L35g; L[35] = L35a + L35b + L35c + L35d + L35e + L35f + L35g; /* Deductions - see limitations in instructions. */ GetLine( "L37a", &L37a ); /* Fed int + div exempt from state taxation. */ L["37a"] = L37a; GetLine( "L37b", &L37b ); /* Adjustment for Internal Revenue Code sections 168(k) + 179 deprec. expense */ L["37b"] = L37b; L[37] = L37a + L37b; GetLine( "L38", &L[38] ); /* Employee compensation earned in OH by non-residents. */ GetLine( "L39a", &L39a ); /* Military pay. */ L["39a"] = L39a; GetLine( "L39b", &L39b ); /* Military Retirement Income. */ L["39b"] = L39b; L[39] = L39a + L39b; GetLine( "L40a", &L40a ); /* State/municipal income tax overpayments. */ L["40a"] = L40a; GetLine( "L40b", &L40b ); /* Refund or reimbursements shown on IRS form 1040, line 21 */ L["40b"] = L40b; GetLine( "L40c", &L40c ); /* Repayment of income reported in a prior year, ... */ L["40c"] = L40c; L[40] = L40a + L40b + L40c; GetLine( "L41", &L[41] ); /* Small business investor income deduction */ GetLine( "L42", &L[42] ); /* Disab. & survivor benef. */ GetLine( "L43", &L[43] ); /* Qualifying soc. sec. + railroad benefits. */ GetLine( "L44a", &L44a ); /* Education: Ohio 529 contributions */ L["44a"] = L40a; GetLine( "L44b", &L44b ); /* Education: Ohio 529 contributions */ L["44b"] = L40b; L[44] = L44a + L44b; GetLine( "L45", &L[45] ); /* Ohio National Guard reimbursements */ GetLine( "L46a", &L46a ); /* Unreimbursed health insurance ... */ L["46a"] = L40a; GetLine( "L46b", &L46b ); /* Funds deposited into, and earnings of, a medical savings account */ L["46b"] = L40b; GetLine( "L46c", &L46c ); /* Qualified organ donor expenses */ L["46c"] = L40c; L[46] = L46a + L46b + L46c; GetLine( "L47", &L[47] ); /* Wage expense not deducted */ GetLine( "L48", &L[48] ); /* Interest income from Ohio Public Obligations ... */ GetLine( "L51", &L[51] ); /* Retirement Income Credit (see instructions for credit table) (Limit $200) */ if (L[51] > 200.0) L[51] = 200.0; GetLine( "L52", &L[52] ); /* Senior Citizen Credit (Limit $50 per return) */ if (L[52] > 50.0) L[52] = 50.0; GetLine( "L53", &L[53] ); /* Lump Sum Distribution Credit (you must be 65 years of age or older to claim this credit) */ GetLine( "L54", &L[54] ); /* Child and Dependent Care Credit (see instructions and worksheet) */ GetLine( "L55", &L[55] ); /* Lump Sum Retirement Credit */ GetLine( "L57", &L[57] ); /* Displaced worker credit (Limit $500 single; $1,000 joint, if both spouses qualify) */ if (status == MARRIED_FILLING_JOINTLY) limit = 2.0 * 500.0; else limit = 500.0; L[57] = smallerof( L[57], limit ); GetLine( "L58", &L[58] ); /* Ohio Political Contributions Credit (Limit $50 single; $100 joint) */ if (status == MARRIED_FILLING_JOINTLY) limit = 2.0 * 50.0; else limit = 50.0; L[58] = smallerof( L[58], limit ); GetLine( "L60", &L[60] ); /* Portion of line 3 subjected to tax by other states. */ GetLine( "L63", &L[63] ); /* 2014 income tax paid to other states ... */ /* For non-residents only. */ GetLine( "L65", &L[65] ); /* Portion Ohio Adj. Gross Income not earned in Oh. */ GetLine( "L68", &L[68] ); /* Nonrefundable Business Credits, Sched-E line 10 */ GetLine( "L72a", &L72a ); /* Refundable Business Jobs Credits, */ L[72] = L72a; GetLine( "L72b", &L72b ); /* Refundable Pass-through Entity Credits, */ L["72b"] = L72b; GetLine( "L72c", &L72c ); /* Refundable Histroic Preservation Credits, */ L["72c"] = L72c; GetLine( "L72d", &L72d ); /* Refundable Motion Picture Credits */ L["72d"] = L72d; GetLine( "L72e", &L72e ); /* Financial Institutions Tax (FIT) credit */ L["72e"] = L72e; L[73] = L72a + L72b + L72c + L72d + L72e; L[23] = L[73]; /* ---- Do Calculations. ---- */ L[36] = L[33] + L[34] + L[35]; for (j = 37; j <= 48; j++) L[49] = L[49] + L[j]; L[50] = L[36] - L[49]; L[2] = L[50]; L[3] = L[1] + L[2]; if (L[3] <= 40000.0) exemption_amnt = 2200.0; else if (L[3] <= 80000.0) exemption_amnt = 1950.0; else exemption_amnt = 1700.0; L[4] = exemption_amnt * exemptions; L[5] = NotLessThanZero( L[3] - L[4] ); L[6] = TaxRateFunction( L[5], status ); if (L[5] <= 10000.0) L[56] = 88.0; for (j = 51; j <= 58; j++) L[59] = L[59] + L[j]; L[7] = L[59]; L[8] = NotLessThanZero( L[6] - L[7] ); if (L[5] < 30000) L[9] = 20.0 * exemptions; L[10] = NotLessThanZero( L[8] - L[9] ); if ((status == MARRIED_FILLING_JOINTLY) && (qualify_jfc)) { /*Joint_Filing_Credit*/ if (L[5] < 25000) jfc = 0.20; else if (L[5] < 50000) jfc = 0.15; else if (L[5] < 75000) jfc = 0.10; else jfc = 0.05; L[11] = smallerof( jfc * L[10], 650.0 ); L["11p"] = jfc*100.0; } /*Joint_Filing_Credit*/ L[12] = L[10] - L[11]; /* L[13] computed below, which depends on L[71] and the following prior lines. */ L[61] = L[3]; factor62 = 0.0001 * (int)(10000.0 * (L[60] / L[61])); /* 4-digits right of decimal-pt. */ L["62p"] = factor62; L[62] = factor62 * L[12]; L[64] = smallerof( L[62], L[63] ); L[69] = L[64]; L[66] = L[3]; factor67 = 0.0001 * (int)(10000.0 * (L[65] / L[66])); /* 4-digits right of decimal-pt. */ L["67p"] = factor67; L[67] = factor67 * L[12]; L[70] = L[67]; L[71] = L[68] + L[69] + L[70]; L[13] = L[71]; /* Resuming now with calculations at line 17. */ L[17] = NotLessThanZero( L[12] - (L[13] + L[14] + L[15] + L[16]) ); L[20] = L[17] + L[18] + L[19]; L[24] = L[21] + L[22] + L[23]; if ((status == SINGLE) && (L[1] <= 12200.0) && (L[50] == 0.0)) fprintf(outfile, "You do not need to file Ohio tax return (Fed AGI < minimum).\n"); if ((status == MARRIED_FILLING_JOINTLY) && (L[1] <= 14400.0) && (L[50] == 0.0)) fprintf(outfile, "You do not need to file Ohio tax return (Fed AGI < minimum).\n"); if ((L[4] >= L[3]) && (L[50] == 0.0)) fprintf(outfile, "You do not need to file Ohio tax return (L[4] >= L[3]).\n"); /* Output the Results. */ showline(1); showline(2); showline(3); fprintf(outfile,"Exemptions = %d\n", exemptions ); for (j = 4; j <= 10; j++) showline(j); fprintf(outfile, "L10a = %6.2f\n", L[10]); for (j = 11; j <= 19; j++) showline(j); showline_wmsg( 20, "Total Ohio Tax" ); showline_wmsg( 21, "Amount Withheld" ); showline(22); showline(23); showline_wmsg( 24, "Total Payments" ); if (L[24] > L[20]) { L[25] = L[24] - L[20]; showline_wmsg( 25, "AMOUNT OVERPAID" ); } else { L[29] = L[20] - L[24]; showline_wmsg( 29, "AMOUNT DUE" ); } showline(33); showline(34); showline_wlabel( "L35a", L35a ); showline_wlabel( "L35b", L35b ); showline_wlabel( "L35c", L35c ); showline_wlabel( "L35d", L35d ); showline_wlabel( "L35e", L35e ); showline_wlabel( "L35f", L35f ); showline_wlabel( "L35g", L35g ); showline_wmsg( 36, "Total additions" ); showline_wlabel( "L37a", L37a ); showline_wlabel( "L37b", L37b ); showline(38); showline_wlabel( "L39a", L39a ); showline_wlabel( "L39b", L39b ); showline_wlabel( "L40a", L40a ); showline_wlabel( "L40b", L40b ); showline_wlabel( "L40c", L40c ); showline(41); showline(42); showline(43); showline_wlabel( "L44a", L44a ); showline_wlabel( "L44b", L44b ); showline(45); showline_wlabel( "L46a", L46a ); showline_wlabel( "L46b", L46b ); showline_wlabel( "L46c", L46c ); showline(47); showline(48); showline_wmsg( 49, "Total Deductions" ); showline_wmsg( 50, "Net adjustments" ); for (j = 51; j <= 58; j++) showline(j); showline_wmsg(59,"Total Schedule B Credits"); showline(60); showline(61); fprintf(outfile," (L62 [%g]) \t", factor62 ); for (j = 62; j <= 66; j++) showline(j); fprintf(outfile," (L67 [%g]) \t", factor67 ); for (j = 67; j <= 73; j++) showline(j); fclose(infile); fclose(outfile); outfile = fopen(it1040_xfdf_outfname,"w"); output_xfdf_form_data(outfile, it1040_2014, L); fclose(outfile); Display_File( outfname ); printf("\nResults written to file: %s\n", outfname); return 0; }