mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Use default best before date when adding product through API
This commit is contained in:
@@ -166,6 +166,16 @@ class StockService extends BaseService
|
||||
|
||||
$amount = $amount - $productDetails->stock_amount - $productDetails->product->tare_weight;
|
||||
}
|
||||
|
||||
//Sets the default best before date, if none is supplied
|
||||
if ($bestBeforeDate == null)
|
||||
{
|
||||
if ($productDetails->product->default_best_before_days == -1) {
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
} else {
|
||||
$bestBeforeDate = date('Y-m-d', strtotime(date('Y-m-d') . ' + '.$productDetails->product->default_best_before_days.' days'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($transactionType === self::TRANSACTION_TYPE_PURCHASE || $transactionType === self::TRANSACTION_TYPE_INVENTORY_CORRECTION)
|
||||
{
|
||||
|
Reference in New Issue
Block a user