flatten code

This commit is contained in:
imanghafoori 2019-04-04 23:53:59 +04:30
parent 07806c44fc
commit ca93e36826
1 changed files with 9 additions and 8 deletions

View File

@ -125,14 +125,15 @@ class OrderItemRepository extends Repository
->where('channel_id', $orderItem->order->channel->id)
->first();
if ($orderedInventory) {
if (($qty = $orderedInventory->qty - $orderItem->qty_to_cancel) < 0) {
$qty = 0;
}
$orderedInventory->update([
'qty' => $qty
]);
if (! $orderedInventory)
return ;
if (($qty = $orderedInventory->qty - $orderItem->qty_to_cancel) < 0) {
$qty = 0;
}
$orderedInventory->update([
'qty' => $qty
]);
}
}