<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://htyp.org/mw/index.php?action=history&amp;feed=atom&amp;title=VbzCart%2Fqueries%2FqryItms_to_restock</id>
	<title>VbzCart/queries/qryItms to restock - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://htyp.org/mw/index.php?action=history&amp;feed=atom&amp;title=VbzCart%2Fqueries%2FqryItms_to_restock"/>
	<link rel="alternate" type="text/html" href="https://htyp.org/mw/index.php?title=VbzCart/queries/qryItms_to_restock&amp;action=history"/>
	<updated>2026-07-08T03:32:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://htyp.org/mw/index.php?title=VbzCart/queries/qryItms_to_restock&amp;diff=10920&amp;oldid=prev</id>
		<title>Woozle: New page: ==Details== * &#039;&#039;&#039;Returns&#039;&#039;&#039;: List of items where we need more of them, either to fill orders or to meet minimum stock levels. Accounts for restock items already requested and items current...</title>
		<link rel="alternate" type="text/html" href="https://htyp.org/mw/index.php?title=VbzCart/queries/qryItms_to_restock&amp;diff=10920&amp;oldid=prev"/>
		<updated>2008-12-03T21:30:10Z</updated>

		<summary type="html">&lt;p&gt;New page: ==Details== * &amp;#039;&amp;#039;&amp;#039;Returns&amp;#039;&amp;#039;&amp;#039;: List of items where we need more of them, either to fill orders or to meet minimum stock levels. Accounts for restock items already requested and items current...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Details==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Returns&amp;#039;&amp;#039;&amp;#039;: List of items where we need more of them, either to fill orders or to meet minimum stock levels. Accounts for restock items already requested and items currently in stock.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Requires&amp;#039;&amp;#039;&amp;#039;: {{vbzcart/query|qryItms_to_restock_union}}&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Used by&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;History&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;2008-11-18&amp;#039;&amp;#039;&amp;#039; created for new restocking process&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;2008-11-19&amp;#039;&amp;#039;&amp;#039; added additional fields from revised union query&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;2008-11-22&amp;#039;&amp;#039;&amp;#039; various quantities need to be SUMmed, else we got the wrong answer (probably just the first matching row)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Notes&amp;#039;&amp;#039;&amp;#039;: It might be a good diagnostic to run this query without the final &amp;quot;HAVING&amp;quot; clause (or with QtyToGet&amp;lt;0) and look for anything that doesn&amp;#039;t make sense. Hopefully most of the negative numbers are overstocked items and unclosed restock requests (they should be closed).&lt;br /&gt;
==SQL==&lt;br /&gt;
&amp;lt;section begin=sql /&amp;gt;&amp;lt;mysql&amp;gt;CREATE OR REPLACE VIEW qryItms_to_restock AS&lt;br /&gt;
SELECT&lt;br /&gt;
  ID_Item,&lt;br /&gt;
  COUNT(ID_Item) AS DupCount,&lt;br /&gt;
  SUM(iru.QtyOpen) AS QtyOpen,&lt;br /&gt;
  SUM(iru.QtyForSale) AS QtyForSale,&lt;br /&gt;
  SUM(iru.QtyMin_Stk) AS QtyMin_Stk,&lt;br /&gt;
  SUM(iru.QtyOnOrder) AS QtyOnOrder,&lt;br /&gt;
  SUM(IFNULL(QtyOpen,0))&lt;br /&gt;
    -SUM(IFNULL(QtyForSale,0))&lt;br /&gt;
    +SUM(IFNULL(QtyMin_Stk,0))&lt;br /&gt;
    -SUM(IFNULL(QtyOnOrder,0))&lt;br /&gt;
    AS QtyToGet&lt;br /&gt;
FROM qryItms_to_restock_union AS iru&lt;br /&gt;
GROUP BY ID_Item&lt;br /&gt;
HAVING QtyToGet&amp;gt;0;&amp;lt;/mysql&amp;gt;&lt;br /&gt;
&amp;lt;section end=sql /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Woozle</name></author>
	</entry>
</feed>