public void BuildBody()
        {
            Customer customer = folio.Customer;
            Product  product  = folio.Product;

            ticket.TextLocationMode = TicketPaperLocation.Body;
            ticket.SideText("Fecha de expedición:", DateTime.Today.ToShortDateString());
            ticket.SideText("Recepción de equipos", $"Folio: {folio.ID}");
            ticket.Separator(TicketSeparator.Dash);
            ticket.CenterText("[Datos del cliente]");
            ticket.LeftText($"Nombre: {customer.Firstname} {customer.Lastname}");
            //if (!string.IsNullOrWhiteSpace(customer.Telephone))
            //    ticket.LeftText($"Teléfono: {customer.Telephone}");
            if (!string.IsNullOrWhiteSpace(customer.Email))
            {
                ticket.LeftText($"Email: {customer.Email}");
            }
            ticket.Separator(TicketSeparator.Asterisk);
            ticket.CenterText("[Datos del equipo]");
            ticket.LeftText($"Marca: {product.Trademark}");
            ticket.LeftText($"Modelo: {product.Model}");
            ticket.LeftText($"No. de Serie:");
            ticket.LeftText($"{product.SerialNumber}");
            ticket.LeftText($"Descripción de la falla:");
            foreach (Issue i in issues)
            {
                ticket.RightText($"* {i.Text}");
            }
            ticket.Separator(TicketSeparator.Dash);
        }
Пример #2
0
        private static void BuildBody(TicketDocument ticket, OrderDataModel order)
        {
            CustomerModel customer = order.Customer;

            ticket.TextLocationMode = TextTicketLocation.Body;
            ticket.SideText("Fecha de expedición:", DateTime.Today.ToShortDateString());
            ticket.SideText("Fecha de venta:", order.DateAdded.ToShortDateString());
            ticket.SideText("Folio:", $"#{order.ID}");
            ticket.Separator(TicketSeparator.Dash);

            // Cliente
            ticket.CenterText("[Datos del cliente]");
            ticket.LeftText($"Nombre: {customer.Firstname} {customer.Lastname}");
            if (!string.IsNullOrWhiteSpace(customer.Email))
            {
                ticket.LeftText($"Email: {customer.Email}");
            }

            ticket.Separator(TicketSeparator.Asterisk);

            // Venta
            ticket.CenterText("[Datos de venta]");
            ticket.SideText("Método de pago:", order.PaymentMethod.ToString());
            ticket.SideText("Método de envío:", order.ShippingMethod.ToString());
            ticket.Separator(TicketSeparator.Blank);
            ticket.Separator(TicketSeparator.Dash);
            ticket.LeftText("Producto\tP/U\tCant\tTotal");
            ticket.Separator(TicketSeparator.Dash);

            // Productos
            StringBuilder serials    = new StringBuilder();
            bool          hasSerials = false;

            foreach (OrderProductModel op in order.Cart)
            {
                string prod = (op.Name.Length < 8) ? op.Name.PadRight(8) : op.Name.Substring(0, 8);

                ticket.LeftText($"-{prod}\t${op.Price:#.##}\t{op.Quantity}\t${op.Total:#.##}");

                if (op.SerialNumbers.Count() > 0)
                {
                    hasSerials = true;
                    foreach (ProductSerialModel serial in op.SerialNumbers)
                    {
                        serials
                        .Append($"-{prod} {serial.SerialNumber}"
                                .PadRight(TicketLen))
                        .Append($"{serial.DateStart.ToShortDateString()} {serial.DateEnd.ToShortDateString()}"
                                .PadRight(TicketLen));
                    }
                }
            }
            if (hasSerials)
            {
                ticket.Separator(TicketSeparator.Dash);
                // Serials
                ticket.CenterText("# Serie | Garantía");
                ticket.Separator(TicketSeparator.Blank);
                ticket.LeftText(serials.ToString());
            }

            ticket.Separator(TicketSeparator.Dash);

            // Totales
            var orderTotals = order.OrderTotals.OrderBy(o => o.SortOrder);

            foreach (OrderTotalModel ot in orderTotals)
            {
                ticket.RightText($"{ot.Title}: {((ot.Value != 0) ? $"{ot.Value:#.##}" : "N/A")}");
            }
            ticket.RightText($"IVA: 16%");
            ticket.Separator(TicketSeparator.Dash);
        }