Merge pull request #474 from jitendra-webkul/jitendra

Inventory issue fix
This commit is contained in:
JItendra Singh 2019-01-18 17:24:25 +05:30 committed by GitHub
commit e7c5c373e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,9 @@ class ShipmentItemRepository extends Repository
*/
public function updateProductInventory($data)
{
if (! $data['product'])
return;
$orderedInventory = $data['product']->ordered_inventories()
->where('channel_id', $data['shipment']->order->channel->id)
->first();
@ -54,6 +57,9 @@ class ShipmentItemRepository extends Repository
->where('inventory_source_id', $data['shipment']->inventory_source_id)
->first();
if (!$inventory)
return;
if (($qty = $inventory->qty - $data['qty']) < 0) {
$qty = 0;
}