public function testNuevoCorteSucursal()
 {
     $id = ScenarioMaker::CreateSucursalAndReturnID("N");
     EfectivoController::NuevoCorteSucursal(0, $id);
     //now, 'UltimoCorte' should not return null
     $this->assertNotNull(EfectivoController::UltimoCorte(SucursalDAO::getByPK($id)));
 }
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$page->addComponent(new TitleComponent("Billetes"));
$page->addComponent(new MessageComponent("Lista de billetes"));
$tabla = new TableComponent(array("nombre" => "Nombre", "valor" => "Valor", "id_moneda" => "Moneda", "foto_billete" => "Foto"), EfectivoController::ListaBillete());
function funcion_moneda($id_moneda)
{
    return MonedaDAO::getByPK($id_moneda) ? MonedaDAO::getByPK($id_moneda)->getNombre() : "-----";
}
$tabla->addColRender("id_moneda", "funcion_moneda");
$tabla->addOnClick("id_billete", "(function(a){ window.location = 'efectivo.billete.ver.php?bid=' + a; })");
$page->addComponent($tabla);
$page->render();
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$historial = EfectivoController::ObtenerHistorialTipoCambio();
$mostrar_act = EfectivoController::MostrarEquivalenciasActualizar();
$page->addComponent(new TitleComponent("Tipos de Cambio"));
if (count($mostrar_act["servicios"]) > 0) {
    $page->addComponent("<div class=\"POS Boton\" onclick=\"window.location = 'efectivo.editar.tipo_cambio.php'\">Actualizar Tipos Cambio</div>");
    $tabla = new TableComponent(array("conversion" => "Tipo Cambio al " . date("d-m-Y", $mostrar_act["servicios"][0]["fecha"]) . " (" . $mostrar_act["servicios"][0]["servicio"] . ")"), $mostrar_act["servicios"][0]["tipos_cambio"]);
    $page->addComponent($tabla);
} else {
    $page->addComponent(new TitleComponent("Si usted requiere tipos de cambio, verifique lo siguiente:", 2));
    $page->addComponent(new TitleComponent("- Que tenga configurada la moneda base de la <a href=\"empresas.lista.php\">Empresa</a>", 3));
    $page->addComponent(new TitleComponent("- Que tenga activa mas de una <a href=\"efectivo.lista.moneda.php\">moneda</a> en el sistema", 3));
    $page->addComponent(new TitleComponent("- Si tiene estos parametros de configuracion y no aparecen los tipos de cambio, contacte a personal de Caffeina", 3));
}
if (count($mostrar_act["sistema"]) > 0) {
    $tabla2 = new TableComponent(array("conversion" => "Sistema actualizado al " . date("d-m-Y", $mostrar_act["sistema"][0]["fecha"])), $mostrar_act["sistema"][0]["tipos_cambio"]);
    $page->addComponent($tabla2);
}
$page->addComponent(new TitleComponent("Historial de Tipos Cambio en el Sistema", 2));
if (count($historial) < 1) {
    $page->addComponent(new TitleComponent("No hay registros", 3));
} else {
    $datos_concentrados = array();
    foreach ($historial as $h) {
        $servicio = $h["servicio"];
        $fecha = date("d-m-Y h:i:s", $h["fecha"]);
        $moneda_origen = $h["moneda_origen"];
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
EfectivoController::NuevoCorte();
$page->render();
return;
//
// Parametros necesarios
//
$page->requireParam("cid", "GET", "Esta caja no existe.");
$esta_caja = CajaDAO::getByPK($_GET["cid"]);
$page->addComponent(new TitleComponent("Corte a la caja " . $esta_caja->getDescripcion() . ". El saldo esperado es de: " . $esta_caja->getSaldo(), 3));
//
// Forma de producto
//
$form = new DAOFormComponent(new CorteDeCaja());
$form->addApiCall("api/sucursal/caja/corte", "GET");
$form->onApiCallSuccessRedirect("sucursales.lista.caja.php");
$form->hideField(array("id_corte_de_caja", "saldo_esperado", "id_caja", "fecha"));
$form->makeObligatory(array("saldo_real", "saldo_final"));
$form->createComboBoxJoinDistintName("id_cajero", "id_usuario", "nombre", UsuarioDAO::search(new Usuario(array("id_rol" => 3, "activo" => 1), SesionController::getCurrentUser())));
$form->createComboBoxJoinDistintName("id_cajero_nuevo", "id_usuario", "nombre", UsuarioDAO::search(new Usuario(array("id_rol" => 3, "activo" => 1), SesionController::getCurrentUser())));
$form->setValueField("id_caja", $_GET["cid"]);
$form->sendHidden("id_caja");
$page->addComponent($form);
$page->render();
 public function testUltimoCorte3()
 {
     $id = ScenarioMaker::CreateSucursalAndReturnID();
     $this->assertNull(EfectivoController::UltimoCorte(SucursalDAO::getByPK($id)));
 }
Example #6
0
 protected function GenerateResponse()
 {
     try {
         $this->response = EfectivoController::ObtenerEquivalenciaMoneda(isset($_POST['id_empresa']) ? $_POST['id_empresa'] : null, isset($_POST['id_moneda']) ? $_POST['id_moneda'] : null);
     } catch (Exception $e) {
         //Logger::error($e);
         throw new ApiException($this->error_dispatcher->invalidDatabaseOperation($e->getMessage()));
     }
 }
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$page->addComponent(new TitleComponent("Monedas"));
$page->addComponent(new MessageComponent("Lista de monedas"));
$tabla = new TableComponent(array("nombre" => "Nombre", "simbolo" => "Simbolo", "activa" => "Activa"), EfectivoController::ListaMoneda());
function funcion_bool_to_string($valor)
{
    return $valor === true || $valor === "1" || $valor === 1 ? "<strong>Si</strong>" : "No";
}
$tabla->addColRender("activa", "funcion_bool_to_string");
//
//                function funcion_moneda($id_moneda)
//                {
//                    return (MonedaDAO::getByPK($id_moneda) ? MonedaDAO::getByPK($id_moneda)->getNombre() : "-----" );
//                }
//                $tabla->addColRender("id_moneda", "funcion_moneda");
$tabla->addOnClick("id_moneda", "(function(a){ window.location = 'efectivo.moneda.ver.php?mid=' + a; })");
$page->addComponent($tabla);
$page->render();
 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 #9
0
$tabla_cuentas_bancarias->addNoData("No hay ninguna cuenta bancaria registrada. <a href='#'>&iquest; Desea agregar un elemento?.</a>");
$page->addComponent($tabla_cuentas_bancarias);
$page->addComponent(new TitleComponent("Configuracion de formatos", 2));
$configuracion_formatos = new FormComponent();
$configuracion_formatos->addField("pie_pagina", "Pie de Pagina", "text", "");
$configuracion_formatos->addField("formato_papel", "Formato de Papel", "text", "A4");
$page->addComponent($configuracion_formatos);
/*
 * Tab ConfiguraciĆ³n
 */
$page->nextTab("Configuracion");
$page->addComponent(new TitleComponent("Contabilidad", 2));
$page->addComponent("<br />");
$configuracion_moneda_form = new DAOFormComponent(new Moneda());
$configuracion_moneda_form->hideField(array("simbolo", "nombre", "activa"));
$configuracion_moneda_form->createComboBoxJoin("id_moneda", "simbolo", EfectivoController::ListaMoneda());
$page->addComponent($configuracion_moneda_form);
$page->addComponent("<br />");
$page->addComponent(new TitleComponent("Ejercicio", 3));
$configuracion_ejercicio_form = new FormComponent();
$configuracion_ejercicio_form->addField("ejercicio", "A&#241;o del Ejercicio", "text", date("Y"), "ejercicio");
$page->addComponent($configuracion_ejercicio_form);
$page->addComponent(new TitleComponent("Periodo", 3));
$configuracion_periodo_form = new FormComponent();
$configuracion_periodo_form->addField("duracion_periodo", "Duracion de periodos (meses)", "number", "1", "duracion_periodo");
$configuracion_periodo_form->addField("periodo_actual", "Periodo Actual", "number", "1", "periodo_actual");
$page->addComponent($configuracion_periodo_form);
$page->addComponent(new TitleComponent("Impuestos", 2));
$impuestos_compra_form = new FormComponent();
$valores = array();
foreach (ImpuestoDAO::getAll() as $impuesto) {
Example #10
0
 ***/
define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
$page->requireParam("sid", "GET", "Esta sucursal no existe.");
/* ********************************************************************* 
 * Corte
 * ********************************************************************* */
$sucursal = SucursalDAO::getByPK($_GET['sid']);
if (is_null($sucursal)) {
    $page->render();
    exit;
}
$page->addComponent(new TitleComponent("Sucursal " . $sucursal->getDescripcion(), 1));
$table = "<table>";
$cortes = EfectivoController::UltimoCorte($sucursal);
if (!is_null($cortes)) {
    $fecha_inicial = $cortes->getFin();
} else {
    $fecha_inicial = $sucursal->getFechaApertura();
}
$fecha_final = time();
$table .= "  <tr>";
$table .= td("<b>Corte</b>");
$table .= td("<b>Del</b>");
$table .= "    <td colspan= \"2\">" . date("d/m/Y g:i:s A", $fecha_inicial) . "</td>";
$table .= "    <td><b>Al</b></td>";
$table .= "    <td colspan= \"2\">" . date("d/m/Y g:i:s A", $fecha_final) . "</td>";
$table .= "    <td></td>";
$table .= "  </tr>";
#------------------------------------