Voided total for bill receipts.. can't completely test at the moment
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Aug 2006 05:34:14 +0000 (05:34 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Aug 2006 05:34:14 +0000 (05:34 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5582 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Open-ILS/xul/staff_client/server/patron/bill_details.xul
Open-ILS/xul/staff_client/server/patron/bills.js
Open-ILS/xul/staff_client/server/patron/bills_overlay.xul

index a6de4a1..9d91b92 100644 (file)
@@ -167,7 +167,7 @@ OpenILS.data.prototype = {
                                }, 
                                '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/> ',
                                },
index cc4ef56..47a6414 100644 (file)
@@ -33,6 +33,7 @@ circ.print_list_template_editor.prototype = {
                                        '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",
@@ -153,7 +154,7 @@ circ.print_list_template_editor.prototype = {
                                                                                        );
                                                                                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(', ');
index a6837f0..3559efb 100644 (file)
                }
 
                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();
index c4b87e2..2f29f58 100644 (file)
@@ -9,6 +9,7 @@ patron.bills = function (params) {
        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); 
        }
@@ -52,6 +53,7 @@ patron.bills.prototype = {
                                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);        
                }
@@ -93,6 +95,7 @@ patron.bills.prototype = {
                                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);   
                }
@@ -246,6 +249,10 @@ patron.bills.prototype = {
                                                                        obj.tally_selected();
                                                                }
                                                        ],
+                                                       'voided_balance' : [
+                                                               ['render'],
+                                                               function(e) { return function() {}; }
+                                                       ],
                                                        'selected_balance' : [
                                                                ['render'],
                                                                function(e) { return function() {}; }
@@ -404,6 +411,24 @@ patron.bills.prototype = {
 
        /*****************************************************************************************************************************/
 
+       '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;
@@ -457,8 +482,8 @@ patron.bills.prototype = {
                                }
                                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';
@@ -491,6 +516,7 @@ patron.bills.prototype = {
                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,
index 9019726..2f7caf1 100644 (file)
@@ -14,6 +14,7 @@
        <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>