Neustrukturierung Customer / Lead / Booking Phase 2
This commit is contained in:
parent
313f0dbf4e
commit
6df9c401af
69 changed files with 3809 additions and 374 deletions
36
app/Exceptions/Offer/InvalidOfferStatusException.php
Normal file
36
app/Exceptions/Offer/InvalidOfferStatusException.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions\Offer;
|
||||
|
||||
use App\Models\Offer;
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Geworfen, wenn eine Aktion den Offer in einem Status verlangt, in dem er
|
||||
* gerade nicht ist (z. B. accept auf einem Draft, convertToBooking auf nicht-accepted).
|
||||
*/
|
||||
class InvalidOfferStatusException extends DomainException
|
||||
{
|
||||
public readonly int $offerId;
|
||||
public readonly string $currentStatus;
|
||||
/** @var string[] */
|
||||
public readonly array $expectedStatuses;
|
||||
|
||||
/**
|
||||
* @param string[] $expected
|
||||
*/
|
||||
public function __construct(Offer $offer, array $expected, string $action)
|
||||
{
|
||||
$this->offerId = $offer->id;
|
||||
$this->currentStatus = $offer->status;
|
||||
$this->expectedStatuses = $expected;
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'Offer #%d hat status=%s, Aktion „%s" erfordert status ∈ {%s}.',
|
||||
$offer->id,
|
||||
$offer->status,
|
||||
$action,
|
||||
implode(', ', $expected)
|
||||
));
|
||||
}
|
||||
}
|
||||
31
app/Exceptions/Offer/OfferNotEditableException.php
Normal file
31
app/Exceptions/Offer/OfferNotEditableException.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions\Offer;
|
||||
|
||||
use App\Models\OfferVersion;
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Geworfen, wenn eine nicht-Draft-Version verändert werden soll.
|
||||
* Klar abgrenzbarer Typ zu {@see InvalidOfferStatusException}
|
||||
* (dort: Offer.status passt nicht; hier: OfferVersion.status blockiert Edits).
|
||||
*/
|
||||
class OfferNotEditableException extends DomainException
|
||||
{
|
||||
public readonly int $versionId;
|
||||
public readonly string $currentStatus;
|
||||
|
||||
public function __construct(OfferVersion $v, string $attemptedAction = 'ändern')
|
||||
{
|
||||
$this->versionId = $v->id;
|
||||
$this->currentStatus = $v->status;
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'OfferVersion #%d ist nicht mehr editierbar (status=%s). '
|
||||
. 'Aktion „%s" erfordert eine Draft-Version — nutze createNewVersion() / supersede().',
|
||||
$v->id,
|
||||
$v->status,
|
||||
$attemptedAction
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue