public function receivedPartial($quantity, $reason = '', $cost = 0)
{
$current = $this->getAttribute('quantity');
if ((double) $quantity === (double) $current || $quantity > $current) {
return $this->receivedAll($reason, $cost);
}
// Only allow the previous state of ordered
$this->validatePreviousState([$this::STATE_ORDERED_PENDING], $this::STATE_ORDERED_RECEIVED_PARTIAL);
// Get the left over amount of quantity still to be received
$left = (double) $current - (double) $quantity;
$this->setAttribute('quantity', $left);
$previousState = $this->getAttribute('state');
$this->setAttribute('state', $this::STATE_ORDERED_RECEIVED_PARTIAL);
if (empty($reason)) {
$reason = $this->getTransactionReason('received-partial');
}
if ($this->processStockPutAndSave($left, 'inventory.transaction.received.partial', $reason, $cost)) {
return $this->returnToPreviousState($previousState);
}
return false;
}