Browse Source

The corrects a hereunto unknown very minor bug where data is not being check for value in the deposit calculator function.

devel
Jonathan Rosenbaum 8 years ago
parent
commit
7fb848f7d4
  1. 60
      js/transaction.js

60
js/transaction.js

@ -106,7 +106,7 @@ $(function() {
$('[href*="trans_id=' + this.name + '"]').show(); $('[href*="trans_id=' + this.name + '"]').show();
$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); $.post("json/transaction.php",{ paid: 0, transaction_id: this.name } );
} }
// Deposit Calculator for clicks // Deposit Calculator for clicks
deposit_calculator(); deposit_calculator();
@ -449,37 +449,39 @@ $(function() {
$.post("json/transaction.php",{"deposit": deposit}, function(data) { $.post("json/transaction.php",{"deposit": deposit}, function(data) {
var obj = $.parseJSON(data);
$.each(obj,function(k,v){ if (data) {
var obj = $.parseJSON(data);
// Cash / Check / Credit
$("#" + k + "_cash span").text("$" + payment_result(v.cash)); $.each(obj,function(k,v){
$("#" + k + "_check span").text("$" + payment_result(v.check));
$("#" + k + "_credit span").text("$" + payment_result(v.credit)); // Cash / Check / Credit
$("#" + k + "_cash span").text("$" + payment_result(v.cash));
// Sum $("#" + k + "_check span").text("$" + payment_result(v.check));
var sum = Number(v.check) + Number(v.cash); $("#" + k + "_credit span").text("$" + payment_result(v.credit));
$("#" + k + "_sum span").text("$" + sum.toFixed(2));
// Sum
// Difference (regexp - good up to 6 places and 2 digits) var sum = Number(v.check) + Number(v.cash);
var deposit_amount = $('input[name="' + k + '"]').parent().prev().prev().text().replace(/\$(\d*(?:,\d{3})*\.\d*)\s+/, "$1" ); $("#" + k + "_sum span").text("$" + sum.toFixed(2));
deposit_amount = deposit_amount.replace(/,/, "");
if (deposit_amount != 0) { // Difference (regexp - good up to 6 places and 2 digits)
var diff = deposit_amount - sum; var deposit_amount = $('input[name="' + k + '"]').parent().prev().prev().text().replace(/\$(\d*(?:,\d{3})*\.\d*)\s+/, "$1" );
$("#" + k + "_difference span").text("$"+ diff.toFixed(2)); deposit_amount = deposit_amount.replace(/,/, "");
if ( diff == 0 ) { if (deposit_amount != 0) {
$("#" + k + "_difference").css("color","green"); var diff = deposit_amount - sum;
$("#" + k + "_difference span").text("$"+ diff.toFixed(2));
if ( diff == 0 ) {
$("#" + k + "_difference").css("color","green");
} else {
$("#" + k + "_difference").css("color","red");
}
} else { } else {
$("#" + k + "_difference").css("color","red"); $("#" + k + "_difference span").text("n/a");
} }
} else {
$("#" + k + "_difference span").text("n/a");
}
});
}); // each
} // if data
}); // end function }); // end function

Loading…
Cancel
Save