Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Marking records in table
Message
 
 
To
24/08/2001 11:15:15
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00548667
Message ID:
00548684
Views:
8
>I have a receivables table and I want to flag them so I can move them to a history table or I want to
>change the amount owed.
>
>Here is an example of my data
>
>Acct_num;Price;Inv_date
>1;40.00;06/27/01
>1;40.00;07/27/01
>
>The customer pays 60 dollars. I want to flag the oldest date as paid and then replace the next one with
>the remaining amount owed which would be 20 dollars. This is just an example of what I need to do. The
>oldest record needs to be changed first and then continue on. Any ideas on how I could do this?
>
>TIA,
>Tyler

First of all, create an index on your table, say, history:
index on bintoc(acct_Num)+bintoc({^2000-01-01}-Inv_Date) tag History
local lnAcct_Num, lnPrice, lnDecrTotal, lnRecPrice 
lnPrice=60
lnAcctNum=1
lnDecrTotal= m.lnPrice
set exact off
seek bintoc(m.lnAcct_Num)
scan while bintoc(acct_Num)+bintoc({^2000-01-01}-Inv_Date) = bintoc(m.lnAcct_Num) and m.lnDecrTotal>0
    if m.lnDecrTotal>=m.lnPrice
         lnRecPrice=Price
         replace Price with 0, flag with 'Paid'
         m.lnDecrTotal=m.lnDecrTotal-m.lnRecPrice
    else && Decrease Total now is less than price
         replace price with Price-m.lnDecrTotal
         lnDecrTotal=0 && Go out
    endif
endscan
This is off the top of my head and not tested...
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform