Fixes/changes for pull request #349

This commit is contained in:
Bernd Bestel 2019-08-31 14:08:15 +02:00
parent 6ec3872518
commit a4454f825a
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 23 additions and 17 deletions

View File

@ -10,6 +10,7 @@
- Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31)
- Userfields of type "checkbox" are rendered as a checkmark in tables when checked (instead of "1" as till now)
- API improvements
- New endpoint `/stock/shoppinglist/add-product` to add a product to a shopping list (thanks @Forceu)
- New endpoint `/stock/shoppinglist/remove-product` to remove a product from a shopping list (thanks @Forceu)
- When adding a product (through `stock/product/{productId}/add` or `stock/product/{productId}/inventory`) with omitted best before date and if the given product has "Default best before days" set, the best before date is calculated based on that (so far always today was used which is still the case when no date is supplied and also the product has no "Default best before days set) (thanks @Forceu)
- Field `stock_amount` of endpoint `/stock/products/{productId}´ now returns `0` instead of `null` when the given product is not in stock (thanks @Forceu)

View File

@ -556,7 +556,12 @@ class StockService extends BaseService
throw new \Exception('Shopping list does not exist');
}
$alreadyExistingEntry = $this->Database->shopping_list()->where('product_id', $productId->id)->fetch();
if (!$this->ProductExists($productId))
{
throw new \Exception('Product does not exist');
}
$alreadyExistingEntry = $this->Database->shopping_list()->where('product_id = :1 AND shopping_list_id = :2', $productId, $listId)->fetch();
if ($alreadyExistingEntry) // Update
{
$alreadyExistingEntry->update(array(