/// <summary> /// Calculate and returns the invoice amount /// </summary> /// <param name="projectId"></param> /// <param name="userId"></param> /// <returns></returns> public decimal GetInvoiceAmount(int timeSpend, int userId) { // Fetch the invoice instaince from the factory based on the type IInvoiceCalculationRule invoice = this._invoiceFactory.GetCalculationRule(CalculationType.Normal); InvoiceParameters parameters = new InvoiceParameters() { Hours = timeSpend, Rate = 100 // TODO: dummy value, replace with actual rate. }; // Calculate and return the invoice amout based on the rule return(invoice.CalculateInvoice(parameters)); }
private void ImportFile() { var excelBook = _excelApp.ActiveWorkbook; Worksheet excelSheet = excelBook.ActiveSheet; if (excelSheet.Name != _sheetName01) return; _cells.GetRange(2, 4, 2, 7).ClearContents(); var openFileDialog1 = new OpenFileDialog { Filter = @"Archivos CSV|*.csv", FileName = @"Parametros Modify Invoice.csv", Title = @"Programa de Lectura", InitialDirectory = @"C:\Data\Loaders\Parametros" }; if (openFileDialog1.ShowDialog() != DialogResult.OK) return; var filePath = openFileDialog1.FileName; var inputFileDescription = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = false, EnforceCsvColumnAttribute = true }; var cc = new CsvContext(); var invoiceParameters = cc.Read<InvoiceParameters>(filePath, inputFileDescription); foreach (var p in invoiceParameters) { try { parameters = new InvoiceParameters(); parameters = p; _cells.GetCell(2, 4).Value = p.Percentage; _cells.GetCell(2, 5).Value = p.Days; _cells.GetCell(2, 6).Value = p.Branchcode; _cells.GetCell(2, 7).Value = p.Bankaccount; } catch (Exception error) { MessageBox.Show(string.Format("Error: {0}", error.Message)); } } _cells.GetRange(1, TittleRow + 1, ResultColumn, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "@"; _cells.GetRange(9, TittleRow + 1, 10, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "$ #,##0.00"; _cells.GetRange(12, TittleRow + 1, 13, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "$ #,##0.00"; _cells.GetCell(2, 4).NumberFormat = "0.00%"; excelSheet.Cells.Columns.AutoFit(); excelSheet.Cells.Rows.AutoFit(); }
/// <summary> /// Calculating the invoice and returning the bill amount - normal caculation /// </summary> /// <returns></returns> public decimal CalculateInvoice(InvoiceParameters parameters) { return(parameters.Hours * parameters.Rate); }