Exemple #1
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')]);
     }
     /**
      * $Parking & $Client
      * Datos del parking tiket, y Cliente
      * @var array attrs.
      */
     $Client = Client::find($recordId);
     /**
      * $total_price
      * monto a abonar
      * @var int
      */
     $Invoice = new Invoice();
     //Attributes to partial
     $this->vars['total'] = Calc::discount($Invoice->getPrice($Client->billing), $Client->options['discount'], $Client->options['amount']);
     # Monto a abonar
     $this->vars['discount'] = $Client->options['discount'];
     $this->vars['amount'] = $Client->options['amount'];
     $this->vars['Client'] = $Client;
     # Datos del cliente
     $Client->expiration = Request::input('Client.expiration');
     $Client->options = Request::input('Client.options');
     $Client->save();
     /**
      * $Till
      * Nuevo tiket en caja.
      * @var Till
      */
     $Till = new Till();
     $Till->action = 'sale_subs';
     $Till->seller = BackendAuth::getUser()->first_name;
     $Till->billing = $Client->billing;
     $Till->subtotal = $Invoice->getPrice($Client->billing);
     $Till->total = Calc::discount($Invoice->getPrice($Client->billing), $Client->options['discount'], $Client->options['amount']);
     # Monto a abonar
     $Till->save();
     Flash::success('Se ha modificado la fecha de vencimiento de pago con éxito a ' . Request::input('Client.expiration'));
     $this->asExtension('FormController')->update($recordId, $context);
 }
Exemple #2
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']];
 }
Exemple #3
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);
 }
Exemple #4
0
 /**
  * Set Full name client
  * @param string $value #Nombre completo del cliente
  */
 public function setBillingAttribute($value)
 {
     $this->attributes['billing'] = @Client::find(Request::input('Parking.client'))->billing;
 }