Difference between revisions of "VbzCart/queries/qryRstkItms expected"
Jump to navigation
Jump to search
(New page: ==Details== * '''Returns''': Restock items requested, not yet received, but possibly expected because the restock request hasn't been closed or orphaned. * '''Requires''': {{vbzcart/table|...) |
(discarded) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==About== |
− | * '''Returns''': Restock items requested, not yet received, but possibly expected because the restock request hasn't been closed or | + | * '''Returns''': Restock items requested (ordered), not yet received, but possibly expected because the restock request hasn't been terminated (closed, orphaned, or killed). |
* '''Requires''': {{vbzcart/table|rstk_rcd_line}}, {{vbzcart/table|rstk_rcd}}, {{vbzcart/query|qryRstkItms_active}} | * '''Requires''': {{vbzcart/table|rstk_rcd_line}}, {{vbzcart/table|rstk_rcd}}, {{vbzcart/query|qryRstkItms_active}} | ||
+ | * '''Used by''': {{vbzcart/query|qryRstkItms_expected_byItem}} | ||
+ | * '''Algorithm''': any positive quantities in '''<'''{{vbzcart/query|qryRstkItms_active|<all items in <active restock requests>>}} - <{{vbzcart|table|rstk_rcd_line|items received}} on those item requests>'''>''' | ||
* '''History''': | * '''History''': | ||
** '''2008-11-19''' Created for new restock process | ** '''2008-11-19''' Created for new restock process | ||
** '''2008-11-24''' '''QtyRecd''' falls back on '''QtyFiled''' if null | ** '''2008-11-24''' '''QtyRecd''' falls back on '''QtyFiled''' if null | ||
+ | ** '''2008-12-04''' renamed: qryRstkItms_en_route → qryRstkItms_expected | ||
+ | ** '''2010-01-03''' fixed syntax: have to recalculate aggregate functions to use them in a HAVING clause (bleh) | ||
+ | ** '''2010-01-04''' updated to use QtyExp instead of QtyOrd (field renamed/changed in {{vbzcart/query|qryRstkItms_active}}) | ||
+ | ** '''2016-03-02''' Query no longer works; removing from database. | ||
==SQL== | ==SQL== | ||
− | + | <mysql>CREATE OR REPLACE VIEW qryRstkItms_expected AS | |
SELECT | SELECT | ||
rqi.ID_Restock, | rqi.ID_Restock, | ||
rqi.ID_Item, | rqi.ID_Item, | ||
− | SUM(rqi. | + | SUM(rqi.QtyExp) AS QtyExp, |
SUM(IFNULL(rcl.QtyRecd,rcl.QtyFiled)) AS QtyRecd | SUM(IFNULL(rcl.QtyRecd,rcl.QtyFiled)) AS QtyRecd | ||
FROM | FROM | ||
Line 17: | Line 23: | ||
LEFT JOIN qryRstkItms_active AS rqi ON (rc.ID_Restock=rqi.ID_Restock) AND (rcl.ID_Item=rqi.ID_Item) | LEFT JOIN qryRstkItms_active AS rqi ON (rc.ID_Restock=rqi.ID_Restock) AND (rcl.ID_Item=rqi.ID_Item) | ||
GROUP BY rqi.ID_Restock, rqi.ID_Item | GROUP BY rqi.ID_Restock, rqi.ID_Item | ||
− | HAVING | + | HAVING (SUM(rqi.QtyExp)-SUM(IFNULL(rcl.QtyRecd,rcl.QtyFiled)))>0;</mysql> |
− |
Latest revision as of 22:56, 2 March 2016
About
- Returns: Restock items requested (ordered), not yet received, but possibly expected because the restock request hasn't been terminated (closed, orphaned, or killed).
- Requires:
- REDIRECT Template:l/vc/table, rstk_rcd,
- REDIRECT Template:l/vc/query
- Used by: qryRstkItms_expected_byItem
- Algorithm: any positive quantities in <<all items in <active restock requests>> - <items received on those item requests>>
- History:
- 2008-11-19 Created for new restock process
- 2008-11-24 QtyRecd falls back on QtyFiled if null
- 2008-12-04 renamed: qryRstkItms_en_route → qryRstkItms_expected
- 2010-01-03 fixed syntax: have to recalculate aggregate functions to use them in a HAVING clause (bleh)
- 2010-01-04 updated to use QtyExp instead of QtyOrd (field renamed/changed in qryRstkItms_active)
- 2016-03-02 Query no longer works; removing from database.
SQL
<mysql>CREATE OR REPLACE VIEW qryRstkItms_expected AS SELECT
rqi.ID_Restock, rqi.ID_Item, SUM(rqi.QtyExp) AS QtyExp, SUM(IFNULL(rcl.QtyRecd,rcl.QtyFiled)) AS QtyRecd
FROM
(rstk_rcd_line AS rcl LEFT JOIN rstk_rcd AS rc ON rcl.ID_RstkRcd=rc.ID) LEFT JOIN qryRstkItms_active AS rqi ON (rc.ID_Restock=rqi.ID_Restock) AND (rcl.ID_Item=rqi.ID_Item)
GROUP BY rqi.ID_Restock, rqi.ID_Item HAVING (SUM(rqi.QtyExp)-SUM(IFNULL(rcl.QtyRecd,rcl.QtyFiled)))>0;</mysql>