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();
}
}