* --- CHKACCNT.PRG
* this routine goes through the CLIENT.DBF and, for each client, checks
* the ACCOUNT.DBF and readds the current balance, compares the values
* and fixes any errors.
DO WHILE .NOT. eof()
? 'Checking client '+trim(first)+' '+trim(last)
* --- save the pertinent data, clientno and balance
old_bal = balance
key = str(clientno,4)
* --- check for the clients ledger
* --- if no ledger is found, go to next patient
?? ' No ledger.'
* --- initialize memvars to record charges and payments
mpaid = 0.00
mcost = 0.00
* --- go through the clients ledger and recalculate
do while account->clientno=client->clientno .and. .not. eof()
mcost = charge + mcost
mpaid = paid + mpaid
* --- calculate actual balance according to ledger
new_bal = mcost - mpaid
* --- if they match, go to next client
if old_bal = new_bal
?? ' Balance correct.'
* --- if they do not match, update the client database with new bal
* and go to the next client
?? ' Updating current balance.'
replace balance with new_bal
?? ' Done.'