Esempio n. 1
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;
 }