LP#1249398 clear negative balance UI user/berick/lp1249398-clear-negative-balance-ui-option
authorBill Erickson <berick@esilibrary.com>
Mon, 11 Nov 2013 14:16:03 +0000 (09:16 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 11 Nov 2013 14:38:36 +0000 (09:38 -0500)
New "Clear Negative Balance" option in patron billing UI.  Selected
negative-balance transactions are updated to have a zero balance by
modifying void payments attached to the transaction.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
Open-ILS/xul/staff_client/server/patron/bill2.js
Open-ILS/xul/staff_client/server/patron/bill2.xul

index c3c6cf0..dc224bb 100644 (file)
 <!ENTITY staff.patron.bill_interface.void_all_billings.accesskey "V">
 <!ENTITY staff.patron.bill_interface.refund.label "Refund">
 <!ENTITY staff.patron.bill_interface.refund.accesskey "R">
+<!ENTITY staff.patron.bill_interface.zeroize.label "Clear Negative Balance">
+<!ENTITY staff.patron.bill_interface.zeroize.accesskey "C">
 <!ENTITY staff.patron.bill_interface.full_details.label "Full Details">
 <!ENTITY staff.patron.bill_interface.full_details.accesskey "D">
 <!ENTITY staff.patron.bill_interface.show_in_catalog.label "Show in Catalog">
index 3856f72..135d04b 100644 (file)
@@ -369,7 +369,8 @@ var api = {
     'USER_ORG_UNIT_OPT_IN_FEATURE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.enabled' },
     'USER_ORG_UNIT_OPT_IN_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.check' },
     'USER_ORG_UNIT_OPT_IN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.create' },
-    'GET_BARCODES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.get_barcodes' }
+    'GET_BARCODES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.get_barcodes' },
+    'ZEROIZE_TRANSACTION' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.zeroize_transaction' }
 }
 
 var urls = {
index f7d7d5f..ec7b4a4 100644 (file)
@@ -48,7 +48,15 @@ staff.patron.bills.handle_refund.message_singular=Are you sure you would like to
 staff.patron.bills.handle_refund.title=Refund Excess Payment
 staff.patron.bills.handle_refund.btn_yes=Yes
 staff.patron.bills.handle_refund.btn_no=No
-staff.patron.bills.handle_refund.confirm_message=Check here to confirm this message
+
+staff.patron.bills.handle_zeroize.confirm_message=Check here to confirm this message
+staff.patron.bills.handle_zeroize.message_plural=Are you sure you would like to clear the negative balance on bills %1$s?
+staff.patron.bills.handle_zeroize.message_singular=Are you sure you would like to clear the negative balance on bill %1$s?
+staff.patron.bills.handle_zeroize.title=Clear Negative Balance
+staff.patron.bills.handle_zeroize.btn_yes=Yes
+staff.patron.bills.handle_zeroize.btn_no=No
+staff.patron.bills.handle_zeroize.confirm_message=Check here to confirm this message
+
 staff.patron.bill_history.print_bills.print_error=printing bills
 staff.patron.bill_history.column.xact_type.label=Transaction Type
 staff.patron.bill_history.column.last_billing_type.label=Last Billing Type
index 8a248f3..5070e1e 100644 (file)
@@ -108,6 +108,12 @@ function event_listeners() {
             false
         );
 
+        window.bill_event_listeners.add($('zeroize'), 
+            'command',
+            handle_zeroize,
+            false
+        );
+
         window.bill_event_listeners.add($('opac'), 
             'command',
             handle_opac,
@@ -382,6 +388,48 @@ function handle_refund() {
     distribute_payment();
 }
 
+/**
+ * Calls open-ils.circ.money.zeroize_transaction on selected, negative-
+ * balance transactions to produce a zero-balance transaction.
+ * Successfully cleared transactions will disappear from the billing list.
+ */
+function handle_zeroize() {
+
+    var msgkey = g.bill_list_selection.length > 1 ?
+        'staff.patron.bills.handle_zeroize.message_plural' :
+        'staff.patron.bills.handle_zeroize.message_singular';
+
+    var msg = $("patronStrings").getFormattedString(
+        msgkey, [g.bill_list_selection]);
+        
+    var r = g.error.yns_alert(msg,
+        $("patronStrings").getString(
+            'staff.patron.bills.handle_zeroize.title'),
+        $("patronStrings").getString(
+            'staff.patron.bills.handle_zeroize.btn_yes'),
+        $("patronStrings").getString(
+            'staff.patron.bills.handle_zeroize.btn_no'),null,
+        $("patronStrings").getString(
+            'staff.patron.bills.handle_zeroize.confirm_message'));
+
+    if (r == 0) {
+        var xact_ids = [];
+        for (var i = 0; i < g.bill_list_selection.length; i++) {
+            var bill_id = g.bill_list_selection[i];
+            xact_ids.push(bill_id);
+        }
+
+        var mod_ids = g.network.simple_request(
+            'ZEROIZE_TRANSACTION', [ses(), xact_ids]);
+
+        g.error.sdump('D_DEBUG', 'zeroized transactions ' + mod_ids);
+
+        refresh();
+        tally_all();
+        distribute_payment();
+    }
+}
+
 
 function check_all() {
     try {
@@ -525,6 +573,7 @@ function init_lists() {
             $('add').setAttribute('disabled', g.bill_list_selection.length == 0);
             $('voidall').setAttribute('disabled', g.bill_list_selection.length == 0);
             $('refund').setAttribute('disabled', g.bill_list_selection.length == 0);
+            $('zeroize').setAttribute('disabled', g.bill_list_selection.length == 0);
             $('opac').setAttribute('disabled', g.bill_list_selection.length == 0);
             $('copy_details').setAttribute('disabled', g.bill_list_selection.length == 0);
         },
index b0135b4..93096bb 100644 (file)
@@ -42,6 +42,7 @@
         <command id="copy_details" label="&staff.patron.items_overlay.sel_copy_details.label;" accesskey="&staff.patron.items_overlay.sel_copy_details.accesskey;" disabled="true"/>
         <command id="voidall" label="&staff.patron.bill_interface.void_all_billings.label;" accesskey="&staff.patron.bill_interface.void_all_billings.accesskey;" disabled="true"/>
         <command id="refund" label="&staff.patron.bill_interface.refund.label;" accesskey="&staff.patron.bill_interface.refund.accesskey;" disabled="true"/>
+        <command id="zeroize" label="&staff.patron.bill_interface.zeroize.label;" accesskey="&staff.patron.bill_interface.zeroize.accesskey;" disabled="true"/>
         <command id="add" label="&staff.patron.bill_interface.add_billing.label;" accesskey="&staff.patron.bill_interface.add_billing.accesskey;" disabled="true"/>
         <command id="details" label="&staff.patron.bill_interface.full_details.label;" accesskey="&staff.patron.bill_interface.full_details.accesskey;" disabled="true"/>
     </commandset>
@@ -52,6 +53,7 @@
             <menuitem command="copy_details" />
             <menuitem command="voidall" />
             <menuitem command="refund" />
+            <menuitem command="zeroize" />
             <menuitem command="add" />
             <menuitem command="details" />
         </menupopup>