It is your decision, but i still say : Don't put calculated values in
It really is a question of balance.
Is it better to keep calculated values up to date on the WRITE, or
determine those calculated values on a READ?
If the application will perform a WRITE more frequently than a READ, or
even in a roughly equivalent frequency, then calculate on a READ.
If the application will be doing more READs than WRITEs, then calculate
and store the values upon WRITE. The more often the READs are done, the
better for your throughput. The more expensive (processing-wise) your
calculations are, the better for your throughput.
In Juan's case, I don't think I would do it on a per-lineitem for the
invoice, but I would do it on persisting the invoice. Give the user the
option to 'recalc my bill' if they really wanted to see the fully
determined invoice, but on the first addition or deletion or change of a
lineitem, I'd clear the subtotal, taxes, and total, and show/enable the
If a user is sitting down to enter 10 lineitems, don't let the
'automatic calcs' get in the way of the users throughput in entering