protected virtual void AddEntry( int entryIndex, decimal billableHours, decimal ratePerHour, int weekNumber, DateTime startDate, DateTime endDate, InvoiceConfiguration invoiceConfiguration, bool isSplitRate = false) { Excel.Application excelApplication = ExcelGenerator.GetExcelApplication(); // Qty... ExcelCell qtyStartCell = Helpers.Excel.ToCell(invoiceConfiguration.QtyStartCell); excelApplication.Cells[qtyStartCell.Row + entryIndex, qtyStartCell.Column].Value = billableHours; // Description... ExcelCell descriptionStartCell = Helpers.Excel.ToCell(invoiceConfiguration.DescriptionStartCell); string description = string.Format("{0} | {1}", invoiceConfiguration.Description, this.GetTimesheetWeekString(weekNumber, startDate, endDate, isSplitRate)); excelApplication.Cells[descriptionStartCell.Row + entryIndex, descriptionStartCell.Column].Value = description; // PO Number... int PONumber = invoiceConfiguration.PONumber; ExcelCell POStartCell = Helpers.Excel.ToCell(invoiceConfiguration.PONumberStartCell); excelApplication.Cells[POStartCell.Row + entryIndex, POStartCell.Column].Value = invoiceConfiguration.PONumber; // Rate... ExcelCell rateStartCell = Helpers.Excel.ToCell(invoiceConfiguration.RateStartCell); excelApplication.Cells[rateStartCell.Row + entryIndex, rateStartCell.Column].Value = ratePerHour; }
// Methods // -------------------------------------------------------------------------- #region Methods protected virtual void LoadConfigurationFile() { XElement root = XElement.Load(this.ConfigurationFile); this.PersonalConfiguration = PersonalConfiguration.FromXml(root); this.MiscellaneousConfiguration = MiscellaneousConfiguration.FromXml(root); this.TimesheetConfiguration = TimesheetConfiguration.FromXml(root); this.InvoiceConfiguration = InvoiceConfiguration.FromXml(root); this.RatesConfiguration = RatesConfiguration.FromXml(root); this.DayTypeConfiguration = DayTypeConfiguration.FromXml(root); // Set the configuration to NOT dirty - we just loaded it! this.IsDirty = false; }
private void AddSplitRateEntries(ref int entryIndex, Timesheet timesheet, InvoiceConfiguration invoiceConfiguration) { if (!timesheet.IsSplitRate()) { MessageBox.Show("InvoiceGenerator.AddSplitRateEntries(...) encountered a problem; parameter 'timesheet' must be a 'split rate' Timesheet (e.g Timesheet.IsSplitRate() == true)."); return; } decimal ratePerHour = 0; decimal billableHours = 0; IEnumerable<TimesheetDate> timesheetDates = timesheet.Dates.Where(p => p.IsValidDate); foreach (TimesheetDate timesheetDate in timesheetDates) { if (ratePerHour == 0) { ratePerHour = timesheetDate.RatePerHour; billableHours += timesheetDate.BillableHours; } else if (timesheetDate.RatePerHour != ratePerHour) { // Add Entries... AddEntry(++entryIndex, billableHours, ratePerHour, timesheet.WeekNumber, timesheet.StartDate.Date, timesheet.EndDate.Date, invoiceConfiguration, true); // Reset our counters... ratePerHour = timesheetDate.RatePerHour; billableHours = timesheetDate.BillableHours; } else { // Roll up totals... billableHours += timesheetDate.BillableHours; } } // Get the last entry... if (timesheetDates != null) { AddEntry(++entryIndex, billableHours, ratePerHour, timesheet.WeekNumber, timesheet.StartDate.Date, timesheet.EndDate.Date, invoiceConfiguration, true); } }