#2156 added note field to consume page

This commit is contained in:
me-ssaxena 2024-12-16 17:15:52 +00:00
parent 11ea8f3716
commit 4ed6630907
4 changed files with 20 additions and 4 deletions

View File

@ -315,8 +315,13 @@ class StockApiController extends BaseApiController
$allowSubproductSubstitution = $requestBody['allow_subproduct_substitution']; $allowSubproductSubstitution = $requestBody['allow_subproduct_substitution'];
} }
$note = null;
if (array_key_exists('note', $requestBody)) {
$note = $requestBody['note'];
}
$transactionId = null; $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; $args['transactionId'] = $transactionId;
return $this->StockTransactions($request, $response, $args); return $this->StockTransactions($request, $response, $args);
} }

View File

@ -22,6 +22,7 @@
jsonData.exact_amount = $('#consume-exact-amount').is(':checked'); jsonData.exact_amount = $('#consume-exact-amount').is(':checked');
jsonData.spoiled = $('#spoiled').is(':checked'); jsonData.spoiled = $('#spoiled').is(':checked');
jsonData.allow_subproduct_substitution = true; jsonData.allow_subproduct_substitution = true;
jsonData.note = jsonForm.note;
if ($("#use_specific_stock_entry").is(":checked")) if ($("#use_specific_stock_entry").is(":checked"))
{ {

View File

@ -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)) if (!$this->ProductExists($productId))
{ {
@ -456,7 +456,7 @@ class StockService extends BaseService
'transaction_id' => $transactionId, 'transaction_id' => $transactionId,
'user_id' => GROCY_USER_ID, 'user_id' => GROCY_USER_ID,
'location_id' => $stockEntry->location_id, 'location_id' => $stockEntry->location_id,
'note' => $stockEntry->note 'note' => $note
]); ]);
$logRow->save(); $logRow->save();
@ -491,7 +491,7 @@ class StockService extends BaseService
'transaction_id' => $transactionId, 'transaction_id' => $transactionId,
'user_id' => GROCY_USER_ID, 'user_id' => GROCY_USER_ID,
'location_id' => $stockEntry->location_id, 'location_id' => $stockEntry->location_id,
'note' => $stockEntry->note 'note' => $note
]); ]);
$logRow->save(); $logRow->save();

View File

@ -135,6 +135,16 @@
)) ))
@endif @endif
<div class="form-group">
<label for="note">{{ $__t('Note') }}</label>
<div class="input-group">
<input type="text"
class="form-control"
id="note"
name="note">
</div>
</div>
<button id="save-consume-button" <button id="save-consume-button"
class="btn btn-success">{{ $__t('OK') }}</button> class="btn btn-success">{{ $__t('OK') }}</button>