private void OutputRSRecord(TextWriter writer, DelimitedRow paySummary, DelimitedRow empRow, DelimitedRow supRow, decimal statewideTransitTax, Accumulators accum) { decimal grossPay = paySummary.GetDecimal("Gross Taxable Income"); FixedWidthRecord rec = new FixedWidthRecord(mRecordLength); rec.SetString(1, 2, "RS", "Record Identifier"); rec.SetString(3, 2, "41", "State Numeric Code"); rec.SetString(10, 9, paySummary.GetString("SSN").Replace("-", "").PadLeft(9, '0'), "SSN"); rec.SetString(19, 15, empRow.GetString("FName"), "First Name"); rec.SetString(34, 15, empRow.GetString("MInit"), "Middle Initial"); rec.SetString(49, 20, empRow.GetString("LName"), "Last Name"); string address = empRow.GetString("Address1") + " " + empRow.GetString("Address2"); rec.SetString(73, 22, address, "Location Address"); rec.SetString(95, 22, address, "Delivery Address"); rec.SetString(117, 22, empRow.GetString("City"), "City"); rec.SetString(139, 2, empRow.GetString("State"), "State"); string zip = empRow.GetInteger("Zip Code").ToString("00000"); rec.SetString(141, 5, zip, "Zipcode"); //rec.SetString(197, 6, "12" + (string)cboTaxYear.SelectedItem, "Reporting Period"); DateTime hireDate = DateTime.Parse(supRow.GetString("HireDate")); rec.SetString(227, 8, hireDate.ToString("MMddyyyy"), "Hire Date"); string termDate = supRow.GetString("TerminationDate"); if (string.IsNullOrEmpty(termDate)) { termDate = "00000000"; } else { termDate = DateTime.Parse(termDate).ToString("MMddyyyy"); } rec.SetString(235, 8, termDate, "Termination Date"); rec.SetString(248, 20, "013375439", "Oregon BIN"); rec.SetString(274, 2, "41", "State Numeric Code"); rec.SetMoney(276, 11, grossPay, ref accum.StateWages, "State Taxable Wages"); rec.SetMoney(287, 11, paySummary.GetDecimal("State Tax"), ref accum.SITW, "SITW"); rec.SetMoney(348, 11, grossPay, ref accum.StatewideTransitWages, "Statewide Transit Wages"); rec.SetMoney(359, 11, statewideTransitTax, ref accum.StatewideTransitTax, "Statewide Transit Tax"); writer.WriteLine(rec.GetContents()); }
/// <summary> /// Employee wage record /// </summary> /// <param name="writer"></param> /// <param name="paySummary"></param> /// <param name="empRow"></param> private void OutputRWRecord(TextWriter writer, DelimitedRow paySummary, DelimitedRow empRow, Accumulators accum) { decimal grossPay = paySummary.GetDecimal("Gross Taxable Income"); accum.EmployeeRecordCount++; FixedWidthRecord rec = new FixedWidthRecord(mRecordLength); decimal dummy = 0M; //MessageBox.Show("Name=" + empSummary.GetString("Name") + " GrossPay=" + grossPay.ToString() + // " Address=" + empRow.GetString("Address1")); rec.SetString(1, 2, "RW", "Record Identifier"); rec.SetString(3, 9, paySummary.GetString("SSN").Replace("-", "").PadLeft(9, '0'), "SSN"); rec.SetString(12, 15, empRow.GetString("FName"), "First Name"); rec.SetString(27, 15, empRow.GetString("MInit"), "Middle Initial"); rec.SetString(42, 20, empRow.GetString("LName"), "Last Name"); string address = empRow.GetString("Address1") + " " + empRow.GetString("Address2"); rec.SetString(66, 22, address, "Location Address"); rec.SetString(88, 22, address, "Delivery Address"); rec.SetString(110, 22, empRow.GetString("City"), "City"); rec.SetString(132, 2, empRow.GetString("State"), "State"); string zip = empRow.GetInteger("Zip Code").ToString("00000"); rec.SetString(134, 5, zip, "Zipcode"); rec.SetMoney(188, 11, grossPay, ref accum.FederalWages, "Federal Taxable Wages"); rec.SetMoney(199, 11, paySummary.GetDecimal("Federal Tax"), ref accum.FITW, "FITW"); rec.SetMoney(210, 11, paySummary.GetDecimal("Gross SS Taxable Income"), ref accum.SocialSecurityWages, "Social Security Wages"); rec.SetMoney(221, 11, paySummary.GetDecimal("Social Security Tax"), ref accum.SocialSecurityTaxes, "Social Security Tax"); rec.SetMoney(232, 11, paySummary.GetDecimal("Gross FICA Taxable Income"), ref accum.MedicareWages, "Medicare Wages"); rec.SetMoney(243, 11, paySummary.GetDecimal("Medicare Tax"), ref accum.MedicareTaxes, "Medicare Tax"); rec.SetMoney(254, 11, paySummary.GetDecimal("Tips"), ref accum.SocialSecurityTips, "Social Security Tips"); rec.SetMoney(276, 11, 0M, ref dummy, "Dependent Care Benefits"); rec.SetMoney(287, 11, 0M, ref dummy, "Deferred Comp 401(K)"); rec.SetMoney(298, 11, 0M, ref dummy, "Deferred Comp 403(B)"); rec.SetMoney(309, 11, 0M, ref dummy, "Deferred Comp 408(K)"); rec.SetMoney(320, 11, 0M, ref dummy, "Deferred Comp 457(b)"); rec.SetMoney(331, 11, 0M, ref dummy, "Deferred Comp 501(c)"); rec.SetMoney(353, 11, 0M, ref dummy, "Non-Qualified 457 Dist/Cont"); rec.SetMoney(364, 11, 0M, ref dummy, "Employer FSA"); rec.SetMoney(375, 11, 0M, ref dummy, "Non-qualified NOT 457"); rec.SetMoney(386, 11, 0M, ref dummy, "Non-taxable Combat Pay"); rec.SetMoney(408, 11, 0M, ref dummy, "Employer Group Term Premiums"); rec.SetMoney(419, 11, 0M, ref dummy, "Income from Nonstatutory Stock Options"); rec.SetMoney(430, 11, 0M, ref dummy, "Section 409A Deferrals"); rec.SetMoney(441, 11, 0M, ref dummy, "ROTH Contributions 401(k)"); rec.SetMoney(452, 11, 0M, ref dummy, "ROTH Contributions 403(b)"); rec.SetMoney(463, 11, 0M, ref dummy, "Cost of Employer Health Coverage"); rec.SetMoney(474, 11, 0M, ref dummy, "Small Employer Health Reimbursement Arrangement"); rec.SetString(486, 1, "1", "Statutory Employee"); rec.SetString(488, 1, "0", "Retirement Plan"); rec.SetString(489, 1, "0", "Third Party Sick Pay"); writer.WriteLine(rec.GetContents()); }
private void ReadTestFile1() { try { mFileName = "TestFile1.txt"; using (TextReader reader = new StreamReader(mFileName)) { DelimitedReader delReader = new DelimitedReader(reader, ',', true); DelimitedRow row = delReader.CurrentValues; DelimitedRow totals = delReader.ColumnTotals; if (row == null) { Failure("Initial row is null"); } if (row.Count != 6) { Failure("Initial row column wrong count"); } if (totals != null) { Failure("Initial totals must be null"); } if (!delReader.HasCurrent) { Failure("Initial has no current"); } if (row.GetIndex("Name") != 0) { Failure("Name index != 0"); } if (row.GetIndex("Weight") != 2) { Failure("Weight index != 2"); } if ((string)row.GetValue("Name") != "Dog") { Failure("Name!=Dog"); } if (!(row.GetValue("Weight") is decimal)) { Failure("Dog weight is not decimal"); } if ((decimal)row.GetValue("Weight") != 20.5M) { Failure("Dog weight is not 20.5M"); } if (row.GetDecimal("Weight") != 20.5M) { Failure("Dog weight is not 20.5M (2)"); } if (!(row.GetValue("Length") is int)) { Failure("Length is not integer"); } if (row.GetInteger("Length") != 26) { Failure("Dog Length is not 26"); } row = delReader.NextLine(); if (!delReader.HasCurrent) { Failure("Second has no current"); } if (row.Count != 6) { Failure("Second row column count wrong"); } if (row.GetString("Name") != "Big Fish") { Failure("Second name is not Fish"); } if (row.GetString("Color") != "Silver") { Failure("Second color is not Silver"); } if (row.GetDecimal("Weight") != 3.5M) { Failure("Second Weight should be 3.5M"); } if (row.GetInteger("Units") != 200) { Failure("Second units is not 200"); } totals = delReader.ReadUntilChange("Break"); row = delReader.CurrentValues; if (row.GetString("Name") != "Small Fish") { Failure("UntilChange Break wrong row"); } if (!(totals.GetValue("Name") is string)) { Failure("UntilChange Name should be string"); } if (!(totals.GetValue("Weight") is decimal)) { Failure("UntilChange Weight should be decimal"); } if (totals.GetDecimal("Weight") != 3.5M) { Failure("UntilChange Weight should be 3.5M"); } totals = delReader.ReadUntilChange("Break"); row = delReader.CurrentValues; if (row.GetString("Name") != "guppy") { Failure("UntilChange2 Break wrong row"); } if (totals.GetDecimal("Weight") != ((decimal)1 + 8.5M + 300.5M)) { Failure("UntilChange2 wrong Weight total"); } if (totals.GetInteger("Units") != (3000 + 5 + 1)) { Failure("UntilChange2 wrong Units total"); } if (!(row.GetValue("Units") is int)) { Failure("UntilChange2 wrong Units type"); } row = delReader.NextLine(); if (row.GetString("Name") != "") { Failure("Blank Name is not blank"); } if (row.GetString("Color") != "none") { Failure("Blank Color is not none"); } if (row.GetString("Weight") != "") { Failure("Blank Weight is not blank"); } if (row.GetString("Length") != "") { Failure("Blank Length is not blank"); } if (row.GetInteger("Units") != 100) { Failure("Blank Units is not 100"); } row = delReader.NextLine(); if (row.GetString("Name") != "tall grass") { Failure("tall grass wrong name"); } if (!delReader.HasCurrent) { Failure("tall grass has no current"); } delReader.NextLine(); if (delReader.HasCurrent) { Failure("should not have current"); } if (!(delReader.Add("a", "B") is string)) { Failure("Add string string is not string"); } if (!(delReader.Add("a", 1) is string)) { Failure("Add string int is not string"); } if (!(delReader.Add(2, "B") is string)) { Failure("Add int string is not string"); } if (!(delReader.Add(2.5M, "B") is string)) { Failure("Add decimal string is not string"); } if (!(delReader.Add(2, 1) is int)) { Failure("Add int int is not int"); } if (!(delReader.Add(2.5M, 3.5M) is decimal)) { Failure("Add decimal decimal is not decimal"); } if (!(delReader.Add(2.5M, 3) is decimal)) { Failure("Add decimal int is not decimal"); } if (!(delReader.Add(2, 3.5M) is decimal)) { Failure("Add int decimal is not decimal"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }