is this what you want to do?
http://www.innovationplaygrounds.com/test/monthlypayments.cfm

Here is how I calculated months remaining until the next august.
<cfset remaining = 12-((mm+4) mod 12)>
<cfset prorate = round(amount*remaining/12*100)/100>

a variation of this would be:
<cfset remaining = 12-((mm+(12-EXPmm)) mod 12)>
<cfset prorate = round(amount*remaining/12*100)/100>
:if you had a variable expiry date

HTH
Eric

From: "Brad T Comer- Ameritech" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: CF-Talk <[EMAIL PROTECTED]>
Subject: RE: ?? prorating a purchase?
Date: Fri, 12 Apr 2002 08:41:45 -0500

Let me try to explain it again:

Users can purchase X from my site; the Month(Now()) determines the pro-rated
amount they will be charged.

The cycle is from EXPDATE = 8/31/Year(Now())

So if I buy today (April) and the item expires EXPDATE; thus they would only
be paying for {4} months;
so that would be (2500 / 12) * {4}

However lets say that the Month(Now()) was October:
so that would be (2500 / 12) * {11}

IF the Month(Now()) is August:
then it would be 2500 flat rate.

I currently have this code, but I dont think it is working correctly: can
anyone make a suggestion?

<cfparam name="Attributes.MonthlyCost" default="0">
<cfparam name="Attributes.TypeCost" default="0">

<cfif NOT Val(Attributes.MonthlyCost) OR NOT Val(Attributes.TypeCost)>
        <cfexit>
</cfif>

<cfset CurMonth = Month(Now())>
<cfset ExpMonth = Month(DateAdd("m", -1, Request.DefaultExpDate))>

<cfset MonthDiff = CurMonth - ExpMonth>
<cfif MonthDiff Contains "-">
        <cfset MonthDiff = RemoveChars(MonthDiff, 1,1)>
</cfif>
<cfif MonthDiff EQ 0> <!--- Full Price --->
        <cfset Cost = Attributes.TypeCost>
<cfelse> <!--- Pro-Rated --->
        <cfset Cost = (Attributes.MonthlyCost*MonthDiff)>
</cfif>
<!--- <cfset ExpMonth = DateAdd("m", -1,
Month(Request.DefaultExpMonth))> --->

<cfoutput>
#Request.DefaultExpDate#<br>#MonthDiff#<br>
MonthlyCost-#Attributes.MonthlyCost#<br>
Cost-#Cost#<br>
</cfoutput>

<cfset Caller.Total = Cost>

-----Original Message-----
From: Eric Dawson [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 12, 2002 8:32 AM
To: CF-Talk
Subject: Re: ?? prorating a purchase?


Not sure I understand.
I am presuming someone is buying something and paying a monthly fee.

as they go through time they can continue to pay monthly - or pay for the
remaining amount owing?

When prorating by months in a period I usually calculate the difference in
months by:
EXPYear*12 + EXPMonth - CurYear*12 - CurMonth

From: "Brad T Comer- Ameritech" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: CF-Talk <[EMAIL PROTECTED]>
Subject: ??
Date: Fri, 12 Apr 2002 07:54:46 -0500

Can anyone assist, I have a headache from this puppy!

Prorating a purchase:
X=Cost 2500 for a year OR 2500/12 *
DifferenceInMonthsFromEXPMonthandCurrentMonth
Exp date is 08/31/02

If i make a purchase today I should be charged the difference in months
times {X}

Thanks
BtC




______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to