Skip to content

Commit

Permalink
PISHPS-306: cypress fix (#850)
Browse files Browse the repository at this point in the history
* PISHPS-306: cypress fix

* PISHPS-306: cypress fix #2
  • Loading branch information
m-muxfeld-diw authored Oct 1, 2024
1 parent a64d76e commit 6849f72
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/Controller/Api/Order/RefundControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ public function refundOrderID(RequestDataBag $data, Context $context): JsonRespo
try {
$this->creditNoteService->addCreditNoteToOrder($orderId, $refundId, $items, $context);
} catch (CreditNoteException $exception) {
$this->logger->error($exception->getMessage(), ['code' => $exception->getCode(),]);
return $this->buildErrorResponse($exception->getMessage());
if ($exception->getCode() === CreditNoteException::CODE_ADDING_CREDIT_NOTE_LINE_ITEMS) {
$this->logger->error($exception->getMessage(), ['code' => $exception->getCode(),]);
return $this->buildErrorResponse($exception->getMessage());
}
if ($exception->getCode() === CreditNoteException::CODE_WARNING_LEVEL) {
$this->logger->warning($exception->getMessage(), ['code' => $exception->getCode(),]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
</input-field>
<input-field type="bool">
<name>refundManagerCreateCreditNotes</name>
<defaultValue>true</defaultValue>
<defaultValue>false</defaultValue>
<label>Create Credit Notes</label>
<label lang="de-DE">Gutschriften erstellen</label>
<label lang="nl-NL">Creditnota's maken</label>
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Refund/Exceptions/CreditNoteException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ final private function __construct(string $message, int $code)
parent::__construct($message, $code);
}

public static function forAddingLineItems(string $message): CreditNoteException
public static function forAddingLineItems(string $message, int $code = self::CODE_ADDING_CREDIT_NOTE_LINE_ITEMS): CreditNoteException
{
return new self($message, self::CODE_ADDING_CREDIT_NOTE_LINE_ITEMS);
return new self($message, $code);
}

public static function forRemovingLineItems(string $message, int $code = self::CODE_REMOVING_CREDIT_NOTE_LINE_ITEMS): CreditNoteException
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Refund/RefundCreditNoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function addCreditNoteToOrder(string $orderId, string $refundId, array $l
}

if (empty($data['lineItems'])) {
throw CreditNoteException::forAddingLineItems(sprintf('No credit note line items found for order. OrderID: %s RefundID: %s', $orderId, $refundId));
throw CreditNoteException::forAddingLineItems(sprintf('No credit note line items found for order. OrderID: %s RefundID: %s', $orderId, $refundId), CreditNoteException::CODE_WARNING_LEVEL);
}

$this->logger->debug('Adding credit note to order', ['orderId' => $orderId, 'refundId' => $refundId, 'lineItems' => $data['lineItems']]);
Expand Down
2 changes: 1 addition & 1 deletion src/Setting/MollieSettingStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class MollieSettingStruct extends Struct
/**
* @var bool
*/
protected $refundManagerCreateCreditNotesEnabled = true;
protected $refundManagerCreateCreditNotesEnabled = false;

/**
* @var string
Expand Down

0 comments on commit 6849f72

Please sign in to comment.