Example #1
0
 public function getTimes()
 {
     /**
      * $Parking
      * $Client
      * @var array attributes
      */
     $Parking = Parking::find($this->parkingId);
     $Client = Client::find($Parking->client_id);
     /**
      * $start_time      # Hora de ingreso
      * $end_time        # Hora de retiro
      * @var timestamp
      */
     $start_time = $Parking->checkin;
     $end_time = date('Y-m-d H:i:s', time());
     $currents = Calc::currentTime($start_time, $end_time);
     return $times = ['start_time' => $start_time, 'end_time' => $end_time, 'total_time' => $currents['total_time'], 'decimal_time' => $currents['decimal_time']];
 }
Example #2
0
 public function onCheckout($recordId = null, $context = null)
 {
     /**
      * Validar si la caja esta abierta,
      * antes de crear una venta.
      * @return [type] [description]
      */
     if (!CashRegister::is_open()) {
         throw new ValidationException(['please_opening_cash_register' => trans('awme.parking::lang.sales.please_opening_cash_register')]);
     }
     /**
      * [$Invoice description]
      * @var Invoice
      */
     $Invoice = new Invoice();
     $Invoice->parkingId = $recordId;
     $times = $Invoice->getTimes();
     /**
      * $Parking & $Client
      * Datos del parking tiket, y Cliente
      * @var array attrs.
      */
     $Parking = Parking::find($recordId);
     $Client = Client::find($Parking->client_id);
     /**
      * $total_price
      * monto a abonar
      * @var int
      */
     $total_price = Checkout::total($times['decimal_time'], $Client);
     ///Attributes to partial
     $this->vars['times'] = $times;
     # Tiempos (start_time, end_time, total_time, decimal_time)
     $this->vars['discount'] = $Parking->options['discount'];
     $this->vars['amount'] = $Parking->options['amount'];
     $this->vars['total'] = Calc::discount($total_price, $Parking->options['discount'], $Parking->options['amount']);
     # Monto a abonar
     $this->vars['Parking'] = $Parking;
     # Datos del tiket
     $this->vars['Client'] = $Client;
     # Datos del cliente
     $this->asExtension('FormController')->update($recordId, $context);
     /**
      * $Parking Checkout
      * @var timestamp $checkout #endtime
      * @var string    $status   # tiket cerrado
      * @var int       $total    # total a pagar.
      */
     $Parking->checkout = $times['end_time'];
     $Parking->status = 'Cerrado';
     $Parking->total = $total_price;
     $Parking->save();
     /**
      * $Till
      * Nuevo tiket en caja.
      * @var Till
      */
     $Till = new Till();
     $Till->action = 'sale';
     $Till->seller = BackendAuth::getUser()->first_name;
     $Till->tiket = $Parking->tiket;
     $Till->billing = $Parking->billing;
     $Till->subtotal = $total_price;
     $Till->total = $Parking->billing == 'Hora' ? $this->vars['total'] : 0;
     $Till->save();
     /**
      * $Garage
      * @var string    $status # Liberar cochera
      */
     $Garage = Garage::find($Parking->garage_id);
     $Garage->status = 'Disponible';
     $Garage->save();
     return Flash::success('Tiempo transcurrido: ' . $times['total_time'] . ' Con un Total a abonar de: $' . $total_price);
 }
Example #3
0
 /**
  * Set the Tiket Number
  *
  * @param  string  $value
  * @return string
  */
 public function setTiketAttribute($value)
 {
     /**
      * Tiket automatico, segĂșn numero de id.
      */
     if (!$value) {
         if (!$this->attributes['id']) {
             $tiket = Parking::where('id', '>', '0')->orderBy('created_at', 'desc')->first();
             if ($tiket) {
                 $tiket_id = $tiket->id + 1;
             } else {
                 $tiket_id = 1;
             }
         } else {
             $tiket_id = $this->attributes['id'];
         }
         $this->attributes['tiket'] = str_pad($tiket_id, 6, "0", STR_PAD_LEFT);
     } else {
         $this->attributes['tiket'] = $value;
     }
 }