mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-23 01:03:23 -05:00
Redeemable now properly adds discount when there has been previous transactions .
* some fun math!
This commit is contained in:
parent
8f45c94cd8
commit
e37a0ec2f7
@ -630,15 +630,21 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// figure out remaining hours that can be redeemed if volunteer hours have been redeemed.
|
// 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) {
|
if (volunteer) {
|
||||||
var vhr = obj.volunteer_hour_value * volunteer[year].volunteer_hours_redeemed;
|
var vhr = obj.volunteer_hour_value * volunteer[year].volunteer_hours_redeemed + (spinner_value * obj.volunteer_hour_value);
|
||||||
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed;
|
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) {
|
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
|
// 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
|
// if running volunteer_hours >= special_volunteer_hours_qualification the special_discount kicks in
|
||||||
@ -649,7 +655,7 @@ $(function() {
|
|||||||
if (price >= redeemable_value) {
|
if (price >= redeemable_value) {
|
||||||
|
|
||||||
// discount is now applied if transaction is over special_volunteer_hours_qualification
|
// 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;
|
var value_to_apply_discount, difference, hours_applied_with_value;
|
||||||
|
|
||||||
@ -664,12 +670,12 @@ $(function() {
|
|||||||
|
|
||||||
if (price > max_discount_price) {
|
if (price > max_discount_price) {
|
||||||
max_discount_price_difference = 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;
|
value_to_apply_discount = (price - max_discount_price_difference) - redeemable_value;
|
||||||
difference = (price - max_discount_price_difference) - obj.sweat_equity_limit;
|
difference = (price - max_discount_price_difference) - obj.sweat_equity_limit;
|
||||||
hours_applied_with_value = difference - value_to_apply_discount;
|
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) -
|
redeemable_value = (max_discount_price_difference + difference) -
|
||||||
(hours_applied_with_value * (discount / 100).toFixed(2));
|
(hours_applied_with_value * (discount / 100).toFixed(2));
|
||||||
} else {
|
} else {
|
||||||
@ -677,7 +683,7 @@ $(function() {
|
|||||||
value_to_apply_discount = price - redeemable_value;
|
value_to_apply_discount = price - redeemable_value;
|
||||||
hours_applied_with_value = difference - value_to_apply_discount;
|
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));
|
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
|
// volunteer hours redeemed if the redeemable_value <= obj.sweat_equity_limit
|
||||||
} else {
|
} else {
|
||||||
if (exceeded_sweat_equity_limit === true) {
|
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 {
|
} else {
|
||||||
amount.val(price - redeemable_value);
|
amount.val(price - redeemable_value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user