Use new org-specific billing_type's with default prices, and remove the 'Billing...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 Nov 2008 18:17:36 +0000 (18:17 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 Nov 2008 18:17:36 +0000 (18:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11257 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/patron/bill_wizard.js

index 4cb9345..0fad32f 100644 (file)
@@ -506,7 +506,6 @@ OpenILS.data.prototype = {
                        }
                );
 
-
                this.chain.push(
                        function() {
                                var f = gen_fm_retrieval_func(
@@ -744,7 +743,26 @@ OpenILS.data.prototype = {
                        }
                );
 
-
+               this.chain.push(
+                       function() {
+                               var f = gen_fm_retrieval_func(
+                                       'cbt',
+                                       [
+                                               api.FM_CBT_RETRIEVE.app,
+                                               api.FM_CBT_RETRIEVE.method,
+                                               [ obj.session.key, obj.list.au[0].ws_ou() ],
+                                               false
+                                       ]
+                               );
+                               try {
+                                       f();
+                               } catch(E) {
+                                       var error = 'Error: ' + js2JSON(E);
+                                       obj.error.sdump('D_ERROR',error);
+                                       throw(E);
+                               }
+                       }
+               );
 
                if (typeof this.on_complete == 'function') {
 
index c9b924e..28e2def 100644 (file)
@@ -140,6 +140,7 @@ const api = {
        'FM_BRE_DELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.delete', 'secure' : false },
        'FM_BRE_UNDELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.undelete', 'secure' : false },
        'FM_BRN_FROM_MARCXML' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.marcxml_to_brn', 'secure' : false },
+       'FM_CBT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.billing_type.ranged.retrieve.all', 'secure' : false },
        'FM_CCS_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all', 'secure' : false },
        'FM_CIRC_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve' },
        'FM_CIRC_DETAILS.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve.authoritative' },
index cf67a2d..e7451a1 100644 (file)
@@ -100,18 +100,27 @@ function patron_bill_init() {
         JSAN.use('util.functional');
         var ml = util.widgets.make_menulist(
             util.functional.map_list(
-                g.OpenILS.data.list.billing_type.sort(),
-                function(obj) { return [ obj, obj ]; }
-            )
+                g.OpenILS.data.list.cbt.sort( function(a,b) { if (a.name()>b.name()) return 1; if (a.name()<b.name()) return -1; return 0; } ), //g.OpenILS.data.list.billing_type.sort(),
+                function(obj) { return [ obj.name(), obj.id() ]; } //function(obj) { return [ obj, obj ]; }
+            ),
+            g.OpenILS.data.list.cbt.sort( function(a,b) { if (a.name()>b.name()) return 1; if (a.name()<b.name()) return -1; return 0; } )[0]
         );
         ml.setAttribute('id','billing_type');
         document.getElementById('menu_placeholder').appendChild(ml);
+        ml.addEventListener(
+            'command',
+            function() {
+                $('bill_amount').value = g.OpenILS.data.hash.cbt[ ml.value ].default_price();
+            },
+            false
+        ); 
 
         retrieve_patron();
 
         $('billing_location').setAttribute('value', g.OpenILS.data.hash.aou[ g.OpenILS.data.list.au[0].ws_ou() ].name() );
 
-        $('bill_amount').focus();
+        $('bill_amount').value = g.OpenILS.data.hash.cbt[ ml.value ].default_price();
+        $('bill_amount').select(); $('bill_amount').focus();
 
         if (xul_param('xact_id',{'modal_xulG':true})) { 
             g.mbts_id = xul_param('xact_id',{'modal_xulG':true});
@@ -150,14 +159,14 @@ function patron_bill_finish() {
                 billing.note( $('bill_note').value );
                 billing.xact( xact_id );
                 billing.amount( util.money.sanitize( $('bill_amount').value ) );
-                billing.billing_type( $('billing_type').value );
+                billing.billing_type( g.OpenILS.data.hash.cbt[$('billing_type').value].name() );
             var mb_id = g.network.request(
                 api.FM_MB_CREATE.app,
                 api.FM_MB_CREATE.method,
                 [ ses(), billing ]
             );
             if (typeof mb_id.ilsevent != 'undefined') throw(mb_id);
-            alert($('patronStrings').getString('staff.patron.bill_wizard.patron_bill_finish.billing_added'));
+            //alert($('patronStrings').getString('staff.patron.bill_wizard.patron_bill_finish.billing_added'));
         } else {
             throw(xact_id);
         }