예제 #1
0
 /**
  * GENERA UN RECIBO BANCARIO POR CADA RECIBO DE CLIENTE    
  */
 static function RecibosIndividuales($filtro)
 {
     $recibos = new RecibosClientes();
     $clientes = new Clientes();
     $tablaRecibos = $recibos->getDataBaseName() . "." . $recibos->getTableName();
     $tablaClientes = $clientes->getDataBaseName() . "." . $clientes->getTableName();
     $em = new EntityManager($recibos->getConectionName());
     if ($em->getDbLink()) {
         $filtro .= " and (Remesar='1') and (CHAR_LENGTH(r.Iban)>23) and (r.Iban<>'ES8200000000000000000000') and (r.Importe>0)";
         $query = "select r.IDRecibo " . "from {$tablaRecibos} as r " . "left join {$tablaClientes} as c on r.IDCliente=c.IDCliente " . "where {$filtro} " . "order by c.RazonSocial,r.Vencimiento ASC";
         $em->query($query);
         $rows = $em->fetchResult();
     }
     unset($recibos);
     $total = 0;
     foreach ($rows as $row) {
         $recibo = new RecibosClientes($row['IDRecibo']);
         $cliente = $recibo->getIDCliente();
         $total += $recibo->getImporte();
         $recibos[] = array('numeroFactura' => $recibo->getIDFactura()->getNumeroFactura(), 'importe' => $recibo->getImporte(), 'idMandato' => $recibo->getMandato(), 'fechaMandato' => $recibo->getFechaMandato('aaaammdd'), 'bic' => $recibo->getBic() == '' ? "BBBBESPP" : $recibo->getBic(), 'iban' => $recibo->getIban(), 'razonSocial' => $cliente->getRazonSocial(), 'direccion1' => $cliente->getDireccion(), 'direccion2' => $cliente->getIDPoblacion()->getMunicipio() . " " . $cliente->getCodigoPostal() . " " . $cliente->getIDProvincia()->getProvincia(), 'pais' => $cliente->getIDPais()->getCodigo(), 'texto' => "Factura N. {$recibo->getIDFactura()->getNumeroFactura()} {$recibo->getIDFactura()->getFecha()} {$recibo->getImporte()}");
     }
     unset($cliente);
     unset($recibo);
     return array('nRecibos' => count($rows), 'importeTotal' => $total, 'recibos' => $recibos);
 }
예제 #2
0
 public function ListAction()
 {
     $filtro = $this->request['filtro'];
     $desde = new Fecha($filtro['desdeFecha']);
     $hasta = new Fecha($filtro['hastaFecha']);
     $filtroSucursal = $filtro['idSucursal'] ? "IDSucursal='{$filtro['idSucursal']}'" : "1";
     $filtroEstado = $filtro['idEstado'] != '' ? "IDEstado='{$filtro['idEstado']}'" : "1";
     $filtroQuery = "(Vencimiento>='{$desde->getaaaammdd()}') and (Vencimiento<='{$hasta->getaaaammdd()}') and ({$filtroSucursal}) and ({$filtroEstado})";
     // and (Iban<>0)";
     $recibos = new RecibosClientes();
     $rows = $recibos->cargaCondicion("IDRecibo", $filtroQuery, "Vencimiento ASC");
     unset($recibos);
     $array = array();
     foreach ($rows as $row) {
         $recibo = new RecibosClientes($row['IDRecibo']);
         $array[] = array('IDRecibo' => $recibo->getIDRecibo(), 'NumeroFactura' => $recibo->getIDFactura()->getNumeroFactura(), 'RazonSocial' => $recibo->getIDCliente()->getRazonSocial(), 'Fecha' => $recibo->getFecha(), 'Vencimiento' => $recibo->getVencimiento(), 'Importe' => $recibo->getImporte(), 'Remesa' => $recibo->getIDRemesa(), 'Iban' => $recibo->getIban(), 'Estado' => $recibo->getIDEstado()->getDescripcion());
     }
     unset($recibo);
     $this->values['datos'] = $array;
     return array('values' => $this->values, 'template' => $this->entity . '/list.html.twig');
 }
 /**
  * Guarda todos los recibos que le vienen en el request y
  * comprueba el cuadre entre el importe total de todos los
  * recibos de cada factura y el importe total de la factura
  *
  * @return array
  */
 public function guardarAction()
 {
     if ($this->values['permisos']['permisosModulo']['UP']) {
         $arrayFacturas = array();
         foreach ($this->request['RecibosClientes'] as $recibo) {
             $objeto = new RecibosClientes($recibo['IDRecibo']);
             $objeto->setVencimiento($recibo['Vencimiento']);
             $objeto->setImporte($recibo['Importe']);
             $objeto->setIban($recibo['Iban']);
             $objeto->setConcepto($recibo['Concepto']);
             $objeto->setIDRemesa($recibo['IDRemesa']);
             $objeto->setIDEstado($recibo['IDEstado']);
             $objeto->save();
             // Guardo temporalmente todas las facturas afectadas
             $arrayFacturas[] = $objeto->getIDFactura()->getIDFactura();
         }
         unset($objeto);
         // Comprobar cuadre recibos-factura
         $arrayFacturas = array_unique($arrayFacturas);
         foreach ($arrayFacturas as $idFactura) {
             $factura = new FemitidasCab($idFactura);
             $totalFactura = $factura->getTotal();
             $sumaRecibos = $factura->getSumaRecibos();
             if ($totalFactura != $sumaRecibos) {
                 $diferencia = $totalFactura - $sumaRecibos;
                 $this->values['errores'][] = "Descuadre en factura {$factura->getNumeroFactura()} -> Total Factura: {$totalFactura} Suma Recibos {$sumaRecibos}. Diferencia {$diferencia}";
             }
         }
         unset($factura);
         return $this->listAction();
     } else {
         return array('template' => '_global/forbiden.html.twig');
     }
 }
 private function ApunteDetalleCobro($nAsiento, $fecha, array $cabecera)
 {
     $filtro = "IDCliente='{$cabecera['IDCliente']}' and Vencimiento='{$cabecera['Vencimiento']}' and IDRemesa='{$cabecera['IDRemesa']}' and IDEstado='{$cabecera['IDEstado']}'";
     $recibo = new RecibosClientes();
     $recibos = $recibo->cargaCondicion("*", $filtro);
     unset($recibo);
     $cliente = new Clientes($cabecera['IDCliente']);
     foreach ($recibos as $recibo) {
         $recibo = new RecibosClientes($recibo['IDRecibo']);
         $apunte = new ContaPlusDiario($nAsiento, $fecha);
         $apunte->setSubCta($cliente->getCContable());
         $apunte->setContra($recibo->getCContable());
         $apunte->setConcepto("Cob Ftra Cliente " . $cliente->getRazonSocial());
         $apunte->setDocumento($recibo->getIDFactura()->getNumeroFactura());
         $apunte->setEuroHaber($recibo->getImporte());
         $apuntes[] = $apunte;
     }
     unset($apunte);
     unset($recibo);
     return $apuntes;
 }