Exemplo n.º 1
0
 public function getBuscar(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');
     }
     $listSat = ArchivoSat::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) {
         $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr);
     })->lists('uuid');
     $archivosEmpresa = ArchivoEmpresa::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) {
         $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr);
     })->whereNotIn('uuid', $listSat)->get();
     $archivosSat = ArchivoSat::whereIn('uuid', $listSat)->get();
     return response()->json($archivosSat->merge($archivosEmpresa), 200);
 }
Exemplo n.º 2
0
 /**
  * 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);
             }
         }
     }
 }