private function registrarPagoSolicitud($pago_sol_legacy) { //Encontrar solicitud_id $solicitud_id = Solicitud::where('obs', 'LIKE', '% #SIGI: ' . $pago_sol_legacy->solicitud_id)->pluck('id'); if (!empty($solicitud_id)) { //Enconrar egreso_id $cuenta_bancaria_id = $this->getCuentaBancariaId($pago_sol_legacy->cta_b); if (!empty($cuenta_bancaria_id)) { $egreso = Egreso::where('cuenta_bancaria_id', '=', $cuenta_bancaria_id); if ($pago_sol_legacy->tipo == 'ch') { $egreso->where('cheque', '=', $pago_sol_legacy->poliza); } else { $egreso->where('poliza', '=', $pago_sol_legacy->poliza); } $egreso = $egreso->first(); if (empty($egreso->id)) { dd('Egreso no encontrado ' . $pago_sol_legacy->poliza); } //Crear Relación $egreso->solicitudes()->attach($solicitud_id); } } else { dd('No se encontró la Solicitud ' . $pago_sol_legacy->solicitud_id); } }
private function registrarComprobacion($comp_legacy) { $user_id = $this->getUserId($comp_legacy->responsable); $elabora = $this->getUserId($comp_legacy->usr_elabora); $comp = Comp::create(['oficio_c' => $comp_legacy->oficio_c, 'estatus' => $comp_legacy->estatus, 'comp_siiau' => $comp_legacy->comp_siiau, 'user_id' => $user_id, 'elabora' => $elabora, 'created_at' => '', 'updated_at' => '']); $comp_chegs = \DB::connection($this->db_origen)->table('tbl_comprobacion')->where('comp_id', '=', $comp_legacy->comp_id)->get(); foreach ($comp_chegs as $comp_cheg) { $cuenta_bancaria_id = $this->getCuentaBancariaId($comp_cheg->cta_b); if (!empty($cuenta_bancaria_id)) { $egreso = Egreso::where('cuenta_bancaria_id', '=', $cuenta_bancaria_id); if ($comp_cheg->tipo == 'ch') { $egreso->where('cheque', '=', $comp_cheg->ch_eg); } else { $egreso->where('poliza', '=', $comp_cheg->ch_eg); } $egreso = $egreso->first(); if (empty($egreso->id)) { dd('Egreso no encontrado ' . $comp_cheg->ch_eg); } //Crear Relación $egreso->comps()->save($comp); } $gxc_id = $this->getGxCId($comp_cheg); if (!empty($gxc_id) && $gxc_id > 0) { $this->importarCompRms($comp, $gxc_id); $this->importarFacturas($comp, $gxc_id); } } }
/** * Lista los documentos para agregar a relación. * * @return Response */ public function create($rel_interna_id) { $presupuesto = \Session::get('sel_presupuesto'); $rel_interna = RelInterna::findOrFail($rel_interna_id); $gruposHelper = new GruposHelper(); $arr_usuarios_grupo = $gruposHelper->getGruposColectivos(\Auth::user()->id); switch ($rel_interna->tipo_documentos) { case 'Egresos': $modelo = 'Guia\\Models\\Egreso'; break; case 'Solicitudes': $modelo = 'Guia\\Models\\Solicitud'; break; } $documentos_en_transito = []; $documentos_en_transito = RelInternaDoc::distinct()->select('docable_id')->whereDocableType($modelo)->where('validacion', '=', '')->groupBy('docable_id')->lists('docable_id')->all(); if ($rel_interna->tipo_documentos == 'Egresos') { $documentos = Egreso::where('fecha', '>=', $presupuesto . '-01-01')->whereNested(function ($query) use($arr_usuarios_grupo) { $query->whereIn('user_id', $arr_usuarios_grupo); $query->orWhere('user_id', '=', \Auth::user()->id); })->whereNotIn('id', $documentos_en_transito)->orderBy('cheque', 'desc')->get(); $documentos->load('benef'); $documentos->load('cuentaBancaria'); } if ($rel_interna->tipo_documentos == 'Solicitudes') { $documentos = Solicitud::whereNested(function ($query) use($arr_usuarios_grupo) { $query->whereIn('user_id', $arr_usuarios_grupo); $query->orWhere('user_id', '=', \Auth::user()->id); })->whereNotIn('id', $documentos_en_transito)->orderBy('id')->get(); $documentos->load('benef'); $documentos->load('proyecto'); } $accion = 'agregar-docs'; return view('relint.formRelInternaDoc', compact('rel_interna', 'documentos', 'accion')); }
/** * Display a listing of the resource. * * @return Response */ public function index($scope = null) { $presupuesto = \Session::get('sel_presupuesto'); //Determina Acciones Unidad de Presupuesto $user = \Auth::user(); $arr_roles = $user->roles()->lists('role_name')->all(); if (array_search('Ejecutora', $arr_roles) !== false || array_search('Presupuesto', $arr_roles) !== false) { $acciones_presupuesto = true; } else { $acciones_presupuesto = false; } if ($scope == 'asignados') { $filtro = new FiltroEstatusResponsable(); $filtro->filtroEgresos(); $egresos = Egreso::estatusResponsable($filtro->arr_estatus, $filtro->arr_responsable)->withTrashed()->with('benef', 'proyectos.fondos', 'cuentaBancaria', 'user', 'ocs', 'solicitudes')->orderBy('fecha', 'DESC')->paginate(100); } else { $egresos = Egreso::where('fecha', '>=', $presupuesto . '-01-01')->withTrashed()->with('benef', 'proyectos.fondos', 'cuentaBancaria', 'user', 'ocs', 'solicitudes')->orderBy('fecha', 'DESC')->paginate(100); } return view('egresos.indexEgresos', compact('egresos', 'acciones_presupuesto')); }
private function registrarProyectoEgreso($gxc) { //Determinar proyecto_id $proyecto_id = Proyecto::where('proyecto', 'LIKE', $gxc->proy)->pluck('id'); //Enconrar egreso_id $cuenta_bancaria_id = $this->getCuentaBancariaId($gxc->cta_b); if (!empty($cuenta_bancaria_id)) { $query_egreso = Egreso::where('cuenta_bancaria_id', '=', $cuenta_bancaria_id); if ($gxc->tipo == 'ch') { $query_egreso->where('cheque', '=', $gxc->poliza); $legacy_fecha = \DB::connection($this->db_origen)->table('tbl_cheques')->where('cta_b', $gxc->cta_b)->where('cheque', $gxc->poliza)->pluck('fecha'); } else { $query_egreso->where('poliza', '=', $gxc->poliza); $legacy_fecha = \DB::connection($this->db_origen)->table('tbl_egresos')->where('cta_b', $gxc->cta_b)->where('egreso_id', $gxc->poliza)->pluck('fecha'); } $query_egreso->where('fecha', $legacy_fecha); $egreso = $query_egreso->first(); if (empty($egreso->id)) { dd('Egreso no encontrado ' . $gxc->poliza); } //Crear Relación $egreso->proyectos()->attach($proyecto_id, ['monto' => round($gxc->monto, 2)]); } }
public function importarReembolsosFaltantes() { $legacy_reembolsos = \DB::connection($this->db_origen)->table('tbl_reembolsos')->where('cta_b', $this->cuenta_bancaria->cuenta_bancaria)->whereNotIn('ingreso_id', $this->reembolsos_importados)->get(); foreach ($legacy_reembolsos as $legacy_reembolso) { $cuenta_bancaria_id_egreso = $this->getCuentaBancariaId($legacy_reembolso->cta_b_cheg); $legacy_ingreso = \DB::connection($this->db_origen)->table('tbl_ingresos')->where('cta_b', $legacy_reembolso->cta_b)->where('ingreso_id', $legacy_reembolso->ingreso_id)->first(); if (!empty($legacy_ingreso->ingreso_id)) { //Crear No Identificado $no_identificado = NoIdentificado::create(['cuenta_bancaria_id' => $this->cuenta_bancaria->id, 'fecha' => $legacy_ingreso->fecha, 'monto' => $legacy_ingreso->monto, 'no_deposito' => '', 'identificado' => 0]); $poliza = Poliza::create(['fecha' => $legacy_ingreso->fecha, 'tipo' => 'Ingreso', 'concepto' => $legacy_ingreso->cmt, 'user_id' => \Auth::user()->id]); $poliza->polizaCargos()->create(['cuenta_id' => 10, 'monto' => $legacy_ingreso->monto, 'origen_id' => $no_identificado->id, 'origen_type' => 'Guia\\Models\\NoIdentificado']); $egreso_query = Egreso::where('cuenta_bancaria_id', $cuenta_bancaria_id_egreso); if ($legacy_reembolso->tipo == 'ch') { $egreso_query->where('cheque', $legacy_reembolso->ch_eg); } else { $egreso_query->where('poliza', $legacy_reembolso->ch_eg); } $egreso_id = $egreso_query->pluck('id'); $origen_id = $egreso_id; $origen_type = 'Guia\\Models\\Egreso'; $cuenta_id = $this->getCuentaId($legacy_ingreso->concepto); $poliza_abono = $poliza->polizaAbonos()->create(['cuenta_id' => $cuenta_id, 'monto' => $legacy_ingreso->monto, 'origen_id' => $origen_id, 'origen_type' => $origen_type]); //Registrar RMs del Ingreso $legacy_ingreso_rms = \DB::connection($this->db_origen)->table('tbl_ingresos_rm')->where('cta_b', $legacy_ingreso->cta_b)->where('ingreso_id', $legacy_ingreso->ingreso_id)->get(); if (count($legacy_ingreso_rms) > 0) { foreach ($legacy_ingreso_rms as $legacy_ingreso_rm) { $rm_id = Rm::whereRm($legacy_ingreso_rm->rm)->pluck('id'); $poliza_abono->rms()->attach($rm_id, ['monto' => $legacy_ingreso_rm->monto]); } } } } }
private function getChequesImportados() { $cheques_importados = Egreso::where('cuenta_bancaria_id', $this->cuenta_bancaria->id)->lists('cheque')->all(); return $cheques_importados; }
private function getEgresos() { $egresos = Egreso::where('cuenta_bancaria_id', $this->cuenta_bancaria_id)->whereBetween('fecha', [$this->fecha_inicio, $this->fecha_fin])->with('benef', 'cuenta')->get(); return $egresos; }