Original Problem
The According to MODORDERS-106 description the last step in receiving/check-in flow is to update the status of PO Line line to "Partially Received" or "Fully Received". It's possible that something may go wrong and status won't be updated even though the items were actually received. So the mechanism to guarantee the status is up-to-date needs to be worked out.
From the technical side, this means that there may be a discrepancy between the status of the PO line and the statuses of its associated Pieces in the database. The following relationships connections are possible between POLine PO line with PARTIALLY_RECEIVED and FULLY_RECEIVED statuses and state of pieces:
- there are pieces related to PO line that are in the RECEIVED and EXPECTED statuses - the PO line must be in the PARTIALLY_RECEIVED status;
- all pieces are in RECEIVED status - the PO line must be in FULLY_RECEIVED status.
Thus, the task is to create a mechanism that would allow changing the status of the PO line when the status of its associated pieces changes.
...