public function testNuevoCorteSucursal() { $id = ScenarioMaker::CreateSucursalAndReturnID("N"); EfectivoController::NuevoCorteSucursal(0, $id); //now, 'UltimoCorte' should not return null $this->assertNotNull(EfectivoController::UltimoCorte(SucursalDAO::getByPK($id))); }
public function testUltimoCorte3() { $id = ScenarioMaker::CreateSucursalAndReturnID(); $this->assertNull(EfectivoController::UltimoCorte(SucursalDAO::getByPK($id))); }
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()); }
***/ 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>"; #------------------------------------