protected function processStockPutAndSave($quantity, $event = '', $reason = '', $cost = 0)
{
$stock = $this->getStockRecord();
$this->dbStartTransaction();
try {
if ($stock->put(floatval($quantity), $reason, $cost) && $this->save()) {
$this->dbCommitTransaction();
if ($event) {
$this->fireEvent($event, ['transaction' => $this]);
}
return $this;
}
} catch (\Exception $e) {
$this->dbRollbackTransaction();
}
return false;
}