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()); }
$table .= " <td>Efectivo Inicial</td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " <td>" . FormatMoney($fondo_inicial) . "</td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " </tr>"; #------------------------------------ $table .= " <tr>"; $table .= " <td></td>"; $table .= " <td>Ventas</td>"; $table .= td("", 5); $table .= " </tr>"; #------------------------------------ $ventas_efectivo = VentaDAO::TotalVentasNoCanceladasAContadoDesdeHasta($fecha_inicial, $fecha_final); $ventas_efectivo = $ventas_efectivo["total"]; $table .= " <tr>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " <td>Efectivo</td>"; $table .= " <td>" . FormatMoney($ventas_efectivo) . "</td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " <td></td>"; $table .= " </tr>"; #------------------------------------ $ventas_cheque = 0; $table .= " <tr>"; $table .= " <td></td>";