bill patron dialog cont; sorta working
authorBill Erickson <berick@esilibrary.com>
Wed, 21 May 2014 21:36:25 +0000 (17:36 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 21 May 2014 21:36:25 +0000 (17:36 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index 8fabfa8..8aefec4 100644 (file)
@@ -56,6 +56,44 @@ function($q , egCore , patronSvc) {
         });
     }
 
+    service.billPatron = function(args) {
+        var groc = new egCore.idl.mg();
+        groc.billing_location(egCore.auth.user().ws_ou());
+        groc.note(args.note);
+        groc.usr(patronSvc.current.id());
+        
+        // create the xact
+        return egCore.net.request(
+            'open-ils.circ',
+            'open-ils.circ.money.grocery.create',
+            egCore.auth.token(), groc
+
+        // create the billing on the new xact
+        ).then(function(xact_id) {
+            if (evt = egCore.evt.parse(xact_id)) 
+                return alert(evt);
+
+            var bill = new egCore.idl.mb();
+            bill.xact(xact_id);
+            bill.amount(args.amount);
+            bill.btype(args.billingType);
+            bill.billing_type(egCore.env.cbt.map[args.billingType].name());
+            bill.note(args.note);
+
+            return egCore.net.request(
+                'open-ils.circ', 
+                'open-ils.circ.money.billing.create',
+                egCore.auth.token(), bill
+            );
+
+        // check the billing response
+        }).then(function(bill_id) {
+            if (evt = egCore.evt.parse(bill_id)) 
+                return alert(evt);
+
+        });
+    }
+
     return service;
 }])
 
@@ -230,8 +268,12 @@ function($scope,  $q , $routeParams,  $locale , egCore , egGridDataProvider , bi
             }
         }).result.then(
             function(args) {
-                console.log('BILL: ' + JSON.stringify(args));
-                //billSvc.billPatron(args);
+                // send the billing to the server using the arguments
+                // provided in the billing dialog, then refresh
+                billSvc.billPatron(args).then(function() {
+                    $scope.payment_amount = 0;
+                    $scope.gridRevision++;
+                });
             }
         );
     }