diff --git a/js/transaction.js b/js/transaction.js index 20d6be8..073ab5f 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -746,7 +746,8 @@ $(function() { var redeemable_value = obj.current_year_volunteer_hours * obj.volunteer_hour_value; $("#redeemable_hours").spinner({ - step: 0.25, + step: 0.01, + incremental: true, numberFormat: "n", max: obj.current_year_volunteer_hours, min: 0, @@ -794,7 +795,31 @@ $(function() { if ($(this).data('onInputPrevented')) return; // test if value is greater than current_year_volunteer_hours console.log($(this).spinner("value")); - + + var sweat_equity_hours = obj.sweat_equity_limit / (obj.volunteer_hours_redeemed * obj.volunteer_hour_value); + var redeemable_value = obj.volunteer_hour_value * $(this).spinner("value"); + + // check box to use 25% or 50% ? Also, check for 50% when no sweat_equity. + + // no volunteer_hours_redeemed or still less than the allowable sweat_equity_hours + if (isNaN(sweat_equity_hours) || volunteer_hours_redeemed < sweat_equity_hours) { + console.log(sweat_equity_hours); + // only 1 bike per year earned with sweat_equity_hours + if (price >= redeemable_value) { + amount.val(price - redeemable_value); + } else if (redeemable_value > price) { + event.preventDefault(); + } + // if running volunteer_hours >= special_volunteer_hours_qualification the special_discount kicks in + // other wise it is 25% + + } else if (sweat_equity_hours >= 1) { + // only 1 bike per year earned with sweat_equity_hours + + // if running volunteer_hours >= special_volunteer_hours_qualification the special_discount kicks in + // other wise it is 25% + + } var val = this.value, $this = $(this),