mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 21:06:15 +02:00
Stockjournal: Add "Done by"
This commit is contained in:
parent
836bcc82e5
commit
abd2590979
|
|
@ -33,10 +33,8 @@ class StockController extends BaseController
|
|||
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->renderPage($response, 'stockjournal', [
|
||||
'stockLog' => $this->getDatabase()->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'stockLog' => $this->getDatabase()->uihelper_stock_journal()->orderBy('row_created_timestamp', 'DESC'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
74
migrations/0115.sql
Normal file
74
migrations/0115.sql
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
ALTER TABLE stock_log
|
||||
RENAME TO stock_log_old;
|
||||
|
||||
CREATE TABLE stock_log(
|
||||
id INTEGER not null primary key autoincrement unique,
|
||||
product_id INTEGER not null,
|
||||
amount DECIMAL(15, 2) not null,
|
||||
best_before_date DATE,
|
||||
purchased_date DATE,
|
||||
used_date DATE,
|
||||
spoiled INTEGER default 0 not null,
|
||||
stock_id TEXT not null,
|
||||
transaction_type TEXT not null,
|
||||
price DECIMAL(15, 2),
|
||||
undone TINYINT default 0 not null CHECK(undone IN (0, 1)),
|
||||
undone_timestamp DATETIME,
|
||||
opened_date DATETIME,
|
||||
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
location_id INTEGER,
|
||||
recipe_id INTEGER,
|
||||
correlation_id TEXT,
|
||||
transaction_id TEXT,
|
||||
stock_row_id INTEGER,
|
||||
shopping_location_id INTEGER,
|
||||
qu_factor_purchase_to_stock REAL default 1.0 not null,
|
||||
user_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO stock_log
|
||||
(product_id, amount, best_before_date, purchased_date, used_date, spoiled, stock_id, transaction_type, price, undone,
|
||||
undone_timestamp, opened_date, row_created_timestamp, user_id)
|
||||
SELECT product_id,
|
||||
amount,
|
||||
best_before_date,
|
||||
purchased_date,
|
||||
used_date,
|
||||
spoiled,
|
||||
stock_id,
|
||||
transaction_type,
|
||||
price,
|
||||
undone,
|
||||
undone_timestamp,
|
||||
opened_date,
|
||||
row_created_timestamp,
|
||||
(SELECT id FROM users WHERE username = 'admin')
|
||||
FROM stock_log_old;
|
||||
|
||||
DROP TABLE stock_log_old;
|
||||
|
||||
|
||||
CREATE VIEW uihelper_stock_journal
|
||||
AS
|
||||
SELECT stock_log.id,
|
||||
stock_log.row_created_timestamp,
|
||||
stock_log.correlation_id,
|
||||
stock_log.undone,
|
||||
stock_log.undone_timestamp,
|
||||
stock_log.row_created_timestamp,
|
||||
stock_log.transaction_type,
|
||||
stock_log.spoiled,
|
||||
stock_log.amount,
|
||||
stock_log.location_id,
|
||||
l.name AS location_name,
|
||||
p.name AS product_name,
|
||||
qu.name AS qu_name,
|
||||
qu.name_plural AS qu_name_plural,
|
||||
u.display_name AS user_display_name
|
||||
|
||||
FROM stock_log
|
||||
JOIN users_dto u on stock_log.user_id = u.id
|
||||
JOIN products p on stock_log.product_id = p.id
|
||||
JOIN locations l on p.location_id = l.id
|
||||
JOIN quantity_units qu ON p.qu_id_stock = qu.id;
|
||||
|
|
@ -112,7 +112,8 @@ class StockService extends BaseService
|
|||
'location_id' => $locationId,
|
||||
'transaction_id' => $transactionId,
|
||||
'shopping_location_id' => $shoppingLocationId,
|
||||
'qu_factor_purchase_to_stock' => $quFactorPurchaseToStock
|
||||
'qu_factor_purchase_to_stock' => $quFactorPurchaseToStock,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRow->save();
|
||||
|
||||
|
|
@ -259,7 +260,8 @@ class StockService extends BaseService
|
|||
'price' => $stockEntry->price,
|
||||
'opened_date' => $stockEntry->opened_date,
|
||||
'recipe_id' => $recipeId,
|
||||
'transaction_id' => $transactionId
|
||||
'transaction_id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRow->save();
|
||||
|
||||
|
|
@ -283,7 +285,8 @@ class StockService extends BaseService
|
|||
'price' => $stockEntry->price,
|
||||
'opened_date' => $stockEntry->opened_date,
|
||||
'recipe_id' => $recipeId,
|
||||
'transaction_id' => $transactionId
|
||||
'transaction_id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRow->save();
|
||||
|
||||
|
|
@ -328,7 +331,8 @@ class StockService extends BaseService
|
|||
'qu_factor_purchase_to_stock' => $stockRow->qu_factor_purchase_to_stock,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_id' => $transactionId,
|
||||
'stock_row_id' => $stockRow->id
|
||||
'stock_row_id' => $stockRow->id,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logOldRowForStockUpdate->save();
|
||||
|
||||
|
|
@ -369,7 +373,8 @@ class StockService extends BaseService
|
|||
'qu_factor_purchase_to_stock' => $stockRow->qu_factor_purchase_to_stock,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_id' => $transactionId,
|
||||
'stock_row_id' => $stockRow->id
|
||||
'stock_row_id' => $stockRow->id,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logNewRowForStockUpdate->save();
|
||||
|
||||
|
|
@ -738,7 +743,8 @@ class StockService extends BaseService
|
|||
'transaction_type' => self::TRANSACTION_TYPE_PRODUCT_OPENED,
|
||||
'price' => $stockEntry->price,
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'transaction_id' => $transactionId
|
||||
'transaction_id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRow->save();
|
||||
|
||||
|
|
@ -777,7 +783,8 @@ class StockService extends BaseService
|
|||
'transaction_type' => self::TRANSACTION_TYPE_PRODUCT_OPENED,
|
||||
'price' => $stockEntry->price,
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'transaction_id' => $transactionId
|
||||
'transaction_id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRow->save();
|
||||
|
||||
|
|
@ -914,7 +921,8 @@ class StockService extends BaseService
|
|||
'opened_date' => $stockEntry->opened_date,
|
||||
'location_id' => $stockEntry->location_id,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_Id' => $transactionId
|
||||
'transaction_Id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRowForLocationFrom->save();
|
||||
|
||||
|
|
@ -930,7 +938,8 @@ class StockService extends BaseService
|
|||
'opened_date' => $stockEntry->opened_date,
|
||||
'location_id' => $locationIdTo,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_Id' => $transactionId
|
||||
'transaction_Id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRowForLocationTo->save();
|
||||
|
||||
|
|
@ -957,7 +966,8 @@ class StockService extends BaseService
|
|||
'opened_date' => $stockEntry->opened_date,
|
||||
'location_id' => $stockEntry->location_id,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_Id' => $transactionId
|
||||
'transaction_Id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRowForLocationFrom->save();
|
||||
|
||||
|
|
@ -973,7 +983,8 @@ class StockService extends BaseService
|
|||
'opened_date' => $stockEntry->opened_date,
|
||||
'location_id' => $locationIdTo,
|
||||
'correlation_id' => $correlationId,
|
||||
'transaction_Id' => $transactionId
|
||||
'transaction_Id' => $transactionId,
|
||||
'user_id' => GROCY_USER_ID
|
||||
]);
|
||||
$logRowForLocationTo->save();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
<th>{{ $__t('Booking time') }}</th>
|
||||
<th>{{ $__t('Booking type') }}</th>
|
||||
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif">{{ $__t('Location') }}</th>
|
||||
<th>{{ $__t('Done by') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
|
|
@ -70,7 +71,7 @@
|
|||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span class="name-anchor @if($stockLogEntry->undone == 1) text-strike-through @endif">{{ FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->name }}</span>
|
||||
<span class="name-anchor @if($stockLogEntry->undone == 1) text-strike-through @endif">{{ $stockLogEntry->product_name }}</span>
|
||||
@if($stockLogEntry->undone == 1)
|
||||
<br>
|
||||
{{ $__t('Undone on') . ' ' . $stockLogEntry->undone_timestamp }}
|
||||
|
|
@ -79,7 +80,7 @@
|
|||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<span class="locale-number locale-number-quantity-amount">{{ $stockLogEntry->amount }}</span> {{ $__n($stockLogEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->qu_id_stock)->name_plural) }}
|
||||
<span class="locale-number locale-number-quantity-amount">{{ $stockLogEntry->amount }}</span> {{ $__n($stockLogEntry->amount, $stockLogEntry->qu_name, $stockLogEntry->qu_name_plural) }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $stockLogEntry->row_created_timestamp }}
|
||||
|
|
@ -93,7 +94,10 @@
|
|||
@endif
|
||||
</td>
|
||||
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif">
|
||||
{{ FindObjectInArrayByPropertyValue($locations, 'id', $stockLogEntry->location_id)->name }}
|
||||
{{ $stockLogEntry->location_name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $stockLogEntry->user_display_name }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user