try { $('payment').focus(); } catch(E) { alert('Error in default_focus(): ' + E); }
}
-function tally_pending() {
+function tally_pending(for_real) {
try {
var payments = [];
JSAN.use('util.money');
var payment_tendered = util.money.dollars_float_to_cents_integer( tb.value );
var payment_pending = 0;
var retrieve_ids = g.bill_list.dump_retrieve_ids();
+ var seen = {};
+ var danger = false;
for (var i = 0; i < retrieve_ids.length; i++) {
var row_params = g.row_map[retrieve_ids[i]];
- if (g.check_map[retrieve_ids[i]]) {
- var value = util.money.dollars_float_to_cents_integer( row_params.row.my.payment_pending );
- payment_pending += value;
- if (value != '0.00') { payments.push( [ retrieve_ids[i], util.money.cents_as_dollars(value) ] ); }
+ if (g.check_map[retrieve_ids[i]]) {
+ if (typeof seen[ retrieve_ids[i] ] == 'undefined') {
+ seen[ retrieve_ids[i] ] = 1;
+ var value = util.money.dollars_float_to_cents_integer(
+ row_params.row.my.payment_pending );
+ payment_pending += value;
+ if (value != '0.00') { payments.push(
+ [ retrieve_ids[i], util.money.cents_as_dollars(value) ] ); }
+ } else {
+ seen[ retrieve_ids[i] ]++;
+ danger = true;
+ }
}
}
var change_pending = payment_tendered - payment_pending;
+ if (danger && for_real) {
+ var proceed = g.error.yns_alert_formatted(
+ 'Please copy the text from this dialog and paste into a support\n'
+ + 'or helpdesk ticket, along with the patron barcode, time of\n'
+ + 'occurence, your type of operating system, and any interesting\n'
+ + 'details such as network or staff client slowness, other error\n'
+ + 'dialogs around the same time, or anything else out of the norm.\n\n'
+ + js2JSON(seen)
+ + '\n\nWe have attempted to auto-correct the error. Please verify the\n'
+ + ' following amounts:\n\npayment tendered = '
+ + util.money.cents_as_dollars(payment_tendered)
+ + '\npayment pending = ' + util.money.cents_as_dollars(payment_pending)
+ + '\nchange pending = ' + util.money.cents_as_dollars(change_pending)
+ + '\n\nPress OK to continue with these amounts, Cancel otherwise',
+ 'WARNING: duplicate payment bug encountered',
+ 'OK',
+ 'Cancel',
+ null,
+ ''
+ );
+ if (proceed != 0) {
+ payments = [];
+ payment_pending = 0;
+ change_pending = payment_tendered;
+ }
+ }
$('pending_payment').value = util.money.cents_as_dollars( payment_pending );
$('pending_change').value = util.money.cents_as_dollars( change_pending );
$('change_due').value = util.money.cents_as_dollars( change_pending );
payment_blob.note = payment_blob.note || '';
//payment_blob.cash_drawer = 1; // FIXME: get new Config() to work
payment_blob.payment_type = $('payment_type').value;
- var tally_blob = tally_pending();
+ var tally_blob = tally_pending(true);
payment_blob.payments = tally_blob.payments;
// Handle patron credit
if ( payment_blob.payment_type == 'credit_payment' ) { // paying with patron credit