Consume opened products first (closes #1183)

This commit is contained in:
Bernd Bestel 2020-12-19 10:28:35 +01:00
parent 44cdd42062
commit eb4a748da3
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
8 changed files with 13 additions and 11 deletions

View File

@ -47,6 +47,8 @@
- This "Quick consume amount" can optionally also be used as the default on the consume page (new stock setting / top right corner settings menu)
- Products can now be duplicated (new button on the products list page, all fields will be preset from the copied product, except the name)
- When consuming or opening a parent product, which is currently not in stock, any in-stock sub product will now be consumed/opened (like already automatically done when consuming recipes)
- Opened stock entries get now consumed first by default when no specific stock entry is used/selected
- So the default consume rule is now "Opened first, then first due first, then first in first out"
- Optimized/clarified what the total/unit price is on the purchase page (thanks @kriddles)
- On the purchase page the amount field is now displayed above/before the due date for better `TAB` handling (thanks @kriddles)
- Changed that when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is disabled, products now get internally a due date of "never overdue" (aka `2999-12-31`) instead of today (thanks @kriddles)
@ -94,7 +96,7 @@
### Recipe improvements/fixes
- It's now possible to print recipes (button next to the recipe title) (thanks @zsarnett)
- Changed that recipe costs are now based on the costs of the products picked by the default consume rule "First due first, then first in first out" (thanks @kriddles)
- Changed that recipe costs are now based on the costs of the products picked by the default consume rule ("Opened first, then first due first, then first in first out") (thanks @kriddles)
- Recipe costs were based on the last purchase price per product before, so this now better reflects the current real costs
- Improved the recipe add workflow (a recipe called "New recipe" is now not automatically created when starting to add a recipe) (thanks @zsarnett)
- On the recipe page, the calories and costs per ingredient are now shown to get a better overview of how much each ingredient contributed

View File

@ -586,7 +586,7 @@ class StockApiController extends BaseApiController
$allowSubproductSubstitution = true;
}
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution, false), $request->getQueryParams());
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution, true), $request->getQueryParams());
}
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)

View File

@ -1644,7 +1644,7 @@
},
"/stock/products/{productId}/entries": {
"get": {
"summary": "Returns all stock entries of the given product in order of next use (first due first, then first in first out)",
"summary": "Returns all stock entries of the given product in order of next use (Opened first, then first due first, then first in first out)",
"tags": [
"Stock"
],

View File

@ -847,7 +847,7 @@ msgstr ""
msgid "Use a specific stock item"
msgstr ""
msgid "The first item in this list would be picked by the default rule which is \"First due first, then first in first out\""
msgid "The first item in this list would be picked by the default rule which is \"Opened first, then first due first, then first in first out\""
msgstr ""
msgid "Mark %1$s of %2$s as open"
@ -1699,7 +1699,7 @@ msgstr ""
msgid "Not enough in stock (not included in costs), %s ingredient missing"
msgstr ""
msgid "Based on the prices of the default consume rule which is \"First due first, then first in first out\""
msgid "Based on the prices of the default consume rule which is \"Opened first, then first due first, then first in first out\""
msgstr ""
msgid "Not enough in stock (not included in costs), %1$s missing, %2$s already on shopping list"

View File

@ -691,10 +691,10 @@ class StockService extends BaseService
$result = $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen);
// In order of next use:
// First due first, then first in first out
// Opened first, then first due first, then first in first out
if ($ordered)
{
return $result->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC');
return $result->orderBy('open', 'DESC')->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC');
}
return $result;
@ -702,7 +702,7 @@ class StockService extends BaseService
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
{
$stockEntries = $this->GetProductStockEntries($productId, $excludeOpened, $allowSubproductSubstitution);
$stockEntries = $this->GetProductStockEntries($productId, $excludeOpened, $allowSubproductSubstitution, true);
return FindAllObjectsInArrayByPropertyValue($stockEntries, 'location_id', $locationId);
}

View File

@ -118,7 +118,7 @@
for="use_specific_stock_entry">{{ $__t('Use a specific stock item') }}
&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
title="{{ $__t('The first item in this list would be picked by the default rule which is "First due first, then first in first out"') }}"></i>
title="{{ $__t('The first item in this list would be picked by the default rule which is "Opened first, then first due first, then first in first out"') }}"></i>
</label>
</div>
<select disabled

View File

@ -320,7 +320,7 @@
<label>{{ $__t('Costs') }}&nbsp;</label>
<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
title="{{ $__t('Based on the prices of the default consume rule which is "First due first, then first in first out"') }}"></i>
title="{{ $__t('Based on the prices of the default consume rule which is "Opened first, then first due first, then first in first out"') }}"></i>
<h3 class="locale-number locale-number-currency pt-0">{{ $costs }}</h3>
</div>
@endif

View File

@ -73,7 +73,7 @@
for="use_specific_stock_entry">{{ $__t('Use a specific stock item') }}
&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
title="{{ $__t('The first item in this list would be picked by the default rule which is "First due first, then first in first out"') }}"></i>
title="{{ $__t('The first item in this list would be picked by the default rule which is "Opened first, then first due first, then first in first out') }}"></i>
</label>
</div>
<select disabled