Simple math
Posted: 2016-08-23 05:48
Using Appgini 5.51.
Given three fields:
budget
actual
remaining
The following syntax works:
sql("UPDATE monthly_budget set remaining = budget - actual ", $eo);
ONLY if actual is not NULL...
for example, if "budget" = $1000.00 and "actual" = null, then "remaining" will NOT calculate; however, if "budget" = $1000.00 and "actual" = .00 then "remaining" computes to $1000.00 as it should.
My problem is that "actual" needs to be a Read Only field. "Actual" only gets changed via a posted transaction, creating a detailed transaction audit trail. If I allow an operator, when setting up a new account, access to the "actual' field and and she/he fails to enter ".00" (thus the "actual" would be NULL) the "remaining" amount will be incorrect.
Zero fill works, but it makes for sloppy looking reports etc.
Looking for help...
Buck
Given three fields:
budget
actual
remaining
The following syntax works:
sql("UPDATE monthly_budget set remaining = budget - actual ", $eo);
ONLY if actual is not NULL...
for example, if "budget" = $1000.00 and "actual" = null, then "remaining" will NOT calculate; however, if "budget" = $1000.00 and "actual" = .00 then "remaining" computes to $1000.00 as it should.
My problem is that "actual" needs to be a Read Only field. "Actual" only gets changed via a posted transaction, creating a detailed transaction audit trail. If I allow an operator, when setting up a new account, access to the "actual' field and and she/he fails to enter ".00" (thus the "actual" would be NULL) the "remaining" amount will be incorrect.
Zero fill works, but it makes for sloppy looking reports etc.
Looking for help...
Buck