Fixed GetProductIdFromBarcode returned wrong id & use default qu_factor_purchase_to_stock when not provided when adding products to stock (fixes #1068)

This commit is contained in:
Bernd Bestel
2020-10-18 14:09:54 +02:00
parent f7a1634442
commit ccd2caa44c

View File

@@ -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)