示例#1
0
        public void PrintToReceipt()
        {
            for (int i = 0; i < Lines.Count; i++)
            {
                string line = Lines[i];
#if !DEBUG
                // Change formatting for the PosPrinter
                while (line.Contains("   "))
                {
                    line = line.Replace("   ", "  ");
                }
                line = line.Replace("  ", PrinterEscapeCodes.SetRight + PrinterEscapeCodes.SetSize(8));
#endif
#if !DEMO
                PrinterManager.PrintLineToReceipt(DeviceManager.ActivePosPrinterLocal, line);
#endif
            }
        }
示例#2
0
        private static void PrintTicketItemOptions(PosPrinter printer, TicketItem ticketItem)
        {
            Item item = Item.Get(ticketItem.ItemId);

            // Get the option sets for this category
            List <ItemOption> options1 = new List <ItemOption>(ItemOption.GetInSet(item.ItemOptionSetIds[0]));
            List <ItemOption> options2 = new List <ItemOption>(ItemOption.GetInSet(item.ItemOptionSetIds[1]));
            List <ItemOption> options3 = new List <ItemOption>(ItemOption.GetInSet(item.ItemOptionSetIds[2]));

            // Get the options for this ticket item's category
            List <TicketItemOption> ticketItemOptions = new List <TicketItemOption>(
                TicketItemOption.GetAll(ticketItem.PrimaryKey));

            if (options1.Count > 0)
            {
                string line = "";
                if (ProcessItemOption(ticketItemOptions, options1, ref line))
                {
                    PrintLineToReceipt(printer, PrinterEscapeCodes.SetSize(5) +
                                       "[" + line + "]");
                }
            }
            if (options2.Count > 0)
            {
                string line = "";
                if (ProcessItemOption(ticketItemOptions, options2, ref line))
                {
                    PrintLineToReceipt(printer, PrinterEscapeCodes.SetSize(5) +
                                       "[" + line + "]");
                }
            }
            if (options3.Count > 0)
            {
                string line = "";
                if (ProcessItemOption(ticketItemOptions, options3, ref line))
                {
                    PrintLineToReceipt(printer, PrinterEscapeCodes.SetSize(5) +
                                       "[" + line + "]");
                }
            }
        }
示例#3
0
        private static double[] PrintTicketItemToReceipt(PosPrinter printer,
                                                         TicketItem ticketItem, bool showMakeTags, TicketItemPrintOptions printOptions,
                                                         TicketType ticketType)
        {
            Item item     = Item.Get(ticketItem.ItemId);
            int  quantity = ticketItem.Quantity;

            // Reasons to skip this TicketItem
            if ((printOptions == TicketItemPrintOptions.OnlyChanged) &&
                !ticketItem.IsChanged &&
                (ticketItem.OrderTime != null))
            {
                return(null);
            }
            if ((printOptions == TicketItemPrintOptions.AllNonCanceled) &&
                ticketItem.IsCanceled)
            {
                return(null);
            }
            if ((printOptions == TicketItemPrintOptions.AllUnfired) &&
                (ticketItem.IsCanceled || !item.IsFired || (ticketItem.FireTime != null)))
            {
                return(null);
            }

            // Return verse actual quantity
            if (printOptions == TicketItemPrintOptions.TicketItemReturn)
            {
                quantity = ticketItem.QuantityPendingReturn;
            }

            // Setup make-tags
            string cost = null;

            if (showMakeTags || (printOptions == TicketItemPrintOptions.AllAsVoid) ||
                (printOptions == TicketItemPrintOptions.TicketItemVoid))
            {
                if (ticketItem.IsCanceled && ticketItem.PreparedTime.HasValue)
                {
                    cost = "[" + Strings.CancelMade + "]";
                }
                else if (ticketItem.IsCanceled)
                {
                    cost = "[" + Strings.CancelUnmade + "]";
                }
                else if (showMakeTags)
                {
                    if ((ticketType == TicketType.DineIn) && (item.IsFired))
                    {
                        cost = (printOptions != TicketItemPrintOptions.AllUnfired)
                            ? Strings.Hold : Strings.Fired;
                    }
                    else if (ticketItem.OrderTime == null)
                    {
                        cost = Strings.Make;
                    }
                    else
                    {
                        cost = Strings.Changed;
                    }
                }
            }

            // Actually want to display cost, and not a make-tag
            if (cost == null)
            {
                cost = ticketItem.GetTotalCost(ticketItem.QuantityPendingReturn).
                       ToString("C2");
            }

            // Print the item's quantity, name, and cost
            PrintLineToReceipt(printer,
                               quantity +
                               PrinterEscapeCodes.SetSize(5) +
                               item.FullName +
                               PrinterEscapeCodes.SetRight +
                               cost);

            if (printOptions != TicketItemPrintOptions.TicketItemReturn)
            {
                // Print TicketItemOption(s) for this TicketItem
                PrintTicketItemOptions(printer, ticketItem);

                if (ticketItem.SpecialInstructions != null)
                {
                    // ToDo: This line needs to wrap if receipt tape is not wide enough
                    // for the entire special comment
                    PrintLineToReceipt(printer,
                                       PrinterEscapeCodes.SetSize(5) +
                                       "+[" +
                                       ticketItem.SpecialInstructions +
                                       "]");
                }
            }
            else
            {
                double returnAmount   = ticketItem.GetTotalCost(ticketItem.QuantityPendingReturn);
                double couponAmount   = ticketItem.GetTotalCoupon(returnAmount);
                double discountAmount = ticketItem.GetTotalDiscount(returnAmount);
                returnAmount -= couponAmount - discountAmount;
                double taxAmount = ticketItem.GetTax(returnAmount);
                if (couponAmount > 0)
                {
                    PrintLineToReceipt(printer, PrinterEscapeCodes.SetSize(5) + Strings.Coupons +
                                       PrinterEscapeCodes.SetRight + couponAmount.ToString("C2"));
                }
                if (discountAmount > 0)
                {
                    PrintLineToReceipt(printer, PrinterEscapeCodes.SetSize(5) + Strings.Discounts +
                                       PrinterEscapeCodes.SetRight + discountAmount.ToString("C2"));
                }
                return(new [] {
                    returnAmount,
                    taxAmount
                });
            }
            return(null);
        }