[ Foro de C# ]

Generar Tique-Factura (Comprobante "A") con Epson TM220-U220.

25-Aug-2017 01:45
Ivan Sini
2 Respuestas

Buenas noches. Les escribo para hacerles la siguiente consulta.
Tengo una aplicacion para facturar, desarrollada utilizando C# y Visual Studio 2012.
En ella, emito ticket fiscales de tipo A y B.
Los ticket/facturas B, la controladora fiscal EPSON me las imprime sin ningún problema. El inconveniente me surge con los tickets de tipo A, ya que tras transcurrir el proceso la impresora no emite factura, ni ninguna señal, ni da ningun error, simplemente no hace nada. Debugeando el código, las instrucciones se ejecutan correctamente y tras ejecutarse todo el codigo no se produce error, pero tampoco se imprime nada. Adjunto el código que utilizo para comunicarme con la impresora. Aclaro que utilizo la libreria fiscal  axPrinterFiscal1, tanto para emitir tickets A y B. (Reitero que para los de tipo B no tengo ningún problema).

Código:


  axPrinterFiscal1.PortNumber = short.Parse(puertoCOM.ToString()); ; //El numero de puerto al cual se encuentra conectada la Controladora Fiscal
                axPrinterFiscal1.BaudRate = "9600";
                Double TotalNuevo = 0;
                String ventaEpsonA = "M";
                String bultosEpsonA = "0";
                String ImpuestosInternos = "0";
                String printerEpsonA = "P";
                String textoEpsonA = "SUB";
                String pagoEpsonA = "PAGO";
                String monto = "";
                String descripcion = "T";
                String tipoDocumentoFiscal = "T";
                String salidaImpresora = "C";
                String letraFactura = "A";
                String cantidadCopias = "1";
                String tipoFormulario = "P";
                String tipoLetra = "12";
                String IVA_Emisor = "I";
                String IVA_Comprador = "I";
                String nombreCliente1 = _clienteSeleccionado.Nombre; //Variable que contiene el nombre del cliente
                String nombreCliente2 = _clienteSeleccionado.Apellido; //Variable que contiene la razon social del cliente
                String tipoDocumento = "CUIT";
                String numeroDocumento = _clienteSeleccionado.Dni; //Aquí viene una variable que contiene el CUIT del cliente (sin guiones)
                String bienDeUso = "N";
                String remito1 = " ";
                String remito2 = " ";
                String tipoTablaItem = "C";
                String domicilioComprador1 = " "; //Variable que contiene el Domicilio del cliente
                String domicilioComprador2 = "";
                String domicilioComprador3 = "";
                if (_clienteSeleccionado.Direccion != "" || _clienteSeleccionado.Direccion != null)
                {
                    domicilioComprador1 = " ";
                }
                foreach (DataGridViewRow aux in dataGridView1.Rows)
                {
                    TotalNuevo = TotalNuevo + (Convert.ToDouble(aux.Cells[5].Value) - Convert.ToDouble(aux.Cells[6].Value));
                }              
                monto = formatTotal(TotalNuevo, monto).ToString();

                //Función para dar apertura a una factura A, la cual recibe los siguientes parámetros por referencia                        
                axPrinterFiscal1.OpenInvoice(ref tipoDocumentoFiscal, ref salidaImpresora, ref letraFactura, ref cantidadCopias, ref tipoFormulario, ref tipoLetra, ref IVA_Emisor, ref IVA_Comprador, ref nombreCliente1, ref nombreCliente2, ref tipoDocumento, ref numeroDocumento, ref bienDeUso, ref domicilioComprador1, ref domicilioComprador2, ref domicilioComprador3, ref remito1, ref remito2, ref tipoTablaItem);

                //Recorro la grilla para cargar el detalle al cuerpo del Tique Factura
                foreach (DataGridViewRow aux in dataGridView1.Rows)
                {
                    String articulo = aux.Cells[2].Value.ToString();
                    if (articulo.Length > 13)
                    {
                        String precioArticulo;
                        descripcion_resumida = articulo.Substring(0, 13);
                        if (Convert.ToDecimal(aux.Cells[6].Value).ToString() == "0")
                        {
                            precioArticulo = aux.Cells[4].Value.ToString();
                        }
                        else
                        {
                            precioArticulo = (Convert.ToDouble(aux.Cells[4].Value) - ((Convert.ToDouble(aux.Cells[6].Value)) / (Convert.ToDouble(aux.Cells[3].Value)))).ToString();
                        }
                        precioArticulo = precioArticulo.Replace(".", "");
                        precioArticulo = precioArticulo.Replace(",", "");
                        String cant = aux.Cells[3].Value.ToString() + "000";
                        total = total + (Convert.ToDecimal(precioArticulo) * Convert.ToDecimal(cant));
                        String iva = aux.Cells[7].Value.ToString() + "00";
                        axPrinterFiscal1.SendTicketItem(ref articulo, ref cant, ref precioArticulo, ref iva, ref ventaEpsonA, ref bultosEpsonA, ref ImpuestosInternos);
                    }
                    else
                    {
                        String precioArticulo;
                        if (Convert.ToDecimal(aux.Cells[6].Value).ToString() == "0")
                        {
                            precioArticulo = aux.Cells[4].Value.ToString();
                        }
                        else
                        {
                            precioArticulo = (Convert.ToDouble(aux.Cells[4].Value) - ((Convert.ToDouble(aux.Cells[6].Value)) / (Convert.ToDouble(aux.Cells[3].Value)))).ToString();
                        }
                        precioArticulo = precioArticulo.Replace(".", "");
                        precioArticulo = precioArticulo.Replace(",", "");
                        String cant = aux.Cells[3].Value.ToString() + "000";
                        total = total + (Convert.ToDecimal(precioArticulo) * Convert.ToDecimal(cant));
                        String iva = aux.Cells[7].Value.ToString() + "00";
                        axPrinterFiscal1.SendTicketItem(ref articulo, ref cant, ref precioArticulo, ref iva, ref ventaEpsonA, ref bultosEpsonA, ref ImpuestosInternos);
                    }
                }

                //Las siguientes líneas cargan los totales del Ticket
                axPrinterFiscal1.GetInvoiceSubtotal(ref printerEpsonA, ref textoEpsonA);
                axPrinterFiscal1.SendInvoicePayment(ref pagoEpsonA, ref monto, ref descripcion);
                String parametroVacio = "";
                axPrinterFiscal1.CloseInvoice(ref descripcion, ref letraFactura, ref parametroVacio);




Antes que nada muchisimas gracias por su tiempo. Saludos.


25-Aug-2017 04:58
Ivan Sini

Bueno gente, les cuento que ya pude resolver el problema. Aunque no haya tenido respuestas, les dejo la solución por si alguien ingresa buscando con algun problema similar.

Tenía varios problemas.

El mas importante a mi entender era que en ver de invocar al metodo "SendInvoiceItem", estaba invocando "SendTicketItem", el cual se utiliza para comprobantes B. Este metodo recibe 5 paramerosmas, tres de ellos en blanco y dos mas de tazas, acá les dejo la linea:


                        axPrinterFiscal1.SendInvoiceItem(ref articulo, ref cant, ref precioArticulo, ref iva, ref ventaEpsonA, ref bultosEpsonA, ref ImpuestosInternos, ref vacio, ref vacio, ref vacio, ref otrosImpuestos, ref incremetoTasa); 



Luego por las dudas también hice un par de correciones mas, como sacarle el punto al IVA para que quede de la forma iva = 2100.
Otra fue, enviar los domicilios 2 y 3 del comprador, con un "-" en vez de enviarlos vacíos.

En resumen, con todo eso salió finalmente andando. Espero a alguien mas le ayude este tema.

Saludos.


30-Aug-2017 12:40
Nacho Cabanes (+83)

Siento haber llegado tarde, pero me alegro de que lo hayas podido resolver. Posiblemente yo no hubiera dado con esos errores sin conocer bien tu código.






(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)