1
0
mirror of https://github.com/fspc/Yellow-Bike-Database.git synced 2025-02-23 01:03:23 -05:00

Adds to new values (original_price and redeemed_hours) to the history for benefit transactions.

This commit is contained in:
Jonathan Rosenbaum 2017-08-03 19:44:38 +00:00
parent 04846ae362
commit 7147ea6213
2 changed files with 20 additions and 12 deletions

View File

@ -134,3 +134,7 @@ input[value=Save]:focus, input[value=Close]:focus {
.ui-widget input { .ui-widget input {
font-size: .9em; font-size: .9em;
} }
#original_price {
display: none;
}

View File

@ -7,7 +7,7 @@ $(function() {
"use strict"; "use strict";
$.ajaxSetup({async:false}); // best to do this in $.ajax, $.ajaxSetup({async:false}); // best to do this in $.ajax,
// but all ajax needs to be synchronous in this program because of the use of mysql // but all ajax needs to be synchronous in this program because of the use of an "ancient" mysql
$("[name='transaction_type']").attr("tabindex",1); $("[name='transaction_type']").attr("tabindex",1);
$("[name='transaction_type']").focus(); $("[name='transaction_type']").focus();
@ -626,8 +626,6 @@ $(function() {
var redeemable_value; var redeemable_value;
if ($("#transaction_type").val() !== "Stand Time") { if ($("#transaction_type").val() !== "Stand Time") {
redeemable_value = obj.volunteer_hour_value * spinner_value; redeemable_value = obj.volunteer_hour_value * spinner_value;
console.log("HHU " + obj.volunteer_hour_value);
console.log("HHU2 " + spinner_value);
} else { } else {
redeemable_value = obj.stand_time_value * spinner_value redeemable_value = obj.stand_time_value * spinner_value
} }
@ -679,7 +677,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 + " + ( " + value_to_apply_discount + " + " + " ( " + 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 {
@ -687,17 +685,15 @@ $(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(value_to_apply_discount + " + " + " ( " + 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));
} }
console.log("HERE1");
amount.val(redeemable_value); amount.val(redeemable_value);
// volunteer hours redeemed // volunteer hours redeemed
} else { } else {
console.log("HERE2 " + redeemable_value);
amount.val(price - redeemable_value); amount.val(price - redeemable_value);
} }
@ -705,6 +701,7 @@ $(function() {
event.preventDefault(); event.preventDefault();
} }
// some volunteer_hours_redeemed
} else if (sweat_equity_hours >= 1) { } else if (sweat_equity_hours >= 1) {
// only 1 bike per year earned with sweat_equity_hours // only 1 bike per year earned with sweat_equity_hours
@ -768,6 +765,8 @@ $(function() {
$("#paid_label").text("Amount Owed:"); $("#paid_label").text("Amount Owed:");
} }
// show original amount for transaction using volunteer / membership benefits
// Things to do before pressing the save / close button // Things to do before pressing the save / close button
// Membership and Volunteer Benefits // Membership and Volunteer Benefits
@ -782,6 +781,7 @@ $(function() {
price = $(this).cleanVal(); price = $(this).cleanVal();
} }
console.log("original " + price); console.log("original " + price);
$("#original_price").text(price);
$("#redeemable_hours").val(0); $("#redeemable_hours").val(0);
}); });
@ -865,6 +865,7 @@ $(function() {
if (obj) { if (obj) {
var volunteer_hours = obj.volunteer_hours; var volunteer_hours = obj.volunteer_hours;
if ((volunteer_hours && volunteer_hours.length)) { if ((volunteer_hours && volunteer_hours.length)) {
$("#volunteer_hours").prop("title",title).html("Volunteer Hours"); $("#volunteer_hours").prop("title",title).html("Volunteer Hours");
$(".ui-spinner").show(); $(".ui-spinner").show();
@ -1011,6 +1012,7 @@ $(function() {
} }
// store the transaction's history // store the transaction's history
var transaction_history = []; var transaction_history = [];
var current_transaction = var current_transaction =
{ {
@ -1018,7 +1020,9 @@ $(function() {
date_startstorage: $("#date_startstorage").val(), date_startstorage: $("#date_startstorage").val(),
date: date, date: date,
transaction_type: $("#transaction_type").val(), transaction_type: $("#transaction_type").val(),
original_price: $("#original_price").text(),
amount: $("#amount").val(), amount: $("#amount").val(),
redeemed_hours: $("#redeemable_hours").val(),
description: $("#description").val(), description: $("#description").val(),
sold_to: sold_to, sold_to: sold_to,
sold_by: $("[name='sold_by']").val(), sold_by: $("[name='sold_by']").val(),