GetAllTablesAndOpenInvoices() public method

Returns a list of all tables and on hold invoices in the store/restaurant delivery invoices will have a sectionID of XXDELIVERY takeout invoices will have a sectionID of XXTAKEOUT tabs not associated with tables will have a section ID of XXOPEN TABS invoices that are at table will have the section ID of the resturant section that the table diagram screen lists them in(i.e. Bar, Dining Room, ext)
public GetAllTablesAndOpenInvoices ( Context context ) : List
context Context The store id, station id, and cashier id the information should be restricted to.
return List
        static void TestTables()
        {
            try
            {
                pcAmerica.DesktopPOS.API.Client.TableService.Context context = new pcAmerica.DesktopPOS.API.Client.TableService.Context();
                context.CashierID = "100101";
                context.StationID = "01";
                context.StoreID = "1001";

                TableAPI api = new TableAPI();

                List<TableInfo> tables = api.GetAllTablesAndOpenInvoices(context);
                int takeoutOrders = 0;
                int openTabOrders = 0;
                int deliveryOrders = 0;
                int occupiedTables = 0;
                int emptyTables = 0;
                if (tables == null)
                    Console.WriteLine("***ERROR*** No tables or invoices were returned");
                else

                    foreach (TableInfo table in tables)
                    {
                        if (table.SectionID == "XXTAKEOUT")
                        {
                            takeoutOrders++;
                        }
                        else if (table.SectionID == "XXOPEN TABS")
                        {
                            openTabOrders++;
                        }
                        else if (table.SectionID == "XXDELIVERY")
                        {
                            deliveryOrders++;
                        }
                        else if (!string.IsNullOrEmpty(table.OnHoldID))
                        {
                            occupiedTables++;
                        }
                        else
                        {
                            emptyTables++;
                        }
                    }
                Console.WriteLine("Takeout Order Count: {0}", takeoutOrders);
                Console.WriteLine("Open Tabs Order Count: {0}", openTabOrders);
                Console.WriteLine("Delivery Order Count: {0}", deliveryOrders);
                Console.WriteLine("Occupied Table Count: {0}", occupiedTables);
                Console.WriteLine("Empty Table Count: {0}", emptyTables);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }
        static void TestSectionsAndTables()
        {
            try
            {
                SalesAPI salesAPI = new SalesAPI();
                TableAPI tableAPI = new TableAPI();

                pcAmerica.DesktopPOS.API.Client.SalesService.Context context = new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                context.CashierID = "100101";
                context.StoreID = "1001";
                context.StationID = "01";

                pcAmerica.DesktopPOS.API.Client.TableService.Context tableContext = new pcAmerica.DesktopPOS.API.Client.TableService.Context();
                tableContext.CashierID = "100101";
                tableContext.StationID = "01";
                tableContext.StoreID = "1001";
                Invoice inv;
                List<TableInfo> tables = tableAPI.GetAllTablesAndOpenInvoices(tableContext);
                if (tables.Count > 0)
                {
                    int i = 0;
                    for (i = 0; i < tables.Count - 1; i++)
                    {
                        if (tables[i].SectionID.StartsWith("XX") && !tables[i].Occupied) { continue; }
                        inv = salesAPI.StartNewInvoice(context, tables[i].TableNumber, tables[i].SectionID);
                        salesAPI.LockInvoice(context, inv.InvoiceNumber);
                        inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });
                        salesAPI.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                        salesAPI.UnLockInvoice(context, inv.InvoiceNumber);
                        break;
                    }
                }

                inv = salesAPI.StartNewInvoice(context, "Dave", "XXTAKEOUT");
                salesAPI.LockInvoice(context, inv.InvoiceNumber);
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });
                salesAPI.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                salesAPI.UnLockInvoice(context, inv.InvoiceNumber);

                inv = salesAPI.StartNewInvoice(context, "Jay", "XXOPEN TABS");
                salesAPI.LockInvoice(context, inv.InvoiceNumber);
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });
                salesAPI.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                salesAPI.UnLockInvoice(context, inv.InvoiceNumber);

                //NOTE: Delivery invoices will be put into the delivery tab section however the will not be put
                //into Delivery Tracking as there is curently no way to provide customer numbers or a time promised
                inv = salesAPI.StartNewInvoice(context, "Sara", "XXDELIVERY");
                salesAPI.LockInvoice(context, inv.InvoiceNumber);
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });
                salesAPI.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                salesAPI.UnLockInvoice(context, inv.InvoiceNumber);

                Console.WriteLine("There should now be open invoices on the first empty table in the list as well as in the Delivery, Takeout and  Open Tabs sections.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }