Don't like ads? PRO users don't see any ads ;-)
Guest

BenNadelPost

By: a guest on Jul 10th, 2008  |  syntax: ColdFusion  |  size: 2.20 KB  |  hits: 390  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         <cffunction name="getFormattedPrice" output="false" access="public" hint="I format a price">
  2.                 <cfset var price = 0 />
  3.                 <cfif len( trim( getPrice() ) ) >
  4.                         <cfset price = getPrice() />
  5.                 </cfif>
  6.                 <cfreturn LSCurrencyFormat( price )  />
  7.         </cffunction>
  8.  
  9.         <cffunction name="getFormattedSavingsPercent" output="false" access="public" hint="I format the difference between the price and the disc price (aka the discounted amount )">
  10.                 <cfset var savingsPercent  =  0 />
  11.                 <cfif calculateSavings() GT 0 >
  12.                         <cfset savingsPercent = getPrice()/calculateSavings() />
  13.                 </cfif>
  14.                 <cfreturn "%#decimalFormat(savingsPercent)#"/>
  15.         </cffunction>
  16.  
  17.  
  18.         <cffunction name="getFormattedDiscPrice" output="false" access="public" hint="I format a Discprice">
  19.                 <cfset var Discprice = 0 />
  20.                 <cfif len( trim( getDiscPrice() ) ) >
  21.                         <cfset Discprice = getDiscPrice() />
  22.                 </cfif>
  23.                 <cfreturn LSCurrencyFormat( Discprice )  />
  24.         </cffunction>
  25.  
  26. <cffunction name="calculateSavings" output="false" access="public" hint="I get the savings amount from the price and disc price">
  27.                 <cfset var savings  = 0 />
  28.                 <cfif  val( getPrice() ) GT 0>
  29.                         <cfset savings = getPrice() - val( getDiscPrice() ) >
  30.                 </cfif>
  31.                 <cfreturn savings />
  32.         </cffunction>
  33.        
  34.         <cffunction name="isDiscounted" access="public" output="false">
  35.                 <cfreturn getPrice() IS NOT getDiscPrice() >
  36.         </cffunction>
  37.  
  38.         <cffunction name="getFormattedSavings" output="false" access="public" hint="I format the difference between the price and the disc price (aka the discounted amount )">
  39.                 <cfreturn LSCurrencyFormat( calculateSavings() )  />
  40.         </cffunction>
  41.        
  42.         <cffunction name="getPrice" access="public" output="false">
  43.                 <cfreturn variables.instance.price>
  44.         </cffunction>
  45.  
  46.         <cffunction name="setPrice" access="public" output="false">
  47.                 <cfargument name="price" required="true">
  48.                 <cfset variables.instance.price = arguments.price>
  49.         </cffunction>
  50.  
  51.         <cffunction name="getDiscPrice" access="public" output="false">
  52.                 <cfreturn variables.instance.discPrice>
  53.         </cffunction>
  54.  
  55.         <cffunction name="setDiscPrice" access="public" output="false">
  56.                 <cfargument name="discPrice" required="true">
  57.                 <cfset variables.instance.discPrice = arguments.discPrice>
  58.         </cffunction>