More Fixes
This commit is contained in:
parent
cbc8f85cc0
commit
5e5493ff82
3 changed files with 14 additions and 31 deletions
|
|
@ -72,3 +72,6 @@ php artisan cashier:webhook
|
|||
|
||||
# TODO
|
||||
- Allow changing e-mail quand ca sera supporté sur CRM (use soundsystem mechanism)
|
||||
|
||||
# FIXME
|
||||
Envoi d’un mail de remboursement avec l’avoir en pièce jointe : l’avoir est vide
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class SystempayCreditTransactionUpdate
|
|||
return ResponseType::expiredPayment();
|
||||
case \in_array($transStatus, ['SUSPENDED']):
|
||||
return ResponseType::suspendedPayment();
|
||||
case $this->isCancelledPayment($transStatus) or
|
||||
case $this->isCanceledPayment($transStatus) or
|
||||
\in_array($transStatus, ['CANCELLED']):
|
||||
return ResponseType::canceledPayment();
|
||||
case $this->isPendingPayment($transStatus):
|
||||
|
|
@ -165,7 +165,7 @@ class SystempayCreditTransactionUpdate
|
|||
* @param string $transStatus
|
||||
* @return boolean
|
||||
*/
|
||||
private function isCancelledPayment(string $transStatus): bool
|
||||
private function isCanceledPayment(string $transStatus): bool
|
||||
{
|
||||
$canceled_statuses = [
|
||||
'NOT_CREATED',
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ class Order extends Model
|
|||
static::updating(function (self $model) {
|
||||
static::assertValidateStatus($model);
|
||||
static::assertCancelStatus($model);
|
||||
static::assertDeliveryStatusCanBeChanged($model);
|
||||
|
||||
if ($model->validation_status->equals(ValidationStatus::validated())) {
|
||||
OrderIsValidated::dispatchUnless($model->mail_sent, $model);
|
||||
|
|
@ -285,12 +284,15 @@ class Order extends Model
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getCanBeCancelledAttribute(): bool
|
||||
public function getCanBeCanceledAttribute(): bool
|
||||
{
|
||||
// * Si le status de validation n'est pas annulé
|
||||
return $this->getOriginal('validation_status') !== ValidationStatus::canceled()->value &&
|
||||
// * Si le statut de livraison n'est pas récupéré
|
||||
$this->getOriginal('delivery_status') !== DeliveryStatus::recovered()->value;
|
||||
!\in_array($this->getOriginal('delivery_status'), [
|
||||
DeliveryStatus::recovered()->value,
|
||||
DeliveryStatus::canceled()->value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -304,7 +306,10 @@ class Order extends Model
|
|||
public function getCanBeRefundAttribute(): bool
|
||||
{
|
||||
return $this->total_ttc > $this->total_refund and
|
||||
!$this->delivery_status->equals(DeliveryStatus::recovered());
|
||||
!\in_array($this->getOriginal('delivery_status'), [
|
||||
DeliveryStatus::recovered()->value,
|
||||
DeliveryStatus::canceled()->value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -581,31 +586,6 @@ class Order extends Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if delivery status can be changed.
|
||||
*
|
||||
* @param self $model
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException If the order is canceled while it cannot be.
|
||||
*/
|
||||
public static function assertDeliveryStatusCanBeChanged(self $model)
|
||||
{
|
||||
$deliveryStatusHasChanged = $model->getOriginal('delivery_status') !== $model->delivery_status->value;
|
||||
if ($deliveryStatusHasChanged and !$model->validation_status->equals(ValidationStatus::validated())) {
|
||||
throw ValidationException::withMessages([
|
||||
'messages' =>
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
"L'état de livraison de la commande ne peut être modifié car la commande '{$model->id}' n'est pas validée"
|
||||
]);
|
||||
}
|
||||
if ($model->getOriginal('validation_status') === ValidationStatus::canceled()->value) {
|
||||
throw ValidationException::withMessages([
|
||||
'messages' =>
|
||||
"L'état de livraison de la commande ne peut être modifié car la commande '{$model->id}' est annulée"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get updated current session order
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue