This is probably going to be more of a database structure question than scripts.
I want to create like a floating value which will represent the balance of items which need to be despatched or are left over from a previous despatch.
I have already set the system up so I can despatch part of an order or full.
On a part despatch order you need to enter a quantity of how many are going out on that particular note. This then will update a balance which will be taken into account when the next despatch note is created. Showing how many you need to despatch.
I use the Despatch_Notes table to hold account level information. All of the products are sent to Despatch_Details maybe a join table is needed to be able to have a balance?
Ordered is a value that is copied over from the Order_Details table. Despatched is a value that the user will have to type in to affect balance which will be used across any despatch notes related to this specific order. Currently Balance is just a calculation (Ordered - Despatched)
Sorry if Im abit vague on my explanation.