Normal Topic Query - long (Read 918 times)
Justin_ICC
Junior Member
**
Offline



Posts: 95
Joined: Feb 5th, 2004
Query - long
May 13th, 2004 at 6:34pm
Print Post Print Post  
This is for the lantica team. Have you considered creating a query command?
Ie @XQuery(Database,form,retrieve spec, dest variables)
or @XQuery(Application,Spec, dest) where Application would typically be @fn, Spec would be a specially formated string eg. oracle style "select *fields* from *forms*" or something like that and dest would be a destination variable (most likely an array).

This would let users pull up records based on multiple criteria.

For example I would like our payment screen to pull up every payment previously made on account and then calculate what portion of the current payment (if any) was interest.

For example:
I have an account with a listed amount of $100.00
It accrues interest at 24%/year
6 months down the road I start making payments of $60.00/month
at the point when I make my first payment the new balance will be $138.00
so it will be reduced to $78.00
At the second payment the balance would be the interest on $100 - the interest on the $60 for 1 month (for cumulative interest)

That would make it $140.57-61.09 = 79.48 as new bal with interest of which $60 is paid at this point $120 has been paid, the account balance is $19.48 and $20 has been paid in interest.
At the third month they then pay $19.48 to clear the account.

What I would like to do is have the program sum all the payments and subtract them from the listed amount to do this though I need to be able to only pull the payments on a specific account number.

Part of the problem with this is what if someone goes and corrects an older payment. I want it to sum only those payments made before the date of that payment.

Also if possible I would like a window which shows the date & amount of each payment made which would be an unbound LE as a subform is not possible since it is stored in the same database. To do this would require the ability to pull up all payments for a specific account & return 2 pieces of information. I can't seem to find any commands to do this

In this case a query command (ie SQL style) would be very useful.

Hope someone can help me!

Justin
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Query - long
Reply #1 - May 13th, 2004 at 7:27pm
Print Post Print Post  
Quote:
This is for the lantica team. Have you considered creating a query command? 
Ie @XQuery(Database,form,retrieve spec, dest variables)


Yes. Very much so.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Justin_ICC
Junior Member
**
Offline



Posts: 95
Joined: Feb 5th, 2004
Re: Query - long
Reply #2 - May 13th, 2004 at 7:31pm
Print Post Print Post  
Well hopefully we see something like that down the road - I think I managed to figure out how to do the payment thing - I read through the program again in the inside sesame may 2004 - and I think I now understand how to take advantage of the features in it. Unfortunatelly the code is uncommented so it was hard to really get the "grit" out of it.

I'll post a commented code to here once I get it written.

Justin
  
Back to top
 
IP Logged
 
Justin_ICC
Junior Member
**
Offline



Posts: 95
Joined: Feb 5th, 2004
Re: Query - long
Reply #3 - May 13th, 2004 at 8:00pm
Print Post Print Post  
Here is my first draft of this program I haven't had much chance to test - if nothing else it explains the article a little easier (at least I think so).

Code
Select All
////////////////////////////////////////////////////////////////////////////////////
// Calculate Interest paid on an account
//
// Layout Elements used:
// Acct#  - account number
// PayID    - Unique payment Identifier
// PmtDate  - Date of payment
// PmtHere  - Amount Paid to Us
// PmtDir   - Amount Paid to Client
// List Amt - Amount account was listed for
// Int_Pd   - Amount of interest paid on the account
////////////////////////////////////////////////////////////////////////////////////

var vPIDs as string            // Variable to store payments on account
var vNextOne as string            // Variable to act as temporary active payment acct
var vPaymentInfo as string      // Variable to store retrieve information
var vTotalOfPay as double      // variable to store total of payments

// variables to be converted from vPaymentInfo - to ease processing.
var vCurDate as date
var vCurPmtH as double
var vCurPmtD as double

vTotalOfPay = 0;

if @IsBlank(PmtHere) then
{
}
else
{
      // Perform a lookup on the current database for the current account
      // and pull up all Payment ID's to identify each payment. And store it in vPIDs
      vPIDs = @XLookupAll(@fn,Acct#,"Acct#","PayID")
      // store in VPIDs semicolon delimited list of Payment ID's where the
      // current Acct# matches the Acct# in the current database.

      // while there are still payments unaccounted for.
      while @Len(vPIDs) > 0
      {
            // Set vNextOne to the next payment in the list.
            vNextOne = Split(vPids,";");

            // Pull up the payment where current payment (vNextOne) matches.
            // The unique paymentID in the database.
            // Retrieve PmtDate, PmtHere and PmtDir fields and separate them by semicolons.
            vPaymentInfo = @XLookupSourceList(@Fn, vNextOne, "PaymentID", "PmtDate;PmtHere;PmtDir");
            
            // Process the payment
            vCurDate = @ToDate (Split(vPaymentInfo,";"));
            vCurPmtH = @ToMoney(Split(vPaymentInfo,";"));
            vCurPmtD = @ToMoney(Split(vPaymentInfo,";"));

            // if the payment is not after today and it is not this payment
            if (vCurDate <= @Date AND vNextOne <> PayID) then
            {
                  // add current payment here & dir to the total
                  // one should always be 0 while the other should have an amount.
                  vTotalOfPay += vCurPmtH;
                  vTotalOfPay += vCurPmtD;
            }

      } // END WHILE
}

// if there was interest paid (more was paid than listed amt)
if vTotalOfPay > List Amt then
{
      // set Int_Pd to the amount of the interest that has been paid.
      Int_Pd = vTotalOfPay - List Amt;
}
else // otherwise
{
      // set Int_Pd to 0
      Int_Pd = 0;
}
 



Justin
« Last Edit: May 14th, 2004 at 12:30pm by Justin_ICC »  
Back to top
 
IP Logged