This commit is contained in:
Kevin Adametz 2020-05-06 15:52:59 +02:00
parent 68b9d1ff88
commit b9c26d06d0
75 changed files with 2143 additions and 818 deletions

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@ -160,6 +161,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereOriginStartDate($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingFile[] $booking_files
* @property-read int|null $booking_files_count
* @property float|null $price_balance
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking wherePriceBalance($value)
*/
class Booking extends Model
{
@ -236,7 +239,9 @@ class Booking extends Model
'travel_company_id',
'travel_documents',
'price',
'price_canceled',
'price_total',
'price_balance',
'deposit_total',
'final_payment',
'final_payment_date',
@ -317,36 +322,6 @@ class Booking extends Model
2 => 'success',
];
/*
*
* <ul class="tabscontrol flatlist clearfix" id="tabscontrol">
<li class="tab"><a href="#customer" class="active"><?php echo __('Kunde') ?></a></li>
<?php if ($booking->relatedExists('Application')): ?>
<li class="tab"><a href="#application" class="active"><?php echo __('Reiseanmeldung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Confirmation')): ?>
<li class="tab"><a href="#confirmation" class="active"><?php echo __('Reisebestätigung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Invoice')): ?>
<li class="tab"><a href="#invoice" class="active"><?php echo __('Rechnung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Storno')): ?>
<li class="tab"><a href="#storno" class="active"><?php echo __('Storno') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('TravelInsurance')): ?>
<li class="tab"><a href="#travelinsurance" class="active"><?php echo __('Versicherung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('InsuranceCertificate')): ?>
<li class="tab"><a href="#insurance" class="active"><?php echo __('Sicherungsschein') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Voucher')): ?>
<li class="tab"><a href="#voucher" class="active"><?php echo __('Voucher') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Coupon')): ?>
<li class="tab"><a href="#coupon" class="active"><?php echo __('Gutscheine') ?></a></li>
<?php endif; ?>
*/
/*public function branch()
{
@ -535,15 +510,69 @@ class Booking extends Model
public function getPriceAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price']), 2, ',', '.');
return Util::_number_format($this->attributes['price']);
}
public function getPriceRaw()
{
return $this->attributes['price'];
}
public function getPriceCanceledAttribute()
{
return Util::_number_format($this->attributes['price_canceled']);
}
public function getPriceCanceledRaw()
{
return $this->attributes['price_canceled'];
}
public function getPriceTotalAttribute()
{
return Util::_number_format($this->attributes['price_total']);
}
public function getPriceTotalRaw()
{
return $this->attributes['price_total'];
}
public function getCanceledAttribute()
{
return Util::_number_format($this->attributes['canceled']);
}
public function getCanceledRaw()
{
return $this->attributes['canceled'];
}
public function getPriceBalanceAttribute()
{
return Util::_number_format($this->attributes['price_balance']);
}
public function getPriceBalanceRaw()
{
return $this->attributes['price_balance'];
}
public function getDepositTotalAttribute()
{
return Util::_number_format($this->attributes['deposit_total']);
}
public function getDepositTotalRaw()
{
return $this->attributes['deposit_total'];
}
public function getFinalPaymentAttribute()
{
return Util::_number_format($this->attributes['final_payment']);
}
public function getFinalPaymentRaw()
{
return $this->attributes['final_payment'];
}
public function findBeforeDraftItemRelation($reid)
{
$before = false;
@ -585,56 +614,48 @@ class Booking extends Model
return Carbon::parse($this->attributes['booking_date'])->format(\Util::formatDateDB());
}
//erlös #getRevenueFactor
public function proceedsRaw(){
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
$total += $entry->amount / $entry->factor;
}
return $this->attributes['price'] - $total;
public function getFinalPaymentDateFormat(){
if(!$this->attributes['final_payment_date']){ return ""; }
return Carbon::parse($this->attributes['final_payment_date'])->format(\Util::formatDateDB());
}
public function isCanceled(){
return ($this->attributes['canceled'] > 0);
}
//erlös #getRevenueFactor
public function proceeds(){
$proceeds = $this->attributes['price']
// - $this->getServiceTotal()
// - $this->getServiceFee()
- $this->getServiceProviderEntriesAmountFactorTotal();
return number_format(($proceeds), 2, ',', '.');
public function proceeds($raw = false){
$proceeds = $this->attributes['price'] - $this->attributes['price_balance'] - $this->getServiceProviderPaymentsFactorTotal(true);
return $raw ? $proceeds : Util::_number_format($proceeds);
}
public function getServiceProviderEntriesAmountFactorTotal()
public function getServiceTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
foreach ($this->booking_service_items as $booking_service_item){
$total += $booking_service_item->getServicePriceRaw();
}
return $raw ? $total : Util::_number_format($total);
}
public function getServiceProviderPaymentsFactorTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount / $entry->factor;
}
return $total;
return $raw ? $total : Util::_number_format($total);
}
public function getServiceProviderPaymentsTotalRaw()
public function getServiceProviderPaymentsTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount;
}
return $total;
}
public function getServiceProviderPaymentsTotal()
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
$total += $entry->amount;
}
return number_format(($total), 2, ',', '.');
return $raw ? $total : Util::_number_format($total);
}
public function getKontoNumber(){