mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Some refinements for #501
This commit is contained in:
parent
3a36bdaf45
commit
0816359867
@ -35,3 +35,6 @@ msgstr "Stock entry edited (old values)"
|
|||||||
|
|
||||||
msgid "stock-edit-new"
|
msgid "stock-edit-new"
|
||||||
msgstr "Stock entry edited (new values)"
|
msgstr "Stock entry edited (new values)"
|
||||||
|
|
||||||
|
msgid "self-production"
|
||||||
|
msgstr "Self-production"
|
||||||
|
@ -35,3 +35,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "stock-edit-new"
|
msgid "stock-edit-new"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "self-production"
|
||||||
|
msgstr ""
|
||||||
|
@ -1618,3 +1618,12 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "A purchased date is required"
|
msgid "A purchased date is required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "When a product is selected, one unit (per serving in purchase quantity unit) will be added to stock on consuming this recipe"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Produces product"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "This booking cannot be undone"
|
||||||
|
msgstr ""
|
||||||
|
@ -20,6 +20,22 @@ ADD correlation_id TEXT;
|
|||||||
ALTER TABLE stock_log
|
ALTER TABLE stock_log
|
||||||
ADD transaction_id TEXT;
|
ADD transaction_id TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE stock_log
|
||||||
|
ADD stock_row_id INTEGER;
|
||||||
|
|
||||||
|
DROP VIEW stock_current_locations;
|
||||||
|
CREATE VIEW stock_current_locations
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
1 AS id, -- Dummy, LessQL needs an id column
|
||||||
|
s.product_id,
|
||||||
|
s.location_id AS location_id,
|
||||||
|
l.name AS location_name
|
||||||
|
FROM stock s
|
||||||
|
JOIN locations l
|
||||||
|
ON s.location_id = l.id
|
||||||
|
GROUP BY s.product_id, s.location_id, l.name;
|
||||||
|
|
||||||
ALTER TABLE recipes
|
ALTER TABLE recipes
|
||||||
ADD product_id INTEGER;
|
ADD product_id INTEGER;
|
||||||
|
|
||||||
@ -38,19 +54,3 @@ FROM recipes r
|
|||||||
LEFT JOIN recipes_pos_resolved rpr
|
LEFT JOIN recipes_pos_resolved rpr
|
||||||
ON r.id = rpr.recipe_id
|
ON r.id = rpr.recipe_id
|
||||||
GROUP BY r.id;
|
GROUP BY r.id;
|
||||||
|
|
||||||
ALTER TABLE stock_log
|
|
||||||
ADD stock_row_id INTEGER;
|
|
||||||
|
|
||||||
DROP VIEW stock_current_locations;
|
|
||||||
CREATE VIEW stock_current_locations
|
|
||||||
AS
|
|
||||||
SELECT
|
|
||||||
1 AS id, -- Dummy, LessQL needs an id column
|
|
||||||
s.product_id,
|
|
||||||
s.location_id AS location_id,
|
|
||||||
l.name AS location_name
|
|
||||||
FROM stock s
|
|
||||||
JOIN locations l
|
|
||||||
ON s.location_id = l.id
|
|
||||||
GROUP BY s.product_id, s.location_id, l.name;
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
$(document).ready(function() {
|
$('#save-recipe-button').on('click', function(e)
|
||||||
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
|
||||||
} );
|
|
||||||
|
|
||||||
$('#save-recipe-button').on('click', function(e)
|
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -351,15 +347,4 @@ $(window).on("message", function(e)
|
|||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|
||||||
{
|
|
||||||
var productId = $(e.target).val();
|
|
||||||
|
|
||||||
if (productId)
|
|
||||||
{
|
|
||||||
Grocy.Components.ProductCard.Refresh(productId);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
@ -67,15 +67,6 @@ class RecipesService extends BaseService
|
|||||||
throw new \Exception('Recipe does not exist');
|
throw new \Exception('Recipe does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$recipeRow = $this->Database->recipes()->where('id = :1', $recipeId)->fetch();
|
|
||||||
if ($recipeRow->product_id != null)
|
|
||||||
{
|
|
||||||
$recipeResolvedRow = $this->Database->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
|
||||||
$price = number_format($recipeResolvedRow->costs, 2);
|
|
||||||
$bookingAmount = floatval($recipeRow->desired_servings);
|
|
||||||
$this->StockService->AddProduct($recipeRow->product_id, $bookingAmount, null, StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d'), $price);
|
|
||||||
}
|
|
||||||
|
|
||||||
$recipePositions = $this->Database->recipes_pos_resolved()->where('recipe_id', $recipeId)->fetchAll();
|
$recipePositions = $this->Database->recipes_pos_resolved()->where('recipe_id', $recipeId)->fetchAll();
|
||||||
foreach ($recipePositions as $recipePosition)
|
foreach ($recipePositions as $recipePosition)
|
||||||
{
|
{
|
||||||
@ -84,6 +75,13 @@ class RecipesService extends BaseService
|
|||||||
$this->StockService->ConsumeProduct($recipePosition->product_id, $recipePosition->recipe_amount, false, StockService::TRANSACTION_TYPE_CONSUME, 'default', $recipeId);
|
$this->StockService->ConsumeProduct($recipePosition->product_id, $recipePosition->recipe_amount, false, StockService::TRANSACTION_TYPE_CONSUME, 'default', $recipeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$recipeRow = $this->Database->recipes()->where('id = :1', $recipeId)->fetch();
|
||||||
|
if (!empty($recipeRow->product_id))
|
||||||
|
{
|
||||||
|
$recipeResolvedRow = $this->Database->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
||||||
|
$this->StockService->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function RecipeExists($recipeId)
|
private function RecipeExists($recipeId)
|
||||||
|
@ -12,6 +12,7 @@ class StockService extends BaseService
|
|||||||
const TRANSACTION_TYPE_STOCK_EDIT_NEW = 'stock-edit-new';
|
const TRANSACTION_TYPE_STOCK_EDIT_NEW = 'stock-edit-new';
|
||||||
const TRANSACTION_TYPE_STOCK_EDIT_OLD = 'stock-edit-old';
|
const TRANSACTION_TYPE_STOCK_EDIT_OLD = 'stock-edit-old';
|
||||||
const TRANSACTION_TYPE_PRODUCT_OPENED = 'product-opened';
|
const TRANSACTION_TYPE_PRODUCT_OPENED = 'product-opened';
|
||||||
|
const TRANSACTION_TYPE_SELF_PRODUCTION = 'self-production';
|
||||||
|
|
||||||
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
|
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
|
||||||
{
|
{
|
||||||
@ -242,7 +243,7 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($transactionType === self::TRANSACTION_TYPE_PURCHASE || $transactionType === self::TRANSACTION_TYPE_INVENTORY_CORRECTION)
|
if ($transactionType === self::TRANSACTION_TYPE_PURCHASE || $transactionType === self::TRANSACTION_TYPE_INVENTORY_CORRECTION || $transactionType == self::TRANSACTION_TYPE_SELF_PRODUCTION)
|
||||||
{
|
{
|
||||||
if ($transactionId === null)
|
if ($transactionId === null)
|
||||||
{
|
{
|
||||||
|
@ -63,12 +63,6 @@
|
|||||||
'hint' => $__t('The ingredients listed here result in this amount of servings')
|
'hint' => $__t('The ingredients listed here result in this amount of servings')
|
||||||
))
|
))
|
||||||
|
|
||||||
@include('components.productpicker', array(
|
|
||||||
'products' => $products,
|
|
||||||
'isRequired' => false,
|
|
||||||
'label' => 'Creates Product'
|
|
||||||
))
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input type="hidden" name="not_check_shoppinglist" value="0">
|
<input type="hidden" name="not_check_shoppinglist" value="0">
|
||||||
@ -89,6 +83,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@include('components.productpicker', array(
|
||||||
|
'products' => $products,
|
||||||
|
'isRequired' => false,
|
||||||
|
'label' => 'Produces product',
|
||||||
|
'prefillById' => $recipe->product_id,
|
||||||
|
'disallowAllProductWorkflows' => true,
|
||||||
|
'hint' => $__t('When a product is selected, one unit (per serving in purchase quantity unit) will be added to stock on consuming this recipe')
|
||||||
|
))
|
||||||
|
|
||||||
@include('components.userfieldsform', array(
|
@include('components.userfieldsform', array(
|
||||||
'userfields' => $userfields,
|
'userfields' => $userfields,
|
||||||
'entity' => 'recipes'
|
'entity' => 'recipes'
|
||||||
@ -222,11 +225,6 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mt-5">
|
|
||||||
<div class="col">
|
|
||||||
@include('components.productcard')
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -137,7 +137,7 @@
|
|||||||
<a class="btn btn-sm btn-outline-primary py-0 recipe-order-missing-button hide-when-embedded hide-on-fullscreen-card @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif" href="#" data-toggle="tooltip" title="{{ $__t('Put missing products on shopping list') }}" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}">
|
<a class="btn btn-sm btn-outline-primary py-0 recipe-order-missing-button hide-when-embedded hide-on-fullscreen-card @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif" href="#" data-toggle="tooltip" title="{{ $__t('Put missing products on shopping list') }}" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}">
|
||||||
<i class="fas fa-cart-plus"></i>
|
<i class="fas fa-cart-plus"></i>
|
||||||
</a>
|
</a>
|
||||||
<a id="selectedRecipeEditButton" class="btn btn-sm btn-outline-info hide-when-embedded hide-on-fullscreen-card py-0" href="{{ $U('/recipe/') }}{{ $selectedRecipe->id }}?product={{ $selectedRecipe->product_id }}">
|
<a id="selectedRecipeEditButton" class="btn btn-sm btn-outline-info hide-when-embedded hide-on-fullscreen-card py-0" href="{{ $U('/recipe/') }}{{ $selectedRecipe->id }}">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
<a id="selectedRecipeDeleteButton" class="btn btn-sm btn-outline-danger hide-when-embedded hide-on-fullscreen-card py-0" href="#" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}">
|
<a id="selectedRecipeDeleteButton" class="btn btn-sm btn-outline-danger hide-when-embedded hide-on-fullscreen-card py-0" href="#" data-recipe-id="{{ $selectedRecipe->id }}" data-recipe-name="{{ $selectedRecipe->name }}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user