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
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
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