Пример #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Log::info('Iniciando proceso de lectura de ventas');
     $disk = Storage::disk("sales");
     $files = $disk->allfiles();
     foreach ($files as $file) {
         Log::info('Lectura de archivos para procesar');
         $sales_log = SalesLog::where("file_name", $file)->first();
         if (!isset($sales_log)) {
             Log::info('Procesando archivo ' . $file);
             $contents = $disk->get($file);
             $count = 0;
             $description = '';
             $op_location = '';
             $cl_location = '';
             $rows = str_getcsv($contents, "\n");
             //parse the rows
             foreach ($rows as $row) {
                 $datas = str_getcsv($row, '|');
                 if (count($datas) == 17) {
                     $sales = new Sales(['transaction_id' => $datas[0], 'reference' => $datas[1], 'ra_start_date' => $datas[2], 'ra_end_date' => $datas[3], 'factura_uuid' => $datas[4], 'ammount' => $datas[5], 'ammount_applied' => 0, 'credit_debit' => $datas[6], 'payment_method' => $datas[7], 'ra_total' => $datas[8], 'customer_number' => $datas[9], 'op_location' => $datas[10], 'cl_location' => $datas[11], 'gl_account' => $datas[12], 'concept' => $datas[13], 'description' => $datas[14], 'date' => $datas[15], 'factura_number' => $datas[16]]);
                     $sales->save();
                     $count++;
                     $op_location = $datas[10];
                     $cl_location = $datas[11];
                     $description = $datas[14];
                     $payment_method = PaymentMethod::where("payment_method", $datas[7])->first();
                     if (!isset($payment_method)) {
                         Log::info('Agregando nuevo metodo de pago ' . $datas[7]);
                         $payment_method_ = new PaymentMethod(['payment_method' => $datas[7]]);
                         $payment_method_->save();
                     }
                 }
             }
             $sales_log_ = new SalesLog(['file_name' => $file, 'process' => $count, 'description' => $description, 'op_location' => $op_location, 'cl_location' => $cl_location]);
             $sales_log_->save();
             Log::info('Archivo procesado ' . $file . ' renglones procesados ' . $count);
         }
     }
     Log::info('Finalizando proceso de lectura de ventas');
 }
Пример #2
0
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('antiguedad.view')) {
             $fechaActual = Carbon::now()->format('Y/m/d');
             $payment_methods = PaymentMethod::all();
             $plazas = Place::plazasArray($this->user_auth->id);
             return view('contabilidad::OldBalance.form', compact("payment_methods", "plazas", "fechaActual"));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }