public function getEditar() { $user = User::find(session('id')); if (session('level') > 3) { $contribuyentes = Contribuyente::all(); } else { $contribuyentes = Contribuyente::where('user_id', '=', session('id'))->get(); } return view('contribuyentes.editar', compact('contribuyentes')); }
/** * Execute the console command. * * @return mixed */ public function handle() { $contribuyentes = Contribuyente::all(); foreach ($contribuyentes as $contr) { $nuevasCanceladas = []; $listSat = ArchivoSat::where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->lists('uuid'); $archivosEmpresa = ArchivoEmpresa::where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->whereNotIn('uuid', $listSat)->get(); $archivosSat = ArchivoSat::whereIn('uuid', $listSat)->get(); $archivos = $archivosSat->merge($archivosEmpresa); foreach ($archivos as $datos) { $servidorSat = new ConsultarSat($datos->uuid, $datos->rfc_emisor, $datos->rfc_receptor, $datos->total); $servidorSat->hacerPeticion(); if ($servidorSat->fueCanceladaRecientemente()) { $nuevasCanceladas[] = array('uuid' => $datos->uuid, 'contribuyente' => $contr->nombre, 'rfc' => $contr->rfc); } } } }
public function getIngresos(Request $request) { try { $contr = $request->cont; $desde = Carbon::createFromFormat('Y-m-d', $request->desde)->startOfDay(); $hasta = Carbon::createFromFormat('Y-m-d', $request->hasta)->endOfDay(); } catch (\Exception $e) { return view('vacio'); } $sat = ArchivoSat::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->get(); $empresa = ArchivoEmpresa::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->get(); $todos = $sat->count() + $empresa->count(); if ($todos == 0) { return view('vacio'); } $diff = new DiferenciasCFID($sat, $empresa, $contr); $ingresos = $diff->getIngresos(); $contr = Contribuyente::where('rfc', '=', $contr)->first(); $array = ['nombre' => $contr->nombre, 'rfc' => $contr->rfc, 'ingresos' => $ingresos]; Excel::create('Ingresos', function ($excel) use($array) { $excel->sheet('New sheet', function ($sheet) use($array) { $sheet->loadView('descargas.reporte-ingresos', $array); }); })->download('xlsx'); }
public function postAddcontr(Request $request) { $id = $request->id; $id_user = Auth::user()->id; $contr = Contribuyente::find($id); $carga = Cargas::where('user_id', '=', $id_user)->where('procesado', '=', false)->first(); $numero = $carga->sat()->count() + $carga->empresa()->count(); if ($numero > 0) { return response()->json(array('resp' => 'no'), 200); } $carga->rfc = $contr->rfc; $carga->save(); return response()->json(array('resp' => 'yes', 'data' => $contr), 200); }