Quote
I have a Javascript in the background, so every time the job is opened it will auto update the fields
An item might be updated right after your javascript
finishes.
From that point until your javascript runs
again, your invoice-level total is
wrong.
You database
must be your Single Source of Truth.
If your invoices have only a few items each, I would strongly recommend calculating the total "on the fly".
If they really
do have a lot of items (and I'm talking
thousands of items, here) then use a database
Trigger to maintain the invoice-level total when
any individual item changes (or is added or deleted).
Trying to do it periodically with a batch program is a recipe for disaster.
Regards, Phill W.