Added a dialog to show product related resolved QU conversions (references #2056 and #1360)

This commit is contained in:
Bernd Bestel
2022-12-04 19:02:15 +01:00
parent d889e9d3ad
commit 50fac692ad
8 changed files with 368 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
DROP VIEW quantity_unit_conversions_resolved;
CREATE VIEW quantity_unit_conversions_resolved
AS
@@ -127,7 +126,7 @@ AS (
ON s.to_qu_id = c.from_qu_id
AND s.product_id IS NULL
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id) -- Do this only, if there is no product_specific conversion between the units in s
AND c.path NOT LIKE ('%/' || s.from_qu_id || '/%')
AND c.path NOT LIKE ('%/' || s.from_qu_id || '/%')
UNION
@@ -144,13 +143,13 @@ AS (
ON c.to_qu_id = s.from_qu_id
AND s.product_id IS NULL
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id) -- Do this only, if there is no product_specific conversion between the units in s
AND c.path NOT LIKE ('%/' || s.to_qu_id || '/%')
AND c.path NOT LIKE ('%/' || s.to_qu_id || '/%')
UNION
-- Fourth case: Add the default unit conversions that are reachable by a given product.
-- We cannot start with them directly, as we only want to add default conversions,
-- where at least one of the units is 'reachable' from the product's storage quantity unit.
-- where at least one of the units is 'reachable' from the product's stock quantity unit.
-- Thus we add these cases here.
SELECT DISTINCT
1, c.product_id,
@@ -159,7 +158,7 @@ AS (
s.factor
FROM closure c, conversion_factors s
WHERE NOT EXISTS(SELECT 1 FROM conversion_factors ci WHERE ci.product_id = c.product_id AND ci.from_qu_id = s.from_qu_id AND ci.to_qu_id = s.to_qu_id)
AND c.path LIKE ('%/' || s.from_qu_id || '/' || s.to_qu_id || '/%')
AND c.path LIKE ('%/' || s.from_qu_id || '/' || s.to_qu_id || '/%')
)
SELECT DISTINCT