• Input rows:

    days Qty [Aging Stock] priority

    269 285 305 1

    287 30 300 2

    output:

    269 285 305 1 -- same as input row1

    269 20 305 2 -- few qty from row-2 to fill row1 qty

    287 10 300 2 -- remaining qty from row-2

    Explantion for output:

    ouput row 1) same as input row

    ouput row 2) in input row 1 in 269 days still we can store more 20 qty (305-285) , So from input row 2 values we can store 20 Qtys from 30 Qty

    ouput row 3) remaining 10qtys from input row 2