Example #1
0
        /// <summary>
        /// Lectura Z
        /// </summary>
        /// <returns>Respuesta de la operación</returns>
        public ResponseBussiness <OperationResponse> LecturaZ(LecturaCaja lecturaCaja)
        {
            return(tryCatch.SafeExecutor(() =>
            {
                OperationResponse resultado = new OperationResponse();
                LecturaZGuardarResponse lecturaZGuardarResponse = new LecturaZGuardarResponse();
                LecturaTotalDetalleFormaPago lecturaTotalDetalleFormaPagoCA = null;
                using (TransactionScope scope = new TransactionScope())
                {
                    int secuencia = 1;
                    // Se ejecuta la lectura X
                    LecturaX lecturaX = repository.ObtenerFoliosLecturaX(token.CodeStore, token.CodeBox, token.CodeEmployee, 0);
                    foreach (var lecturaTotalDetalleFormaPago in lecturaCaja.LecturasTotales)
                    {
                        resultado = repository.LecturaX(token.CodeStore, token.CodeBox, token.CodeEmployee, lecturaTotalDetalleFormaPago.InformacionAsociadaFormasPago.CodigoFormaPago, secuencia, lecturaTotalDetalleFormaPago.ImporteFisico, lecturaTotalDetalleFormaPago.ImporteTeorico, lecturaTotalDetalleFormaPago.ImporteFisico, lecturaX);
                        if (lecturaTotalDetalleFormaPago.InformacionAsociadaFormasPago.CodigoFormaPago == "CA")
                        {
                            lecturaTotalDetalleFormaPagoCA = lecturaTotalDetalleFormaPago;
                        }
                        secuencia = secuencia + 1;
                    }
                    // Se ejecutar la lectura Z
                    if (lecturaTotalDetalleFormaPagoCA != null)
                    {
                        lecturaZGuardarResponse = repository.LecturaZ(token.CodeStore, token.CodeBox, token.CodeEmployee,
                                                                      lecturaX.FolioCorteParcial, lecturaTotalDetalleFormaPagoCA.ImporteFisico,
                                                                      lecturaTotalDetalleFormaPagoCA.ImporteTeorico, lecturaTotalDetalleFormaPagoCA.ImporteFisico, 0);
                        resultado.CodeNumber = lecturaZGuardarResponse.CodeNumber;
                        resultado.CodeDescription = lecturaZGuardarResponse.CodeDescription;
                        // Se persisten las denominaciones
                        foreach (var item in lecturaTotalDetalleFormaPagoCA.InformacionAsociadaDenominaciones)
                        {
                            repository.PersistirDenominacionesRetiro(lecturaX.FolioCorteParcial, item.CodigoFormaPago, item.TextoDenominacion, item.Cantidad);
                        }
                    }
                    scope.Complete();
                }

                // Imprimir Ticket
                PrintTickectLecturaBusiness printTickectLectura = new PrintTickectLecturaBusiness(token);
                PrintLecturaRequest printLecturaRequest = new PrintLecturaRequest();
                printLecturaRequest.FolioCorte = lecturaZGuardarResponse.FolioCorte;
                printLecturaRequest.TipoLectura = "z";
                printTickectLectura.PrintNow(printLecturaRequest);

                PrintTicketEgresosBusiness printTicketEgresos = new PrintTicketEgresosBusiness(token);
                PrintTicketEgresosRequest printTicketEgresosRequest = new PrintTicketEgresosRequest();
                printTicketEgresosRequest.FolioCorteZ = lecturaZGuardarResponse.FolioCorte;
                printTicketEgresos.PrintNow(printTicketEgresosRequest);

                return resultado;
            }));
        }
Example #2
0
        /// <summary>
        /// Regresa el listado de importes por forma de pago registrados en la caja
        /// </summary>
        /// <param name="codeStore">Código de la tienda</param>
        /// <param name="codeBox">Código de la caja</param>
        /// <param name="caja">Código de la caja sobre la cual se requiere la infromación</param>
        /// <returns>Listado de importes</returns>
        public LecturaTotalDetalleFormaPago[] ObtenerTotalesPorFormaPago(int codeStore, int codeBox, int caja)
        {
            List <LecturaTotalDetalleFormaPago> list = new List <LecturaTotalDetalleFormaPago>();
            var parameters = new Dictionary <string, object>();

            parameters.Add("@CodigoTienda", codeStore);
            parameters.Add("@CodigoCaja", codeBox);
            parameters.Add("@CodigoCajaInformacion", caja);
            foreach (var r in data.GetDataReader("sp_vanti_server_ReporteTotalesPorFormaPago", parameters))
            {
                LecturaTotalDetalleFormaPago lectura = new LecturaTotalDetalleFormaPago();
                lectura.ImporteFisico  = 0;
                lectura.ImporteRetiro  = 0;
                lectura.ImporteTeorico = Convert.ToDecimal(r.GetValue(0));
                lectura.InformacionAsociadaFormasPago = new ConfigGeneralesCajaTiendaFormaPago();
                lectura.InformacionAsociadaFormasPago.IdentificadorFormaPago = r.GetValue(1).ToString();
                lectura.InformacionAsociadaFormasPago.CodigoFormaPago        = r.GetValue(2).ToString();
                lectura.InformacionAsociadaFormasPago.DescripcionFormaPago   = r.GetValue(3).ToString();
                lectura.TotalIngresosConRetirosParciales             = lectura.ImporteTeorico;
                lectura.TotalIngresosConRetirosParcialesConFondoFijo = lectura.ImporteTeorico;
                // Agregar información referente a retiros parciales
                if (lectura.InformacionAsociadaFormasPago.CodigoFormaPago == "CA")
                {
                    List <System.Data.SqlClient.SqlParameter> parametersOut = new List <System.Data.SqlClient.SqlParameter>();
                    parametersOut.Add(new System.Data.SqlClient.SqlParameter()
                    {
                        ParameterName = "@TotalRetirosParciales", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Decimal, Scale = 2
                    });
                    var resultado = data.ExecuteProcedure("[dbo].[sp_vanti_server_ReporteTotalesRetirosParciales]", parameters, parametersOut);
                    lectura.TotalRetirosParciales            = Convert.ToDecimal(resultado["@TotalRetirosParciales"]);
                    lectura.TotalIngresosConRetirosParciales = lectura.TotalIngresosConRetirosParciales + lectura.TotalRetirosParciales;
                    // Ajuste para fondo fijo
                    List <System.Data.SqlClient.SqlParameter> parametersFFOut = new List <System.Data.SqlClient.SqlParameter>();
                    parametersFFOut.Add(new System.Data.SqlClient.SqlParameter()
                    {
                        ParameterName = "@TotalFondoFijo", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Decimal, Scale = 2
                    });
                    var resultadoFF = data.ExecuteProcedure("[dbo].[sp_vanti_server_ReporteTotalesFondoFijo]", parameters, parametersFFOut);
                    lectura.TotalFondoFijo = Convert.ToDecimal(resultadoFF["@TotalFondoFijo"]);
                    lectura.TotalIngresosConRetirosParcialesConFondoFijo = lectura.TotalIngresosConRetirosParciales + lectura.TotalFondoFijo;
                }
                list.Add(lectura);
            }
            return(list.ToArray());
        }
Example #3
0
        /// <summary>
        /// Lectura Z Offline
        /// </summary>
        /// <returns>Respuesta de la operación</returns>
        public ResponseBussiness <LecturaZGuardarResponse> LecturaZOffline(LecturaCaja lecturaCaja)
        {
            return(tryCatch.SafeExecutor(() =>
            {
                OperationResponse resultado = new OperationResponse();
                LecturaZGuardarResponse lecturaZGuardarResponse = new LecturaZGuardarResponse();
                LecturaTotalDetalleFormaPago lecturaTotalDetalleFormaPagoCA = null;
                using (TransactionScope scope = new TransactionScope())
                {
                    int secuencia = 1;
                    // Se ejecuta la lectura X
                    LecturaX lecturaX = repository.ObtenerFoliosLecturaX(token.CodeStore, token.CodeBox, token.CodeEmployee, 1);
                    foreach (var lecturaTotalDetalleFormaPago in lecturaCaja.LecturasTotales)
                    {
                        // Se pone el parámetro de Caja = 0 porque es BackOffice
                        resultado = repository.LecturaX(token.CodeStore, 0, token.CodeEmployee,
                                                        lecturaTotalDetalleFormaPago.InformacionAsociadaFormasPago.CodigoFormaPago, secuencia,
                                                        lecturaTotalDetalleFormaPago.ImporteFisico, lecturaTotalDetalleFormaPago.ImporteTeorico,
                                                        lecturaTotalDetalleFormaPago.ImporteFisico, lecturaX);
                        if (lecturaTotalDetalleFormaPago.InformacionAsociadaFormasPago.CodigoFormaPago == "CA")
                        {
                            lecturaTotalDetalleFormaPagoCA = lecturaTotalDetalleFormaPago;
                        }
                        secuencia = secuencia + 1;
                    }
                    // Se ejecutar la lectura Z
                    if (lecturaTotalDetalleFormaPagoCA != null)
                    {
                        lecturaZGuardarResponse = repository.LecturaZ(token.CodeStore, token.CodeBox, token.CodeEmployee,
                                                                      lecturaX.FolioCorteParcial, lecturaTotalDetalleFormaPagoCA.ImporteFisico,
                                                                      lecturaTotalDetalleFormaPagoCA.ImporteTeorico, lecturaTotalDetalleFormaPagoCA.ImporteFisico, 1);
                        resultado.CodeNumber = lecturaZGuardarResponse.CodeNumber;
                        resultado.CodeDescription = lecturaZGuardarResponse.CodeDescription;

                        // Se persisten las denominaciones
                        foreach (var item in lecturaTotalDetalleFormaPagoCA.InformacionAsociadaDenominaciones)
                        {
                            repository.PersistirDenominacionesRetiro(lecturaX.FolioCorteParcial, item.CodigoFormaPago, item.TextoDenominacion, item.Cantidad);
                        }
                    }
                    scope.Complete();
                }
                return lecturaZGuardarResponse;
            }));
        }