mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 21:26:16 +02:00
Round value and factor_purchas_amount. Include currency for stock value
This commit is contained in:
parent
43ada96ba9
commit
9ec1d308ae
|
|
@ -25,7 +25,7 @@ SELECT
|
||||||
IFNULL(s.location_id, p.location_id) AS location_id,
|
IFNULL(s.location_id, p.location_id) AS location_id,
|
||||||
s.product_id,
|
s.product_id,
|
||||||
SUM(s.amount) AS amount,
|
SUM(s.amount) AS amount,
|
||||||
SUM(s.amount / s.qu_factor_purchase_to_stock) as factor_purchase_amount,
|
ROUND(SUM(s.amount / s.qu_factor_purchase_to_stock),2) as factor_purchase_amount,
|
||||||
ROUND(SUM(IFNULL(s.price, 0) * (s.amount / s.qu_factor_purchase_to_stock)),2) AS value,
|
ROUND(SUM(IFNULL(s.price, 0) * (s.amount / s.qu_factor_purchase_to_stock)),2) AS value,
|
||||||
MIN(s.best_before_date) AS best_before_date,
|
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
|
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
|
||||||
|
|
@ -40,9 +40,9 @@ AS
|
||||||
SELECT
|
SELECT
|
||||||
pr.parent_product_id AS product_id,
|
pr.parent_product_id AS product_id,
|
||||||
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id), 0) AS amount,
|
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id), 0) AS amount,
|
||||||
IFNULL((SELECT SUM(amount / qu_factor_purchase_to_stock) FROM stock WHERE product_id = pr.parent_product_id), 0) as factor_purchase_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,
|
SUM(s.amount) * IFNULL(qucr.factor, 1) AS amount_aggregated,
|
||||||
IFNULL((SELECT SUM(IFNULL(price,0) * (amount / qu_factor_purchase_to_stock)) FROM stock WHERE product_id = pr.parent_product_id), 0) AS value,
|
IFNULL(ROUND((SELECT SUM(IFNULL(price,0) * (amount / qu_factor_purchase_to_stock)) FROM stock WHERE product_id = pr.parent_product_id),2), 0) AS value,
|
||||||
MIN(s.best_before_date) AS best_before_date,
|
MIN(s.best_before_date) AS best_before_date,
|
||||||
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id AND open = 1), 0) AS amount_opened,
|
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = pr.parent_product_id AND open = 1), 0) AS amount_opened,
|
||||||
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id IN (SELECT sub_product_id FROM products_resolved WHERE parent_product_id = pr.parent_product_id) AND open = 1), 0) * IFNULL(qucr.factor, 1) AS amount_opened_aggregated,
|
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id IN (SELECT sub_product_id FROM products_resolved WHERE parent_product_id = pr.parent_product_id) AND open = 1), 0) * IFNULL(qucr.factor, 1) AS amount_opened_aggregated,
|
||||||
|
|
@ -67,9 +67,9 @@ UNION
|
||||||
SELECT
|
SELECT
|
||||||
pr.sub_product_id AS product_id,
|
pr.sub_product_id AS product_id,
|
||||||
SUM(s.amount) AS amount,
|
SUM(s.amount) AS amount,
|
||||||
SUM(s.amount / s.qu_factor_purchase_to_stock) as factor_purchase_amount,
|
ROUND(SUM(s.amount / s.qu_factor_purchase_to_stock),2) as factor_purchase_amount,
|
||||||
SUM(s.amount) AS amount_aggregated,
|
SUM(s.amount) AS amount_aggregated,
|
||||||
SUM(IFNULL(s.price, 0) * (s.amount / s.qu_factor_purchase_to_stock)) AS value,
|
ROUND(SUM(IFNULL(s.price, 0) * (s.amount / s.qu_factor_purchase_to_stock)),2) AS value,
|
||||||
MIN(s.best_before_date) AS best_before_date,
|
MIN(s.best_before_date) AS best_before_date,
|
||||||
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND open = 1), 0) AS amount_opened,
|
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND open = 1), 0) AS amount_opened,
|
||||||
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND open = 1), 0) AS amount_opened_aggregated,
|
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND open = 1), 0) AS amount_opened_aggregated,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||||
$('#productcard-product-description').html(productDetails.product.description);
|
$('#productcard-product-description').html(productDetails.product.description);
|
||||||
$('#productcard-product-stock-amount').text(stockAmount);
|
$('#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));
|
$('#productcard-product-stock-qu-name').text(__n(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural));
|
||||||
$('#productcard-product-stock-value').text(stockValue);
|
$('#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').text((productDetails.last_purchased || '2999-12-31').substring(0, 10));
|
||||||
$('#productcard-product-last-purchased-timeago').attr("datetime", productDetails.last_purchased || '2999-12-31');
|
$('#productcard-product-last-purchased-timeago').attr("datetime", productDetails.last_purchased || '2999-12-31');
|
||||||
$('#productcard-product-last-used').text((productDetails.last_used || '2999-12-31').substring(0, 10));
|
$('#productcard-product-last-used').text((productDetails.last_used || '2999-12-31').substring(0, 10));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user