Feature: #918 - Create cancellations and returns and change their status
See Issue 918
Description
Cancellations and returns (see Feature: #916 - Cancellations and returns with lines)
are created and changed by services in
\Extcode\, like shipments (see
Feature: #905 - Create shipments and derive the shipping status). The backend UI and
the restocking follow separately.
Order stores a cancellation or a return
with its products in one database transaction. The order is locked while the
quantities are checked:
- Only products of the order with a count greater than 0 can be added, a
cancellation or a return can not be created as
rejected. Otherwise an\Invalidis thrown.Argument Exception - A cancellation must not exceed the ordered count minus the counts in shipments which are not canceled and in cancellations which are not rejected.
- A return must not exceed the shipped count minus the counts in returns which are not rejected.
- If a count is exceeded, nothing is stored and the outcome is
Order.Return Creation Outcome:: Quantity Exceeded - The creation is written to the order history with the type
cancellation_orstatus return_, the subjectstatus return:<uid>and the products and counts as data.
Listeners of the new event
\Extcode\ can prevent the
creation with veto. EXT:cart vetoes products which are not cancelable
or not returnable. If the request comes from the backend and the
cancellation or return has an override reason, it is created anyway; the veto
reason and the override reason are written to the order history. A frontend
or API request never overrides a veto
(Order). Listeners of the new event
\Extcode\ react to the
creation.
Order changes the status of a
cancellation or a return atomically, with the new events
Before (with veto) and
After. accepted and rejected are
final, a change from them is Status. A return
gets the received date when it becomes received without one.
Order contain per ordered product the counts in
cancellations and returns which are not rejected, the canceled count
(accepted cancellations) and the returned count (accepted returns), and
whether the product is cancelable and returnable. Cancellations which are
not rejected reduce the count available for a shipment.
After a cancellation is created or its status is changed, the shipping status of the order is derived again:
canceled: all ordered quantities of shippable products are canceled.shipped: all quantities of shippable products which are not canceled are shipped.
Returns do not change the shipping status of the order.
The order history in the order details of the backend module shows the details of a change in a new column: the shipment, cancellation or return it belongs to, the products and counts, the reason of a return and the veto and override reasons.
Impact
Without the feature toggle cart. nothing changes for
existing shops.
Order needs the Order as
new constructor argument.