issue #727
This commit is contained in:
parent
68bb6a6149
commit
12a8a91476
|
|
@ -4,6 +4,7 @@ namespace Webkul\Sales\Repositories;
|
|||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
/**
|
||||
* ShipmentItem Reposotory
|
||||
|
|
@ -31,16 +32,16 @@ class ShipmentItemRepository extends Repository
|
|||
{
|
||||
if (! $data['product'])
|
||||
return;
|
||||
|
||||
|
||||
$orderedInventory = $data['product']->ordered_inventories()
|
||||
->where('channel_id', $data['shipment']->order->channel->id)
|
||||
->first();
|
||||
|
||||
|
||||
if ($orderedInventory) {
|
||||
if (($orderedQty = $orderedInventory->qty - $data['qty']) < 0) {
|
||||
$orderedQty = 0;
|
||||
}
|
||||
|
||||
|
||||
$orderedInventory->update([
|
||||
'qty' => $orderedQty
|
||||
]);
|
||||
|
|
@ -59,7 +60,7 @@ class ShipmentItemRepository extends Repository
|
|||
|
||||
if (!$inventory)
|
||||
return;
|
||||
|
||||
|
||||
if (($qty = $inventory->qty - $data['qty']) < 0) {
|
||||
$qty = 0;
|
||||
}
|
||||
|
|
@ -67,5 +68,7 @@ class ShipmentItemRepository extends Repository
|
|||
$inventory->update([
|
||||
'qty' => $qty
|
||||
]);
|
||||
|
||||
Event::fire('catalog.product.update.after', $data['product']);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue