How POS system manage Stock Quantity

To manage Stock in the POS System, We can build a View with the following Tables :

  1. Products
  2. Purchase Details
  3. Sell Details
  4. Purchase Return Details
  5. Sell Return Details
  6. Damage
View :

CREATE OR REPLACE VIEW V_STOCK AS
SELECT A.PRODUCT_ID,
 NVL(A.STOCK,0)
+NVL(B.QTY,0)
-NVL(C.QTY,0)
-NVL(D.QTY,0)
+NVL(E.QTY,0)
-NVL(F.QTY,0) CSTOCK
FROM
(SELECT PRODUCT_ID,STOCK FROM PRODUCTS) A,
(SELECT PRODUCT,SUM(QTY) QTY FROM PURCHASE_DETAILS GROUP BY PRODUCT) B,
(SELECT PRODUCT,SUM(QTY) QTY FROM SALES_DETAILS GROUP BY PRODUCT) C,
(SELECT PRODUCT,SUM(QTY) QTY FROM PURCHASE_RETURN_DETAILS GROUP BY PRODUCT) D,
(SELECT PRODUCT,SUM(QTY) QTY FROM SALES_RETURN_DETAILS GROUP BY PRODUCT) E,
(SELECT PRODUCT,SUM(QTY) QTY FROM DAMAGE GROUP BY PRODUCT) F
WHERE A.PRODUCT_ID=B.PRODUCT(+)
AND   A.PRODUCT_ID=C.PRODUCT(+)
AND   A.PRODUCT_ID=D.PRODUCT(+)
AND   A.PRODUCT_ID=E.PRODUCT(+)
AND   A.PRODUCT_ID=F.PRODUCT(+);

You can create a LOV with the following Query in Oracle Forms and Apex:

SELECT A.PRODUCT_ID ,A.PRODUCT_CODE ,A.PRODUCT_NAME ,A.CATEGORIES ,A.SUB_CATEGORIES ,A.UNIT_TYPE ,A.BRAND
      ,A.STOCK ,A.BUY_PRICE ,A.SELL_PRICE ,A.ENTRY_BY ,A.ENTRY_DATE ,A.UPDATE_BY ,A.UPDATE_DATE,B.CSTOCK
FROM
(SELECT PRODUCT_ID ,PRODUCT_CODE ,PRODUCT_NAME ,CATEGORIES ,SUB_CATEGORIES ,UNIT_TYPE ,BRAND
      ,STOCK ,BUY_PRICE ,SELL_PRICE ,ENTRY_BY ,ENTRY_DATE ,UPDATE_BY ,UPDATE_DATE
FROM PRODUCTS) A,
(SELECT PRODUCT_ID,CSTOCK FROM V_STOCK) B
WHERE A.PRODUCT_ID=B.PRODUCT_ID;

You can create report with the above query also.

Video and Script Link



Muhammad Abdullah Al Noor

Muhammad Abdullah Al Noor, An Oracle Apex Consultants and founder of Noors Technology (www.noorstech.com). Core Expertise : Database Administration, Oracle Forms and Reports Development, Oracle Apex Application Designer and Development, Linux Professional etc. Also the owner of TrainerBD Training and OraDemy E-Learning. WhatsApp +8801790721177

Post a Comment

Previous Post Next Post