Keeping track of running balances
Posted: Fri Apr 27, 2007 10:23 am
Hi John:
I want to modify my application to allow the user to keep track of charges (in dollars) for each appointment, and to keep track of each contact's (in my case, each patient's) payments and balance due. The daily calendar view would show, for each appointment, the charge for that appointment, and the patient's current balance due (these would be displayed alongside the date and time of each appointment). Similarly, clicking on any appointment would bring up the "MiniWindowEditAppointment" layout, which would contain fields enabling me to enter the charges and payments for a given appointment, and would also display the patient's current balance due.
Here's my strategy so far:
1) Add ApptCharge field to Appointments. This is the fee our office charges for the current appointment.
2) Add ApptPayment field to Appointments. This is the payment, if any, made by the patient at the time of the current appointment.
3) Add ApptCurrentBal field to Appointments. This is a calculated field, defined as (ApptCharge - ApptPayment). This is the balance due, for the relevant patient, at the time of the current appointment.
4) Add ApptSummBal field to Appointments. This is a summary field, and is defined as the running total of ApptCurrentBal. I hoped that this would give me the total balance due, for the relevant patient, at the time of the selected appointment.
5) Modify "Daily" layout as follows: add two fields to CalDailyAppointments portal (CalDailyAppts::ApptCharge, and CalDailyAppointments::ApptSummBal).
6) Modify "MiniWindowEditAppointment" layout as follows: add four fields (CalDailyAppts::ApptCharge, CalDailyAppts::ApptPayment, CalDailyAppointments::ApptCurrentBal, and CalDailyAppointments::ApptSummBal). The first two fields accept data entry, and the third and fourth display calculated results.
Well, it works -- but only if the appointments in the ContactActivity portal are sorted by date in descending order. When I re-sort my appointments in this portal in ascending order (as I do by default), the result is all screwed up.
Can you help me figure out why the sort-order is messing things up? And how I might fix that?
I want to modify my application to allow the user to keep track of charges (in dollars) for each appointment, and to keep track of each contact's (in my case, each patient's) payments and balance due. The daily calendar view would show, for each appointment, the charge for that appointment, and the patient's current balance due (these would be displayed alongside the date and time of each appointment). Similarly, clicking on any appointment would bring up the "MiniWindowEditAppointment" layout, which would contain fields enabling me to enter the charges and payments for a given appointment, and would also display the patient's current balance due.
Here's my strategy so far:
1) Add ApptCharge field to Appointments. This is the fee our office charges for the current appointment.
2) Add ApptPayment field to Appointments. This is the payment, if any, made by the patient at the time of the current appointment.
3) Add ApptCurrentBal field to Appointments. This is a calculated field, defined as (ApptCharge - ApptPayment). This is the balance due, for the relevant patient, at the time of the current appointment.
4) Add ApptSummBal field to Appointments. This is a summary field, and is defined as the running total of ApptCurrentBal. I hoped that this would give me the total balance due, for the relevant patient, at the time of the selected appointment.
5) Modify "Daily" layout as follows: add two fields to CalDailyAppointments portal (CalDailyAppts::ApptCharge, and CalDailyAppointments::ApptSummBal).
6) Modify "MiniWindowEditAppointment" layout as follows: add four fields (CalDailyAppts::ApptCharge, CalDailyAppts::ApptPayment, CalDailyAppointments::ApptCurrentBal, and CalDailyAppointments::ApptSummBal). The first two fields accept data entry, and the third and fourth display calculated results.
Well, it works -- but only if the appointments in the ContactActivity portal are sorted by date in descending order. When I re-sort my appointments in this portal in ascending order (as I do by default), the result is all screwed up.
Can you help me figure out why the sort-order is messing things up? And how I might fix that?