FIFO - Fill Ratio calculation Purchase order vs GRN
Hi,
I am trying to load purchase order schedules and correspoding Grn (goods receipt note) tables,
Following are the table data
Purchase Order Table
PO NO
PODATE
QTY
SCHEDULE DATE
4400062680
2012-07-05
5750
10-Aug-12
4400062680
2012-07-05
5000
20-Aug-12
4400067840
2012-11-20
670
19-Dec-12
GRN Tabel
PO NO
GrnNo
Date
GateQty
4400062680
5000398459
12-Jul-12
2500
4400062680
5000401805
23-Jul-12
3500
4400062680
5000402948
26-Jul-12
3300
4400062680
5000403243
27-Jul-12
2200
4400067840
5000441410
25-Dec-12
500
I want to generate a result table as follows in load script
PONO
GrnNo
Date
GateQty
FILL RATIO
NO OF DAYS
4400062680
5000398459
12-Jul-12
2500
43.48
-29
4400062680
5000401805
23-Jul-12
3500
104.35
-18
4400062680
5000402948
26-Jul-12
3300
66.00
-25
4400062680
5000403243
27-Jul-12
1700
100.00
-26
4400067840
5000441410
25-Dec-12
500
74.63
6
The Fill Ratio is calculated based on first schedule of the same PO number, once the scheduled qty is completly received, it should consider next available record for the same PO.,Same way the no of days is also calculated