},
'bill_payment' : {
'type' : 'payment',
- 'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>Credit Given:</td> <td align="right">$%credit_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
+ 'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">$%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
'line_item' : 'Bill #%bill_id% Received: $%payment%<br />',
'footer' : '</blockquote> </p> <hr />%PINES_CODE% %TODAY_TRIM%<br/> <br/> ',
},
'payment_type' : 'Cash',
'payment_received' : '10.00',
'payment_applied' : '7.40',
+ 'voided_balance' : '0.00',
'change_given' : '2.60',
'credit_given' : '0.00',
'note' : "The patron's child paid this",
);
break;
case 'payment' :
- macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%' ];
+ macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%' ];
break;
}
var macro_string = macros.join(', ');
}
function retrieve_mb() {
- var mb_list = g.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID', [ ses(), g.mbts_id ] );
- //g.error.sdump('D_DEBUG',g.error.pretty_print( js2JSON(mb_list) ));
+ g.mb_list = g.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID', [ ses(), g.mbts_id ] );
+ //g.error.sdump('D_DEBUG',g.error.pretty_print( js2JSON(g.mb_list) ));
var mb_funcs = [];
- function gen_mb_func(r) {
+ function gen_mb_func(i,r) {
return function() {
- g.bill_list.append( { 'retrieve_id' : r.id(), 'row' : { my : { 'mb' : r } } } );
+ g.bill_list.append( { 'retrieve_id' : i, 'row' : { my : { 'mb' : r } } } );
}
}
- for (var i = 0; i < mb_list.length; i++) {
- mb_funcs.push( gen_mb_func(mb_list[i]) );
+ for (var i = 0; i < g.mb_list.length; i++) {
+ mb_funcs.push( gen_mb_func(i,g.mb_list[i]) );
}
JSAN.use('util.exec');
}
function handle_void() {
- var msg = 'Are you sure you would like to void bill' + ( g.bill_list_selection.length > 1 ? 's ' : ' ') + g.bill_list_selection + '?';
+ JSAN.use('util.functional');
+ var msg = 'Are you sure you would like to void bill' + ( g.bill_list_selection.length > 1 ? 's ' : ' ') + util.functional.map_list( g.bill_list_selection, function(o) { return g.mb_list[o].id(); }) + '?';
var r = g.error.yns_alert(msg,'Voiding Bills','Yes','No',null,'Check here to confirm this message');
if (r == 0) {
+ g.data.stash_retrieve();
for (var i = 0; i < g.bill_list_selection.length; i++) {
- var robj = g.network.simple_request('FM_MB_VOID',[ses(),g.bill_list_selection[i]]);
+ var robj = g.network.simple_request('FM_MB_VOID',[ses(),g.mb_list[g.bill_list_selection[i]].id()]);
+ if (! g.data.voided_billings ) g.data.voided_billings = [];
if (robj.ilsevent) {
switch(robj.ilsevent) {
- case -1 : g.error.standard_network_error_alert('Void of Bill #' + g.bill_list_selection[i] + ' failed.'); break;
- default: g.error.standard_unexpected_error_alert('Void of Bill #' + g.bill_list_selection[i] + ' failed.',robj); break;
+ case -1 : g.error.standard_network_error_alert('Void of Bill #' + g.mb_list[g.bill_list_selection[i]].id() + ' failed.'); break;
+ default: g.error.standard_unexpected_error_alert('Void of Bill #' + g.mb_list[g.bill_list_selection[i]].id() + ' failed.',robj); break;
}
+ } else {
+ g.data.voided_billings.push( g.mb_list[g.bill_list_selection[i]] );
+ g.data.stash('voided_billings');
}
}
retrieve_mbts();
try {
obj.OpenILS = {}; JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
obj.data = obj.OpenILS.data;
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
} catch(E) {
alert(E);
}
obj.controller.view.bill_payment_amount.focus();
obj.distribute_payment(obj.controller.view.bill_payment_amount);
obj.tally_selected();
+ obj.tally_voided();
} catch(E) {
obj.error.standard_unexpected_error_alert('bills -> refresh',E);
}
obj.distribute_payment(obj.controller.view.bill_payment_amount);
obj.controller.view.bill_payment_amount.select();
obj.tally_selected();
+ obj.tally_voided();
} catch(E) {
obj.error.standard_unexpected_error_alert('bills -> init',E);
}
obj.tally_selected();
}
],
+ 'voided_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
'selected_balance' : [
['render'],
function(e) { return function() {}; }
/*****************************************************************************************************************************/
+ 'tally_voided' : function() {
+
+ var obj = this;
+ JSAN.use('util.money');
+ var voided_total = 0;
+
+ obj.data.stash_retrieve();
+
+ for (var i = 0; i < obj.data.voided_billings.length; i++) {
+ var billing = obj.data.voided_billings[i];
+ var bv = util.money.dollars_float_to_cents_integer( billing.amount() );
+ voided_total += bv;
+ }
+ obj.controller.view.voided_balance.setAttribute('value', '$' + util.money.cents_as_dollars( voided_total ) );
+ },
+
+ /*****************************************************************************************************************************/
+
'apply_payment' : function() {
var obj = this;
}
if ( obj.pay( payment_blob ) ) {
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
obj.refresh();
- //alert('FIXME: Receipt goes here\n' + js2JSON(payment_blob));
try {
obj.data.stash_retrieve();
var template = 'bill_payment';
try {
obj.previous_summary = {
original_balance : obj.controller.view.bill_total_owed.value,
+ voided_balance : obj.controller.view.voided_balance.value,
payment_received : obj.controller.view.bill_payment_amount.value,
payment_applied : obj.controller.view.bill_payment_applied.value,
change_given : obj.controller.view.bill_change_amount.value,
<hbox>
<label style="font-weight: bold;" value="Selected Balance:"/><label id="selected_balance"/>
<label style="font-weight: bold;" value="Un-Selected:"/><label id="unselected_balance"/>
+ <label style="font-weight: bold;" value="Voided:"/><label id="voided_balance"/>
</hbox>
<listbox id="bill_list" flex="1"/>
<hbox>