示例#1
0
 public function spAction()
 {
     $resultCajaDetalle = ExpStoresProcedures::getCajaDetalle($this->_serviceLocator, 15, '2015-09-08', '2015-09-16');
     echo "<pre>";
     var_dump($resultCajaDetalle);
     echo "</pre>";
     exit;
 }
示例#2
0
 /**
  * registro Conciliacion Caja
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @param \Tesoreria\Models\ERequest $request
  * @return \Tesoreria\Models\EResponse
  */
 public static function registroConciliacionCaja($serviceLocator, $request)
 {
     $response = new EResponse();
     $params = array();
     $params["request"] = $request;
     $params = json_encode($params);
     $conexion = $serviceLocator->get(Constants::SCHEMA_1)->getDriver()->getConnection();
     $conexion->beginTransaction();
     try {
         self::init($serviceLocator);
         ExpLog::save($serviceLocator, $request->header->serieEquipo, Constants::LOG_ACTIVIDAD, "", "registro Conciliacion Caja", $params, "", $request->header->usuario);
         $objRegistracion = ExpRegistracion::crearRegistracion($serviceLocator, Constants::PA_SIS_RECAUDACION_EXTERNA, $request);
         $result = ExpRegistracion::crearDetalle($serviceLocator, $objRegistracion, $request);
         /// --------------------------------- CARGO EL ITEM ACTUALIZADO PARA HACER VISIBLE LOS CAMBIOS -------------------------------- //
         // Busco un maestro especifico, en este caso la terminal que esta interactuando
         $maestroTerminal = self::$maestroBaseDao->getOneObject(array('codigo_alternativo' => $request->header->serieEquipo));
         // ----- Realizo la busqueda del item de pesos para la terminal en cuestion ------------- ///
         $condicion = 'owner = ' . $maestroTerminal->getId();
         $resultSetItemPesos = ExpStoresProcedures::findItems($serviceLocator, Constants::MA_BA_PESOS, $condicion);
         if (count($resultSetItemPesos) == 0) {
             throw new Exception("Error: el item de pesos de la terminal no ha sido encontrado");
         }
         $itemPesos = self::$itemDao->getOneObject(array('it_id' => $resultSetItemPesos[0]->it_id));
         /// -----------------------------------------------------------------------------------------------------------------------------------//
         // ----- Construyo el parametro de retorno de los items ------------- ///
         // Items de Pesos
         $paramItem1 = new ParamItems();
         $paramItem1->setNombre('Pesos');
         $paramItem1->setItems(array($itemPesos));
         // Seteo la variable para retornar
         $response->param_items = array($paramItem1);
         /// ------------------------------ CONFIGURACION DATOS PARAM_INFORME -------------------------------///
         $paramDAInforme = ExpStoresProcedures::getCajaDetalle($serviceLocator, $maestroTerminal->getId(), date('Y-m-d'), date('Y-m-d'));
         $resultCierres = from('$detalle')->in($paramDAInforme)->where('$detalle =>  $detalle->id_operacion == 8 && $detalle->entidad == "' . $maestroTerminal->nombre . '"')->orderBy('$detalle => $detalle->fecha_registracion')->select('$detalle');
         $ultimoCierre = $resultCierres[count($resultCierres) - 1]->fecha_registracion;
         $response->param_informe->info_detalle_registraciones = from('$detalle')->in($paramDAInforme)->where('$detalle =>  $detalle->id_operacion != 8 && $detalle->fecha_registracion >  "' . $ultimoCierre . '" && $detalle->entidad == "' . $maestroTerminal->nombre . '"')->select('$detalle');
         /// ------------------------------ CONFIGURACION DATOS PARAM_INFORME_RECAUDACION -------------------------------///
         # 1. Busco y Construyo datos de ingresos detallados en SIRIS
         $newRequest = new \stdClass();
         $newRequest->secuencia = Constants::SEQ_0;
         $newRequest->serieEquipo = $request->header->serieEquipo;
         $newRequest->trxEquipo = "1";
         $newRequest->usuario = $request->header->usuario;
         $newRequest->password = $request->header->password;
         $responseResport = \Siris\Experts\ExpReporte::analyticalReport($serviceLocator, $newRequest);
         $response->param_informe->informe_recaudaciones = $responseResport->informe;
         /// ------------------------------ CONFIGURACION DATOS PARAM_COMPLEMENTARIOS -------------------------------///
         // Saldo de Pesos inicial para la terminal
         $paramComp = new ParamComplementarios();
         $paramComp->setNombre('Saldo_Inicial');
         # 1. Recalculo el saldo incial a partir de las registraciones
         //$saldoInicial= floatval($itemPesos->cantidad);
         # 1.1 obtengo el ultimo cierre para determinal que operaciones se han realizado posterior a este
         $resultCierres = from('$detalle')->in($paramDAInforme)->where('$detalle =>  $detalle->id_operacion == 8 && $detalle->entidad == "' . $maestroTerminal->nombre . '"')->orderBy('$detalle => $detalle->fecha_registracion')->select('$detalle');
         $ultimoCierre = $resultCierres[count($resultCierres) - 1]->fecha_registracion;
         # 1.2 Obtengo el movimiento de apertura
         $movimientoSaldoApertura = from('$detalle')->in($paramDAInforme)->where('$detalle =>  $detalle->id_operacion != 8 && $detalle->fecha_registracion >  "' . $ultimoCierre . '"
             && $detalle->entidad == "' . $maestroTerminal->nombre . '" && $detalle->concepto == "Saldo Apertura"')->select('new {
                 "Valor" => $detalle->valor
               }');
         $paramComp->setValor(floatval($movimientoSaldoApertura[0]->Valor));
         # 2. Seteo la variable para retornar
         $response->param_complementarios = array($paramComp);
         /// ------------------------------ CONFIGURACION DATOS PARAM_DA -------------------------------///
         # 1. Configuracion de pesos tipo ENTRDA/SALIDA de la terminal
         $valores = new \stdClass();
         $idConf = Constants::CONF_DA_PESOS_OWNER;
         $valores->{$idConf} = $maestroTerminal->getId();
         $paramDAPesosTerminal = ExpConfiguracion::getParamDatosAdicionales($serviceLocator, Constants::MA_BA_PESOS, $valores, Constants::MO_ENTRADA_SALIDA);
         # 2. Configuracion del SOBRANTE DE CAJA
         $valores = new \stdClass();
         $idConf = Constants::CONF_DA_SOBRANTE_OWNER;
         $valores->{$idConf} = $maestroTerminal->getId();
         $paramDASobrante = ExpConfiguracion::getParamDatosAdicionales($serviceLocator, Constants::MA_BA_SOBRANTE, $valores, Constants::MO_ENTRADA_CORTO);
         # 3. Configuracion de saldo de Cierre tipo ENTRDA de la terminal
         $valores = new \stdClass();
         $idConf = Constants::CONF_DA_SALDO_CIERRE_OWNER;
         $valores->{$idConf} = $maestroTerminal->getId();
         $paramDASaldoCierre = ExpConfiguracion::getParamDatosAdicionales($serviceLocator, Constants::MA_BA_SALDO_CIERRE, $valores, Constants::MO_ENTRADA_CORTO);
         # 4. Configuracion del FALTANTE DE CAJA
         $valores = new \stdClass();
         $idConf = Constants::CONF_DA_FALTANTE_OWNER;
         $valores->{$idConf} = $maestroTerminal->getId();
         $paramDAFaltante = ExpConfiguracion::getParamDatosAdicionales($serviceLocator, Constants::MA_BA_FALTANTE, $valores, Constants::MO_ENTRADA_CORTO);
         # 5. Finalmente cargo la variable PARAM_DA
         $allParamDA = array($paramDAPesosTerminal, $paramDAFaltante, $paramDASobrante, $paramDASaldoCierre);
         $response->param_da = $allParamDA;
         $response->result = $maestroTerminal->getId();
         $conexion->commit();
         return $response;
     } catch (Exception $e) {
         $conexion->rollback();
         ExpLog::save($serviceLocator, $request->header->serieEquipo, Constants::LOG_ERROR, "", "registro Apertura Caja", $params, $e->getMessage(), $request->header->usuario);
         $error = new Error();
         $error->setMensaje("Error: no se pudo realizar el Reporte de Deposito.");
         $response->error = $error;
         return $response;
     }
 }
示例#3
0
 /**
  * Get Ticket Cierre Unificado
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @param \Tesoreria\Models\Registracion $objRegistracion
  * @param \Siris\Models\Ticket[] $ticketCierreSiris
  * @param boolean $forzado
  * @return \Siris\Models\Ticket[]
  */
 public static function getTicketCierreUnificado($serviceLocator, $objRegistracion = null, $ticketCierreSiris = null, $forzado)
 {
     self::init($serviceLocator);
     $hash = chunk_split($objRegistracion->getHashControl(), 5, ' ');
     $terminal = $objRegistracion->getEntidad($serviceLocator);
     $cajaDetalle = ExpStoresProcedures::getCajaDetalle($serviceLocator, $terminal->getId(), date('Y-m-d'), date('Y-m-d'));
     $resultCierres = from('$detalle')->in($cajaDetalle)->where('$detalle =>  $detalle->id_operacion == ' . Constants::PA_SIS_CIERRE_CAJA . ' && $detalle->entidad == "' . $terminal->getNombre() . '"')->orderBy('$detalle => $detalle->fecha_registracion')->select('$detalle');
     $condicionFechaRegistracion = "";
     if (count($resultCierres) > 1) {
         $ultimoCierre = $resultCierres[count($resultCierres) - 1]->fecha_registracion;
         $condicionFechaRegistracion = ' && $detalle->fecha_registracion >  "' . $ultimoCierre . '" ';
     }
     ######## EXTRACCIONES DE EFECTIVO #########
     $extraccionesEfectivo = from('$detalle')->in($cajaDetalle)->where('$detalle =>  $detalle->id_operacion == ' . Constants::PA_SIS_EGRESO_EFECTIVO . ' && $detalle->id_concepto == ' . Constants::MA_BA_RETIRO_EFECTIVO . ' && $detalle->entidad == "' . $terminal->nombre . '"' . $condicionFechaRegistracion)->select('$detalle');
     $texto = $ticketCierreSiris[0]->texto;
     $texto[] = "";
     $texto[] = "----------------------------------------";
     $texto[] = "";
     $texto[] = "         EXTRACCIONES DE EFECTIVO       ";
     $texto[] = "";
     $totalExtraccion = 0;
     foreach ($extraccionesEfectivo as $ext) {
         $totalExtraccion += $ext->valor;
         $montoExtraccion = number_format($ext->monto_operacion, 2, ",", ".");
         $texto[] = "Monto:  " . $montoExtraccion;
     }
     if ($totalExtraccion > 0) {
         $texto[] = "";
         $texto[] = "Total Extracciones:  " . number_format($totalExtraccion, 2, ",", ".");
     }
     ######## RECAUDACIONES EXTERNAS (CONCILIACION) #########
     $recaudacionesExternas = from('$detalle')->in($cajaDetalle)->where('$detalle =>  $detalle->id_operacion == ' . Constants::PA_SIS_RECAUDACION_EXTERNA . ' && $detalle->id_concepto == ' . Constants::MA_BA_RECAUDACION_EXTERNA . ' && $detalle->entidad == "' . $terminal->nombre . '"' . $condicionFechaRegistracion)->select('$detalle');
     $texto[] = "";
     $texto[] = "----------------------------------------";
     $texto[] = "";
     $texto[] = "          RECAUDACIONES EXTERNAS        ";
     $texto[] = "";
     $totalRecaudaciones = 0;
     foreach ($recaudacionesExternas as $rec) {
         $usosDAItem = self::$usoDAItemDao->getAllObjects(array("item_id" => $rec->id_item));
         $entidad = "XXXXXX";
         foreach ($usosDAItem as $uso) {
             if ($uso->getConfDatosAdicionales($serviceLocator)->getId() == Constants::CONF_DA_ENTES_RECAUDADORES) {
                 $objEntidad = self::$maestroBaseDao->getById($uso->getValor());
                 $entidad = $objEntidad->getNombre();
             }
         }
         $totalRecaudaciones += $rec->valor;
         $montoRecaudacion = number_format($rec->valor, 2, ",", ".");
         $texto[] = "Entidad:  " . $entidad;
         $texto[] = "Monto:    " . $montoRecaudacion;
         $texto[] = "";
     }
     if ($totalRecaudaciones > 0) {
         $texto[] = "";
         $texto[] = "Total Recaudacion Ext.:  " . number_format($totalRecaudaciones, 2, ",", ".");
     }
     ######## CORTES DE CAJA #########
     $cortesCaja = from('$detalle')->in($cajaDetalle)->where('$detalle =>  $detalle->id_operacion == ' . Constants::PA_SIS_CORTE_CAJA . ' && $detalle->id_concepto == ' . Constants::MA_BA_PESOS . ' && $detalle->tipo_movimiento == "' . Constants::MO_SALIDA . '" && $detalle->entidad == "' . $terminal->nombre . '"' . $condicionFechaRegistracion)->select('$detalle');
     $texto[] = "";
     $texto[] = "----------------------------------------";
     $texto[] = "";
     $texto[] = "              CORTES DE CAJA            ";
     $texto[] = "";
     $totalCortes = 0;
     foreach ($cortesCaja as $cor) {
         $totalCortes += $cor->valor;
         $montoCorte = number_format($cor->valor, 2, ",", ".");
         $texto[] = "Monto:  " . $montoCorte;
     }
     if ($totalCortes > 0) {
         $texto[] = "";
         $texto[] = "Total Cortes Caja:  " . number_format($totalCortes, 2, ",", ".");
     }
     if ($forzado) {
         $texto[] = "";
         $texto[] = "CONCEPTO:  CIERRE FORZADO";
     }
     $ticketCierre = new Ticket();
     $ticketCierre->texto = $texto;
     $ticketFinalCierre = self::getTicketCajaNoCuadrada($serviceLocator, "CIERRE", $objRegistracion, array($ticketCierre));
     return $ticketFinalCierre;
 }