public function returnedAll($reason = '', $cost = 0)
{
/*
* Only allow returns when the transaction state is
* sold, reserved, checkout, or returned partial
*/
$this->validatePreviousState([$this::STATE_COMMERCE_SOLD, $this::STATE_COMMERCE_RESERVED, $this::STATE_COMMERCE_CHECKOUT, $this::STATE_COMMERCE_RETURNED_PARTIAL], $this::STATE_COMMERCE_RETURNED);
// Set the state to returned
$this->setAttribute('state', $this::STATE_COMMERCE_RETURNED);
$current = $this->getAttribute('quantity');
/*
* Set the quantity to zero because we are
* returning all of the stock
*/
$this->setAttribute('quantity', 0);
if (empty($reason)) {
$reason = $this->getTransactionReason('returned');
}
return $this->processStockPutAndSave($current, 'inventory.transaction.removed', $reason, $cost);
}