public static function Corte($fecha_final, $id_sucursal, $total_efectivo)
 {
     if ($fecha_final > time()) {
         throw new BusinessLogicException("You must give a time in the past.");
     }
     if ($fecha_final == 0) {
         $fecha_final = time();
     }
     $suc = SucursalDAO::getByPK($id_sucursal);
     if (is_null($suc)) {
         throw new InvalidDataException("'Sucursal' does not exist");
     }
     $corte = EfectivoController::UltimoCorte($suc);
     if (is_null($corte)) {
         //'CordeDeSucursal' has never happende,
         //use the opening date.
         $start_date = $suc->getFechaApertura();
     } else {
         $start_date = $corte->getFin();
     }
     //ASSERT( $fecha_final . "<=" . $start_date );
     $ingresos_por_tipo = array("BANCO" => 0.0, "CAJA" => 0.0);
     $ventas = VentasController::Lista($start_date, $fecha_final);
     //esto regresa, total, subtotal, impuesto
     $ventasTotal = VentaDAO::TotalVentasNoCanceladasAContadoDesdeHasta($start_date, $fecha_final);
     //$abonosTotal = AbonoVenta::TotalAbonosNoCanceladosDesdeHasta( $start_date, $fecha_final );
     /*
     foreach( $ventas as $v ){
     
         switch( $v->tipo_de_pago ){
             cash :      $ingresos[ cash ] += $v->getTotal();
             banco :     $ingresos[ banco ] += $v->getTotal()
             cheque :
             default: throw new Exception();
     
         }
     }
     */
     $cu = SesionController::Actual();
     $corte = new CorteDeSucursal();
     $corte->setIdSucursal($id_sucursal);
     $corte->setIdUsuario($cu["id_usuario"]);
     $corte->setInicio($start_date);
     $corte->setFin($fecha_final);
     $corte->setFechaCorte(time());
     try {
         CorteDeSucursalDAO::save($corte);
     } catch (Exception $e) {
         throw new InvalidDatabaseException($e);
     }
     return array("id_corte_sucursal" => $corte->getIdCorteSucursal());
 }
Example #2
0
<?php

/**
 * Description:
 *
 *
 * Author:
 *     Manuel Garcia (manuel)
 *     Alan Gonzalez (alan)
 *
 ***/
define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$page->addComponent(new TitleComponent("Cortes de sucursal"));
$cortes = CorteDeSucursalDAO::getAll();
$tabla = new TableComponent(array("fecha_corte" => "Fecha corte", "id_sucursal" => "Sucursal", "id_usuario" => "Usuario", "inicio" => "Inicio", "fin" => "Fin"), $cortes);
$tabla->addColRender("id_sucursal", "funcion_sucursal");
$tabla->addColRender("id_usuario", "getUserName");
$tabla->addColRender("inicio", "R::FriendlyDateFromUnixTime");
$tabla->addColRender("fin", "R::FriendlyDateFromUnixTime");
$tabla->addColRender("fecha_corte", "R::FriendlyDateFromUnixTime");
$page->addComponent($tabla);
$page->render();
Example #3
0
 /**
  *
  *
  * Returns:
  *     Object of type CorteDeSucursal which is the last time this happened.
  *     May return null otherwise.
  *
  ***/
 private static function UltimoCorteSucursal($sucursal)
 {
     if (!$sucursal instanceof Sucursal) {
         throw new InvalidDataException("Argument must be instance of Sucursal");
     } else {
         $v_sucursal = SucursalDAO::getByPK($sucursal->getIdSucursal());
     }
     if (is_null($v_sucursal)) {
         throw new InvalidDataException("Sucursal does not exist");
     }
     $cortes = CorteDeSucursalDAO::search(new CorteDeSucursal($v_sucursal->AsArray()), "fin", "desc");
     if (sizeof($cortes) == 0) {
         return null;
     }
     return $cortes[0];
 }
Example #4
0
<?php

/**
 * Description:
 *
 *
 * Author:
 *     Alan Gonzalez (alan)
 *
 ***/
define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$page->requireParam("cid", "GET", "Este corte no existe.");
$corte = CorteDeSucursalDAO::getByPk($_GET["cid"]);
if (is_null($corte)) {
    //whops
    $page->render();
}
$page->addComponent(new TitleComponent("Corte"));
$page->render();