Example #1
0
 public function postCorridaFinanciera()
 {
     //Datos del formulario necesarios para la corrida financiera
     $datosCorridaFinanciera = Input::all();
     $corridafinanciera = new CorridaFinanciera($datosCorridaFinanciera['saldofinanciar'], $datosCorridaFinanciera['inflacion'], $datosCorridaFinanciera['plazo'], $datosCorridaFinanciera['gasadmon'], $datosCorridaFinanciera['apartmes']);
     $corridaFinanciera = $corridafinanciera->hacerCorridaFinanciera();
     $encabezados = array(1 => "Mes", 2 => "Saldo inicial", 3 => "Inflacion mensual", 4 => "Saldo actualizado", 5 => "Actualizacion", 6 => "Meses", 7 => "Monto del pago", 8 => "Capital", 9 => "Tasa de interes", 10 => "Interes aplicable", 11 => "Administracion y cobranza", 12 => "Prepagos", 13 => "Total a pagar", 14 => "Saldo final", 15 => "Subtotal", 16 => "Iva por pagar");
     $reportExcel = new ReporteExcel($corridaFinanciera, $encabezados);
     $reportExcel->hacerReporte();
     return "";
 }
Example #2
0
 public function postBuscarcotizacion()
 {
     if (!empty(Input::get('examinar'))) {
         return View::make('ventas/cotizaciones/cotizacionesCliente')->with('cotizaciones', $this->responseAjax->getCotizaciones(Input::get('cliente')));
     } else {
         if (!empty(Input::get('examinarCot'))) {
             $cotizacion = DB::table('cotizacion')->where('id_cotizacion', Input::get('cotizacion'))->get()[0];
             $prepagos = DB::table('prepagoCotizacion')->where('fk_cotizacion', $cotizacion->id_cotizacion)->get();
             //$excepciones = DB::table('cotizacion_excepcion')->where('fk_cotizacion', $cotizacion->id_cotizacion)->get();
             $excepciones = DB::table('coti_excepcion_Accesorios')->where('fk_cotizacion', Input::get('cotizacion'))->get();
             $tipo_excepcion = null;
             if ($excepciones != null) {
                 $tipo_excepcion = 1;
             } else {
                 $excepciones = DB::table('coti_excepcion_Monto_Fijo')->where('fk_cotizacion', Input::get('cotizacion'))->get();
                 if ($excepciones != null) {
                     $tipo_excepcion = 2;
                 }
             }
             $p = null;
             for ($prepago = 0; $prepago < count($prepagos); $prepago++) {
                 $p[$prepago] = array('fecha' => $prepagos[$prepago]->fecha, 'monto' => $prepagos[$prepago]->monto);
             }
             $c = new CorridaFinanciera($cotizacion->saldo_financiar, $cotizacion->inflacion, $cotizacion->plazo, $cotizacion->gas_admon_cobra, $cotizacion->apart_mes, $p, $cotizacion->dia_corte, $cotizacion->apartir_de, null, $excepciones, $tipo_excepcion);
             return View::make('ventas/cotizaciones/salidaCotizacion')->with('info', array('cotizacion' => $c->getCorridaHastaMes($cotizacion->plazo), 'id_cotizacion' => $cotizacion->id_cotizacion));
         } else {
             if (!empty(Input::get('editar'))) {
                 return View::make('ventas/cotizaciones/modificaCotizacion')->with('info', array('desarrollos' => DB::table('desarrollo')->get(), 'cotizacion' => $this->accion->getInfoCotizacion(Input::get('cotizacion'))));
             } else {
                 if (!empty(Input::get('modificarCot'))) {
                     $prepagos = null;
                     for ($prepago = 0; $prepago < Input::get('prepagos'); $prepago++) {
                         $prepagos[$prepago] = array('fecha' => Input::get('fechaPrepago' . ($prepago + 1)), 'monto' => Input::get('importePrepago' . ($prepago + 1)));
                     }
                     $excepciones = null;
                     if (Input::get('eleccion') == 1) {
                         $excepciones = new excepcion(Input::get('desde'), Input::get('hasta'), null);
                     } else {
                         if (Input::get('eleccion') == 2) {
                             $excepciones = new excepcion(Input::get('desde'), Input::get('hasta'), Input::get('cantidadFija'));
                         }
                     }
                     $this->accion->modificarCotizacion(Input::get('cotizacion'), Input::get('numeroLote'), Input::get('rfc'), date('Y-m-d'), Input::get('descuento'), Input::get('porDescuento'), Input::get('pagofirma'), Input::get('porFirma'), Input::get('plazo'), Input::get('inflacion'), Input::get('gastosAdministracion'), Input::get('apartMes'), Input::get('apartirDe'), Input::get('saldoFinanciero'), Input::get('diaCorte'), $prepagos, $excepciones, Input::get('eleccion'));
                     return View::make('ventas/mensajeVentas')->with('datos', array('mensaje' => 'Se ha modificado de menera correcta la cotización', 'tipo_mensaje' => true, 'seccion' => 'Ventas | Cotizacion | Modificar', 'cabecera' => 'Cotización Modificada', 'icono' => 'glyphicon glyphicon-pencil'));
                 } else {
                     if (!empty(Input::get('eliminar'))) {
                         DB::table('prepagoCotizacion')->where('fk_cotizacion', Input::get('cotizacion'))->delete();
                         DB::table('coti_excepcion_Monto_Fijo')->where('fk_cotizacion', Input::get('cotizacion'))->delete();
                         DB::table('coti_excepcion_Monto_Fijo')->where('fk_cotizacion', Input::get('cotizacion'))->delete();
                         DB::table('cotizacion')->where('id_cotizacion', Input::get('cotizacion'))->delete();
                         return View::make('ventas/mensajeVentas')->with('datos', array('mensaje' => 'Se ha eliminado de menera correcta la cotización', 'tipo_mensaje' => true, 'seccion' => 'Ventas | Cotizacion | Eliminar', 'cabecera' => 'Cotización Eliminada', 'icono' => 'glyphicon glyphicon-trash'));
                     } else {
                         if (!empty(Input::get('cotizacion'))) {
                             $variables = DB::table('conjunto_variables')->get()[0];
                             $cotizacion = $this->mysqli->query('select * from cotizacion where id_cotizacion=' . Input::get('id_cotizacion'));
                             $cotizacion = $cotizacion->fetch_object();
                             //$excepciones = DB::table('cotizacion_excepcion')->where('fk_cotizacion', Input::get('id_cotizacion'))->get();
                             $excepciones_solo_acceorios = DB::table('coti_excepcion_Accesorios')->where('fk_cotizacion', Input::get('cotizacion'))->get();
                             $excepciones_monto_fijo = DB::table('coti_excepcion_Monto_Fijo')->where('fk_cotizacion', Input::get('cotizacion'))->get();
                             $consulta_prepagos = $this->mysqli->query('select * from prepagoCotizacion where fk_cotizacion=' . Input::get('id_cotizacion'));
                             $prepago = 0;
                             $prepagos = null;
                             while (($objec = $consulta_prepagos->fetch_object()) != null) {
                                 $prepagos[$prepago] = $objec;
                                 $prepago++;
                             }
                             $corrida = new CorridaFinanciera($cotizacion->saldo_financiar, $variables->interes, $cotizacion->plazo, $variables->porc_gas_admonYcobra / 100, $cotizacion->apart_mes, $prepagos, Input::get('diaCorte'), $cotizacion->apartir_de, null, null, null);
                             $corrida = $corrida->getCorridaHastaMes($cotizacion->plazo);
                             $docexcel = new reporteCotizacion($corrida, array(0 => 'Vencimiento', 1 => 'Mensualidad', 2 => 'Saldo Inicial', 3 => '% de actualización mensual', 4 => 'Saldo actualizado', 5 => 'Actualizacion', 6 => 'Meses', 8 => 'Capital', 7 => 'Sub-Total', 9 => 'Tasa de interés mensual', 10 => 'Interés mensual', 11 => 'Gastos de Administracion y cobranza', 12 => 'Prepagos', 13 => 'Total a pagar', 14 => 'Saldo insoluto de capital'), null, null);
                             $docexcel->hacerReporte();
                         } else {
                             return View::make('ventas/cotizaciones/tablaClientes')->with('clientes', array('clientes' => $this->accion->todosClientes(Input::get('apellidoPaterno'), Input::get('apellidoMaterno'), Input::get('nombres'), Input::get('denominacion')), 'soloBusca' => true));
                         }
                     }
                 }
             }
         }
     }
 }
Example #3
0
 public function postHistorialReestructuracion()
 {
     if (!empty(Input::get('examinar'))) {
         $abonos_capital = null;
         $reestructuracion = DB::table('restructuracion')->where('id_restructuracion', Input::get('reestructuracion'))->get()[0];
         $cuenta_reestructurada = DB::table('cuenta')->where('id_cuenta', $reestructuracion->fk_cuenta)->get()[0];
         $abonosCapital = DB::table('abono_capital')->where('fk_cuenta', $cuenta_reestructurada->id_cuenta)->orderBy('fecha', 'asc')->get();
         for ($prepago = 0; $prepago < count($abonosCapital); $prepago++) {
             $abonos_capital[$prepago] = array('fecha' => $abonosCapital[$prepago]->fecha, 'monto' => $abonosCapital[$prepago]->monto, 'folio' => $abonosCapital[$prepago]->fk_folio, 'id_prepago' => $abonosCapital[$prepago]->id_abono_capital, 'abonoCapital' => true);
         }
         $prepagos = DB::table('prepago')->where('fk_cuenta', $cuenta_reestructurada->id_cuenta)->orderBy('fecha_promesa', 'asc')->get();
         $indice = count($abonosCapital);
         for ($prepago = 0; $prepago < count($prepagos); $prepago++) {
             $abonos_capital[$indice] = array('fecha' => $prepagos[$prepago]->fecha_promesa, 'monto' => $prepagos[$prepago]->monto, 'folio' => null, 'id_prepago' => $prepagos[$prepago]->id_prepago, 'abonoCapital' => false, 'estado' => $prepagos[$prepago]->estado, 'moratorios' => $prepagos[$prepago]->moratorios);
             $indice++;
         }
         // Ordenar el arreglo abonos_capital por fecha
         $tipo_excepcion = null;
         $excepciones = DB::table('excepcion_Accesorios')->where('fk_cuenta', $cuenta_reestructurada->id_cuenta)->get();
         if ($excepciones != null) {
             $tipo_excepcion = 1;
         } else {
             $excepciones = DB::table('excepcion_Monto_Fijo')->where('fk_cuenta', $cuenta_reestructurada->id_cuenta)->get();
             if ($excepciones != null) {
                 $tipo_excepcion = 2;
             }
         }
         $corrida_financiera = new CorridaFinanciera($reestructuracion->saldo_financiar_anterior, 4, $reestructuracion->plazo_anterior, 0.7, 13, $abonos_capital, $reestructuracion->dia_corte_anterior, $reestructuracion->fecha_inicial_pago_anterior, null, $excepciones, $tipo_excepcion);
         return View::make('cobranza/reportes/corridaFinancieraHistorica')->with('corrida', $corrida_financiera->getCorridaHastaMes($reestructuracion->plazo_anterior));
     } else {
         return View::make('cobranza/reportes/reestructuraciones')->with('reestructuraciones', $this->response->getHistorialReestructuracion(Input::get('contratos')));
     }
 }