public function noIdentificados($cuenta_bancaria_id, $aaaa, $mm)
 {
     $fecha = FechasUtility::fechasConciliacion($aaaa, $mm);
     $this->fecha_inicio = $fecha['inicial'];
     $this->fecha_fin = $fecha['final'];
     /**
      * @todo Agregar campo fecha_identificado a tabla no_identificados
      * @todo Incluir identificados c/fecha_identificado(año/mes) mayor al consultado
      */
     $no_identificados = NoIdentificado::where('cuenta_bancaria_id', $cuenta_bancaria_id)->whereBetween('fecha', [$this->fecha_inicio, $this->fecha_fin])->where('identificado', 0)->orderBy('fecha')->get();
     return view('conciliacion.noIdentificados', compact('no_identificados'));
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $tipo = $request->input('tipo');
     $egreso_id = $request->input('egreso_id');
     if ($tipo == 'Ingreso' && !empty($egreso_id)) {
         $no_identificado_id = $request->input('no_identificado_id');
         $no_identificado = NoIdentificado::findOrFail($no_identificado_id);
         $egreso = Egreso::findOrFail($egreso_id);
         $egreso->load('rms');
         //Determina el monto total
         $sum_monto = 0;
         $arr_monto_rms = [];
         foreach ($egreso->rms as $rm) {
             $monto_rm_id = $request->input('monto_rm_id_' . $rm->id);
             if (!empty($monto_rm_id)) {
                 $arr_monto_rms[$rm->id] = $monto_rm_id;
             }
         }
         //Determina el monto total
         foreach ($arr_monto_rms as $monto_rm) {
             $sum_monto += $monto_rm;
         }
         //Generar Póliza
         $poliza = Poliza::create(['cuenta_bancaria_id' => $no_identificado->cuenta_bancaria_id, 'fecha' => Carbon::now()->toDateString(), 'tipo' => $tipo, 'user_id' => \Auth::user()->id]);
         //Generar Cargo (cuenta_id => 10 //No Identificado)
         $poliza->polizaCargos()->create(['cuenta_id' => 10, 'monto' => $sum_monto, 'origen_id' => $no_identificado_id, 'origen_type' => 'Guia\\Models\\NoIdentificado']);
         //Generar Abono
         $poliza_abono = $poliza->polizaAbonos()->create(['cuenta_id' => $egreso->cuenta_id, 'monto' => $sum_monto, 'origen_id' => $egreso_id, 'origen_type' => 'Guia\\Models\\Egreso']);
         //Insertar RMs
         foreach ($arr_monto_rms as $rm => $monto) {
             $poliza_abono->rms()->attach($rm, ['monto' => $monto]);
         }
         //Actualizar NoIdentificado
         if (round($no_identificado->monto, 2) == round($sum_monto, 2)) {
             $no_identificado->identificado = 1;
             $no_identificado->fecha_identificado = Carbon::now()->toDateString();
             $no_identificado->save();
         }
         return redirect()->action('EgresosController@show', $egreso_id)->with(['message' => 'Póliza de Ingreso creada con éxito']);
     } else {
         return redirect()->back()->with(['message' => 'No se puede realizar esta acción']);
     }
 }
Exemplo n.º 3
0
 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]);
                 }
             }
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $no_identificado = NoIdentificado::findOrFail($id);
     if ($no_identificado->identificado == 1) {
         return redirect()->back()->with(['message' => 'El depósito ya ha sido identificado por lo que no puede ser eliminado', 'alert-class' => 'alert-warning']);
     }
     $no_identificado->delete();
     return redirect()->action('NoIdentificadoController@index')->with(['message' => 'Depósito eliminado con éxito', 'alert-class' => 'alert-success']);
 }