Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue #20988:require reservation to issue #111

Merged
merged 1 commit into from

2 participants

@garyhgohoos
Collaborator

No description provided.

@gpazo gpazo merged commit 5397b4b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 21, 2014
  1. @garyhgohoos
This page is out of date. Refresh to see the latest.
View
20 dbscripts/functions/issueallbalancetoshipping.sql
@@ -19,13 +19,10 @@ DECLARE
BEGIN
IF (pordertype = 'SO') THEN
FOR _s IN SELECT coitem_id,
- noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned -
- ( SELECT COALESCE(SUM(shipitem_qty), 0)
- FROM shipitem, shiphead
- WHERE ( (shipitem_orderitem_id=coitem_id)
- AND (shipitem_shiphead_id=shiphead_id)
- AND (NOT shiphead_shipped)
- AND (shiphead_order_type=pordertype) ) ) ) AS balance
+ CASE WHEN (fetchMetricBool('RequireSOReservations'))
+ THEN coitem_qtyreserved
+ ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) )
+ END AS _balance
FROM coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)
WHERE ( (coitem_status NOT IN ('C','X'))
AND (item_type != 'K')
@@ -41,13 +38,8 @@ BEGIN
ELSEIF (pordertype = 'TO') THEN
FOR _s IN SELECT toitem_id,
- noNeg( toitem_qty_ordered - toitem_qty_shipped -
- ( SELECT COALESCE(SUM(shipitem_qty), 0)
- FROM shipitem, shiphead
- WHERE ( (shipitem_orderitem_id=toitem_id)
- AND (shipitem_shiphead_id=shiphead_id)
- AND (NOT shiphead_shipped)
- AND (shiphead_order_type=pordertype) ) ) ) AS balance
+ noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) )
+ AS balance
FROM toitem
WHERE ( (toitem_status NOT IN ('C','X'))
AND (toitem_tohead_id=pheadid) ) LOOP
View
18 dbscripts/functions/issuelinebalancetoshipping.sql
@@ -30,21 +30,15 @@ BEGIN
_itemlocSeries := COALESCE(pitemlocseries,0);
IF (pordertype = 'SO') THEN
- SELECT noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned -
- ( SELECT COALESCE(SUM(shipitem_qty), 0)
- FROM shipitem, shiphead
- WHERE ((shipitem_orderitem_id=coitem_id)
- AND (shipitem_shiphead_id=shiphead_id)
- AND (NOT shiphead_shipped) ) ) ) INTO _qty
+ SELECT CASE WHEN (fetchMetricBool('RequireSOReservations'))
+ THEN coitem_qtyreserved
+ ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) )
+ END INTO _qty
FROM coitem
WHERE (coitem_id=pitemid);
ELSEIF (pordertype = 'TO') THEN
- SELECT noNeg( toitem_qty_ordered - toitem_qty_shipped -
- ( SELECT COALESCE(SUM(shipitem_qty), 0)
- FROM shipitem, shiphead
- WHERE ( (shipitem_orderitem_id=toitem_id)
- AND (shipitem_shiphead_id=shiphead_id)
- AND (NOT shiphead_shipped) ) ) ) INTO _qty
+ SELECT noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) )
+ INTO _qty
FROM toitem
WHERE (toitem_id=pitemid);
ELSE
View
28 dbscripts/functions/sufficientinventorytoshipitem.sql
@@ -14,11 +14,11 @@ CREATE OR REPLACE FUNCTION sufficientInventoryToShipItem(TEXT, INTEGER, NUMERIC)
-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
-- See www.xtuple.com/CPAL for the full text of the software license.
DECLARE
- pordertype ALIAS FOR $1;
- porderitemid ALIAS FOR $2;
- pqty ALIAS FOR $3;
- _returnVal INTEGER;
- _isqtyavail BOOLEAN;
+ pordertype ALIAS FOR $1;
+ porderitemid ALIAS FOR $2;
+ pqty ALIAS FOR $3;
+ _returnVal INTEGER;
+ _isqtyavail BOOLEAN;
BEGIN
IF (porderitemid IS NULL) THEN
@@ -32,6 +32,7 @@ BEGIN
WHERE (coitem_id=porderitemid)) THEN
RETURN 0;
END IF;
+
SELECT (((COALESCE(pqty, roundQty(item_fractional,
noNeg(coitem_qtyord - coitem_qtyshipped +
coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id)
@@ -125,6 +126,23 @@ BEGIN
RETURN -3;
END IF;
+ IF (pordertype = 'SO') THEN
+ IF ( SELECT fetchMetricBool('RequireSOReservations') ) THEN
+ SELECT (COALESCE(pqty, coitem_qtyreserved) <= coitem_qtyreserved)
+ INTO _isqtyavail
+ FROM coitem, itemsite, item
+ WHERE ((coitem_itemsite_id=itemsite_id)
+ AND (coitem_status <> 'X')
+ AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N')))
+ AND (itemsite_item_id=item_id)
+ AND (coitem_id=porderitemid));
+ END IF;
+ END IF;
+
+ IF (NOT _isqtyavail) THEN
+ RETURN -4;
+ END IF;
+
RETURN 0;
END;
$$ LANGUAGE 'plpgsql';
View
28 dbscripts/metasql/issueToShipping-detail.mql
@@ -70,6 +70,34 @@ FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
JOIN itemloc ON (itemloc_id=reserve_supply_id)
WHERE ( (coitem_status NOT IN ('C','X'))
AND (item_type != 'K')
+ AND (itemsite_controlmethod IN ('L', 'S'))
+<? if exists("warehous_id") ?>
+ AND (itemsite_warehous_id=<? value("warehous_id") ?>)
+<? endif ?>
+ AND (coitem_cohead_id=<? value("sohead_id") ?>) )
+UNION ALL
+SELECT coitem_id AS lineitem_id,
+ CASE WHEN (itemsite_costmethod = 'J') THEN 1
+ ELSE 0
+ END AS job, 1 AS indent,
+ '' AS shiphead_number,
+ '' AS linenumber, 'N/A',
+ 'N/A' AS itemdescrip,
+ '' AS warehous_code,
+ NULL AS scheddate,
+ '' AS uom_name,
+ coitem_qtyreserved AS qtyord,
+ NULL AS qtyshipped,
+ NULL AS qtyreturned,
+ NULL AS atshipping,
+ coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3
+FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
+ JOIN item ON (item_id=itemsite_item_id)
+ JOIN site() ON (warehous_id=itemsite_warehous_id)
+WHERE ( (coitem_status NOT IN ('C','X'))
+ AND (item_type != 'K')
+ AND (itemsite_controlmethod = 'R')
+ AND (coitem_qtyreserved > 0.0)
<? if exists("warehous_id") ?>
AND (itemsite_warehous_id=<? value("warehous_id") ?>)
<? endif ?>
Something went wrong with that request. Please try again.