mirror of
				https://github.com/fspc/Yellow-Bike-Database.git
				synced 2025-10-31 08:55:36 -04:00 
			
		
		
		
	Gives a 0 value when there is no vhr & vhr
This commit is contained in:
		
							parent
							
								
									2f33f8eef8
								
							
						
					
					
						commit
						165b81adc5
					
				| @ -629,6 +629,14 @@ $(function() { | |||||||
| 			discount = obj.volunteer_discount; | 			discount = obj.volunteer_discount; | ||||||
| 		}  | 		}  | ||||||
| 
 | 
 | ||||||
|  | 		var year = d.getFullYear(); | ||||||
|  | 		var vhr = obj.volunteer_hour_value * volunteer[year].volunteer_hours_redeemed; | ||||||
|  | 		var remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed; | ||||||
|  | 		var exceeded_sweat_equity_limit = false;		 | ||||||
|  | 		if (vhr > obj.sweat_equity_limit) { | ||||||
|  | 			exceeded_sweat_equity_limit = true; | ||||||
|  | 		}		 | ||||||
|  | 		 | ||||||
| 		// 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 (isNaN(sweat_equity_hours) || volunteer_hours_redeemed < sweat_equity_hours) { */ | 		/* if (isNaN(sweat_equity_hours) || volunteer_hours_redeemed < sweat_equity_hours) { */ | ||||||
| 			 | 			 | ||||||
| @ -644,8 +652,9 @@ $(function() { | |||||||
| 					sweat_equity_limit = obj.stand_time_value * spinner_value; | 					sweat_equity_limit = obj.stand_time_value * spinner_value; | ||||||
| 				}			 | 				}			 | ||||||
| 			 | 			 | ||||||
| 				// discount is now applied
 | 				// discount is now applied if transaction is over special_volunteer_hours_qualification
 | ||||||
| 				if (sweat_equity_limit > obj.sweat_equity_limit) { | 				if (sweat_equity_limit > obj.sweat_equity_limit || exceeded_sweat_equity_limit === true) { | ||||||
|  | 					 | ||||||
| 					 | 					 | ||||||
| 					var value_to_apply_discount, difference, hours_applied_with_value; | 					var value_to_apply_discount, difference, hours_applied_with_value; | ||||||
| 
 | 
 | ||||||
| @ -653,10 +662,15 @@ $(function() { | |||||||
| 					// are maxable redeemable hours less than price
 | 					// are maxable redeemable hours less than price
 | ||||||
| 					var max_discount_price; | 					var max_discount_price; | ||||||
| 					if ($("#transaction_type").val() !== "Stand Time") {	 | 					if ($("#transaction_type").val() !== "Stand Time") {	 | ||||||
|  | 						if (exceeded_sweat_equity_limit === true) { | ||||||
|  | 							max_discount_price =  remaining * obj.volunteer_hour_value; | ||||||
|  | 						} else { | ||||||
| 							max_discount_price = obj.current_year_volunteer_hours * obj.volunteer_hour_value; | 							max_discount_price = obj.current_year_volunteer_hours * obj.volunteer_hour_value; | ||||||
|  | 						} | ||||||
| 					} else { | 					} else { | ||||||
| 						max_discount_price = obj.stand_time_value * obj.volunteer_hour_value; | 						max_discount_price = obj.stand_time_value * obj.volunteer_hour_value; | ||||||
| 					}						 | 					}						 | ||||||
|  | 					 | ||||||
| 					var max_discount_price_difference; | 					var max_discount_price_difference; | ||||||
| 					 | 					 | ||||||
| 					if (price > max_discount_price) { | 					if (price > max_discount_price) { | ||||||
| @ -666,7 +680,7 @@ $(function() { | |||||||
| 						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 + " + ( " + value_to_apply_discount + " + " + " ( " + 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 {  | ||||||
| @ -674,7 +688,7 @@ $(function() { | |||||||
| 						value_to_apply_discount = price - sweat_equity_limit; | 						value_to_apply_discount = price - sweat_equity_limit; | ||||||
| 						hours_applied_with_value = difference - value_to_apply_discount; | 						hours_applied_with_value = difference - value_to_apply_discount; | ||||||
| 						 | 						 | ||||||
| 						//console.log(value_to_apply_discount + " + " + " ( " + 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));				 | ||||||
| 					} | 					} | ||||||
| 							 | 							 | ||||||
| @ -870,11 +884,13 @@ $(function() { | |||||||
| 					var volunteer_hours_redeemed = 0;								 | 					var volunteer_hours_redeemed = 0;								 | ||||||
| 					var obj = $.parseJSON(data); | 					var obj = $.parseJSON(data); | ||||||
| 
 | 
 | ||||||
| 					var volunteer = "", remaining = "", vhr = ""; | 					var volunteer = "", remaining = 0, vhr = ""; | ||||||
| 					if (obj.volunteer) { | 					if (obj.volunteer) { | ||||||
| 						volunteer = $.parseJSON(obj.volunteer); | 						volunteer = $.parseJSON(obj.volunteer); | ||||||
| 						remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed; | 						remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed; | ||||||
| 						vhr = volunteer[year].volunteer_hours_redeemed; | 						vhr = volunteer[year].volunteer_hours_redeemed; | ||||||
|  | 					} else { | ||||||
|  | 						vhr = 0; | ||||||
| 					}			 | 					}			 | ||||||
| 					 | 					 | ||||||
| 					var title = obj.normal_full_name + "\r\n" + | 					var title = obj.normal_full_name + "\r\n" + | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user