From ccd2caa44c7266a0686e213511112920a620b517 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 18 Oct 2020 14:09:54 +0200 Subject: [PATCH] Fixed GetProductIdFromBarcode returned wrong id & use default qu_factor_purchase_to_stock when not provided when adding products to stock (fixes #1068) --- services/StockService.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/StockService.php b/services/StockService.php index b5a0ea49..6093b93d 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -86,11 +86,16 @@ class StockService extends BaseService throw new \Exception('Product does not exist or is inactive'); } - // Tare weight handling + $productDetails = (object) $this->GetProductDetails($productId); + if ($quFactorPurchaseToStock == null) + { + $quFactorPurchaseToStock = $productDetails->product->qu_factor_purchase_to_stock; + } + + // Tare weight handling // The given amount is the new total amount including the container weight (gross) // The amount to be posted needs to be the given amount - stock amount - tare weight - $productDetails = (object) $this->GetProductDetails($productId); if ($productDetails->product->enable_tare_weight_handling == 1) { @@ -230,7 +235,7 @@ class StockService extends BaseService if ($productDetails->product->enable_tare_weight_handling == 1) { - if($consumeExactAmount) + if ($consumeExactAmount) { $amount = floatval($productDetails->stock_amount) + floatval($productDetails->product->tare_weight) - $amount; } @@ -604,7 +609,7 @@ class StockService extends BaseService throw new \Exception("No product with barcode $barcode found"); } - return intval($potentialProduct->id); + return intval($potentialProduct->product_id); } public function GetProductPriceHistory(int $productId)