mirror of
https://github.com/grocy/grocy.git
synced 2026-04-04 03:46:16 +02:00
Simplify the transfer to use the existing function (which also adds logs)
This commit is contained in:
parent
277dbc47c0
commit
e2e2cb6d93
|
|
@ -1007,11 +1007,11 @@ class StockService extends BaseService
|
|||
]);
|
||||
$logRow->save();
|
||||
|
||||
$update = [
|
||||
$stockEntry->update([
|
||||
'open' => 1,
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'best_before_date' => $newBestBeforeDate
|
||||
];
|
||||
]);
|
||||
|
||||
$amount -= $stockEntry->amount;
|
||||
}
|
||||
|
|
@ -1048,20 +1048,21 @@ class StockService extends BaseService
|
|||
]);
|
||||
$logRow->save();
|
||||
|
||||
$update = [
|
||||
$stockEntry->update([
|
||||
'amount' => $amount,
|
||||
'open' => 1,
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'best_before_date' => $newBestBeforeDate
|
||||
];
|
||||
]);
|
||||
|
||||
$amount = 0;
|
||||
}
|
||||
if ($product->move_on_open) {
|
||||
$update['location_id'] = $product->default_consume_location_id ?? $stockEntry->location_id;
|
||||
$locationIdTo = $product->default_consume_location_id;
|
||||
if ($locationIdTo) {
|
||||
$this->TransferProduct($stockEntry->product_id, $amount, $stockEntry->location_id, $locationIdTo, $stockEntry->stock_id, $transactionId);
|
||||
}
|
||||
}
|
||||
|
||||
$stockEntry->update($update);
|
||||
}
|
||||
|
||||
return $transactionId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user