diff --git a/controllers/GenericEntityApiController.php b/controllers/GenericEntityApiController.php
index 4f416b88..42483342 100644
--- a/controllers/GenericEntityApiController.php
+++ b/controllers/GenericEntityApiController.php
@@ -116,8 +116,7 @@ class GenericEntityApiController extends BaseApiController
$userfields = null;
}
- $object = $this->getDatabase()->{$args['entity']}
- ($args['objectId']);
+ $object = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($object == null)
{
@@ -136,8 +135,7 @@ class GenericEntityApiController extends BaseApiController
public function GetObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
- $objects = $this->getDatabase()->{$args['entity']}
- ();
+ $objects = $this->getDatabase()->{$args['entity']}();
$allUserfields = $this->getUserfieldsService()->GetAllValues($args['entity']);
foreach ($objects as $object)
@@ -184,13 +182,11 @@ class GenericEntityApiController extends BaseApiController
{
try
{
- return $this->FilteredApiResponse($response, $this->getDatabase()->{$args['entity']}
- ()->where('name LIKE ?', '%' . $args['searchString'] . '%'), $request->getQueryParams());
+ return $this->FilteredApiResponse($response, $this->getDatabase()->{$args['entity']}(), $request->getQueryParams());
}
catch (\PDOException $ex)
{
throw new HttpBadRequestException($request, $ex->getMessage(), $ex);
- //return $this->GenericErrorResponse($response, 'The given entity has no field "name"', $ex);
}
}
else
diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php
index eede7ef1..3c935d66 100644
--- a/controllers/StockApiController.php
+++ b/controllers/StockApiController.php
@@ -108,13 +108,6 @@ class StockApiController extends BaseApiController
$shoppingLocationId = $requestBody['shopping_location_id'];
}
- $quFactorPurchaseToStock = null;
-
- if (array_key_exists('qu_factor_purchase_to_stock', $requestBody) && is_numeric($requestBody['qu_factor_purchase_to_stock']))
- {
- $quFactorPurchaseToStock = $requestBody['qu_factor_purchase_to_stock'];
- }
-
$transactionType = StockService::TRANSACTION_TYPE_PURCHASE;
if (array_key_exists('transaction_type', $requestBody) && !empty($requestBody['transactiontype']))
@@ -122,7 +115,7 @@ class StockApiController extends BaseApiController
$transactionType = $requestBody['transactiontype'];
}
- $bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $quFactorPurchaseToStock, $locationId, $shoppingLocationId);
+ $bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
@@ -372,7 +365,7 @@ class StockApiController extends BaseApiController
$shoppingLocationId = $requestBody['shopping_location_id'];
}
- $bookingId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date'], $requestBody['qu_factor_purchase_to_stock']);
+ $bookingId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date']);
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
}
catch (\Exception $ex)
@@ -524,18 +517,6 @@ class StockApiController extends BaseApiController
}
}
- public function ProductBarcodeDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
- {
- try
- {
- return $this->ApiResponse($response, $this->getDatabase()->product_barcodes()->where('barcode = :1', $args['barcode'])->fetch());
- }
- catch (\Exception $ex)
- {
- return $this->GenericErrorResponse($response, $ex->getMessage());
- }
- }
-
public function ProductDetails(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
try
diff --git a/controllers/StockController.php b/controllers/StockController.php
index e68e37d2..18edba1f 100644
--- a/controllers/StockController.php
+++ b/controllers/StockController.php
@@ -30,7 +30,9 @@ class StockController extends BaseController
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
'barcodes' => $productBarcodes,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
- 'locations' => $this->getDatabase()->locations()->orderBy('name')
+ 'locations' => $this->getDatabase()->locations()->orderBy('name'),
+ 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
+ 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
@@ -107,20 +109,24 @@ class StockController extends BaseController
if ($args['productBarcodeId'] == 'new')
{
- return $this->renderPage($response, 'productbarcodesform', [
+ return $this->renderPage($response, 'productbarcodeform', [
'mode' => 'create',
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'product' => $product,
- 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name')
+ 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
+ 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
+ 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
else
{
- return $this->renderPage($response, 'productbarcodesform', [
+ return $this->renderPage($response, 'productbarcodeform', [
'mode' => 'edit',
'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']),
'product' => $product,
- 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name')
+ 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name'),
+ 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
+ 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
]);
}
}
diff --git a/grocy.openapi.json b/grocy.openapi.json
index 757f0a27..af6608b0 100644
--- a/grocy.openapi.json
+++ b/grocy.openapi.json
@@ -2755,57 +2755,6 @@
}
}
},
- "/productbarcodedetails/{barcode}": {
- "get": {
- "summary": "Executes a product barcode details lookoup via the configured plugin with the given barcode",
- "tags": [
- "Product"
- ],
- "parameters": [
- {
- "in": "path",
- "name": "barcode",
- "required": true,
- "description": "The barcode to lookup up",
- "schema": {
- "type": "string"
- }
- },
- {
- "in": "query",
- "name": "add",
- "required": false,
- "description": "When true, the product is added to the database on a successful lookup and the new product id is in included in the response",
- "schema": {
- "type": "boolean",
- "default": false
- }
- }
- ],
- "responses": {
- "200": {
- "description": "An ProductBarcodeDetails object or null, when nothing was found for the given barcode",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ProductBarcodeDetailsResponse"
- }
- }
- }
- },
- "400": {
- "description": "The operation was not successful (possible errors are: Plugin error)",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GenericErrorResponse"
- }
- }
- }
- }
- }
- }
- },
"/recipes/{recipeId}/add-not-fulfilled-products-to-shoppinglist": {
"post": {
"summary": "Adds all missing products for the given recipe to the shopping list",
@@ -3940,8 +3889,9 @@
"id": "1",
"product_id": "13",
"barcode": "01321230213",
- "qu_factor_purchase_to_stock": "10.0",
- "shopping_location_id": "2"
+ "qu_id": "1",
+ "shopping_location_id": "2",
+ "amount": "10"
}
],
"last_purchased": null,
@@ -4004,12 +3954,15 @@
"barcode": {
"type": "string"
},
- "qu_factor_purchase_to_stock": {
- "type": "number",
- "format": "number"
+ "qu_id": {
+ "type": "integer"
},
"shopping_location_id": {
"type": "integer"
+ },
+ "amount": {
+ "type": "number",
+ "format": "number"
}
}
},
diff --git a/localization/en/userfield_types.po b/localization/en/userfield_types.po
index e54d0ea5..19da657b 100644
--- a/localization/en/userfield_types.po
+++ b/localization/en/userfield_types.po
@@ -41,3 +41,9 @@ msgstr "Select list (multiple items can be selected)"
msgid "link"
msgstr "Link"
+
+msgid "file"
+msgstr "File"
+
+msgid "image"
+msgstr "Image"
diff --git a/localization/strings.pot b/localization/strings.pot
index 17ba3c7d..030f3687 100644
--- a/localization/strings.pot
+++ b/localization/strings.pot
@@ -1942,3 +1942,15 @@ msgstr ""
msgid "Save & return to quantity units"
msgstr ""
+
+msgid "price"
+msgstr ""
+
+msgid "means %1$s per %2$s and %3$s per %4$s"
+msgstr ""
+
+msgid "New stock amount"
+msgstr ""
+
+msgid "Price per stock unit"
+msgstr ""
diff --git a/migrations/0103.sql b/migrations/0103.sql
index d118733b..babfc48f 100644
--- a/migrations/0103.sql
+++ b/migrations/0103.sql
@@ -2,39 +2,28 @@
DELETE from stock_log
WHERE product_id NOT IN (SELECT id from products);
-ALTER TABLE stock_log
-ADD qu_factor_purchase_to_stock REAL NOT NULL DEFAULT 1.0;
-
-ALTER TABLE stock
-ADD qu_factor_purchase_to_stock REAL NOT NULL DEFAULT 1.0;
-
+-- Price is based on 1 QU stock
UPDATE stock
-SET qu_factor_purchase_to_stock = (SELECT qu_factor_purchase_to_stock FROM products WHERE product_id = id);
+SET price = ROUND(price / (SELECT qu_factor_purchase_to_stock FROM products WHERE id = product_id), 2);
UPDATE stock_log
-SET qu_factor_purchase_to_stock = (SELECT qu_factor_purchase_to_stock FROM products WHERE product_id = id);
-
---Price is now going forward to be saved as 1 QU Stock
-UPDATE stock
-SET price = ROUND(price / qu_factor_purchase_to_stock, 2);
-
-UPDATE stock_log
-SET price = ROUND(price / qu_factor_purchase_to_stock, 2);
+SET price = ROUND(price / (SELECT qu_factor_purchase_to_stock FROM products WHERE id = product_id), 2);
CREATE TABLE product_barcodes (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
product_id INT NOT NULL,
barcode TEXT NOT NULL UNIQUE,
- qu_factor_purchase_to_stock REAL NOT NULL DEFAULT 1,
+ qu_id INT,
+ amount REAL,
shopping_location_id INTEGER,
row_created_timestamp DATETIME DEFAULT (datetime('now', 'localtime'))
);
-- Convert product table to new product_barcodes table
INSERT INTO product_barcodes
- (product_id, barcode, qu_factor_purchase_to_stock, shopping_location_id)
-WITH barcodes_splitted(id, barcode, str, qu_factor_purchase_to_stock, shopping_location_id) AS (
- SELECT id as product_id, '', barcode || ',', qu_factor_purchase_to_stock, shopping_location_id
+ (product_id, barcode, shopping_location_id)
+WITH barcodes_splitted(id, barcode, str, shopping_location_id) AS (
+ SELECT id as product_id, '', barcode || ',', shopping_location_id
FROM products
UNION ALL
@@ -42,12 +31,11 @@ WITH barcodes_splitted(id, barcode, str, qu_factor_purchase_to_stock, shopping_l
id as product_id,
SUBSTR(str, 0, instr(str, ',')),
SUBSTR(str, instr(str, ',') + 1),
- qu_factor_purchase_to_stock,
shopping_location_id
FROM barcodes_splitted
WHERE str != ''
)
-SELECT id as product_id, barcode, qu_factor_purchase_to_stock, shopping_location_id
+SELECT id as product_id, barcode, shopping_location_id
FROM barcodes_splitted
WHERE barcode != '';
@@ -97,7 +85,6 @@ SELECT
IFNULL(s.location_id, p.location_id) AS location_id,
s.product_id,
SUM(s.amount) AS amount,
- ROUND(SUM(s.amount / s.qu_factor_purchase_to_stock),2) as factor_purchase_amount,
ROUND(SUM(IFNULL(s.price, 0) * s.amount), 2) AS value,
MIN(s.best_before_date) AS best_before_date,
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND location_id = s.location_id AND open = 1), 0) AS amount_opened
@@ -113,7 +100,6 @@ AS
SELECT
pr.parent_product_id AS product_id,
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id), 0) AS amount,
- IFNULL(ROUND((SELECT SUM(amount / qu_factor_purchase_to_stock) FROM stock WHERE product_id = pr.parent_product_id), 2), 0) as factor_purchase_amount,
SUM(s.amount) * IFNULL(qucr.factor, 1) AS amount_aggregated,
IFNULL(ROUND((SELECT SUM(IFNULL(price,0) * amount) FROM stock WHERE product_id = pr.parent_product_id), 2), 0) AS value,
MIN(s.best_before_date) AS best_before_date,
@@ -142,7 +128,6 @@ UNION
SELECT
pr.sub_product_id AS product_id,
SUM(s.amount) AS amount,
- ROUND(SUM(s.amount / s.qu_factor_purchase_to_stock), 2) as factor_purchase_amount,
SUM(s.amount) AS amount_aggregated,
ROUND(SUM(IFNULL(s.price, 0) * s.amount), 2) AS value,
MIN(s.best_before_date) AS best_before_date,
diff --git a/migrations/0104.sql b/migrations/0104.sql
index 970d0cd8..e860397f 100644
--- a/migrations/0104.sql
+++ b/migrations/0104.sql
@@ -10,7 +10,6 @@ select
sl.best_before_date,
sl.purchased_date,
sl.price,
- sl.qu_factor_purchase_to_stock,
sl.location_id,
sl.shopping_location_id
FROM stock_log sl
@@ -53,7 +52,7 @@ SELECT
sw.amount,
sw.best_before_date,
sw.purchased_date,
- sw.price, sw.qu_factor_purchase_to_stock,
+ sw.price,
sw.location_id,
sw.shopping_location_id
FROM stock sw
diff --git a/migrations/0105.sql b/migrations/0105.sql
index e3e29366..dbbc2b2a 100644
--- a/migrations/0105.sql
+++ b/migrations/0105.sql
@@ -15,7 +15,6 @@ SELECT
p.name AS product_name,
(SELECT name FROM product_groups WHERE product_groups.id = product_group_id) AS product_group_name,
EXISTS(SELECT * FROM shopping_list WHERE shopping_list.product_id = sc.product_id) AS on_shopping_list,
- sc.factor_purchase_amount AS factor_purchase_amount,
(SELECT name FROM quantity_units WHERE quantity_units.id = p.qu_id_purchase) AS qu_purchase_unit_name,
(SELECT name_plural FROM quantity_units WHERE quantity_units.id = p.qu_id_purchase) AS qu_purchase_unit_name_plural,
sc.is_aggregated_amount,
@@ -26,7 +25,7 @@ FROM (
FROM stock_current
WHERE best_before_date IS NOT NULL
UNION
- SELECT id, 0, 0, 0, 0, null, 0, 0, 0
+ SELECT id, 0, 0, 0, null, 0, 0, 0
FROM stock_missing_products_including_opened
WHERE id NOT IN (SELECT product_id FROM stock_current)
) sc
@@ -50,7 +49,6 @@ SELECT
p.name AS product_name,
(SELECT name FROM product_groups WHERE product_groups.id = product_group_id) AS product_group_name,
EXISTS(SELECT * FROM shopping_list WHERE shopping_list.product_id = sc.product_id) AS on_shopping_list,
- sc.factor_purchase_amount AS factor_purchase_amount,
(SELECT name FROM quantity_units WHERE quantity_units.id = p.qu_id_purchase) AS qu_purchase_unit_name,
(SELECT name_plural FROM quantity_units WHERE quantity_units.id = p.qu_id_purchase) AS qu_purchase_unit_name_plural,
sc.is_aggregated_amount,
diff --git a/migrations/0109.sql b/migrations/0109.sql
index bce1404c..4b4e511a 100644
--- a/migrations/0109.sql
+++ b/migrations/0109.sql
@@ -4,7 +4,6 @@ AS
SELECT
pr.parent_product_id AS product_id,
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id), 0) AS amount,
- IFNULL(ROUND((SELECT SUM(amount / qu_factor_purchase_to_stock) FROM stock WHERE product_id = pr.parent_product_id), 2), 0) as factor_purchase_amount,
SUM(s.amount * IFNULL(qucr.factor, 1.0)) AS amount_aggregated,
IFNULL(ROUND((SELECT SUM(IFNULL(price,0) * amount) FROM stock WHERE product_id = pr.parent_product_id), 2), 0) AS value,
MIN(s.best_before_date) AS best_before_date,
@@ -33,7 +32,6 @@ UNION
SELECT
pr.sub_product_id AS product_id,
SUM(s.amount) AS amount,
- ROUND(SUM(s.amount / s.qu_factor_purchase_to_stock), 2) as factor_purchase_amount,
SUM(s.amount) AS amount_aggregated,
ROUND(SUM(IFNULL(s.price, 0) * s.amount), 2) AS value,
MIN(s.best_before_date) AS best_before_date,
diff --git a/migrations/0117.sql b/migrations/0117.sql
new file mode 100644
index 00000000..2dfb848c
--- /dev/null
+++ b/migrations/0117.sql
@@ -0,0 +1,71 @@
+DROP VIEW quantity_unit_conversions_resolved;
+CREATE VIEW quantity_unit_conversions_resolved
+AS
+
+-- First: Product "purchase to stock" conversion factor
+SELECT
+ p.id AS id, -- Dummy, LessQL needs an id column
+ p.id AS product_id,
+ p.qu_id_purchase AS from_qu_id,
+ qu_from.name AS from_qu_name,
+ p.qu_id_stock AS to_qu_id,
+ qu_to.name AS to_qu_name,
+ p.qu_factor_purchase_to_stock AS factor
+FROM products p
+JOIN quantity_units qu_from
+ ON p.qu_id_purchase = qu_from.id
+JOIN quantity_units qu_to
+ ON p.qu_id_stock = qu_to.id
+UNION -- Inversed
+SELECT
+ p.id AS id, -- Dummy, LessQL needs an id column
+ p.id AS product_id,
+ p.qu_id_stock AS from_qu_id,
+ qu_to.name AS from_qu_name,
+ p.qu_id_purchase AS to_qu_id,
+ qu_from.name AS to_qu_name,
+ 1 / p.qu_factor_purchase_to_stock AS factor
+FROM products p
+JOIN quantity_units qu_from
+ ON p.qu_id_purchase = qu_from.id
+JOIN quantity_units qu_to
+ ON p.qu_id_stock = qu_to.id
+
+UNION
+
+-- Second: Product specific overrides
+SELECT
+ p.id AS id, -- Dummy, LessQL needs an id column
+ p.id AS product_id,
+ quc.from_qu_id AS from_qu_id,
+ qu_from.name AS from_qu_name,
+ quc.to_qu_id AS to_qu_id,
+ qu_to.name AS to_qu_name,
+ quc.factor AS factor
+FROM products p
+JOIN quantity_unit_conversions quc
+ ON p.id = quc.product_id
+JOIN quantity_units qu_from
+ ON quc.from_qu_id = qu_from.id
+JOIN quantity_units qu_to
+ ON quc.to_qu_id = qu_to.id
+
+UNION
+
+-- Third: Default quantity unit conversion factors
+SELECT
+ p.id AS id, -- Dummy, LessQL needs an id column
+ p.id AS product_id,
+ p.qu_id_stock AS from_qu_id,
+ qu_from.name AS from_qu_name,
+ quc.to_qu_id AS to_qu_id,
+ qu_to.name AS to_qu_name,
+ quc.factor AS factor
+FROM products p
+JOIN quantity_unit_conversions quc
+ ON p.qu_id_stock = quc.from_qu_id
+ AND quc.product_id IS NULL
+JOIN quantity_units qu_from
+ ON quc.from_qu_id = qu_from.id
+JOIN quantity_units qu_to
+ ON quc.to_qu_id = qu_to.id;
diff --git a/public/css/grocy.css b/public/css/grocy.css
index dac48b68..3912c84f 100755
--- a/public/css/grocy.css
+++ b/public/css/grocy.css
@@ -486,6 +486,7 @@ canvas.drawingBuffer {
.user-filter-message {
display: inline-block;
cursor: pointer;
+ line-height: 0.5;
}
.related-links .btn {
diff --git a/public/viewjs/components/productamountpicker.js b/public/viewjs/components/productamountpicker.js
index 44b00a15..5884b357 100644
--- a/public/viewjs/components/productamountpicker.js
+++ b/public/viewjs/components/productamountpicker.js
@@ -11,7 +11,7 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
$("#qu_id").attr("data-destination-qu-name", FindObjectInArrayByPropertyValue(Grocy.QuantityUnits, 'id', destinationQuId).name);
conversionsForProduct.forEach(conversion =>
{
- var factor = conversion.factor;
+ var factor = parseFloat(conversion.factor);
if (conversion.to_qu_id == destinationQuId)
{
factor = 1;
@@ -39,6 +39,15 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
$("#qu_id").val($("#qu_id option:first").val());
}
+ if ($('#qu_id option').length == 1)
+ {
+ $("#qu_id").attr("disabled", "");
+ }
+ else
+ {
+ $("#qu_id").removeAttr("disabled");
+ }
+
$(".input-group-productamountpicker").trigger("change");
}
diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js
index 3d4d3195..f9bf3215 100644
--- a/public/viewjs/components/productcard.js
+++ b/public/viewjs/components/productcard.js
@@ -6,23 +6,12 @@ Grocy.Components.ProductCard.Refresh = function(productId)
function(productDetails)
{
var stockAmount = productDetails.stock_amount || '0';
- var stockFactorPurchaseAmount = productDetails.stock_factor_purchase_amount || '0';
var stockValue = productDetails.stock_value || '0';
var stockAmountOpened = productDetails.stock_amount_opened || '0';
$('#productcard-product-name').text(productDetails.product.name);
$('#productcard-product-description').html(productDetails.product.description);
$('#productcard-product-stock-amount').text(stockAmount);
$('#productcard-product-stock-qu-name').text(__n(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural));
- if (productDetails.last_qu_factor_purchase_to_stock > 1)
- {
- $('#productcard-product-stock-factor-purchase-amount').text('(' + stockFactorPurchaseAmount);
- $('#productcard-product-stock-factor-purchase-qu-name').text(__n(stockFactorPurchaseAmount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural) + ')');
- }
- else
- {
- $('#productcard-product-stock-factor-purchase-amount').text('');
- $('#productcard-product-stock-factor-purchase-qu-name').text('');
- }
$('#productcard-product-stock-value').text(stockValue + ' ' + Grocy.Currency);
$('#productcard-product-last-purchased').text((productDetails.last_purchased || '2999-12-31').substring(0, 10));
$('#productcard-product-last-purchased-timeago').attr("datetime", productDetails.last_purchased || '2999-12-31');
@@ -95,14 +84,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
if (productDetails.last_price !== null)
{
- if (productDetails.last_qu_factor_purchase_to_stock > 1)
- {
- $('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price * productDetails.last_qu_factor_purchase_to_stock).toLocaleString() + ' ' + Grocy.Currency + ' per 1 ' + productDetails.quantity_unit_purchase.name + ' of ' + productDetails.last_qu_factor_purchase_to_stock + ' ' + productDetails.quantity_unit_stock.name_plural);
- }
- else
- {
- $('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per ' + productDetails.quantity_unit_purchase.name);
- }
+ $('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per ' + productDetails.quantity_unit_stock.name);
}
else
{
diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 56f926de..159d0d78 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -48,7 +48,6 @@
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
- jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js
index 807e88b8..d41b3379 100644
--- a/public/viewjs/inventory.js
+++ b/public/viewjs/inventory.js
@@ -45,7 +45,6 @@
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
- jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
diff --git a/public/viewjs/locationform.js b/public/viewjs/locationform.js
index fe8c789b..ee52a703 100644
--- a/public/viewjs/locationform.js
+++ b/public/viewjs/locationform.js
@@ -79,5 +79,5 @@ $('#location-form input').keydown(function(event)
});
Grocy.Components.UserfieldsForm.Load();
-$('#name').focus();
Grocy.FrontendHelpers.ValidateForm('location-form');
+$('#name').focus();
diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js
index 0181d524..9f9dda22 100644
--- a/public/viewjs/mealplan.js
+++ b/public/viewjs/mealplan.js
@@ -180,11 +180,6 @@ var calendar = $("#calendar").fullCalendar({
productDetails.last_price = 0;
}
- if (productDetails.last_qu_factor_purchase_to_stock === null)
- {
- productDetails.last_qu_factor_purchase_to_stock = 1;
- }
-
element.attr("data-product-details", event.productDetails);
var productOrderMissingButtonDisabledClasses = "disabled";
@@ -210,7 +205,7 @@ var calendar = $("#calendar").fullCalendar({
var costsAndCaloriesPerServing = ""
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
- costsAndCaloriesPerServing = '
' + productDetails.last_price / productDetails.last_qu_factor_purchase_to_stock * mealPlanEntry.product_amount + ' / ' + productDetails.product.calories * mealPlanEntry.product_amount + ' kcal ' + '';
+ costsAndCaloriesPerServing = '' + productDetails.last_price * mealPlanEntry.product_amount + ' / ' + productDetails.product.calories * mealPlanEntry.product_amount + ' kcal ' + '';
}
else
{
diff --git a/public/viewjs/productbarcodesform.js b/public/viewjs/productbarcodeform.js
similarity index 73%
rename from public/viewjs/productbarcodesform.js
rename to public/viewjs/productbarcodeform.js
index 29b57822..cdb19a6e 100644
--- a/public/viewjs/productbarcodesform.js
+++ b/public/viewjs/productbarcodeform.js
@@ -3,6 +3,9 @@
e.preventDefault();
var jsonData = $('#barcode-form').serializeJSON();
+ jsonData.amount = jsonData.display_amount;
+ delete jsonData.display_amount;
+
Grocy.FrontendHelpers.BeginUiBusy("barcode-form");
if (Grocy.EditMode === 'create')
@@ -36,12 +39,17 @@
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
});
-$('#barcode').on('change', function(e)
+$('#barcode').on('keyup', function(e)
{
Grocy.FrontendHelpers.ValidateForm('barcode-form');
});
-$('#qu_factor_purchase_to_stock').on('change', function(e)
+$('#qu_id').on('change', function(e)
+{
+ Grocy.FrontendHelpers.ValidateForm('barcode-form');
+});
+
+$('#display_amount').on('keyup', function(e)
{
Grocy.FrontendHelpers.ValidateForm('barcode-form');
});
@@ -62,4 +70,13 @@ $('#barcode-form input').keydown(function(event)
}
}
});
+
+Grocy.Components.ProductAmountPicker.Reload(Grocy.EditObjectProduct.id, Grocy.EditObjectProduct.qu_id_purchase);
+if (Grocy.EditMode == "edit")
+{
+ $("#display_amount").val(Grocy.EditObject.amount);
+ Grocy.Components.ProductAmountPicker.SetQuantityUnit(Grocy.EditObject.qu_id);
+}
+
Grocy.FrontendHelpers.ValidateForm('barcode-form');
+$('#barcode').focus();
diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js
index 3075f25a..09fdf7b8 100644
--- a/public/viewjs/productform.js
+++ b/public/viewjs/productform.js
@@ -8,6 +8,12 @@
Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name,
(result) =>
{
+ if (Grocy.ProductEditFormRedirectUri == "reload")
+ {
+ window.location.reload();
+ return
+ }
+
var returnTo = GetUriParam('returnto');
if (GetUriParam("closeAfterCreation") !== undefined)
{
@@ -32,6 +38,12 @@
}
else
{
+ if (Grocy.ProductEditFormRedirectUri == "reload")
+ {
+ window.location.reload();
+ return
+ }
+
var returnTo = GetUriParam('returnto');
if (GetUriParam("closeAfterCreation") !== undefined)
{
@@ -145,9 +157,6 @@ $('.input-group-qu').on('change', function(e)
$('#qu-conversion-info').addClass('d-none');
}
- $("#qu-conversion-headline-info").text(__t('1 %s is the same as...', $("#qu_id_stock option:selected").text()));
- quConversionsTable.column(4).search("from_qu_id xx" + $("#qu_id_stock").val().toString() + "xx").draw();
-
$("#tare_weight_qu_info").text($("#qu_id_stock option:selected").text());
Grocy.FrontendHelpers.ValidateForm('product-form');
@@ -301,14 +310,14 @@ if (Grocy.EditMode === 'create')
var quConversionsTable = $('#qu-conversions-table').DataTable({
'order': [[1, 'asc']],
- "orderFixed": [[3, 'asc']],
+ "orderFixed": [[4, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 },
- { 'visible': false, 'targets': 3 }
+ { 'visible': false, 'targets': 4 }
],
'rowGroup': {
- dataSrc: 3
+ dataSrc: 4
}
});
$('#qu-conversions-table tbody').removeClass("d-none");
diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js
index 7aefb70d..07696740 100644
--- a/public/viewjs/purchase.js
+++ b/public/viewjs/purchase.js
@@ -3,7 +3,6 @@
e.preventDefault();
var jsonForm = $('#purchase-form').serializeJSON();
- jsonForm.qu_factor_purchase_to_stock = $("#qu_id option:selected").attr("data-qu-factor");
Grocy.FrontendHelpers.BeginUiBusy("purchase-form");
@@ -16,14 +15,14 @@
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
jsonData.price = 0;
- } else
+ }
+ else
{
- // price is saved as 1 QU to stock
- var price = parseFloat(jsonForm.price / jsonForm.qu_factor_purchase_to_stock).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
+ var price = parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
if ($("input[name='price-type']:checked").val() == "total-price")
{
- price = parseFloat(price / jsonForm.amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
+ price = parseFloat(price / jsonForm.display_amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
}
jsonData.price = price;
}
@@ -50,7 +49,6 @@
{
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
}
- jsonData.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
Grocy.Api.Post('stock/products/' + jsonForm.product_id + '/add', jsonData,
function(result)
@@ -66,7 +64,6 @@
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
- jsonDataBarcode.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
@@ -122,6 +119,12 @@
}
Grocy.Components.ProductPicker.GetInputElement().focus();
Grocy.Components.ProductCard.Refresh(jsonForm.product_id);
+
+ $('#price-hint').text("");
+ var priceTypeUnitPrice = $("#price-type-unit-price");
+ var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]");
+ priceTypeUnitPriceLabel.text(__t("Unit price"));
+
Grocy.FrontendHelpers.ValidateForm('purchase-form');
}
},
@@ -155,67 +158,17 @@ if (Grocy.Components.ProductPicker !== undefined)
{
Grocy.Components.ProductCard.Refresh(productId);
- if (document.getElementById("product_id").getAttribute("barcode") != "null")
- {
- Grocy.Api.Get('productbarcodedetails/' + document.getElementById("product_id").getAttribute("barcode"),
- function(resultBarcode)
- {
- if (resultBarcode != null)
- {
- $('#product_id').attr("barcode-qu-factor-purchase-to-stock", resultBarcode.qu_factor_purchase_to_stock);
- $('#product_id').attr("barcode-shopping-location-id", resultBarcode.shopping_location_id);
- }
- else
- {
- $('#product_id').attr("barcode-qu-factor-purchase-to-stock", "null");
- $('#product_id').attr("barcode-shopping-location-id", "null");
- }
- },
- function(xhr)
- {
- console.error(xhr);
- }
- );
- }
- else
- {
- $('#product_id').attr("barcode-qu-factor-purchase-to-stock", "null");
- $('#product_id').attr("barcode-shopping-location-id", "null");
- }
-
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_purchase.id);
- var qu_factor_purchase_to_stock = null;
var barcode_shopping_location_id = null;
- if (document.getElementById("product_id").getAttribute("barcode") != "null" && document.getElementById("product_id").getAttribute("barcode-qu-factor-purchase-to-stock") != "null")
- {
- qu_factor_purchase_to_stock = document.getElementById("product_id").getAttribute("barcode-qu-factor-purchase-to-stock");
- barcode_shopping_location_id = document.getElementById("product_id").getAttribute("barcode-shopping-location-id");
- }
- else
- {
- if (productDetails.last_qu_factor_purchase_to_stock != null)
- {
- qu_factor_purchase_to_stock = productDetails.last_qu_factor_purchase_to_stock;
- }
- else
- {
- qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
- }
- }
-
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
- if (barcode_shopping_location_id != null)
- {
- Grocy.Components.ShoppingLocationPicker.SetId(barcode_shopping_location_id);
- }
- else if (productDetails.last_shopping_location_id != null)
+ if (productDetails.last_shopping_location_id != null)
{
Grocy.Components.ShoppingLocationPicker.SetId(productDetails.last_shopping_location_id);
}
@@ -230,11 +183,11 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
}
- $('#price').val(parseFloat(productDetails.last_price * qu_factor_purchase_to_stock).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
+ $('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }));
var priceTypeUnitPrice = $("#price-type-unit-price");
var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]");
- priceTypeUnitPriceLabel.text(productDetails.quantity_unit_purchase.name + " price");
+ priceTypeUnitPriceLabel.text($("#qu_id option:selected").text() + " " + __t("price"));
refreshPriceHint();
@@ -253,7 +206,7 @@ if (Grocy.Components.ProductPicker !== undefined)
if (productDetails.product.enable_tare_weight_handling == 1)
{
- var minAmount = parseFloat(productDetails.product.tare_weight) / qu_factor_purchase_to_stock + parseFloat(productDetails.stock_amount);
+ var minAmount = parseFloat(productDetails.product.tare_weight) / $("#qu_id option:selected").attr("data-qu-factor") + parseFloat(productDetails.stock_amount);
$("#display_amount").attr("min", minAmount);
$("#display_amount").attr("step", "." + "0".repeat(parseInt(Grocy.UserSettings.stock_decimal_places_amounts) - 1) + "1");
$("#display_amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', minAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts })));
@@ -304,6 +257,40 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.UISound.Error();
}
}
+
+ if (document.getElementById("product_id").getAttribute("barcode") != "null")
+ {
+ Grocy.Api.Get('objects/product_barcodes/search/?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
+ function(barcodeResult)
+ {
+ if (barcodeResult != null)
+ {
+ var barcode = barcodeResult[0];
+
+ if (barcode.amount != null)
+ {
+ $("#display_amount").val(barcode.amount);
+ }
+
+ if (barcode.qu_id != null)
+ {
+ Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
+ }
+
+ if (barcode.shopping_location_id != null)
+ {
+ Grocy.Components.ShoppingLocationPicker.SetId(barcode.shopping_location_id);
+ }
+
+ Grocy.FrontendHelpers.ValidateForm('purchase-form');
+ }
+ },
+ function(xhr)
+ {
+ console.error(xhr);
+ }
+ );
+ }
},
function(xhr)
{
@@ -409,12 +396,7 @@ if (GetUriParam("flow") === "shoppinglistitemtostock")
function refreshPriceHint()
{
- if ($('#amount').val() == 0)
- {
- $('#price-hint').text("");
- return;
- }
- if ($('#price').val() == 0)
+ if ($('#amount').val() == 0 || $('#price').val() == 0)
{
$('#price-hint').text("");
return;
@@ -422,29 +404,14 @@ function refreshPriceHint()
if ($("input[name='price-type']:checked").val() == "total-price")
{
- var price = $('#price').val() / $("#qu_id option:selected").attr("data-qu-factor") / $('#amount').val();
- var quprice = $('#price').val() / $('#amount').val();
+ var price = parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
+ price = parseFloat(price / $('#display_amount').val()).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
- if ($("#qu_id option:selected").attr("data-qu-factor") > 1)
- {
- $('#price-hint').text(__t('means %1$s per %2$s and %3$s per %4$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), $("#qu_id").attr("data-destination-qu-name"), quprice.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-purchase-name")));
- }
- else
- {
- $('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), $("#qu_id").attr("data-destination-qu-name")));
- }
+ $('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), $("#qu_id").attr("data-destination-qu-name")));
}
else
{
- if ($("#qu_id option:selected").attr("data-qu-factor") > 1)
- {
- var price = $('#price').val() / $("#qu_id option:selected").attr("data-qu-factor");
- $('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), $("#qu_id").attr("data-destination-qu-name")));
- }
- else
- {
- $('#price-hint').text("");
- }
+ $('#price-hint').text("");
}
};
@@ -520,3 +487,10 @@ $("#scan-mode-button").on("click", function(e)
$("#scan-mode-status").text(__t("off"));
}
});
+
+$('#qu_id').on('change', function(e)
+{
+ var priceTypeUnitPrice = $("#price-type-unit-price");
+ var priceTypeUnitPriceLabel = $("[for=" + priceTypeUnitPrice.attr("id") + "]");
+ priceTypeUnitPriceLabel.text($("#qu_id option:selected").text() + " " + __t("price"));
+});
diff --git a/public/viewjs/quantityunitconversionform.js b/public/viewjs/quantityunitconversionform.js
index 5acd3cca..1efcfbf3 100644
--- a/public/viewjs/quantityunitconversionform.js
+++ b/public/viewjs/quantityunitconversionform.js
@@ -174,12 +174,12 @@ $('.input-group-qu').on('change', function(e)
if (fromQuId && toQuId)
{
- $('#qu-conversion-info').text(__t('This means 1 %1$s is the same as %2$s %3$s', $("#from_qu_id option:selected").text(), (1 * factor).toString(), __n((1 * factor).toString(), $("#to_qu_id option:selected").text(), $("#to_qu_id option:selected").data("plural-form"))));
+ $('#qu-conversion-info').text(__t('This means 1 %1$s is the same as %2$s %3$s', $("#from_qu_id option:selected").text(), parseFloat((1 * factor)).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), __n((1 * factor).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), $("#to_qu_id option:selected").text(), $("#to_qu_id option:selected").data("plural-form"))));
$('#qu-conversion-info').removeClass('d-none');
if (Grocy.EditMode === 'create')
{
- $('#qu-conversion-inverse-info').text('(' + __t('This means 1 %1$s is the same as %2$s %3$s', $("#to_qu_id option:selected").text(), (1 / factor).toString(), __n((1 / factor).toString(), $("#from_qu_id option:selected").text(), $("#from_qu_id option:selected").data("plural-form"))) + ')');
+ $('#qu-conversion-inverse-info').text(__t('This means 1 %1$s is the same as %2$s %3$s', $("#to_qu_id option:selected").text(), parseFloat((1 / factor)).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), __n((1 / factor).toString(), $("#from_qu_id option:selected").text(), $("#from_qu_id option:selected").data("plural-form"))));
$('#qu-conversion-inverse-info').removeClass('d-none');
}
}
@@ -196,3 +196,8 @@ Grocy.Components.UserfieldsForm.Load();
$('.input-group-qu').trigger('change');
$('#from_qu_id').focus();
Grocy.FrontendHelpers.ValidateForm('quconversion-form');
+
+if (GetUriParam("qu-unit") !== undefined)
+{
+ $("#from_qu_id").attr("disabled", "");
+}
diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js
index 40b83959..580a8972 100644
--- a/public/viewjs/stockentries.js
+++ b/public/viewjs/stockentries.js
@@ -177,7 +177,6 @@ function RefreshStockEntryRow(stockRowId)
);
$('#stock-' + stockRowId + '-price').text(result.price);
- $('#stock-' + stockRowId + '-qu-factor-purchase-to-stock').text(result.qu_factor_purchase_to_stock);
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');
diff --git a/public/viewjs/stockentryform.js b/public/viewjs/stockentryform.js
index fd2a2792..c79d1ad4 100644
--- a/public/viewjs/stockentryform.js
+++ b/public/viewjs/stockentryform.js
@@ -27,7 +27,6 @@
jsonData.location_id = 1;
}
jsonData.price = price;
- jsonData.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
jsonData.open = $("#open").is(":checked");
diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js
index f64e97d0..83915f24 100755
--- a/public/viewjs/stockoverview.js
+++ b/public/viewjs/stockoverview.js
@@ -291,7 +291,6 @@ function RefreshProductRow(productId)
$('#product-' + productId + '-qu-name').text(__n(result.stock_amount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural));
$('#product-' + productId + '-amount').text(result.stock_amount);
$('#product-' + productId + '-consume-all-button').attr('data-consume-amount', result.stock_amount);
- $('#product-' + productId + '-factor-purchase-amount').text(__t('( %s', result.stock_factor_purchase_amount));
$('#product-' + productId + '-value').text(result.stock_value);
$('#product-' + productId + '-next-best-before-date').text(result.next_best_before_date);
$('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date);
diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js
index e80b0596..30821ebc 100644
--- a/public/viewjs/transfer.js
+++ b/public/viewjs/transfer.js
@@ -33,7 +33,6 @@
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
- jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
diff --git a/routes.php b/routes.php
index 6334a857..abcbddf9 100644
--- a/routes.php
+++ b/routes.php
@@ -203,7 +203,6 @@ $app->group('/api', function (RouteCollectorProxy $group) {
$group->get('/stock/transactions/{transactionId}', '\Grocy\Controllers\StockApiController:StockTransactions');
$group->post('/stock/transactions/{transactionId}/undo', '\Grocy\Controllers\StockApiController:UndoTransaction');
$group->get('/stock/barcodes/external-lookup/{barcode}', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
- $group->get('/productbarcodedetails/{barcode}', '\Grocy\Controllers\StockApiController:ProductBarcodeDetails');
$group->get('/stock/journal', '\Grocy\Controllers\StockApiController:Journal');
$group->get('/stock/journal/summary', '\Grocy\Controllers\StockApiController:JournalSummary');
}
diff --git a/services/DemoDataGeneratorService.php b/services/DemoDataGeneratorService.php
index fb72b00e..f9fb3914 100644
--- a/services/DemoDataGeneratorService.php
+++ b/services/DemoDataGeneratorService.php
@@ -185,80 +185,80 @@ class DemoDataGeneratorService extends BaseService
$stockTransactionId = uniqid();
$stockService = new StockService();
- $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 10, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 10, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 10, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 10, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 10, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(21, 1500, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(21, 2500, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(23, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(23, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(24, 2, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(25, 2, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
- $stockService->AddProduct(2, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), 1.0, null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(3, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(4, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(5, 1, date('Y-m-d', strtotime('+20 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(6, 1, date('Y-m-d', strtotime('+600 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(7, 1, date('Y-m-d', strtotime('+800 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(8, 1, date('Y-m-d', strtotime('+900 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(9, 1, date('Y-m-d', strtotime('+14 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(10, 1, date('Y-m-d', strtotime('+21 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(11, 1, date('Y-m-d', strtotime('+10 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(12, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(13, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(14, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-30 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(15, 1, date('Y-m-d', strtotime('-2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(21, 1500, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(21, 2500, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(22, 1, date('Y-m-d', strtotime('+200 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-20 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(23, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-40 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(23, 1, date('Y-m-d', strtotime('+2 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-50 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(24, 2, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(25, 2, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
+ $stockService->AddProduct(2, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime('-10 days')), $this->RandomPrice(), null, $this->NextSupermarketId(), $stockTransactionId);
$stockService->AddMissingProductsToShoppingList();
$stockService->OpenProduct(3, 1);
$stockService->OpenProduct(6, 1);
diff --git a/services/StockService.php b/services/StockService.php
index 156fb9f7..94a50c77 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -79,7 +79,7 @@ class StockService extends BaseService
}
}
- public function AddProduct(int $productId, float $amount, $bestBeforeDate, $transactionType, $purchasedDate, $price, $quFactorPurchaseToStock = null, $locationId = null, $shoppingLocationId = null, &$transactionId = null)
+ public function AddProduct(int $productId, float $amount, $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId = null, $shoppingLocationId = null, &$transactionId = null)
{
if (!$this->ProductExists($productId))
{
@@ -88,11 +88,6 @@ class StockService extends BaseService
$productDetails = (object) $this->GetProductDetails($productId);
- if ($quFactorPurchaseToStock == null)
- {
- $quFactorPurchaseToStock = $productDetails->product->qu_factor_purchase_to_stock;
- }
-
// Tare weight handling
// The given amount is the new total amount including the container weight (gross)
// The amount to be posted needs to be the given amount - stock amount - tare weight
@@ -144,7 +139,6 @@ class StockService extends BaseService
'location_id' => $locationId,
'transaction_id' => $transactionId,
'shopping_location_id' => $shoppingLocationId,
- 'qu_factor_purchase_to_stock' => $quFactorPurchaseToStock,
'user_id' => GROCY_USER_ID
]);
$logRow->save();
@@ -160,7 +154,6 @@ class StockService extends BaseService
'price' => $price,
'location_id' => $locationId,
'shopping_location_id' => $shoppingLocationId,
- 'qu_factor_purchase_to_stock' => $quFactorPurchaseToStock
]);
$stockRow->save();
@@ -342,7 +335,7 @@ class StockService extends BaseService
}
}
- public function EditStockEntry(int $stockRowId, float $amount, $bestBeforeDate, $locationId, $shoppingLocationId, $price, $open, $purchasedDate, $quFactorPurchaseToStock)
+ public function EditStockEntry(int $stockRowId, float $amount, $bestBeforeDate, $locationId, $shoppingLocationId, $price, $open, $purchasedDate)
{
$stockRow = $this->getDatabase()->stock()->where('id = :1', $stockRowId)->fetch();
@@ -364,7 +357,6 @@ class StockService extends BaseService
'opened_date' => $stockRow->opened_date,
'location_id' => $stockRow->location_id,
'shopping_location_id' => $stockRow->shopping_location_id,
- 'qu_factor_purchase_to_stock' => $stockRow->qu_factor_purchase_to_stock,
'correlation_id' => $correlationId,
'transaction_id' => $transactionId,
'stock_row_id' => $stockRow->id,
@@ -391,7 +383,6 @@ class StockService extends BaseService
'shopping_location_id' => $shoppingLocationId,
'opened_date' => $openedDate,
'open' => $open,
- 'qu_factor_purchase_to_stock' => $quFactorPurchaseToStock,
'purchased_date' => $purchasedDate
]);
@@ -406,7 +397,6 @@ class StockService extends BaseService
'opened_date' => $stockRow->opened_date,
'location_id' => $locationId,
'shopping_location_id' => $shoppingLocationId,
- 'qu_factor_purchase_to_stock' => $stockRow->qu_factor_purchase_to_stock,
'correlation_id' => $correlationId,
'transaction_id' => $transactionId,
'stock_row_id' => $stockRow->id,
@@ -528,7 +518,6 @@ class StockService extends BaseService
{
$stockCurrentRow = new \stdClass();
$stockCurrentRow->amount = 0;
- $stockCurrentRow->factor_purchase_amount = 0;
$stockCurrentRow->value = 0;
$stockCurrentRow->amount_opened = 0;
$stockCurrentRow->amount_aggregated = 0;
@@ -539,7 +528,6 @@ class StockService extends BaseService
$productLastPurchased = $this->getDatabase()->products_last_purchased()->where('product_id', $productId)->fetch();
$lastPurchasedDate = null;
$lastPrice = null;
- $lastQuFactorPurchaseToStock = null;
$lastShoppingLocation = null;
$avgPrice = null;
$oldestPrice = null;
@@ -547,7 +535,6 @@ class StockService extends BaseService
{
$lastPurchasedDate = $productLastPurchased->purchased_date;
$lastPrice = $productLastPurchased->price;
- $lastQuFactorPurchaseToStock = $productLastPurchased->qu_factor_purchase_to_stock;
$lastShoppingLocation = $productLastPurchased->shopping_location_id;
$avgPriceRow = $this->getDatabase()->products_average_price()->where('product_id', $productId)->fetch();
if ($avgPriceRow)
@@ -587,7 +574,6 @@ class StockService extends BaseService
'last_purchased' => $lastPurchasedDate,
'last_used' => $productLastUsed,
'stock_amount' => $stockCurrentRow->amount,
- 'stock_factor_purchase_amount' => $stockCurrentRow->factor_purchase_amount,
'stock_value' => $stockCurrentRow->value,
'stock_amount_opened' => $stockCurrentRow->amount_opened,
'stock_amount_aggregated' => $stockCurrentRow->amount_aggregated,
@@ -595,7 +581,6 @@ class StockService extends BaseService
'quantity_unit_purchase' => $quPurchase,
'quantity_unit_stock' => $quStock,
'last_price' => $lastPrice,
- 'last_qu_factor_purchase_to_stock' => $lastQuFactorPurchaseToStock,
'avg_price' => $avgPrice,
'oldest_price' => $oldestPrice,
'last_shopping_location_id' => $lastShoppingLocation,
@@ -728,7 +713,7 @@ class StockService extends BaseService
$bookingAmount = $newAmount;
}
- return $this->AddProduct($productId, $bookingAmount, $bestBeforeDate, self::TRANSACTION_TYPE_INVENTORY_CORRECTION, $purchasedDate, $price, null, $locationId, $shoppingLocationId);
+ return $this->AddProduct($productId, $bookingAmount, $bestBeforeDate, self::TRANSACTION_TYPE_INVENTORY_CORRECTION, $purchasedDate, $price, $locationId, $shoppingLocationId);
}
elseif ($newAmount < $productDetails->stock_amount + $containerWeight)
{
@@ -964,7 +949,8 @@ class StockService extends BaseService
$correlationId = uniqid();
if ($amount >= $stockEntry->amount)
- { // Take the whole stock entry
+ {
+ // Take the whole stock entry
$logRowForLocationFrom = $this->getDatabase()->stock_log()->createRow([
'product_id' => $stockEntry->product_id,
'amount' => $stockEntry->amount * -1,
@@ -973,7 +959,6 @@ class StockService extends BaseService
'stock_id' => $stockEntry->stock_id,
'transaction_type' => self::TRANSACTION_TYPE_TRANSFER_FROM,
'price' => $stockEntry->price,
- 'qu_factor_purchase_to_stock' => $stockEntry->qu_factor_purchase_to_stock,
'opened_date' => $stockEntry->opened_date,
'location_id' => $stockEntry->location_id,
'correlation_id' => $correlationId,
@@ -990,7 +975,6 @@ class StockService extends BaseService
'stock_id' => $stockEntry->stock_id,
'transaction_type' => self::TRANSACTION_TYPE_TRANSFER_TO,
'price' => $stockEntry->price,
- 'qu_factor_purchase_to_stock' => $stockEntry->qu_factor_purchase_to_stock,
'opened_date' => $stockEntry->opened_date,
'location_id' => $locationIdTo,
'correlation_id' => $correlationId,
@@ -1018,7 +1002,6 @@ class StockService extends BaseService
'stock_id' => $stockEntry->stock_id,
'transaction_type' => self::TRANSACTION_TYPE_TRANSFER_FROM,
'price' => $stockEntry->price,
- 'qu_factor_purchase_to_stock' => $stockEntry->qu_factor_purchase_to_stock,
'opened_date' => $stockEntry->opened_date,
'location_id' => $stockEntry->location_id,
'correlation_id' => $correlationId,
@@ -1035,7 +1018,6 @@ class StockService extends BaseService
'stock_id' => $stockEntry->stock_id,
'transaction_type' => self::TRANSACTION_TYPE_TRANSFER_TO,
'price' => $stockEntry->price,
- 'qu_factor_purchase_to_stock' => $stockEntry->qu_factor_purchase_to_stock,
'opened_date' => $stockEntry->opened_date,
'location_id' => $locationIdTo,
'correlation_id' => $correlationId,
@@ -1056,7 +1038,6 @@ class StockService extends BaseService
'best_before_date' => $newBestBeforeDate,
'purchased_date' => $stockEntry->purchased_date,
'stock_id' => $stockEntry->stock_id,
- 'qu_factor_purchase_to_stock' => $stockEntry->qu_factor_purchase_to_stock,
'price' => $stockEntry->price,
'location_id' => $locationIdTo,
'open' => $stockEntry->open,
@@ -1237,7 +1218,6 @@ class StockService extends BaseService
'best_before_date' => $logRow->best_before_date,
'purchased_date' => $logRow->purchased_date,
'price' => $logRow->price,
- 'qu_factor_purchase_to_stock' => $logRow->qu_factor_purchase_to_stock,
'location_id' => $logRow->location_id,
'open' => $open,
'opened_date' => $openedDate
diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php
index 871d0b3d..1d178072 100644
--- a/views/batteriesoverview.blade.php
+++ b/views/batteriesoverview.blade.php
@@ -37,14 +37,14 @@
data-status-filter="overdue"
class="error-message status-filter-message responsive-button">
-
{{ $__t('Clear filter') }}
diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php
index a8d85fe4..6d03bca8 100644
--- a/views/choresoverview.blade.php
+++ b/views/choresoverview.blade.php
@@ -42,14 +42,14 @@
class="normal-message user-filter-message responsive-button">
@endif
-
{{ $__t('Clear filter') }}
diff --git a/views/components/numberpicker.blade.php b/views/components/numberpicker.blade.php
index b98968a8..48d523c6 100644
--- a/views/components/numberpicker.blade.php
+++ b/views/components/numberpicker.blade.php
@@ -15,6 +15,7 @@
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
@php if(!isset($noNameAttribute)) { $noNameAttribute = false; } @endphp
+@php if(empty($contextInfoId)) { $additionalHtmlContextHelp = ''; } @endphp