private PrivateSupplierFileInfoEntity createPrivateSupplierCodeEntity(PrivateSupplierFileInfo fileInfo) { return(new PrivateSupplierFileInfoEntity { AmountAfterTax = fileInfo.AmountAfterTax, CustomerId = fileInfo.CustomerId, GeneralRowId = fileInfo.GeneralRowId, Invoice = fileInfo.Invoice, JournalEntryNumber = fileInfo.JournalEntryNumber, IsMatched = fileInfo.IsMatched, Contract = fileInfo.Contract, RowId = fileInfo.RowId, Amount = fileInfo.Amount, DateOfValue = fileInfo.DateOfValue, Description = fileInfo.Description, SupplierId = fileInfo.SupplierId, TaxRate = fileInfo.TaxRate, }); }
private PrivateSupplierFileInfo CreateExcelRowToPrivateTable(ExcelWorksheet sheet, int rowNum, ref GeneralBillingSummary generalSummary) { try { PrivateSupplierFileInfo fileInfo = new PrivateSupplierFileInfo(); int contract = 0; if (int.TryParse(sheet.Cells[rowNum, 2].Text.Trim(), out contract)) { fileInfo.Contract = contract; int invoice = 0; if (int.TryParse(sheet.Cells[rowNum, 1].Text.Trim(), out invoice)) { DateTime dateOfValue = new DateTime(1, 1, 1); if (DateTime.TryParseExact(sheet.Cells[rowNum, 5].Text.Trim(), "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.AssumeLocal, out dateOfValue)) { fileInfo.Amount = string.IsNullOrEmpty(sheet.Cells[rowNum, 4].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 4].Text.Trim()); fileInfo.TaxRate = string.IsNullOrEmpty(sheet.Cells[rowNum, 6].Text.Trim().Replace("%", "")) ? 0 : int.Parse(sheet.Cells[rowNum, 6].Text.Trim().Replace("%", "")); fileInfo.AmountAfterTax = fileInfo.Amount * (fileInfo.TaxRate != 0 ? (Convert.ToDecimal(fileInfo.TaxRate) / 100) : 0 + 1); generalSummary.TotalCredit += fileInfo.AmountAfterTax < 0 ? -1 * fileInfo.AmountAfterTax : 0; generalSummary.TotalDebit += fileInfo.AmountAfterTax < 0 ? fileInfo.AmountAfterTax : 0; fileInfo.Description = sheet.Cells[rowNum, 3].Text.Trim(); fileInfo.GeneralRowId = generalSummary.RowId; fileInfo.CustomerId = generalSummary.CustomerId; fileInfo.DateOfValue = dateOfValue; fileInfo.RowId = rowNum; fileInfo.Invoice = invoice; return(fileInfo); } } } return(null); } catch (Exception e) { return(null); } }