|
|
@ -630,15 +630,21 @@ $(function() { |
|
|
|
} |
|
|
|
|
|
|
|
// figure out remaining hours that can be redeemed if volunteer hours have been redeemed.
|
|
|
|
var remaining, year = d.getFullYear(), exceeded_sweat_equity_limit = false; |
|
|
|
var remaining, year = d.getFullYear(), exceeded_sweat_equity_limit = false, price_after_redeeming, spinner_difference; |
|
|
|
if (volunteer) { |
|
|
|
var vhr = obj.volunteer_hour_value * volunteer[year].volunteer_hours_redeemed; |
|
|
|
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed; |
|
|
|
var vhr = obj.volunteer_hour_value * volunteer[year].volunteer_hours_redeemed + (spinner_value * obj.volunteer_hour_value); |
|
|
|
console.log(obj.volunteer_hour_value + " * " + volunteer[year].volunteer_hours_redeemed + " = " + vhr ); |
|
|
|
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed; |
|
|
|
//console.log(obj.current_year_volunteer_hours + " - " + volunteer[year].volunteer_hours_redeemed + " = " + remaining );
|
|
|
|
if (vhr > obj.sweat_equity_limit) { |
|
|
|
exceeded_sweat_equity_limit = true; |
|
|
|
exceeded_sweat_equity_limit = true; |
|
|
|
price_after_redeeming = price - (obj.volunteer_hour_value * ((obj.sweat_equity_limit / obj.volunteer_hour_value) - volunteer[year].volunteer_hours_redeemed)); |
|
|
|
spinner_difference = (obj.sweat_equity_limit / obj.volunteer_hour_value) - volunteer[year].volunteer_hours_redeemed; |
|
|
|
console.log(spinner_difference); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// no volunteer_hours_redeemed or still less than the allowable sweat_equity_hours
|
|
|
|
|
|
|
|
// if running volunteer_hours >= special_volunteer_hours_qualification the special_discount kicks in
|
|
|
@ -649,7 +655,7 @@ $(function() { |
|
|
|
if (price >= redeemable_value) { |
|
|
|
|
|
|
|
// discount is now applied if transaction is over special_volunteer_hours_qualification
|
|
|
|
if (redeemable_value > obj.sweat_equity_limit && $("#transaction_type").val() !== "Stand Time") { |
|
|
|
if (redeemable_value > obj.sweat_equity_limit && $("#transaction_type").val() !== "Stand Time" && !price_after_redeeming) { |
|
|
|
|
|
|
|
var value_to_apply_discount, difference, hours_applied_with_value; |
|
|
|
|
|
|
@ -664,12 +670,12 @@ $(function() { |
|
|
|
|
|
|
|
if (price > max_discount_price) { |
|
|
|
max_discount_price_difference = price - max_discount_price; |
|
|
|
//console.log("we have to do things differently " + max_discount_price_difference);
|
|
|
|
console.log("we have to do things differently " + max_discount_price_difference); |
|
|
|
value_to_apply_discount = (price - max_discount_price_difference) - redeemable_value; |
|
|
|
difference = (price - max_discount_price_difference) - obj.sweat_equity_limit; |
|
|
|
hours_applied_with_value = difference - value_to_apply_discount; |
|
|
|
|
|
|
|
//console.log("(" + max_discount_price_difference + " + " + difference + ") - (" + hours_applied_with_value + " * ." + discount + ")");
|
|
|
|
console.log("(" + max_discount_price_difference + " + " + difference + ") - (" + hours_applied_with_value + " * ." + discount + ")"); |
|
|
|
redeemable_value = (max_discount_price_difference + difference) - |
|
|
|
(hours_applied_with_value * (discount / 100).toFixed(2)); |
|
|
|
} else { |
|
|
@ -677,7 +683,7 @@ $(function() { |
|
|
|
value_to_apply_discount = price - redeemable_value; |
|
|
|
hours_applied_with_value = difference - value_to_apply_discount; |
|
|
|
|
|
|
|
//console.log(difference + " - (" + hours_applied_with_value + " * ." + discount + ")");
|
|
|
|
console.log(difference + " - (" + hours_applied_with_value + " * ." + discount + ")"); |
|
|
|
redeemable_value = difference - (hours_applied_with_value * (discount / 100).toFixed(2)); |
|
|
|
} |
|
|
|
|
|
|
@ -686,7 +692,13 @@ $(function() { |
|
|
|
// volunteer hours redeemed if the redeemable_value <= obj.sweat_equity_limit
|
|
|
|
} else { |
|
|
|
if (exceeded_sweat_equity_limit === true) { |
|
|
|
amount.val(price - (redeemable_value * (discount / 100).toFixed(2))); |
|
|
|
console.log(exceeded_sweat_equity_limit); |
|
|
|
if (price_after_redeeming) { |
|
|
|
amount.val(price_after_redeeming - (((spinner_value - spinner_difference) * obj.volunteer_hour_value) * (discount / 100).toFixed(2))); |
|
|
|
} else { |
|
|
|
amount.val(price - (redeemable_value * (discount / 100).toFixed(2))); |
|
|
|
} |
|
|
|
console.log(price_after_redeeming + " - " + redeemable_value + " * ." + discount); |
|
|
|
} else { |
|
|
|
amount.val(price - redeemable_value); |
|
|
|
} |
|
|
|