mirror of
https://github.com/grocy/grocy.git
synced 2025-08-16 10:44:37 +00:00
Qu factor purchase to stock & Product Barcode Details (#801)
* Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
@@ -16,7 +16,7 @@ class StockController extends BaseController
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||
|
||||
return $this->renderPage($response, 'stockoverview', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'currentStock' => $this->getStockService()->GetCurrentStock(true),
|
||||
@@ -36,7 +36,7 @@ class StockController extends BaseController
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||
|
||||
return $this->renderPage($response, 'stockentries', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
@@ -50,8 +50,12 @@ class StockController extends BaseController
|
||||
|
||||
public function Purchase(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
|
||||
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
|
||||
return $this->renderPage($response, 'purchase', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'barcodes' => $productBarcodes,
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
@@ -59,8 +63,12 @@ class StockController extends BaseController
|
||||
|
||||
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
|
||||
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
|
||||
return $this->renderPage($response, 'consume', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'barcodes' => $productBarcodes,
|
||||
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
@@ -68,8 +76,12 @@ class StockController extends BaseController
|
||||
|
||||
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
|
||||
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
|
||||
return $this->renderPage($response, 'transfer', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'barcodes' => $productBarcodes,
|
||||
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
@@ -77,8 +89,12 @@ class StockController extends BaseController
|
||||
|
||||
public function Inventory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
|
||||
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
|
||||
return $this->renderPage($response, 'inventory', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'barcodes' => $productBarcodes,
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
@@ -88,7 +104,7 @@ class StockController extends BaseController
|
||||
{
|
||||
return $this->renderPage($response, 'stockentryform', [
|
||||
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
@@ -104,7 +120,7 @@ class StockController extends BaseController
|
||||
|
||||
return $this->renderPage($response, 'shoppinglist', [
|
||||
'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'missingProducts' => $this->getStockService()->GetMissingProducts(),
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
@@ -158,7 +174,7 @@ class StockController extends BaseController
|
||||
{
|
||||
return $this->renderPage($response, 'productgroups', [
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
|
||||
]);
|
||||
@@ -179,11 +195,12 @@ class StockController extends BaseController
|
||||
{
|
||||
return $this->renderPage($response, 'productform', [
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL')->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL and active = 1')->orderBy('name'),
|
||||
'isSubProductOfOthers' => false,
|
||||
'mode' => 'create'
|
||||
]);
|
||||
@@ -195,11 +212,12 @@ class StockController extends BaseController
|
||||
return $this->renderPage($response, 'productform', [
|
||||
'product' => $product,
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
|
||||
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL and active = 1', $product->id)->orderBy('name'),
|
||||
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
||||
'mode' => 'edit',
|
||||
'quConversions' => $this->getDatabase()->quantity_unit_conversions()
|
||||
@@ -296,7 +314,7 @@ class StockController extends BaseController
|
||||
if ($args['itemId'] == 'new')
|
||||
{
|
||||
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||
'mode' => 'create'
|
||||
]);
|
||||
@@ -305,7 +323,7 @@ class StockController extends BaseController
|
||||
{
|
||||
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||
'mode' => 'edit'
|
||||
]);
|
||||
@@ -339,7 +357,7 @@ class StockController extends BaseController
|
||||
return $this->renderPage($response, 'stockjournal', [
|
||||
'stockLog' => $this->getDatabase()->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
@@ -347,13 +365,41 @@ class StockController extends BaseController
|
||||
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->renderPage($response, 'locationcontentsheet', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
|
||||
]);
|
||||
}
|
||||
|
||||
public function ProductBarcodesEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$product = null;
|
||||
if (isset($request->getQueryParams()['product']))
|
||||
{
|
||||
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
|
||||
}
|
||||
|
||||
if ($args['productBarcodeId'] == 'new')
|
||||
{
|
||||
return $this->renderPage($response, 'productbarcodesform', [
|
||||
'mode' => 'create',
|
||||
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
|
||||
'product' => $product,
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->renderPage($response, 'productbarcodesform', [
|
||||
'mode' => 'edit',
|
||||
'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']),
|
||||
'product' => $product,
|
||||
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function QuantityUnitConversionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$product = null;
|
||||
|
Reference in New Issue
Block a user