コード例 #1
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);
        }