Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfscript>
- getAccountBalance = function(){
- var balance = 120000;
- return balance;
- }
- function payCreditCardBill(accountBalance){
- var ccBill = 1890;
- return accountBalance-ccBill;
- }
- payEMIs = function(accountBalance){
- var mortgageEMI = 1000;
- var carLeaseEMI = 750;
- var healthInsuranceEMI = 250;
- return accountBalance-(mortgageEMI+carLeaseEMI+healthInsuranceEMI);
- }
- miscellenousExpenses = function(accountBalance){
- var shopping = 1500;
- var clubExpense =1000;
- var casinoExpense = 2000;
- return accountBalance-(shopping+clubExpense+casinoExpense);
- }
- checkBalance = function(accountBalance){
- while(accountBalance > 5000){
- accountBalance = miscellenousExpenses(accountBalance);
- writeOutput("checkBalance = " & accountBalance & "<br/>");
- }
- if(accountBalance < 5000)
- throw (message="Account balance below threshold!!!",
- type="info");
- }
- errorHandler = function(error){
- if(error.message contains "Account balance below threshold!"){
- return "You have reached your spending limit!";
- }
- }
- future = runAsync(getAccountBalance)
- .then(payCreditCardBill)
- .then(payEMIs)
- .then(miscellenousExpenses)
- .then(checkBalance)
- .error(errorHandler);
- writeOutput(future.get());
- </cfscript>
Add Comment
Please, Sign In to add comment