/**
  * Agrega un pago a la base de datos
  */
 public function addNewPago($formValues)
 {
     //revisar persona y paquete validos
     $dataaccess = new dalutils();
     $persona = $dataaccess->getRecord('persona', $formValues['idpersona']);
     if ($persona == NULL) {
         throw new Exception('No existe el cliente al cual se le está
             adjudicando el pago');
     }
     $paquete = $dataaccess->getRecord('paquete', $formValues['idpaquete']);
     if ($paquete == NULL) {
         throw new Exception('No existe el paquete');
     }
     $object = new pago();
     $object->populate($formValues);
     //validaciones aqui
     //Regla de Negocio: Solo puede hacer un pago un cliente activo
     if (!$persona->activo) {
         throw new Exception('No es posible generar el pago porque el 
             cliente está inactivo');
     }
     //Regla de Negocio: Un cliente solo puede hacer un pago al mes
     if ($this->isMonthPayed($object->idpersona, $object->fecha)) {
         throw new Exception('No es posible generar el pago porque el 
             cliente ya ha pagado este mes');
     }
     //si aplica descuento, calcular nuevo precio
     if ($object->descuento > 0) {
         $object->monto = $object->monto - $object->monto * $object->descuento / 100;
     }
     //forzar que el registro sea nuevo
     $object->idpago = 0;
     try {
         $result = $object->persist();
     } catch (Exception $e) {
         return false;
     }
     return $result;
 }
Beispiel #2
0
<?php

include_once "../login/check.php";
if (!empty($_GET)) {
    include_once "pdf.php";
    include_once "../funciones.php";
    include_once "../class/pago.php";
    include_once "../class/gasto.php";
    include_once "../class/arrendatario.php";
    $gasto = new gasto();
    $pago = new pago();
    $arrendatario = new arrendatario();
    $fechaInicio = $_GET['FechaInicio'];
    $fechaFin = $_GET['FechaFin'];
    class PDF extends PPDF
    {
        function Cabecera()
        {
        }
    }
    $titulo = "Reporte General";
    $pdf = new PDF("P", "mm", "letter");
    //$pdf=new FPDF("L","mm",array(306,396));
    $borde = 0;
    $pdf->AddPage();
    $totalpagos = 0;
    $totalgastos = 0;
    foreach (rangoFechas($fechaInicio, $fechaFin, "+ 1 month", 1) as $rfechas) {
        $mespagos = 0;
        $mesgastos = 0;
        $mes = date("m", strtotime($rfechas));
Beispiel #3
0
<?php

include_once "../login/check.php";
if (!empty($_POST)) {
    include_once "../class/pago.php";
    $pago = new pago();
    $cod = $_POST['CodPago'];
    $tipo = $_POST['Tipo'];
    switch ($tipo) {
        case 'Monto':
            $values = array("Monto" => "'" . $_POST['Monto'] . "'");
            break;
        case 'Observaciones':
            $values = array("Observaciones" => "'" . $_POST['Obs'] . "'");
            break;
        case 'Fecha':
            $values = array("FechaCancelado" => "'" . $_POST['Fecha'] . "'");
            break;
    }
    $pago->actualizarPago($values, $cod);
}
Beispiel #4
0
<?php

include_once "../login/check.php";
if (!empty($_POST)) {
    include_once "../class/pago.php";
    include_once "../class/arrendatario.php";
    include_once "fpdf/fpdf.php";
    include_once "funciones.php";
    $cod = $_POST['CodArrendatario'];
    $codpago = $_POST['CodPago'];
    $proximoMes = $_POST['proximoMes'];
    $montoPendiente = $_POST['pendiente'];
    $arrendatario = new arrendatario();
    $pago = new pago();
    $valorConcepto = array();
    $valorImporte = array();
    $arren = array_shift($arrendatario->mostrarTodo(1, "CodArrendatario={$cod}"));
    $pagoTotal = 0;
    $i = 0;
    foreach ($codpago as $cpago) {
        $i++;
        $p = array_shift($pago->mostrarTodo(0, "CodPago=" . $cpago));
        if ($p['Monto'] == $arren['Monto']) {
            array_push($valorConcepto, "Alquiler mes de " . mb_strtoupper(strftime("%B", strtotime($p['FechaPago']))) . " de " . $p['Anio'] . " | Cancelado: " . date("d/m/Y", strtotime($p['FechaCancelado'])));
            array_push($valorImporte, $p['Monto'] . " Bs.");
            $pagoTotal += $p['Monto'];
        } else {
            if ($p['Monto'] < $arren['Monto']) {
                array_push($valorConcepto, "Adelanto alquiler mes de " . mb_strtoupper(strftime("%B", strtotime($p['FechaPago']))) . " de " . $p['Anio'] . " | Cancelado: " . date("d/m/Y", strtotime($p['FechaCancelado'])));
                array_push($valorImporte, $p['Monto'] . " Bs.");
                $pagoTotal += $p['Monto'];
Beispiel #5
0
 public function aumentarPagos($id, $fecha)
 {
     $vales = Vale::where('id_distribuidor', $id)->where('estatus', 1)->where('fecha_inicio_pago', '<=', $fecha)->get();
     $pagos = pago::where('id_distribuidor', $id)->where('estado', 3)->get();
     $nPagos = count($pagos);
     for ($i = 0; $i < sizeof($vales); $i++) {
         if ($nPagos == 0) {
             $vales[$i]->pagos_realizados = $vales[$i]->pagos_realizados + 1;
             $importe = $vales[$i]->cantidad;
             $saldoAnterior = $vales[$i]->deuda_actual;
             $pagosRealizados = $vales[$i]->pagos_realizados;
             $numeroPagos = $vales[$i]->numero_pagos;
             $abono = $this->calcularPago($importe, $numeroPagos, $pagosRealizados);
             $vales[$i]->deuda_actual = $saldoAnterior - $abono;
             if ($numeroPagos == $pagosRealizados) {
                 $vales[$i]->estatus = 3;
             }
             $vales[$i]->save();
         } else {
             $vales[$i]->pagos_realizados = $vales[$i]->pagos_realizados + 1;
             $importe = $vales[$i]->cantidad;
             $saldoAnterior = $vales[$i]->deuda_actual;
             $pagosRealizados = $vales[$i]->pagos_realizados;
             $numeroPagos = $vales[$i]->numero_pagos;
             $abono = $this->calcularPago($importe, $numeroPagos, $pagosRealizados);
             $vales[$i]->deuda_actual = $saldoAnterior - $abono;
             if ($numeroPagos == $pagosRealizados) {
                 $vales[$i]->estatus = 3;
             }
             $vales[$i]->save();
             $this->aumentarVariosPagos($vales[$i], $pagos);
         }
     }
 }
Beispiel #6
0
<?php

include_once "../login/check.php";
if (!empty($_GET)) {
    $folder = "../";
    $cod = $_GET['CodArrendatario'];
    $titulo = "Pagar Arrendatario";
    include_once "../cabecerahtml.php";
    include_once "../class/arrendatario.php";
    include_once "../class/pago.php";
    include_once "../funciones.php";
    $arrendatario = new arrendatario();
    $pago = new pago();
    $arren = array_shift($arrendatario->mostrarTodo(1, "CodArrendatario={$cod}"));
    $fechaCancela = $arren['FechaCancela'];
    $fechaHoy = date("Y-m-d");
    ?>
</head>
<body>
<?php 
    include_once "../cabecera.php";
    ?>
<div class="container_12" id="cuerpo">
<div class="prefix_2 grid_8 suffix_2">
	<div class="titulo">Listado de Arrendatarios</div>
	<div class="cuerpo">
    	<table class="tabla">
        <tr class="cabecera"><td>Nombre Esposo</td><td>Nombre Esposa</td><td>Monto</td><td>Fecha de Cancelación</td></tr>
				<tr class="contenido"><td><?php 
    echo $arren['NombreEsposo'];
    ?>
 private function cron_job()
 {
     $pago = new pago();
     $pago->cron_job();
     $recibo = new recibo_cliente();
     $recibo->cron_job();
     $sql = "SELECT * FROM facturascli WHERE NOT pagada AND idfactura NOT IN (SELECT idfactura FROM reciboscli)";
     $data = $this->db->select_limit($sql, FS_ITEM_LIMIT, 0);
     if ($data) {
         foreach ($data as $d) {
             $this->factura = new factura_cliente($d);
             /// generamos los recibos a partir de los pagos en pedidos y albaranes
             $this->generar_recibos_pagos();
             $this->resultados = $recibo->all_from_factura($this->factura->idfactura);
             $this->sync_factura();
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $pago = pago::findOrFail($id);
     $pago->delete();
     session::flash('message', 'pago eliminado de los registros');
     return redirect()->route('admin.pago.index');
 }
Beispiel #9
0
 protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->pago = FALSE;
     $pago = new pago();
     if (isset($_REQUEST['id'])) {
         $this->pago = $pago->get($_REQUEST['id']);
         if (isset($_POST['ajax'])) {
             $this->template = 'ajax_pago';
         } else {
             if (isset($_POST['nota'])) {
                 $this->pago->nota = $_POST['nota'];
                 $this->pago->importe = floatval($_POST['importe']);
                 $this->pago->fecha = $_POST['fecha'];
                 if ($this->pago->save()) {
                     $this->new_message('Datos guardados correctamente.');
                 } else {
                     $this->new_error_msg('Imposible guardar los datos.');
                 }
             }
         }
     } else {
         if (isset($_POST['nota'])) {
             $pago->nota = $_POST['nota'];
             $pago->importe = floatval($_POST['importe']);
             $pago->fecha = $_POST['fecha'];
             if ($pago->save()) {
                 $this->new_message('Datos guardados correctamente.');
             } else {
                 $this->new_error_msg('Imposible guardar los datos.');
             }
         } else {
             if (isset($_GET['delete'])) {
                 $pago2 = $pago->get($_GET['delete']);
                 if ($pago2) {
                     if ($pago2->delete()) {
                         $this->new_message('Pago ' . $_GET['delete'] . ' eliminado correctamente.');
                     } else {
                         $this->new_error_msg('Error al eliminar el pago ' . $_GET['delete']);
                     }
                 } else {
                     $this->new_error_msg('Pago ' . $_GET['delete'] . ' no encontrado.');
                 }
             }
         }
     }
     $this->tipo = FALSE;
     if (isset($_REQUEST['tipo'])) {
         if ($_REQUEST['tipo'] == 'entradas') {
             $this->tipo = 'entradas';
             $this->resultados = $pago->entradas();
         } else {
             if ($_REQUEST['tipo'] == 'salidas') {
                 $this->tipo = 'salidas';
                 $this->resultados = $pago->salidas();
             }
         }
     } else {
         $this->resultados = $pago->all();
     }
 }
Beispiel #10
0
<?php

include_once "../login/check.php";
if (!empty($_POST)) {
    include_once "../class/pago.php";
    $pago = new pago();
    $cod = $_POST['CodArrendatario'];
    $monto = $_POST['Monto'];
    $mes = $_POST['Mes'];
    $anio = $_POST['Anio'];
    $fechaCancelado = $_POST['FechaCancelado'];
    $fecha = date("Y-m-d");
    $fechaRegistro = $fecha;
    $horaRegistro = date("H:i:s");
    $values = array("CodPago" => "NULL", "CodArrendatario" => "{$cod}", "Mes" => "'{$mes}'", "Anio" => "'{$anio}'", "FechaPago" => "'{$fechaCancelado}'", "Monto" => "'{$monto}'", "FechaCancelado" => "'{$fecha}'", "FechaRegistro" => "'{$fechaRegistro}'", "HoraRegistro" => "'{$horaRegistro}'", "Activo" => 1);
    $pago->insertarPago($values);
}
Beispiel #11
0
 private function check_recibo()
 {
     $this->anticipo = FALSE;
     if ($this->factura) {
         $this->recibo->nombrecliente = $this->factura->nombrecliente;
         $this->recibo->cifnif = $this->factura->cifnif;
         $this->recibo->apartado = $this->factura->apartado;
         $this->recibo->ciudad = $this->factura->ciudad;
         $this->recibo->codpais = $this->factura->codpais;
         $this->recibo->codpostal = $this->factura->codpostal;
         $this->recibo->direccion = $this->factura->direccion;
         $this->recibo->provincia = $this->factura->provincia;
         /// ¿El recibo viene de un anticipo?
         $pago = new pago();
         foreach ($pago->all_from_recibo($this->recibo->idrecibo) as $a) {
             $this->anticipo = $a;
         }
         if ($this->recibo->estado != 'Pagado' and is_null($this->recibo->idremesa)) {
             $this->recibo->coddivisa = $this->factura->coddivisa;
             $this->recibo->tasaconv = $this->factura->tasaconv;
             $this->recibo->codpago = $this->factura->codpago;
             $this->recibo->codserie = $this->factura->codserie;
             $cbc = new cuenta_banco_cliente();
             foreach ($cbc->all_from_cliente($this->recibo->codcliente) as $cuenta) {
                 if (is_null($this->recibo->codcuenta)) {
                     $this->recibo->codcuenta = $cuenta->codcuenta;
                     $this->recibo->iban = $cuenta->iban;
                     $this->recibo->swift = $cuenta->swift;
                 }
             }
         }
         $this->recibo->save();
     }
 }
Beispiel #12
0
 * Copyright (C) 2014-2015  Carlos Garcia Gomez  neorazorx@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_model('factura_cliente.php');
require_model('pago.php');
/**
 * Guarda el pago de todas las facturas antiguas que están marcadas como pagadas,
 * pero que no tienen su entrada en pagos.
 */
$data = $db->select("SELECT * FROM facturascli WHERE pagada AND idfactura NOT IN (SELECT idfactura FROM pagos);");
foreach ($data as $d) {
    $factura = new factura_cliente($d);
    $pago = new pago();
    $pago->idfactura = $factura->idfactura;
    $pago->fecha = $factura->fecha;
    $pago->fase = 'Factura';
    $pago->importe = $factura->total;
    $pago->save();
}