phase 2 dev
This commit is contained in:
parent
5a7478907e
commit
ba48745809
59 changed files with 2692 additions and 1994 deletions
|
|
@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @property int $id
|
||||
* @property Carbon $booking_date
|
||||
* @property int $customer_id
|
||||
* @property int $lead_id
|
||||
* @property int $inquiry_id
|
||||
* @property bool $new_drafts
|
||||
* @property int $sf_guard_user_id
|
||||
* @property int $branch_id
|
||||
|
|
@ -212,7 +212,8 @@ class Booking extends Model
|
|||
|
||||
protected $casts = [
|
||||
'customer_id' => 'int',
|
||||
'lead_id' => 'int',
|
||||
'inquiry_id' => 'int',
|
||||
'offer_id' => 'int',
|
||||
'new_drafts' => 'bool',
|
||||
'sf_guard_user_id' => 'int',
|
||||
'branch_id' => 'int',
|
||||
|
|
@ -256,7 +257,8 @@ class Booking extends Model
|
|||
protected $fillable = [
|
||||
'booking_date',
|
||||
'customer_id',
|
||||
'lead_id',
|
||||
'inquiry_id',
|
||||
'offer_id',
|
||||
'new_drafts',
|
||||
'sf_guard_user_id',
|
||||
'branch_id',
|
||||
|
|
@ -393,9 +395,29 @@ class Booking extends Model
|
|||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lead/Inquiry der Buchung.
|
||||
* FK-Spalte `inquiry_id` (vormals `lead_id` — Modul 3 Phase 2 Rename).
|
||||
* Methodenname bleibt `lead()` für Legacy-Kompatibilität; {@see self::inquiry()}
|
||||
* ist der fachlich korrekte Alias und sollte in neuem Code verwendet werden.
|
||||
*/
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
return $this->belongsTo(Lead::class, 'inquiry_id');
|
||||
}
|
||||
|
||||
public function inquiry()
|
||||
{
|
||||
return $this->belongsTo(Lead::class, 'inquiry_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Angebot, aus dem diese Buchung entstanden ist (Modul 6, Ticket B8).
|
||||
* Nullable — nicht jede Buchung hat einen Angebots-Vorlauf.
|
||||
*/
|
||||
public function offer()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Offer::class);
|
||||
}
|
||||
|
||||
public function sf_guard_user()
|
||||
|
|
@ -765,8 +787,6 @@ class Booking extends Model
|
|||
$total_children += $prices['children'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($travel_draft_item) {
|
||||
$travel_draft_item->setPriceAdultRaw($travel_price_adult);
|
||||
$travel_draft_item->setPriceChildrenRaw($travel_price_children);
|
||||
|
|
@ -775,10 +795,23 @@ class Booking extends Model
|
|||
$travel_draft_item->save();
|
||||
}
|
||||
$this->price = $total_adult + $total_children;
|
||||
$this->price_total = $this->getPriceRaw() + $this->getServiceTotal(true);
|
||||
$this->setPriceTotalForCurrentState();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gesamtpreis Reise (price_total): bei Storno mit gesetztem Storno-Betrag = price_canceled
|
||||
* (wie nach createPDF_Storno in BookingPDFRepository), sonst Reisepreis + Vermittlung.
|
||||
*/
|
||||
public function setPriceTotalForCurrentState(): void
|
||||
{
|
||||
if ($this->isCanceled() && $this->attributes['price_canceled'] !== null) {
|
||||
$this->price_total = round((float) $this->getPriceCanceledRaw(), 2);
|
||||
return;
|
||||
}
|
||||
$this->price_total = round((float) $this->getPriceRaw() + (float) $this->getServiceTotal(true), 2);
|
||||
}
|
||||
|
||||
public function getPriceAttribute()
|
||||
{
|
||||
return Util::_number_format($this->attributes['price']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue