added to api #90
This commit is contained in:
parent
9a5a460848
commit
e59e0e3aab
@ -68,6 +68,10 @@ class Bills extends ApiController
|
||||
$item_id = $item['item_id'];
|
||||
|
||||
$item_sku = $item_object->sku;
|
||||
|
||||
// Increase stock (item bought)
|
||||
$item_object->quantity++;
|
||||
$item_object->save();
|
||||
} elseif (!empty($item['sku'])) {
|
||||
$item_sku = $item['sku'];
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use App\Models\Income\InvoicePayment;
|
||||
use App\Models\Income\InvoiceTotal;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Notifications\Item\Item as ItemNotification;
|
||||
use App\Transformers\Income\Invoice as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
@ -76,6 +77,21 @@ class Invoices extends ApiController
|
||||
$item_id = $item['item_id'];
|
||||
|
||||
$item_sku = $item_object->sku;
|
||||
|
||||
// Decrease stock (item sold)
|
||||
$item_object->quantity--;
|
||||
$item_object->save();
|
||||
|
||||
// Notify users if out of stock
|
||||
if ($item_object->quantity == 0) {
|
||||
foreach ($item_object->company->users as $user) {
|
||||
if (!$user->can('read-notifications')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user->notify(new ItemNotification($item_object));
|
||||
}
|
||||
}
|
||||
} elseif (!empty($item['sku'])) {
|
||||
$item_sku = $item['sku'];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user