Booking edit v3

This commit is contained in:
Kevin Adametz 2021-06-18 15:00:12 +02:00
parent 6706d28f51
commit 6880c7e989
20 changed files with 691 additions and 97 deletions

View file

@ -590,8 +590,7 @@ class Booking extends Model
if(empty($nats)){
$nats['de'] = 'de';
}
}
foreach ($nats as $nat){
$data = [
'nat' => $nat,
@ -778,7 +777,7 @@ class Booking extends Model
{
$total = 0;
foreach ($this->service_provider_entries as $entry){
$total += $entry->getAmountRaw() / $entry->factor;
$total += $entry->getAmountRaw() / $entry->getFactortRaw();
}
return $raw ? $total : Util::_number_format($total);
}

View file

@ -83,7 +83,10 @@ class BookingServiceItem extends Model
return $this->belongsTo(TravelCompany::class);
}
public function setServicePriceAttribute($value)
{
$this->attributes['service_price'] = Util::_clean_float($value);
}
public function getServicePriceAttribute()
{
return Util::_number_format($this->attributes['service_price']);
@ -92,4 +95,35 @@ class BookingServiceItem extends Model
{
return $this->attributes['service_price'];
}
public function setCommissionAttribute($value)
{
$this->attributes['commission'] = Util::_clean_float($value);
}
public function getCommissionAttribute()
{
return Util::_number_format($this->attributes['commission']);
}
public function getCommissionRaw()
{
return $this->attributes['commission'];
}
public function setServicePriceRefundAttribute($value)
{
$this->attributes['service_price_refund'] = Util::_clean_float($value);
}
public function getServicePriceRefundAttribute()
{
return Util::_number_format($this->attributes['service_price_refund']);
}
public function getServicePriceRefundRaw()
{
return $this->attributes['service_price_refund'];
}
public function setServicePriceRefundRaw($value)
{
return $this->attributes['service_price_refund'] = $value;
}
}

41
app/Models/Branch.php Normal file
View file

@ -0,0 +1,41 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Branch
*
* @property int $id
* @property string $name
*
* @property Collection|Booking[] $bookings
* @property Collection|SfGuardUser[] $sf_guard_users
*
* @package App\Models
*/
class Branch extends Model
{
protected $table = 'branch';
public $timestamps = false;
protected $fillable = [
'name'
];
public function bookings()
{
return $this->hasMany(Booking::class);
}
public function sf_guard_users()
{
return $this->hasMany(SfGuardUser::class);
}
}

View file

@ -97,6 +97,23 @@ class ServiceProviderEntry extends Model
}
}
public function setFactorAttribute($value)
{
$this->attributes['factor'] = floatval(preg_replace("/[^0-9.-]/", "", str_replace(',', '.', $value)));
}
public function getFactorAttribute()
{
return Util::_number_format($this->attributes['factor'], 4);
}
public function getFactortRaw()
{
return $this->attributes['factor'];
}
public function setAmountAttribute($value)
{
$this->attributes['amount'] = Util::_clean_float($value);
}
public function getAmountAttribute()
{
return Util::_number_format($this->attributes['amount']);
@ -105,7 +122,10 @@ class ServiceProviderEntry extends Model
{
return $this->attributes['amount'];
}
public function setAmountEurAttribute($value)
{
$this->attributes['amount_eur'] = Util::_clean_float($value);
}
public function getAmountEurAttribute()
{
return Util::_number_format($this->attributes['amount_eur']);
@ -135,4 +155,5 @@ class ServiceProviderEntry extends Model
if(!$this->attributes['payment_date']){ return ""; }
return Carbon::parse($this->attributes['payment_date'])->format(\Util::formatDateDB());
}
}