Пример #1
0
        public static TS_BEMensaje SynchronizedSetSale(TerminalSIGES.Models.Lado Cara, TS_BEArticulo Transaccion)
        {
            TS_BELoadInput     cLoadingInput  = TSSalesInput.LoadInput();
            TS_BEClienteInput  cClienteInput  = TSSalesInput.InputClienteAutomaticMethod(Cara);
            TS_BECabeceraInput cCabeceraInput = TSSalesInput.InputCabeceraAutomaticMethod(Cara);

            TS_BEDetalleInput[]   cDetalleInput  = TSSalesInput.InputDetalleAutomaticMethod(Transaccion).ToArray();
            List <TS_BEPagoInput> vPagos         = TSSalesInput.InputPagosAutomaticMethod(Cara, Transaccion);
            TS_BEGrabarConfig     vConfiguracion = new TS_BEGrabarConfig()
            {
                IsNotPrint = Cara.IsImprimir
            };

            if (vPagos == null)
            {
                return(new TS_BEMensaje()
                {
                    mensaje = "EL MONTO TOTAL NO COINCIDE CON LOS PAGOS DE LA VENTA", Ok = false
                });
            }

            TS_BEPagoInput[] cPagoInput = vPagos.ToArray();

            TSSalesInput.InputMoneyAutomaticMethod(Cara, cCabeceraInput, cDetalleInput, cPagoInput);
            TS_SISalesClient client = null;

            try
            {
                client = new TS_SISalesClient(Helper.ServicioSoapBinding(), new EndpointAddress(Config.Services.Sales));
                TS_BERetornoTransaccion respuesta = client.GrabarTransaccion(cDetalleInput, cCabeceraInput, cPagoInput, cClienteInput, cLoadingInput, vConfiguracion);
                if (respuesta.Ok)
                {
                    return(new TS_BEMensaje()
                    {
                        mensaje = respuesta.Codigo, Ok = true
                    });
                }
                else
                {
                    return(new TS_BEMensaje()
                    {
                        mensaje = respuesta.Mensaje, Ok = false
                    });
                }
            }
            catch (Exception e)
            {
                if (client != null)
                {
                    if (client.State == CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
                return(new TS_BEMensaje()
                {
                    mensaje = e.Message, Ok = false
                });
            }
        }
Пример #2
0
        public static TS_BECabeceraInput InputCabeceraAutomaticMethod(TerminalSIGES.Models.Lado Cara)
        {
            string TipoDocumento = "00003";

            if (Cara.Documento == TerminalSIGES.Models.EDocumento.BoletaFactura)
            {
                if (String.IsNullOrEmpty(Cara.Ruc))
                {
                    TipoDocumento = "00003";
                }
                else
                {
                    TipoDocumento = "00001";
                }
            }
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.NotaDespacho)
            {
                TipoDocumento = "99999";
            }
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.Serafin)
            {
                TipoDocumento = "99998";
            }
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.TranferenciaGratuita)
            {
                if (String.IsNullOrEmpty(Cara.Ruc))
                {
                    TipoDocumento = "00003";
                }
                else
                {
                    TipoDocumento = "00001";
                }
            }

            return(new TS_BECabeceraInput()
            {
                TipoVenta = (Cara.Documento == TerminalSIGES.Models.EDocumento.TranferenciaGratuita) ? "T" : "",
                cdcliente = Cara.Codigo,
                cdmoneda = "S",
                cdtipodoc = TipoDocumento,
                cdusuario = TSLoginApp.UserName,
                cdvendedor = "",
                chofer = Cara.Chofer,
                mtovueltodol = Convert.ToDecimal(0),
                mtovueltosol = Convert.ToDecimal(0),
                nroplaca = Cara.Placa,
                nrotarjeta = (Cara.Documento == TerminalSIGES.Models.EDocumento.NotaDespacho) ? Cara.Tarjeta : Cara.Tarjeta_afiliacion,
                observacion = "",
                odometro = String.IsNullOrEmpty(Cara.Odometro) ? "0" : Cara.Odometro,
                redondea_indecopi = 0,
                rscliente = Cara.RazonSocial,
                ruccliente = Cara.Ruc,
                dsusuario = TSLoginApp.UserFull,
            });
        }
Пример #3
0
 public static TS_BEClienteInput InputClienteAutomaticMethod(TerminalSIGES.Models.Lado Cara)
 {
     return(new TS_BEClienteInput()
     {
         cdcliente = Cara.Codigo,
         ruccliente = Cara.Ruc,
         drcliente = Cara.Direccion,
         rscliente = Cara.RazonSocial,
         tipocli = "",
         nroTarjeta = Cara.Tarjeta,
         tarjAfiliacion = Cara.Tarjeta_afiliacion,
         emcliente = Cara.Correo,
     });
 }
Пример #4
0
        public static void InputMoneyAutomaticMethod(TerminalSIGES.Models.Lado Cara, TS_BECabeceraInput cCabecera, TS_BEDetalleInput[] cDetalles, TS_BEPagoInput[] cPagos)
        {
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.Canje || Cara.Documento == TerminalSIGES.Models.EDocumento.NotaDespacho ||
                Cara.Documento == TerminalSIGES.Models.EDocumento.TranferenciaGratuita)
            {
                return;
            }

            decimal TotalProducto = 0;
            decimal TotalPagos    = 0;

            foreach (TS_BEDetalleInput item in cDetalles)
            {
                TotalProducto += item.total;
            }
            foreach (TerminalSIGES.Models.Pago Pago in Cara.Pagos)
            {
                TotalPagos += (Pago.Dolares * TSSalesApp.TipoCambio) + (Pago.Soles);
            }

            cCabecera.mtovueltosol = TotalPagos > TotalProducto ? TotalPagos - TotalProducto : 0;
        }
Пример #5
0
        public async Task Start_Automatic(TerminalSIGES.Models.Lado Lado)
        {
            /** COMIENZA REVISION DE VENTAS PENDIENTES **/
            await Task.Run(() =>
            {
                if (Convert.ToBoolean(TSSalesApp.vTerminal.conexion_dispensador ?? 0) == false || Convert.ToBoolean(TSSalesApp.vParemetros.conexiondispensador ?? false) == false)
                {
                    Lado.Mensaje = "CONEXION A DISPENSADOR CERRADA";
                    return;
                }
                string codigo = Lado.Documento == TerminalSIGES.Models.EDocumento.NotaDespacho         ? Lado.Tarjeta  :
                                Lado.Documento == TerminalSIGES.Models.EDocumento.TranferenciaGratuita ? "XXXXXXXXXXX" :
                                Lado.Documento == TerminalSIGES.Models.EDocumento.Serafin              ? "XXXXXXXXXXX" :
                                Lado.Codigo;

                TS_BECabeceraOutPut vTransaccion = TSSalesApp.SynchronizedGetOPTransaction(Lado.Cara, codigo, true);
                if (vTransaccion.Ok)
                {
                    if (vTransaccion.cDetalleOutPut.Length > 0)
                    {
                        Lado.Mensaje = "ENVIANDO VENTA";
                        var Venta    = new TS_BEArticulo()
                        {
                            item              = vTransaccion.cDetalleOutPut[0].item,
                            dsarticulo        = (vTransaccion.cDetalleOutPut[0].dsarticulo1 ?? "").Trim(),
                            precio            = vTransaccion.cDetalleOutPut[0].precio,
                            cantidad          = vTransaccion.cDetalleOutPut[0].cantidad,
                            cdarticulo        = vTransaccion.cDetalleOutPut[0].cdarticulo,
                            cara              = vTransaccion.cDetalleOutPut[0].cara,
                            hora              = vTransaccion.cDetalleOutPut[0].hora,
                            subtotal          = vTransaccion.cDetalleOutPut[0].subtotal,
                            tipo              = vTransaccion.cDetalleOutPut[0].tipo,
                            mtoimpuesto       = vTransaccion.cDetalleOutPut[0].mtoimpuesto,
                            total             = vTransaccion.cDetalleOutPut[0].total,
                            nrogasboy         = vTransaccion.cDetalleOutPut[0].nrogasboy.Trim(),
                            cdarticulosunat   = vTransaccion.cDetalleOutPut[0].cdarticulosunat,
                            mtodscto          = 0,
                            cdunimed          = vTransaccion.cDetalleOutPut[0].cdunimed,
                            precio_orig       = vTransaccion.cDetalleOutPut[0].precio_orig,
                            redondea_indecopi = vTransaccion.cDetalleOutPut[0].redondea_indecopi,
                            tpformula         = vTransaccion.cDetalleOutPut[0].tpformula,
                            impuesto          = vTransaccion.cDetalleOutPut[0].impuesto,
                            moverstock        = vTransaccion.cDetalleOutPut[0].moverstock,
                            costo             = vTransaccion.cDetalleOutPut[0].costo,
                            trfgratuita       = vTransaccion.cDetalleOutPut[0].trfgratuita,
                            total_display     = vTransaccion.cDetalleOutPut[0].total_display,
                            impuesto_plastico = vTransaccion.cDetalleOutPut[0].impuesto_plastico,
                            valorconversion   = vTransaccion.cDetalleOutPut[0].valorconversion,
                            cdmedequiv        = vTransaccion.cDetalleOutPut[0].cdmedequiv,
                            tpconversion      = vTransaccion.cDetalleOutPut[0].tpconversion
                        };

                        TS_BEMensaje respuesta = TSSalesApp.SynchronizedSetSale(Lado, Venta);
                        if (respuesta.Ok)
                        {
                            Lado.Codigo             = "";
                            Lado.Ruc                = "";
                            Lado.RazonSocial        = "";
                            Lado.Correo             = "";
                            Lado.Direccion          = "";
                            Lado.Placa              = "";
                            Lado.Odometro           = "";
                            Lado.Chofer             = "";
                            Lado.Tarjeta_afiliacion = "";
                            Lado.Pago               = "";
                            Lado.Tarjeta            = "";
                            Lado.Fecha_Nacimiento   = null;
                            Lado.Telefono           = "";
                            Lado.Marca              = "";
                            Lado.Modelo             = "";
                            Lado.Mensaje            = "";
                            Lado.Pago               = "EFECTIVO";
                            Lado.Pagos.Clear();
                            Lado.Documento = TerminalSIGES.Models.EDocumento.BoletaFactura;
                        }
                        else
                        {
                            Lado.Estado.estado = false;
                            Lado.Mensaje       = respuesta.mensaje;
                        }
                    }
                }
                else
                {
                    /**
                     * 1 ERROR GENERAL
                     * 2 ERROR DESCUENTOS
                     * 3 ERROR TABLAS DBF
                     * 4 SIN TRANSACCIONES
                     * 5 SIN CONEXION DISPENSADO
                     * 6 TERMINAL SIN CONEXION DISPENSADOR
                     **/
                    if (vTransaccion.Estado == 4)
                    {
                        Lado.Mensaje = "SIN TRANSACCIONES";
                        return;
                    }
                    Lado.Estado.estado = false;
                    Lado.Mensaje       = vTransaccion.Mensaje;
                }
            });

            /** TERMINA REVISION DE VENTAS PENDIENTES **/
        }
Пример #6
0
        public static List <TS_BEPagoInput> InputPagosAutomaticMethod(TerminalSIGES.Models.Lado Cara, TS_BEArticulo Transaccion)
        {
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.BoletaFactura)
            {
                if (Cara.Pagos.Count > 1)
                {
                    decimal TotalProducto = Transaccion.total;
                    decimal TotalPagos    = 0;

                    List <TS_BEPagoInput> Pagos = new List <TS_BEPagoInput>();

                    foreach (TerminalSIGES.Models.Pago Pago in Cara.Pagos)
                    {
                        TotalPagos += (Pago.Dolares * TSSalesApp.TipoCambio) + (Pago.Soles);
                        Pagos.Add(new TS_BEPagoInput()
                        {
                            cdtppago   = Pago.Codigo,
                            cdbanco    = "",
                            nrocuenta  = "",
                            nrocheque  = "",
                            nrotarjeta = Pago.Referencia,
                            cdtarjeta  = Pago.Tipo,
                            mtopagosol = Pago.Soles,
                            mtopagodol = Pago.Dolares
                        });
                    }

                    if (TotalProducto > TotalPagos)
                    {
                        return(null);
                    }

                    return(Pagos);
                }

                if (Cara.Pagos.Count == 1)
                {
                    if (Cara.Pagos[0].Dolares > 0)
                    {
                        if (Transaccion.total > (Cara.Pagos[0].Dolares * TSSalesApp.TipoCambio) + (Cara.Pagos[0].Soles))
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        Cara.Pagos[0].Soles = Transaccion.total;
                    }

                    return(new List <TS_BEPagoInput>()
                    {
                        new TS_BEPagoInput()
                        {
                            cdtppago = Cara.Pagos[0].Codigo,
                            cdbanco = "",
                            nrocuenta = "",
                            nrocheque = "",
                            nrotarjeta = Cara.Pagos[0].Referencia,
                            cdtarjeta = Cara.Pagos[0].Tipo,
                            mtopagosol = Cara.Pagos[0].Soles,
                            mtopagodol = Cara.Pagos[0].Dolares
                        }
                    });
                }
                else
                {
                    return(new List <TS_BEPagoInput>()
                    {
                        new TS_BEPagoInput()
                        {
                            cdtppago = "00001",
                            cdbanco = "",
                            nrocuenta = "",
                            nrocheque = "",
                            nrotarjeta = "",
                            cdtarjeta = "",
                            mtopagosol = Transaccion.total,
                            mtopagodol = 0
                        }
                    });
                }
            }
            if (Cara.Documento == TerminalSIGES.Models.EDocumento.NotaDespacho)
            {
                return(new List <TS_BEPagoInput>()
                {
                    new TS_BEPagoInput()
                    {
                        cdtppago = "00004",
                        cdbanco = "",
                        nrocuenta = "",
                        nrotarjeta = "",
                        nrocheque = "",
                        cdtarjeta = "",
                        mtopagosol = Transaccion.total,
                        mtopagodol = 0
                    }
                });
            }

            return(new List <TS_BEPagoInput>()
            {
                new TS_BEPagoInput()
                {
                    cdtppago = "00001",
                    cdbanco = "",
                    nrocuenta = "",
                    nrotarjeta = "",
                    nrocheque = "",
                    cdtarjeta = "",
                    mtopagosol = Transaccion.total,
                    mtopagodol = 0
                }
            });
        }