Feature: #905 - Create shipments and derive the shipping status
See Issue 905
Description
Shipments (see Feature: #902 - Shipments with lines) are created and changed by
services in \Extcode\. There is no backend UI
yet, it follows in a later version.
Shipment stores a shipment with its products in
one database transaction. The order is locked while the quantities are
checked, so concurrent requests cannot ship more than ordered:
- Only shippable products of the order with a count greater than 0 can be
added, otherwise an
\Invalidis thrown.Argument Exception - The counts of all shipments which are not canceled must not exceed the
ordered count, otherwise nothing is stored and the outcome is
Shipment.Creation Outcome:: Quantity Exceeded - The creation is written to the order history with the type
shipment_, the subjectstatus shipment:<uid>and the products and counts as data.
Shipment changes the status of a shipment
atomically like the Status does for payment and shipping. A
shipment can only be canceled before it is shipped, a canceled shipment does
not change anymore (Status). Listeners of the new
events \Extcode\ (with
veto) and \Extcode\ react to
a change.
Order returns the
Order of an order: per ordered product the ordered count,
the count in shipments which are not canceled, the shipped count (shipments
with the status shipped or delivered) and the count which is still
available for a shipment.
After a shipment is created or its status is changed, the shipping status of
the order is derived from the shipments and changed via the
Status, so it is written to the order history and the events
and status mails work like for a manual change:
partially_: some quantities are shipped, some are open.shipped shipped: all ordered quantities of shippable products are shipped.- Nothing is shipped (anymore):
open,on_andhold in_stay as set manually; a derivedprocess partially_orshipped shippedfalls back toin_.process
With the feature toggle cart. enabled, an order without
shippable products gets the shipping status not_ when it is
persisted.
Impact
Without the feature toggle nothing changes for existing shops.
\Extcode\ has the new case
Not. Code that matches all cases of the enum has to handle it.