Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Account Aging Report - how do I do mathematics?
Message
From
01/10/1999 00:38:26
 
 
To
28/09/1999 18:17:29
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00270271
Message ID:
00271411
Views:
18
Hi Peter,

Let's see if I understand this. You have charges and payments which could apply to either current,30,60, or 90 day balances. You have already accumulated (and stored) 30,60, and 90 day prior balances, right? You want to apply charges and payments as appropriate.
* Assumes a balance table and a transactions table with pmts and charges
* This is a double scan
CUR,C30,C60,C90 = current,30,60,90 day balance fields
SELECT transactions
SCAN
   * Apply charges as appropriate by date to Balance
ENDSCAN
* Payments
SCAN
   nRunTot=transactions.payment
   REPLACE C90 WITH c90-nRunTot
   nRunTot = IIF(C90>0,0,ABS(c90))
   IF c90 < 0
      REPLACE c90 WITH 0
   ENDIF
   IF nRunTot > 0
      REPLACE C60 WITH c60-nRunTot
      IF c60 < 0
         nRunTot = ABS(c60)
         REPLACE c60 WITH 0
      ENDIF
      IF nRunTot > 0
         REPLACE c30 WITH c30-nRuntot
         IF c30 < 0
            nRuntot = ABS(c30)
            REPLACE c30 with 0
         ENDIF
         IF nRunTot > 0
            REPLACE CUR WITH CUR-nRunTot
         ENDIF
      ENDIF
   ENDIF
ENDSCAN
>I need to add an account aging set of columns to an existing detail report. I believe I have the formulas but am not sure how to get the information into the cursor (or from the cursor) that is used to generate the report...
>
>Here are the formulas - this assumes payments pay off oldest debt
>
>KEY: Ax = Aging total due
> Cx = Charges for that period
> Px = Payments for that period
> PT = Total of payments for all periods
>
>90+ If PT > C90 then A90=0, PT=PT-C90 else A90=C90-PT, PT=0
>60 If PT > C60 then A60=0, PT=PT-C60 else A60=C60-PT, PT=0
>30 If PT > C30 then A30=0, PT=PT-C30 else A30=C30-PT, PT=0
>Cur A30=C0-PT
>
>I use SUM in the SELECT to get the Cx & Px totals. The problem I am having is that I am not sure how to handle the double "math" that is needed for each side of the IF so that I get the right amounts as I work through all the formulas.
>
>Suggestions?
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform