/// <summary> /// Method to calculate the sales, record transaction, print receipt, and backup files /// </summary> void GenerateEndOfDaySalesReport() { EndOfSalesType = "Z"; _pos.GetNextCorteZNumber(); //Calculate sales and print receipts if (master) { //Regular CalculateSales(true); //Record End Of Sales Transaction in db Transaction.RecordEndOfDaySalesTransaction(Constants.DataFolderPath + Constants.EndOfDaySalesFileName, _pos.LastCorteZNumber, TransactionData.FirstReceiptNumber, TransactionData.LastReceiptNumber, TransactionData.TotalItemsSold, TransactionData.PointsTotal, TransactionData.CashTotal, TransactionData.CardTotal, TransactionData.CheckTotal, TransactionData.BankTotal, TransactionData.OtherTotal, TransactionData.TotalAmountSold, TransactionData.ReturnsCash, TransactionData.ReturnsCard, _pos.ExchangeRate, DateTime.Now.ToString(CultureInfo.CurrentCulture)); //Print Receipt PrintReceipt(ReceiptType.DailyRegular, false); CalculateSales(true, true); //Record End Of Sales Transaction in db Transaction.RecordEndOfDaySalesTransaction(Constants.DataFolderPath + Constants.MasterEndOfDaySalesFileName, _pos.LastCorteZNumber, TransactionData.FirstReceiptNumber, TransactionData.LastReceiptNumber, TransactionData.TotalItemsSold, TransactionData.PointsTotal, TransactionData.CashTotal, TransactionData.CardTotal, TransactionData.CheckTotal, TransactionData.BankTotal, TransactionData.OtherTotal, TransactionData.TotalAmountSold, TransactionData.ReturnsCash, TransactionData.ReturnsCard, _pos.ExchangeRate, DateTime.Now.ToString(CultureInfo.CurrentCulture)); //Print Receipt PrintReceipt(ReceiptType.DailyInternal, false); } else { CalculateSales(true); CalculateDelta(); CollectEndOfSalesReceiptInformation(); //Record End Of Sales Transaction in db Transaction.RecordEndOfDaySalesTransaction(Constants.DataFolderPath + Constants.EndOfDaySalesFileName, _pos.LastCorteZNumber, TransactionData.FirstReceiptNumber, TransactionData.LastReceiptNumber, TransactionData.TotalItemsSold, TransactionData.PointsTotal, TransactionData.CashTotal, TransactionData.CardTotal, TransactionData.CheckTotal, TransactionData.BankTotal, TransactionData.OtherTotal, TransactionData.TotalAmountSold, TransactionData.ReturnsCash, TransactionData.ReturnsCard, _pos.ExchangeRate, DateTime.Now.ToString(CultureInfo.CurrentCulture)); //Print Full Detailed Receipt PrintReceipt(ReceiptType.DailyRegular, false); } //BackUp Z Files and Clear Transaction.BackUpTransactionFile(Constants.DataFolderPath + Constants.TransactionsZFileName, true); //Transaction.BackUpTransactionMasterFile(Constants.DataFolderPath + Constants.TransactionsMasterFileName); Transaction.ClearTransactionFile(Constants.DataFolderPath + Constants.TransactionsZFileName); //Transaction.ClearTransactionMasterFile(Constants.DataFolderPath + Constants.TransactionsMasterFileName); FileIO.FileBackUp(Constants.DataFolderPath + Constants.InventoryFileName, Constants.DataFolderPath + Constants.InventoryBackupFolderPath); //Inventory.InventoryBackUp(Constants.DataFolderPath + Constants.InventoryFileName); //BackUp Z Expenses files Expense.BackUpExpensesFile(Constants.DataFolderPath + Constants.ExpenseZFileName, true); Expense.ClearExpensesFile(Constants.DataFolderPath + Constants.ExpenseZFileName); //Backup Z Paymenets Files Transaction.BackUpPaymentsFile(Constants.DataFolderPath + Constants.TransactionsPaymentsZFileName, true); Transaction.ClearPaymentsFile(Constants.DataFolderPath + Constants.TransactionsPaymentsZFileName); //Update POS Data // _pos.LastReceiptNumber = TransactionData.LastReceiptNumber; // _pos.LastTransactionNumber = TransactionData.LastTransactionNumber; // _pos.LastCashierAmountMxn = RegisterNewCash; // _pos.UpdateAllData(); // _pos.SaveDataTableToCsv(); }
public List <Expense> Search(string searchInput) { var expenses = new List <Expense>(); //Return empty list if invalid inputs are entered for the search if (string.IsNullOrWhiteSpace(searchInput) || searchInput == "x") { return(expenses); } if (searchInput == "*") { var allFields = base.DataTable.AsEnumerable(); foreach (var row in allFields) { var expense = new Expense(ExpensesXFilePath, ExpensesZFilePath, ExpensesHistoryFilePath) { Id = Int32.Parse(row["Id"].ToString()), User = row["Usuario"].ToString(), Vendor = row["Proveedor"].ToString(), TicketNumber = row["NumeroTicket"].ToString(), Description = row["Descripcion"].ToString(), Amount = Decimal.Parse(row["Monto"].ToString()), ExpenseCategory = row["CategoriaGasto"].ToString(), Date = Convert.ToDateTime(row["Fecha"].ToString()) }; if (row["Moneda"].ToString().ToUpper() == "USD") { expense.CurrencyType = CurrencyTypeEnum.USD; } else { expense.CurrencyType = CurrencyTypeEnum.MXN; } expense.PaymentType = (PaymentTypeEnum)Enum.Parse(typeof(PaymentTypeEnum), row["MetodoPago"].ToString(), true); expenses.Add(expense); } return(expenses); } var searchField1 = DataTable.AsEnumerable().Where(r => r.Field <string>("CategoriaGasto").ToLower().Contains(searchInput)); var searchField2 = DataTable.AsEnumerable().Where(r => r.Field <string>("Proveedor").ToLower().Contains(searchInput)); foreach (var row in searchField1) { var expense = new Expense(ExpensesXFilePath, ExpensesZFilePath, ExpensesHistoryFilePath) { Id = Int32.Parse(row["Usuario"].ToString()), User = row["Usuario"].ToString(), Vendor = row["Proveedor"].ToString(), TicketNumber = row["NumeroTicket"].ToString(), Description = row["Descripcion"].ToString(), Amount = Decimal.Parse(row["Monto"].ToString()), ExpenseCategory = row["CategoriaGasto"].ToString(), Date = Convert.ToDateTime(row["Fecha"].ToString()) }; if (row["Moneda"].ToString().ToUpper() == "USD") { expense.CurrencyType = CurrencyTypeEnum.USD; } else { expense.CurrencyType = CurrencyTypeEnum.MXN; } expense.PaymentType = (PaymentTypeEnum)Enum.Parse(typeof(PaymentTypeEnum), row["MetodoPago"].ToString(), true); expenses.Add(expense); } foreach (var row in searchField2) { var expense = new Expense(ExpensesXFilePath, ExpensesZFilePath, ExpensesHistoryFilePath) { Id = Int32.Parse(row["Usuario"].ToString()), User = row["Usuario"].ToString(), Vendor = row["Proveedor"].ToString(), TicketNumber = row["NumeroTicket"].ToString(), Description = row["Descripcion"].ToString(), Amount = Decimal.Parse(row["Monto"].ToString()), ExpenseCategory = row["CategoriaGasto"].ToString(), Date = Convert.ToDateTime(row["Fecha"].ToString()) }; if (row["Moneda"].ToString().ToUpper() == "USD") { expense.CurrencyType = CurrencyTypeEnum.USD; } else { expense.CurrencyType = CurrencyTypeEnum.MXN; } expense.PaymentType = (PaymentTypeEnum)Enum.Parse(typeof(PaymentTypeEnum), row["MetodoPago"].ToString(), true); //Add if it does not exist already if (!expenses.Exists(x => x.Id == expense.Id)) { expenses.Add(expense); } } return(expenses); }