public void Add(Paycheck addend) { this.HourlyPay += addend.HourlyPay; this.HourlyPayHours += addend.HourlyPayHours; this.Overtimehourly += addend.Overtimehourly; this.OvertimehourlyHours += addend.OvertimehourlyHours; this.Vacationhourly += addend.Vacationhourly; this.VacationhourlyHours += addend.VacationhourlyHours; this.Sickhourlypay += addend.Sickhourlypay; this.SickhourlypayHours += addend.SickhourlypayHours; this.Bonus += addend.Bonus; //this.PaymentTotal += addend.PaymentTotal; this.OregonWCEE += addend.OregonWCEE; this.Draw += addend.Draw; this.FederalTax += addend.FederalTax; this.SocialSecurityTax += addend.SocialSecurityTax; this.MedicareTax += addend.MedicareTax; this.StateTax += addend.StateTax; this.FederalTaxAdditional += addend.FederalTaxAdditional; this.StateTaxAdditional += addend.StateTaxAdditional; }
private void btnLoadCSV_Click(object sender, EventArgs e) { DialogResult res = dlgOpenCSV.ShowDialog(); if (res != DialogResult.OK) { return; } List <Paycheck> paychecks = GetPaychecks(); paychecks.Sort((p1, p2) => p1.SSN.CompareTo(p2.SSN)); List <Paycheck> bySSN = new List <Paycheck>(); Paycheck bySSNTotal = new Paycheck(); Paycheck currentSSN = null; Dictionary <string, MonthSummary> monthSummaries = new Dictionary <string, MonthSummary>(); foreach (var record in paychecks) { if (currentSSN == null || currentSSN.SSN != record.SSN) { currentSSN = new Paycheck(); currentSSN.Name = record.Name; currentSSN.SSN = record.SSN; bySSN.Add(currentSSN); } currentSSN.Add(record); for (DateTime dateInPeriod = record.StartDate; dateInPeriod <= record.EndDate; dateInPeriod = dateInPeriod.AddDays(1.0d)) { if (dateInPeriod.Day == 12) { MonthSummary monthSum; string key = dateInPeriod.Month.ToString() + "/" + dateInPeriod.Year.ToString(); if (!monthSummaries.TryGetValue(key, out monthSum)) { monthSum = new MonthSummary(); monthSum.MonthYear = key; monthSum.SSN = new List <string>(); monthSummaries.Add(key, monthSum); } if (!monthSum.SSN.Contains(record.SSN)) { monthSum.SSN.Add(record.SSN); } } } } foreach (var record in bySSN) { // We can't just add the records to each other, because the total // hours is total of rounded hours for each employee (not total hours rounded). bySSNTotal.HourlyPayHours += Math.Round(record.TotalHours); bySSNTotal.HourlyPay += record.GrossPay; bySSNTotal.StateTax += record.StateTax; bySSNTotal.StateTaxAdditional += record.StateTaxAdditional; } grdBySSN.Rows.Clear(); EmployeeExport = new StringBuilder(); StatewideTransitExport = new StringBuilder(); StatewideTransitExport.AppendLine("SSN,FirstInitial,LastName,GrossWages,TaxAmount"); foreach (var record in bySSN) { grdBySSN.Rows.Add(record.SSN2, record.Name, Math.Round(record.TotalHours).ToString(), record.GrossPay.ToString("F2"), record.AllSITW.ToString("F0")); string[] nameParts = record.Name.Split(' '); string firstName; string lastName; string middleInitial; if (nameParts.Length == 3 && nameParts[1].Length <= 1) { firstName = nameParts[0]; middleInitial = nameParts[1]; lastName = nameParts[2]; } else { MessageBox.Show("Could not parse name " + record.Name); firstName = nameParts[0]; middleInitial = ""; lastName = nameParts[1] + " " + nameParts[2]; } EmployeeExport.AppendLine( string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",{4},{5},{6}", record.SSN2, lastName, firstName, middleInitial, Math.Round(record.TotalHours), record.GrossPay.ToString("F2"), record.AllSITW.ToString("F0")) ); StatewideTransitExport.AppendLine( string.Format("\"{0}\",\"{1}\",\"{2}\",{3},{4}", record.SSN2, firstName[0], lastName, record.GrossPay.ToString("F2"), (record.GrossPay * 0.001M).ToString("F2")) ); } grdBySSN.Rows.Add("Total", "", Math.Round(bySSNTotal.TotalHours).ToString(), bySSNTotal.GrossPay.ToString("F2"), bySSNTotal.AllSITW.ToString("F0")); paychecks.Sort((p1, p2) => p1.CreatedDate.CompareTo(p2.CreatedDate)); List <Paycheck> byDate = new List <Paycheck>(); Paycheck byDateTotal = new Paycheck(); Paycheck currentDate = null; foreach (var record in paychecks) { if (currentDate == null || currentDate.CreatedDate != record.CreatedDate) { currentDate = new Paycheck(); currentDate.CreatedDate = record.CreatedDate; byDate.Add(currentDate); } currentDate.Add(record); byDateTotal.Add(record); } grdByDate.Rows.Clear(); PayrollExport = new StringBuilder(); foreach (var record in byDate) { grdByDate.Rows.Add(record.CreatedDate.ToShortDateString(), record.AllSITW.ToString("F2")); PayrollExport.AppendLine(string.Format("\"{0}\",{1}", record.CreatedDate.ToShortDateString(), record.AllSITW.ToString("F2"))); } grdByDate.Rows.Add("Total", byDateTotal.AllSITW.ToString("F2")); string employeeCountByMonth = ""; foreach (var monthSum in monthSummaries) { employeeCountByMonth += Environment.NewLine + monthSum.Value.MonthYear + ": " + monthSum.Value.SSN.Count + " employees"; } txtOtterData.Text = "Otter Data:" + Environment.NewLine + "Subject Wages (column B): " + bySSNTotal.GrossPay.ToString("F2") + Environment.NewLine + "Subject Wages (columns C & D): Zero" + Environment.NewLine + "WBF Hours Worked: " + bySSNTotal.TotalHours.ToString("F0") + employeeCountByMonth; btnWriteOPRSFiles.Enabled = true; }