diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php index 27fd5b26..04e132db 100644 --- a/controllers/StockApiController.php +++ b/controllers/StockApiController.php @@ -315,8 +315,13 @@ class StockApiController extends BaseApiController $allowSubproductSubstitution = $requestBody['allow_subproduct_substitution']; } + $note = null; + if (array_key_exists('note', $requestBody)) { + $note = $requestBody['note']; + } + $transactionId = null; - $transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact); + $transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact, $note); $args['transactionId'] = $transactionId; return $this->StockTransactions($request, $response, $args); } diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 8cc9b022..85ca2637 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -22,6 +22,7 @@ jsonData.exact_amount = $('#consume-exact-amount').is(':checked'); jsonData.spoiled = $('#spoiled').is(':checked'); jsonData.allow_subproduct_substitution = true; + jsonData.note = jsonForm.note; if ($("#use_specific_stock_entry").is(":checked")) { diff --git a/services/StockService.php b/services/StockService.php index 56b42b49..eeb02bdb 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -355,7 +355,7 @@ class StockService extends BaseService } } - public function ConsumeProduct(int $productId, float $amount, bool $spoiled, $transactionType, $specificStockEntryId = 'default', $recipeId = null, $locationId = null, &$transactionId = null, $allowSubproductSubstitution = false, $consumeExactAmount = false) + public function ConsumeProduct(int $productId, float $amount, bool $spoiled, $transactionType, $specificStockEntryId = 'default', $recipeId = null, $locationId = null, &$transactionId = null, $allowSubproductSubstitution = false, $consumeExactAmount = false, $note = null) { if (!$this->ProductExists($productId)) { @@ -456,7 +456,7 @@ class StockService extends BaseService 'transaction_id' => $transactionId, 'user_id' => GROCY_USER_ID, 'location_id' => $stockEntry->location_id, - 'note' => $stockEntry->note + 'note' => $note ]); $logRow->save(); @@ -491,7 +491,7 @@ class StockService extends BaseService 'transaction_id' => $transactionId, 'user_id' => GROCY_USER_ID, 'location_id' => $stockEntry->location_id, - 'note' => $stockEntry->note + 'note' => $note ]); $logRow->save(); diff --git a/views/consume.blade.php b/views/consume.blade.php index f2bba01f..58bbd070 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -135,6 +135,16 @@ )) @endif +