01 2020
This commit is contained in:
parent
bed91c4f4a
commit
c8948338bb
122 changed files with 7911 additions and 1639 deletions
|
|
@ -1,53 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Reliese\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Booking
|
||||
* Class Booking
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $booking_date
|
||||
* @property Carbon $booking_date
|
||||
* @property int $customer_id
|
||||
* @property int|null $lead_id
|
||||
* @property int|null $new_drafts
|
||||
* @property int $lead_id
|
||||
* @property bool $new_drafts
|
||||
* @property int $sf_guard_user_id
|
||||
* @property int $branch_id
|
||||
* @property float|null $service_fee
|
||||
* @property int|null $travel_country_id
|
||||
* @property int|null $travel_category_id
|
||||
* @property int|null $pax
|
||||
* @property int|null $coupon_id
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
* @property string|null $title
|
||||
* @property string|null $start_date
|
||||
* @property string|null $end_date
|
||||
* @property int|null $website_id
|
||||
* @property string|null $travel_number
|
||||
* @property string|null $participant_name
|
||||
* @property string|null $participant_firstname
|
||||
* @property string|null $participant_birthdate
|
||||
* @property int|null $participant_salutation_id
|
||||
* @property string|null $ev_number
|
||||
* @property string|null $merlin_knr
|
||||
* @property string|null $merlin_order_number
|
||||
* @property int|null $travel_company_id
|
||||
* @property int|null $travel_documents
|
||||
* @property float|null $price
|
||||
* @property float|null $price_total
|
||||
* @property float|null $deposit_total
|
||||
* @property float|null $final_payment
|
||||
* @property string|null $final_payment_date
|
||||
* @property int|null $travelagenda_id
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Sym\Arrangement[] $arrangements
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingDraftItem[] $booking_draft_items
|
||||
* @property-read \App\Models\TravelCountry|null $lead
|
||||
* @property-read \App\Models\SfGuardUser $sf_guard_user
|
||||
* @property-read \App\Models\TravelAgenda|null $travel_agenda
|
||||
* @property-read \App\Models\TravelCountry|null $travel_country
|
||||
* @property float $service_fee
|
||||
* @property int $travel_country_id
|
||||
* @property int $travel_category_id
|
||||
* @property int $pax
|
||||
* @property int $coupon_id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property string $title
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon $end_date
|
||||
* @property int $website_id
|
||||
* @property string $travel_number
|
||||
* @property string $participant_name
|
||||
* @property string $participant_firstname
|
||||
* @property Carbon $participant_birthdate
|
||||
* @property int $participant_salutation_id
|
||||
* @property string $ev_number
|
||||
* @property string $merlin_knr
|
||||
* @property string $merlin_order_number
|
||||
* @property int $travel_company_id
|
||||
* @property bool $travel_documents
|
||||
* @property float $price
|
||||
* @property float $price_total
|
||||
* @property float $deposit_total
|
||||
* @property float $final_payment
|
||||
* @property Carbon $final_payment_date
|
||||
* @property int $travelagenda_id
|
||||
* @property Branch $branch
|
||||
* @property Coupon $coupon
|
||||
* @property Customer $customer
|
||||
* @property Lead $lead
|
||||
* @property SfGuardUser $sf_guard_user
|
||||
* @property TravelCategory $travel_category
|
||||
* @property TravelCompany $travel_company
|
||||
* @property TravelCountry $travel_country
|
||||
* @property TravelAgenda $travel_agenda
|
||||
* @property Collection|Arrangement[] $arrangements
|
||||
* @property Collection|ArrangementType[] $arrangement_types
|
||||
* @property Collection|BookingApplication[] $booking_applications
|
||||
* @property Collection|BookingConfirmation[] $booking_confirmations
|
||||
* @property Collection|BookingDraftItem[] $booking_draft_items
|
||||
* @property Collection|BookingInvoice[] $booking_invoices
|
||||
* @property Collection|BookingServiceItem[] $booking_service_items
|
||||
* @property Collection|BookingVoucher[] $booking_vouchers
|
||||
* @property Collection|Coupon[] $coupons
|
||||
* @property Collection|InsuranceCertificate[] $insurance_certificates
|
||||
* @property Collection|Participant[] $participants
|
||||
* @property Collection|ServiceProviderEntry[] $service_provider_entries
|
||||
* @property Collection|TravelInsurance[] $travel_insurances
|
||||
* @package App\Models
|
||||
* @property-read int|null $arrangement_types_count
|
||||
* @property-read int|null $arrangements_count
|
||||
* @property-read int|null $booking_draft_items_count
|
||||
* @property-read int|null $booking_service_items_count
|
||||
* @property-read int|null $coupons_count
|
||||
* @property-read int|null $insurance_certificates_count
|
||||
* @property-read int|null $participants_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereBookingDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereBranchId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereCouponId($value)
|
||||
|
|
@ -83,11 +115,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereWebsiteId($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking query()
|
||||
* @property-read int|null $arrangements_count
|
||||
* @property-read int|null $booking_draft_items_count
|
||||
* @property-read int|null $service_provider_entries_count
|
||||
*/
|
||||
class Booking extends Model
|
||||
{
|
||||
|
|
@ -95,40 +123,185 @@ class Booking extends Model
|
|||
|
||||
protected $table = 'booking';
|
||||
|
||||
/*protected $fillable = [
|
||||
'pos',
|
||||
];*/
|
||||
protected $casts = [
|
||||
'customer_id' => 'int',
|
||||
'lead_id' => 'int',
|
||||
'new_drafts' => 'bool',
|
||||
'sf_guard_user_id' => 'int',
|
||||
'branch_id' => 'int',
|
||||
'service_fee' => 'float',
|
||||
'travel_country_id' => 'int',
|
||||
'travel_category_id' => 'int',
|
||||
'pax' => 'int',
|
||||
'coupon_id' => 'int',
|
||||
'website_id' => 'int',
|
||||
'participant_salutation_id' => 'int',
|
||||
'travel_company_id' => 'int',
|
||||
'travel_documents' => 'bool',
|
||||
'price' => 'float',
|
||||
'price_total' => 'float',
|
||||
'deposit_total' => 'float',
|
||||
'final_payment' => 'float',
|
||||
'travelagenda_id' => 'int'
|
||||
];
|
||||
|
||||
public function booking_draft_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\BookingDraftItem', 'booking_id', 'id')->orderBy('pos', 'ASC');
|
||||
}
|
||||
protected $dates = [
|
||||
'booking_date',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'participant_birthdate',
|
||||
'final_payment_date'
|
||||
];
|
||||
|
||||
//on crm
|
||||
public function travel_agenda()
|
||||
protected $fillable = [
|
||||
'booking_date',
|
||||
'customer_id',
|
||||
'lead_id',
|
||||
'new_drafts',
|
||||
'sf_guard_user_id',
|
||||
'branch_id',
|
||||
'service_fee',
|
||||
'travel_country_id',
|
||||
'travel_category_id',
|
||||
'pax',
|
||||
'coupon_id',
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'website_id',
|
||||
'travel_number',
|
||||
'participant_name',
|
||||
'participant_firstname',
|
||||
'participant_birthdate',
|
||||
'participant_salutation_id',
|
||||
'ev_number',
|
||||
'merlin_knr',
|
||||
'merlin_order_number',
|
||||
'travel_company_id',
|
||||
'travel_documents',
|
||||
'price',
|
||||
'price_total',
|
||||
'deposit_total',
|
||||
'final_payment',
|
||||
'final_payment_date',
|
||||
'travelagenda_id'
|
||||
];
|
||||
|
||||
/*public function branch()
|
||||
{
|
||||
return $this->belongsTo(Branch::class);
|
||||
}*/
|
||||
|
||||
public function coupon()
|
||||
{
|
||||
return $this->belongsTo(Coupon::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function sf_guard_user()
|
||||
{
|
||||
return $this->belongsTo(SfGuardUser::class);
|
||||
}
|
||||
|
||||
public function travel_category()
|
||||
{
|
||||
return $this->belongsTo(TravelCategory::class);
|
||||
}
|
||||
|
||||
public function travel_company()
|
||||
{
|
||||
return $this->belongsTo(TravelCompany::class);
|
||||
}
|
||||
|
||||
/* public function travel_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\TravelAgenda', 'travelagenda_id', 'id');
|
||||
}
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id', 'crm_id');
|
||||
}*/
|
||||
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\TravelCountry', 'travel_country_id', 'crm_id');
|
||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Lead', 'lead_id', 'id');
|
||||
}
|
||||
public function travel_agenda()
|
||||
{
|
||||
return $this->belongsTo(TravelAgenda::class, 'travelagenda_id');
|
||||
}
|
||||
|
||||
public function sf_guard_user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\SfGuardUser', 'sf_guard_user_id', 'id');
|
||||
}
|
||||
public function arrangements()
|
||||
{
|
||||
return $this->hasMany(Arrangement::class);
|
||||
}
|
||||
|
||||
public function arrangements()
|
||||
{
|
||||
return $this->hasMany('App\Models\Sym\Arrangement', 'booking_id', 'id')->orderBy('view_position', 'DESC');
|
||||
}
|
||||
public function arrangement_types()
|
||||
{
|
||||
return $this->hasMany(ArrangementType::class);
|
||||
}
|
||||
|
||||
/*public function booking_applications()
|
||||
{
|
||||
return $this->hasMany(BookingApplication::class);
|
||||
}
|
||||
|
||||
public function booking_confirmations()
|
||||
{
|
||||
return $this->hasMany(BookingConfirmation::class);
|
||||
}*/
|
||||
|
||||
public function booking_draft_items()
|
||||
{
|
||||
return $this->hasMany(BookingDraftItem::class)->orderBy('pos', 'ASC');
|
||||
}
|
||||
|
||||
/*public function booking_invoices()
|
||||
{
|
||||
return $this->hasMany(BookingInvoice::class);
|
||||
}*/
|
||||
|
||||
public function booking_service_items()
|
||||
{
|
||||
return $this->hasMany(BookingServiceItem::class);
|
||||
}
|
||||
|
||||
/*public function booking_vouchers()
|
||||
{
|
||||
return $this->hasMany(BookingVoucher::class);
|
||||
}*/
|
||||
|
||||
public function coupons()
|
||||
{
|
||||
return $this->hasMany(Coupon::class);
|
||||
}
|
||||
|
||||
public function insurance_certificates()
|
||||
{
|
||||
return $this->hasMany(InsuranceCertificate::class);
|
||||
}
|
||||
|
||||
public function participants()
|
||||
{
|
||||
return $this->hasMany(Participant::class);
|
||||
}
|
||||
|
||||
public function service_provider_entries()
|
||||
{
|
||||
return $this->hasMany(ServiceProviderEntry::class);
|
||||
}
|
||||
/*
|
||||
public function travel_insurances()
|
||||
{
|
||||
return $this->hasMany(TravelInsurance::class);
|
||||
}*/
|
||||
|
||||
|
||||
public function calculate_price_total()
|
||||
|
|
@ -152,7 +325,7 @@ class Booking extends Model
|
|||
}
|
||||
$total_adult += $prices['adult'];
|
||||
$total_children += $prices['children'];
|
||||
}
|
||||
}
|
||||
|
||||
if($travel_draft_item){
|
||||
$travel_draft_item->setPriceAdultRaw($travel_price_adult);
|
||||
|
|
@ -171,6 +344,11 @@ class Booking extends Model
|
|||
return number_format(($this->attributes['price']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceRaw()
|
||||
{
|
||||
return $this->attributes['price'];
|
||||
}
|
||||
|
||||
public function findBeforeDraftItemRelation($reid)
|
||||
{
|
||||
$before = false;
|
||||
|
|
@ -207,4 +385,56 @@ class Booking extends Model
|
|||
return Carbon::parse($this->attributes['end_date'])->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
|
||||
//erlös #getRevenueFactor
|
||||
public function proceeds(){
|
||||
$proceeds = $this->attributes['price']
|
||||
// - $this->getServiceTotal()
|
||||
// - $this->getServiceFee()
|
||||
- $this->getServiceProviderEntriesAmountFactorTotal();
|
||||
|
||||
return number_format(($proceeds), 2, ',', '.');
|
||||
|
||||
}
|
||||
|
||||
public function getServiceProviderEntriesAmountFactorTotal()
|
||||
{
|
||||
$total = 0;
|
||||
foreach ($this->service_provider_entries as $entry)
|
||||
{
|
||||
$total += $entry->amount / $entry->factor;
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getServiceProviderPaymentsTotal()
|
||||
{
|
||||
$total = 0;
|
||||
foreach ($this->service_provider_entries as $entry)
|
||||
{
|
||||
$total += $entry->amount;
|
||||
}
|
||||
return number_format(($total), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getKontoNumber(){
|
||||
|
||||
switch ($this->ev_number){
|
||||
case 'E01':
|
||||
return '4011';
|
||||
break;
|
||||
case 'E02':
|
||||
return '4012';
|
||||
break;
|
||||
case 'E03':
|
||||
return '4013';
|
||||
break;
|
||||
case 'E04':
|
||||
return '4014';
|
||||
break;
|
||||
|
||||
}
|
||||
return $this->ev_number;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue