Example #1
0
 public function hacerPeticion()
 {
     try {
         $soapclient = new \SoapClient($this->url);
         $prm = array('expresionImpresa' => $this->formatoImpreso);
         $result = $soapclient->Consulta($prm);
         $satus = $result->ConsultaResult->CodigoEstatus;
         $estado = $result->ConsultaResult->Estado;
         $codigo = explode('-', $satus)[0];
         if (str_contains($codigo, 'S')) {
             $archivo = Archivos::where('uuid', '=', $this->uuid)->first();
             $archivo->validado = true;
             if ($archivo->status != $estado) {
                 $this->canceladaRecientemente = true;
             }
             $archivo->status = $estado;
             $archivo->fecha_checado = Carbon::now();
             $archivo->save();
             $this->estatus = $satus;
         }
         return serialize($result);
     } catch (\Exception $e) {
         return null;
     }
 }
Example #2
0
 public static function validado($carga)
 {
     $sat = $carga->sat()->lists('uuid');
     //que son casi todos
     $empresa = $carga->empresa()->whereNotIn('uuid', $sat)->lists('uuid');
     //que son casi todos
     $allSat = Archivos::whereIn('uuid', $sat)->where('validado', '=', true)->count();
     $allEmp = Archivos::whereIn('uuid', $empresa)->where('validado', '=', true)->count();
     $all = $allEmp + $allSat;
     $sumArch = $sat->count() + $empresa->count();
     $val = $sumArch > 0 ? round($all / $sumArch, 2) * 100 : 100;
     return $val;
 }
Example #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $archivos = Archivos::where('validado', '=', false)->get();
     foreach ($archivos as $arch) {
         if ($arch->validado == true) {
             //puede ser que este archivo ya fue validado en otra cola
             continue;
         }
         $datos = $arch->sat;
         if (!$datos) {
             $datos = $arch->empresa;
         }
         $servidorSat = new ConsultarSat($datos->uuid, $datos->rfc_emisor, $datos->rfc_receptor, $datos->total);
         $resp = $servidorSat->hacerPeticion();
         //s$this->info($resp);
     }
 }
Example #4
0
 public function getXml($uuid)
 {
     $archivo = Archivos::where("uuid", "=", $uuid)->first();
     $data = $archivo->sat;
     if (!$data) {
         $data = $archivo->empresa;
     }
     $dom = new \DOMDocument();
     $dom->preserveWhiteSpace = FALSE;
     $dom->loadXML($data->file);
     $dom->formatOutput = TRUE;
     $xml = $dom->saveXml();
     return response()->json(["xml" => $xml], 200);
 }
Example #5
0
 function empresaFiles($text, $isZip = true)
 {
     $id = Auth::user()->id;
     $carga = Cargas::where('user_id', '=', $id)->where('procesado', '=', false)->first();
     $error = "No se ha seleccionado ningun contribuyente, regresa al paso 1";
     if ($carga->rfc == null) {
         throw new \ErrorException($error);
     }
     $parser = new ParserCFID($text);
     $parser->parser();
     $fecha = $parser->getFecha();
     $rfcEmisor = $parser->getRfcEmisor();
     $rfcReceptor = $parser->getRfcReceptor();
     $uuid = $parser->getUUID();
     $total = $parser->getTotal();
     $subtotal = $parser->getSubTotal();
     $error = "No ha seleccionado una fecha regrese al paso 1 para seleccionarla.";
     if (!$carga->anio || !$carga->mes) {
         if ($carga->mes != 0) {
             throw new \ErrorException($error);
         }
     }
     if ($carga->mes == 0) {
         $error = "Esta factura no corresponde al año seleccionado.";
         if ($carga->anio != $fecha->year) {
             if (!$isZip) {
                 throw new \ErrorException($error);
             } else {
                 return "no";
             }
         }
     } elseif ($carga->mes <= 12) {
         $error = "Esta factura no corresponde a la fecha seleccionada.";
         if ($carga->mes != $fecha->month || $carga->anio != $fecha->year) {
             if (!$isZip) {
                 throw new \ErrorException($error);
             } else {
                 return "no";
             }
         }
     } else {
         $error = "Hubo un error en la selección de fecha regrese al paso uno y verifíquelo.";
         throw new \ErrorException($error);
     }
     $rfc = $carga->rfc;
     $error = "Este rfc no pertence al contribuyente seleccionado";
     if ($rfcEmisor != $rfc && $rfcReceptor != $rfc) {
         if (!$isZip) {
             throw new \ErrorException($error);
         } else {
             return $error;
         }
     }
     $error = "Ya existe el UUID: {$uuid}";
     $sat = ArchivoEmpresa::where('uuid', '=', $uuid)->first();
     if ($sat) {
         if (!$isZip) {
             throw new \ErrorException($error);
         } else {
             return $error;
         }
     }
     $tipoEmisor = $parser->getTipoEmisor();
     $tipoReceptor = $parser->getTipoReceptor();
     ArchivoEmpresa::create(['tipo_id' => 2, 'carga_id' => $carga->id, 'fecha' => $fecha, 'rfc_emisor' => $rfcEmisor, 'rfc_receptor' => $rfcReceptor, 'uuid' => $uuid, 'file' => $text, 'tipo_emisor' => $tipoEmisor, 'tipo_receptor' => $tipoReceptor, 'total' => $total, 'subtotal' => $subtotal]);
     $archivo = Archivos::where('uuid', '=', $uuid)->first();
     if (!$archivo) {
         Archivos::create(['uuid' => $uuid]);
     }
     return "yes";
 }