FeWo Mail, Booking Services
This commit is contained in:
parent
730832c8e1
commit
e6cc042aee
62 changed files with 1766 additions and 284 deletions
|
|
@ -163,6 +163,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property-read int|null $booking_files_count
|
||||
* @property float|null $price_balance
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking wherePriceBalance($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingCountryService[] $booking_country_services
|
||||
* @property-read int|null $booking_country_services_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingCountryService[] $booking_country_services_checked
|
||||
* @property-read int|null $booking_country_services_checked_count
|
||||
*/
|
||||
class Booking extends Model
|
||||
{
|
||||
|
|
@ -484,12 +488,45 @@ class Booking extends Model
|
|||
return $this->hasMany(BookingCountryService::class, 'booking_id')->where('status', '=', 0);
|
||||
}
|
||||
|
||||
public function hasBookingCountryServicesUnchecked(){
|
||||
public function booking_company_services()
|
||||
{
|
||||
return $this->hasMany(BookingCompanyService::class, 'booking_id');
|
||||
}
|
||||
public function booking_company_services_checked()
|
||||
{
|
||||
return $this->hasMany(BookingCompanyService::class, 'booking_id')->where('status', '=', 0);
|
||||
}
|
||||
|
||||
public function booking_provider_services()
|
||||
{
|
||||
return $this->hasMany(BookingProviderService::class, 'booking_id');
|
||||
}
|
||||
public function booking_provider_services_checked()
|
||||
{
|
||||
return $this->hasMany(BookingProviderService::class, 'booking_id')->where('status', '=', 0);
|
||||
}
|
||||
|
||||
public function hasBookingServicesUnchecked(){
|
||||
$country_services = true;
|
||||
$provider_services = true;
|
||||
$company_services = true;
|
||||
if(!$this->booking_country_services->count() || $this->booking_country_services_checked->count() ||
|
||||
($this->booking_country_services->count() !== TravelCountryService::where('crm_travel_country_id', '=', $this->travel_country_id)->count())){
|
||||
return false;
|
||||
$country_services = false;
|
||||
}
|
||||
return true;
|
||||
|
||||
if(!$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()){
|
||||
$provider_services = false;
|
||||
}
|
||||
|
||||
if(!$this->booking_company_services->count() || $this->booking_company_services_checked->count()){
|
||||
$company_services = false;
|
||||
}
|
||||
|
||||
if($country_services && $provider_services && $provider_services){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function calculate_price_total()
|
||||
|
|
@ -662,7 +699,7 @@ class Booking extends Model
|
|||
{
|
||||
$total = 0;
|
||||
foreach ($this->service_provider_entries as $entry){
|
||||
$total += $entry->amount / $entry->factor;
|
||||
$total += $entry->getAmountRaw() / $entry->factor;
|
||||
}
|
||||
return $raw ? $total : Util::_number_format($total);
|
||||
}
|
||||
|
|
@ -671,7 +708,7 @@ class Booking extends Model
|
|||
{
|
||||
$total = 0;
|
||||
foreach ($this->service_provider_entries as $entry){
|
||||
$total += $entry->amount;
|
||||
$total += $entry->getAmountRaw();
|
||||
}
|
||||
return $raw ? $total : Util::_number_format($total);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue