# # ######################################################### # # This is the master list of all blue field currency boxes that we are taking control of whereby # floating point contents are rounded ensuring that the form fields and the associated 2D values # are the same and meet the specs "All money fields should be rounded to the nearest whole # dollar amount". This list has been verified as to which various decimal boxes should be in it, # as we do not want to round non-money fields like percents for example. Just prior to writing # values to the 2D itself, we filter out [delete from the list] those boxes which [dynamically] # contain say ALPHA characters, or other non-numeric values. Then we run thru the editied # list of boxes. # list_rnd = %w{box2_23 box2_25 box2_27 box2_29 box2_31 box2_33 box2_35 box2_37 box2_39 box2_41 box2_43 box2_45 box2_47 box2_49 box2_51 box2_53 box2_55 box2_57 box2_59 box2_61 box2_63 box2_65 box2_67 box2_69 box2_71 box2_73 box2_75 box2_77 box2_79 box2_81 box2_83 box2_99 box2_101 box2_103 box2_105 box2_107 box2_109 box2_111 box2_113 box2_115 box2_117 box2_119 box2_121 box2_123 box2_125} # # round_foreign_list holds the boxes that may contain names of countries or US possessions. # foreign_code_list holds the associated code boxes that need to be checked - an "A" indicates # that the associated round_foreign_list box holds the country name. Any other code results # in the same processing as for the round_list boxes. Theses arrays must be the same size. # foreign_code_list = %w{box2_84 box2_86 box2_88 box2_90 box2_92 box2_94 box2_96} foreign_list_rnd = %w{box2_85 box2_87 box2_89 box2_91 box2_93 box2_95 box2_97} # # ######################################################### # # For this form, we have two 'groups' of boxes: The first group we check only the blue field amount # boxes looking for an 'S' in the first character position, else we will round the value if not empty. # The taxpayer is supposed to type in 'STMT' into the amount field to indicate that a single dollar # amount cannot be used to report the information, so a statement is attached to report it instead. # We check the first character position for cases where 'STATEMENT' or 'SEE STATEMENT' was # entered. The analyst has approved this approach in the past, so sticking to it here. # # The second group we need to check the associated code box to see if it contains an 'A' in which case # the associated amount box is assumed to contain the name of a country or US possession, so we # truncate the length of the amount box to the 2D spec size. For those code boxes that do not contain # an 'A', we do the same processing as for the first group. # # The first group: # 0.upto(list_rnd.length-1) { |i| box = list_rnd[i] box_val = eval("#{box}") if (box_val.upcase[0,1] == 'S') print box, 'STMT' elsif (!box_val.empty?) print box, '%0.0f' % box_val.to_f end } # # The second group: # 0.upto(foreign_list_rnd.length-1) { |i| box = foreign_list_rnd[i] box_val = eval("#{box}") for_box_val = eval("#{foreign_code_list[i]}") if (for_box_val.upcase.include?('A')) print box, box_val[0,12] elsif (box_val.upcase[0,1] == 'S') print box, 'STMT' elsif (!box_val.empty?) print box, '%0.0f' % box_val.to_f end } # # ######################################################### # # Welcome to 2D Land: # # Variable Fields - "V": # # Don't restrict special characters in alphanumeric fields (V-variable) unless there is a notation about # allowable special characters in the comment area for the field. We need to use .strip for those fields # that do allow spaces, because these fields cannot have leading or trailing space characters, just do it # after the filtering. # # Strip commas from money fields. # box2_126 = "T1\r1039\rUS\r1120K1\r0\r0\r" << '2007' + ( box2_3.empty? ? '0000' : box2_3.delete('/') ) << "\r" << '20' + ( box2_5.empty? ? '00' : box2_5 ) + ( box2_4.empty? ? '0000' : box2_4.delete('/') ) << "\r" << ( box2_6 == 'APPLIED FOR' ? 'APPLD FOR' : box2_6.delete('-') ) << "\r" << ( box2_7.delete("^A-Z0-9 &-").strip )[0,40] << "\r" << ( box2_8.delete("^A-Z0-9 &-").strip )[0,40] << "\r" << ( box2_9.delete("^A-Z0-9 /-").strip )[0,35] << "\r" << ( ( box2_10.delete("^A-Z ") ).squeeze(' ').strip )[0,22] << "\r" << ( box2_11.delete("^A-Z") )[0,2] << "\r" << ( box2_12.delete("^0-9") )[0,9] << "\r" << ( box2_13.delete("^A-Z /-").strip )[0,35] << "\r" << ( box2_14 == 'APPLIED FOR' ? 'APPLD FOR' : box2_14.delete('-') ) << "\r" << ( box2_15.delete("^A-Z0-9 &-").strip )[0,40] << "\r" << ( box2_16.delete("^A-Z0-9 &-").strip )[0,40] << "\r" << ( box2_17.delete("^A-Z0-9 /-").strip )[0,35] << "\r" << ( ( box2_18.delete("^A-Z ") ).squeeze(' ').strip )[0,22] << "\r" << ( box2_19.delete("^A-Z") )[0,2] << "\r" << ( box2_20.delete("^0-9") )[0,9] << "\r" << ( box2_21.empty? ? '' : ( '%0.5f' % ( box2_21.to_f / 100.0 ) ).delete('.') ) << "\r" << ( box2_1.empty? ? '' : 'X' ) << "\r" << ( box2_2.empty? ? '' : 'X' ) << "\r" << ( box2_22.delete("^A-Z*") )[0,2] << "\r" << # These remaining boxes comprise the blue field special processing that was done above. # Comma deletion starts here with the left paren. (box2_23 << "\r" << ( box2_24.delete("^A-Z*") )[0,2] << "\r" << box2_25 << "\r" << ( box2_26.delete("^A-Z*") )[0,2] << "\r" << box2_27 << "\r" << ( box2_28.delete("^A-Z*") )[0,2] << "\r" << box2_29 << "\r" << ( box2_30.delete("^A-Z*") )[0,2] << "\r" << box2_31 << "\r" << ( box2_32.delete("^A-Z*") )[0,2] << "\r" << box2_33 << "\r" << ( box2_34.delete("^A-Z*") )[0,2] << "\r" << box2_35 << "\r" << ( box2_36.delete("^A-Z*") )[0,2] << "\r" << box2_37 << "\r" << ( box2_38.delete("^A-Z*") )[0,2] << "\r" << box2_39 << "\r" << ( box2_40.delete("^A-Z*") )[0,2] << "\r" << box2_41 << "\r" << ( box2_42.delete("^A-Z*") )[0,2] << "\r" << box2_43 << "\r" << ( box2_44.delete("^A-Z*") )[0,2] << "\r" << box2_45 << "\r" << ( box2_46.delete("^A-Z*") )[0,2] << "\r" << box2_47 << "\r" << ( box2_48.delete("^A-Z*") )[0,2] << "\r" << box2_49 << "\r" << ( box2_50.delete("^A-Z*") )[0,2] << "\r" << box2_51 << "\r" << ( box2_52.delete("^A-Z*") )[0,2] << "\r" << box2_53 << "\r" << ( box2_54.delete("^A-Z*") )[0,2] << "\r" << box2_55 << "\r" << ( box2_56.delete("^A-Z*") )[0,2] << "\r" << box2_57 << "\r" << ( box2_58.delete("^A-Z*") )[0,2] << "\r" << box2_59 << "\r" << ( box2_60.delete("^A-Z*") )[0,2] << "\r" << box2_61 << "\r" << ( box2_62.delete("^A-Z*") )[0,2] << "\r" << box2_63 << "\r" << ( box2_64.delete("^A-Z*") )[0,2] << "\r" << box2_65 << "\r" << ( box2_66.delete("^A-Z*") )[0,2] << "\r" << box2_67 << "\r" << ( box2_68.delete("^A-Z*") )[0,2] << "\r" << box2_69 << "\r" << ( box2_70.delete("^A-Z*") )[0,2] << "\r" << box2_71 << "\r" << ( box2_72.delete("^A-Z*") )[0,2] << "\r" << box2_73 << "\r" << ( box2_74.delete("^A-Z*") )[0,2] << "\r" << box2_75 << "\r" << ( box2_76.delete("^A-Z*") )[0,2] << "\r" << box2_77 << "\r" << ( box2_78.delete("^A-Z*") )[0,2] << "\r" << box2_79 << "\r" << ( box2_80.delete("^A-Z*") )[0,2] << "\r" << box2_81 << "\r" << ( box2_82.delete("^A-Z*") )[0,2] << "\r" << box2_83 << "\r" << ( box2_84.delete("^A-Z*") )[0,2] << "\r" << box2_85 << "\r" << ( box2_86.delete("^A-Z*") )[0,2] << "\r" << box2_87 << "\r" << ( box2_88.delete("^A-Z*") )[0,2] << "\r" << box2_89 << "\r" << ( box2_90.delete("^A-Z*") )[0,2] << "\r" << box2_91 << "\r" << ( box2_92.delete("^A-Z*") )[0,2] << "\r" << box2_93 << "\r" << ( box2_94.delete("^A-Z*") )[0,2] << "\r" << box2_95 << "\r" << ( box2_96.delete("^A-Z*") )[0,2] << "\r" << box2_97 << "\r" << ( box2_98.delete("^A-Z*") )[0,2] << "\r" << box2_99 << "\r" << ( box2_100.delete("^A-Z*") )[0,2] << "\r" << box2_101 << "\r" << ( box2_102.delete("^A-Z*") )[0,2] << "\r" << box2_103 << "\r" << ( box2_104.delete("^A-Z*") )[0,2] << "\r" << box2_105 << "\r" << ( box2_106.delete("^A-Z*") )[0,2] << "\r" << box2_107 << "\r" << ( box2_108.delete("^A-Z*") )[0,2] << "\r" << box2_109 << "\r" << ( box2_110.delete("^A-Z*") )[0,2] << "\r" << box2_111 << "\r" << ( box2_112.delete("^A-Z*") )[0,2] << "\r" << box2_113 << "\r" << ( box2_114.delete("^A-Z*") )[0,2] << "\r" << box2_115 << "\r" << ( box2_116.delete("^A-Z*") )[0,2] << "\r" << box2_117 << "\r" << ( box2_118.delete("^A-Z*") )[0,2] << "\r" << box2_119 << "\r" << ( box2_120.delete("^A-Z*") )[0,2] << "\r" << box2_121 << "\r" << ( box2_122.delete("^A-Z*") )[0,2] << "\r" << box2_123 << "\r" << ( box2_124.delete("^A-Z*") )[0,2] << "\r" << box2_125).delete(',') << "\r" << "*EOD*\r" print 'box2_126', box2_126