//int GetFacturaNumber(string line) //{ // return int.Parse(line.Substring(line.Length - 6, 5)); //} //int GetTable(string line) //{ // return int.Parse(line.Substring(line.Length - 5, 4)); //} private LineOfWork CreateLineOfWork(Dictionary <int, LineOfWork> activeLinesOfWork, DateTime startDate, int tableNumber) { LineOfWork low = new LineOfWork(); low.TableNumber = tableNumber; low.StartDate = startDate; activeLinesOfWork[tableNumber] = low; return(low); }
private LineOfWork CreateLineOfWork(string date_line, int tableNumber) { LineOfWork low = new LineOfWork(); low.TableNumber = tableNumber; low.StartDate = ParseDate(date_line); activeLinesOfWork[tableNumber] = low; shiftLinesOfWork.Add(low); return(low); }
private static int GetSpanKey(LineOfWork low) { if (low.FacturaDate < low.StartDate) { } //TimeSpan span = low.FacturaDate - low.StartDate; int inMinutes = low.ServiceTime; if (inMinutes > 60) { inMinutes = 65; } int result = inMinutes == 0 ? 1 : (inMinutes - 1) / 5 + 1; return(result); }
void ProcessReceipt(IUnitOfWork unitOfWork, Dictionary <int, LineOfWork> activeLinesOfWork, DateTime workDate, int shiftId, List <Report103Line> receiptLines, List <int> result) { Report103Line firstLine = receiptLines[0]; DateTime receiptDate = firstLine.DateAndTime; //date appears in the line before last if (firstLine.FunctionText.Contains("*** FACTURA ***")) { Sale newSale = new Sale(); //FACTURA # newSale.Number = firstLine.Quantity;//first line shows factura # //MESA # int tableNumber = receiptLines[1].Quantity; LineOfWork low = activeLinesOfWork[tableNumber]; //work date newSale.Date = workDate; //get date created from LineOfWork newSale.DateCreated = low.StartDate; //print ticket to client date newSale.DatePrinted = low.PrintTicketDate; //FACTURA DATE newSale.DateClosed = receiptDate; //TURNO newSale.ShiftId = shiftId; //CLIENTE # //sometimes this line doesn't appear if (receiptLines[2].FunctionText.Contains("CLIENTE #")) { newSale.Persons = receiptLines[2].Quantity; } //LINEITEMS for (int i = 3; i < receiptLines.Count; i++) { Report103Line line = receiptLines[i]; //los lineitems tienen 10000 ahí, no preguntes pq if (line.FunctionType == 10000) { //check for new product int plu = line.FunctionNumber; Product prod = unitOfWork.ProductRepository.GetFromPLU(plu); if (prod == null) { prod = new Product(); prod.Code = plu; prod.Name = line.FunctionText.Trim('"'); prod.SalePrice = line.Amount / line.Quantity; prod.ProductType = ProductType.FinishedGoods;//default unitOfWork.ProductRepository.Add(prod); //prod = new MainWindowViewModel().CreateProduct(plu, line.FunctionText.Trim('"'), line.Amount / line.Quantity); } SaleLineItem sli = new SaleLineItem(); sli.Quantity = line.Quantity; sli.UnitMeasure = unitOfWork.UMRepository.GetById(1);// appvm.UnitMeasureManager.Unit; sli.Amount = line.Amount; //get product from PLU or create a new one sli.Product = prod; var invSVC = ServiceContainer.GetService <IInventoryService>(); //update total cost newSale.TotalCost += sli.Cost = invSVC.GetProductCost(prod, sli.Quantity, sli.UnitMeasure); newSale.LineItems.Add(sli); newSale.SaleLineItems.Add(sli); } //DESCONTADO % else if (line.FunctionType == 1000) { System.Diagnostics.Debug.Assert(line.FunctionText.Contains("DESCONTADO %")); newSale.Discount = line.Amount; } //TOTAL else if (line.FunctionNumber == 99) { System.Diagnostics.Debug.Assert(line.FunctionText.Contains("TOTAL")); newSale.Total = line.Amount; newSale.SubTotal = newSale.Total + newSale.Discount; } } //DESCONTADO % //Report103Line discount_line = receiptLines[receiptLines.Count - 6]; //if (discount_line.FunctionText.Contains("DESCONTADO %")) //{ // newSale.Discount = discount_line.Amount; //} //TOTAL //Report103Line total_line = receiptLines[receiptLines.Count - 5]; //if (total_line.FunctionText.Contains("TOTAL")) //{ // newSale.Total = total_line.Amount; // newSale.SubTotal = newSale.Total + newSale.Discount; //} //VOIDS newSale.Voids = low.VoidCount; newSale.VoidsAfterReceipt = low.CriticalVoidCount; //save changes //appvm.SaveChanges(); unitOfWork.OrderRepository.Add(newSale); unitOfWork.SaveChanges(); result.Add(newSale.Id); //remove line of work from active list activeLinesOfWork.Remove(low.TableNumber); } else if (firstLine.FunctionText.Contains("** RECIBO **")) { int tableNumber = receiptLines[1].Quantity; //Transfer Table if (receiptLines[2].FunctionText.Contains("Transfer Table")) { int tableSource = receiptLines[1].Quantity; int tableTarget = receiptLines[3].Quantity; //GetTablesInTransfer(receiptLines, out tableSource, out tableTarget); if (tableSource != tableTarget) { //change table number in line of work for future operations LineOfWork low = activeLinesOfWork[tableSource]; low.TableNumber = tableTarget; activeLinesOfWork.Remove(tableSource); activeLinesOfWork[tableTarget] = low; } } //Split Table else if (receiptLines[2].FunctionText.Contains("Split Table")) { //3rd line bottom up show destination table int tableDestination = receiptLines[receiptLines.Count - 3].Quantity; //create a new LoW if it didn't exist if (!activeLinesOfWork.ContainsKey(tableDestination)) { LineOfWork temp = CreateLineOfWork(activeLinesOfWork, receiptDate, tableDestination); } } //VOID else if (receiptLines[2].FunctionText.Contains("VOID")) { //add a void operation to the line of work LineOfWork low = activeLinesOfWork[tableNumber]; low.VoidCount++; if (low.TicketPrinted) { low.CriticalVoidCount++; } } //Print Ticket else if (receiptLines[receiptLines.Count - 1].FunctionText.Contains("TOTAL")) { LineOfWork low = activeLinesOfWork[tableNumber]; if (!low.TicketPrinted) { //set the print date low.PrintTicketDate = receiptDate; low.TicketPrinted = true; } } else if (!activeLinesOfWork.ContainsKey(tableNumber)) { LineOfWork temp = CreateLineOfWork(activeLinesOfWork, receiptDate, tableNumber); } } //ABRIR CAJON else { } }
void ProcessOperation(List <string> lines) { string firstLine = lines[0]; string date_line = lines[lines.Count - 2]; //date appears in the line before last if (firstLine.Contains("*** FACTURA ***")) { int tableNumber = GetTable(lines[1]); //second line shows table LineOfWork low = activeLinesOfWork[tableNumber]; int facturaNumber = GetFacturaNumber(firstLine); low.FacturaNumber = facturaNumber; low.OperationTrack.Add(Report101Operation.Factura); //Clients string thirdLine = lines[2]; //sometimes this line doesn't appear if (thirdLine.Contains("CLIENTE #")) { low.Clients = int.Parse(thirdLine.Substring(thirdLine.Length - 5, 4)); } //Discount string discount_line = lines[lines.Count - 8]; if (discount_line.Contains("DESCONTADO %")) { string last_piece = discount_line.Split(';').Last(); low.Discount = decimal.Parse(last_piece.Substring(last_piece.Length - 7, 6)); } //Total //int qtty; string name; decimal price; //ParseLineItem(lines[lines.Count - 7], out qtty, out name, out price); low.Total = GetFacturaTotal(lines); //and set the factura date low.FacturaDate = ParseDate(date_line); //remove line of work from active list (it will stay in shift list) activeLinesOfWork.Remove(low.TableNumber); } else if (firstLine.Contains("** RECIBO **")) { int tableNumber = GetTable(lines[1]); //second line shows table int qtty; string name; decimal price; //Transfer Table if (lines[2].Contains("Transfer Table")) { int tableSource, tableTarget = 0; GetTablesInTransfer(lines, out tableSource, out tableTarget); if (tableSource != tableTarget) { //change table number in line of work for future operations LineOfWork low = activeLinesOfWork[tableSource]; low.TableNumber = tableTarget; if (!activeLinesOfWork.ContainsKey(tableTarget)) { activeLinesOfWork[tableTarget] = low; } else { shiftLinesOfWork.Remove(low); } activeLinesOfWork.Remove(tableSource); } } //Split Table else if (lines[2].Contains("Split Table")) { //3rd line bottom up show destination table int tableDestination = GetTable(lines[lines.Count - 3]); //create a new LoW if it didn't exist if (!activeLinesOfWork.ContainsKey(tableDestination)) { LineOfWork temp = CreateLineOfWork(date_line, tableDestination); } } //VOID else if (lines[2].Contains("VOID")) { //add a void operation to the line of work LineOfWork low = activeLinesOfWork[tableNumber]; low.OperationTrack.Add(Report101Operation.Void); } //Print Ticket else if (ParseLineItem(lines[lines.Count - 3], out qtty, out name, out price) && name == "TOTAL") { //add new print operation LineOfWork low = activeLinesOfWork[tableNumber]; low.OperationTrack.Add(Report101Operation.Print); //and set the print date low.PrintTicketDate = ParseDate(date_line); } else if (!activeLinesOfWork.ContainsKey(tableNumber)) { if (tableNumber == 8) { } LineOfWork temp = CreateLineOfWork(date_line, tableNumber); } } //ABRIR CAJON else { abrir_cajon_counter++; } }