problem description
there is a fixed number of incoming and outgoing orders when leaving the warehouse, and you need to subtract the remaining quantity of the entry orders when you complete them. Because the quantity is uncertain, the earliest completed purchase orders are not certain, which is troublesome.
the environmental background of the problems and what methods you have tried
calculate the total inbound amount of all incoming orders, sort by time and calculate a column of the cumulative sum of the remaining total. Compare the column of this cumulative sum with this outgoing order, and the amount of storage is reduced if the column is less than the outgoing order. But the result is not negative (that is, all less than 0 are 0), and then update this value to the surplus of each order.
what result do you expect? What is the error message actually seen?
accurate inventory leftover