This commit is contained in:
@@ -879,8 +879,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
await ExecQueryAsync("CREATE VIEW vpartsonorder AS SELECT partid, partwarehouseid, SUM((COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0))) AS quantityonorder "
|
await ExecQueryAsync("CREATE VIEW vpartsonorder AS SELECT partid, partwarehouseid, SUM((COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0))) AS quantityonorder "
|
||||||
+ "FROM apurchaseorderitem WHERE (COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0)) > 0 GROUP BY partid, partwarehouseid");
|
+ "FROM apurchaseorderitem WHERE (COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0)) > 0 GROUP BY partid, partwarehouseid");
|
||||||
|
|
||||||
//VRESTOCKREQUIRED
|
//VRESTOCKREQUIRED (used by PO indirectly through a keyless model in dbset)
|
||||||
//NOTE: THIS IS SO FAR AS I CAN TELL NOT USED ANYWHERE AT ALL SO FAR....
|
|
||||||
await ExecQueryAsync("CREATE VIEW viewrestockrequired AS SELECT apart.id AS partid, apartwarehouse.id AS partwarehouseid, apart.partnumber, apartwarehouse.name AS displaywarehouse, "
|
await ExecQueryAsync("CREATE VIEW viewrestockrequired AS SELECT apart.id AS partid, apartwarehouse.id AS partwarehouseid, apart.partnumber, apartwarehouse.name AS displaywarehouse, "
|
||||||
+ "amanufacturer.id AS manufacturerid, amanufacturer.name AS displaymanufacturer, awholesaler.id AS wholesalerid, awholesaler.name AS displaywholesaler, "
|
+ "amanufacturer.id AS manufacturerid, amanufacturer.name AS displaymanufacturer, awholesaler.id AS wholesalerid, awholesaler.name AS displaywholesaler, "
|
||||||
+ "aalternativewholesaler.id AS alternativewholesalerid, aalternativewholesaler.name AS displayalternativewholesaler,"
|
+ "aalternativewholesaler.id AS alternativewholesalerid, aalternativewholesaler.name AS displayalternativewholesaler,"
|
||||||
@@ -897,10 +896,27 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
|
|
||||||
//VPARTINVENTORYLIST
|
//VPARTINVENTORYLIST
|
||||||
await ExecQueryAsync("CREATE VIEW vpartinventorylist AS select vpartinventorynow.*, vpartsonordercommitted.quantityonordercommitted, vpartsonorder.quantityonorder from vpartinventorynow "
|
await ExecQueryAsync("CREATE VIEW vpartinventorylist AS select vpartinventorynow.*, vpartsonordercommitted.quantityonordercommitted, vpartsonorder.quantityonorder from vpartinventorynow "
|
||||||
+ "left outer join vpartsonordercommitted on (vpartinventorynow.partid = vpartsonordercommitted.partid and vpartinventorynow.partwarehouseid = vpartsonordercommitted.partwarehouseid)"
|
+ "left join vpartsonordercommitted on (vpartinventorynow.partid = vpartsonordercommitted.partid and vpartinventorynow.partwarehouseid = vpartsonordercommitted.partwarehouseid)"
|
||||||
+ "left outer join vpartsonorder on (vpartinventorynow.partid = vpartsonorder.partid and vpartinventorynow.partwarehouseid = vpartsonorder.partwarehouseid)");
|
+ "left join vpartsonorder on (vpartinventorynow.partid = vpartsonorder.partid and vpartinventorynow.partwarehouseid = vpartsonorder.partwarehouseid)");
|
||||||
|
|
||||||
|
//TODO: make this a view and *it* should be named vpartinventorylist ideally
|
||||||
|
//so either incorporate or rename the existing vpartinventorylist to fit in here
|
||||||
|
//existing vpartinventorylist only used by partinventorydatalist so... :)
|
||||||
|
|
||||||
|
|
||||||
|
// select apart.partnumber,apartwarehouse.name,vpartinventorylist.balance,vpartinventorylist.quantityonorder,vpartinventorylist.quantityonordercommitted,apart.name,
|
||||||
|
// apart.active, apart.cost, apartstocklevel.minimumquantity,apart.retail, aws.name, aaws.name,
|
||||||
|
// GREATEST(
|
||||||
|
// COALESCE(apartstocklevel.minimumquantity, 0) -
|
||||||
|
// (COALESCE(vpartinventorylist.balance, 0) + COALESCE(vpartinventorylist.quantityonorder, 0) - COALESCE(vpartinventorylist.quantityonordercommitted, 0))
|
||||||
|
// ,0)
|
||||||
|
// AS reorderquantity
|
||||||
|
// from vpartinventorylist
|
||||||
|
// LEFT JOIN apart ON (vpartinventorylist.partid = apart.id)
|
||||||
|
// LEFT JOIN apartwarehouse ON (vpartinventorylist.partwarehouseid = apartwarehouse.id)
|
||||||
|
// left join avendor AS aws on (apart.wholesalerid = aws.id)
|
||||||
|
// left join avendor AS aaws on (apart.alternativewholesalerid = aaws.id)
|
||||||
|
// left join apartstocklevel on (apartstocklevel.partid = apart.id AND apartstocklevel.partwarehouseid = vpartinventorylist.partwarehouseid)
|
||||||
|
|
||||||
//----------
|
//----------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user