This commit is contained in:
rahul shukla 2019-03-29 10:24:22 +05:30
parent 68bb6a6149
commit 12a8a91476
1 changed files with 7 additions and 4 deletions

View File

@ -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']);
}
}