}
service.applyPayment = function(
- type, payments, note, check, cc_args, patron_credit) {
+ type, payments, note, check, cc_args, patron_credit, refundable_args) {
return egCore.net.request(
'open-ils.circ',
check_number : check,
payments : payments,
patron_credit : patron_credit,
+ refundable_args: refundable_args,
cc_args : cc_args
},
patronSvc.current.last_xact_id()
function(item) {return item.id == xactId})[0];
var stopFines = gridItem['circulation.stop_fines'];
- if (stopFines === 'LOST') {
+ var ciTime = gridItem['circulation.checkin_time'];
+ if (stopFines === 'LOST' && !ciTime) {
console.debug("Processing lost payment transaction ", xactId);
lostXacts.push(xactId);
}
return $q.when(payments);
}
+ return checkSecondaryAuth().then(
+ function(authKey) {
+ return {
+ secondary_auth_key: authKey,
+ transactions: lostXacts.map(
+ function(id) {return {xact: id}})
+ };
+ },
+ function() { return $q.reject(); }
+ );
+ }
+
+ function checkSecondaryAuth(deferred) {
+
+ if (!deferred) {
+ // Create the deferred object on the first run of this function.
+ deferred = $q.defer();
+ }
+
+ showSecondaryAuthDialog().then(
+ function(authKey) {
+ if (authKey) {
+ deferred.resolve(authKey);
+ } else {
+ return checkSecondaryAuth(deferred);
+ }
+ },
+ function() {
+ deferred.reject();
+ }
+ );
+
+ return deferred.promise;
+ }
+
+ // Returns promise.
+ // Resolves to true on auth success, false on auth failure, and
+ // rejects on Cancel.
+ function showSecondaryAuthDialog() {
+
return $uibModal.open({
templateUrl : './circ/patron/t_lost_payment_auth',
backdrop: 'static',
controller : [
'$scope','$uibModalInstance',
function($scope , $uibModalInstance) {
- $scope.context = {
- username: '',
- password: ''
- };
+ $scope.context = {username: '',password: ''};
$scope.ok = function() {
- console.log($scope.context.username);
- console.log($scope.context.password);
- $uibModalInstance.close(payments);
+ getSecondaryAuthKey(
+ $scope.context.username, $scope.context.password
+ ).then(
+ function(res) {
+ $uibModalInstance.close(res);
+ }
+ );
}
$scope.cancel = function() {
}).result;
}
+ function getSecondaryAuthKey(username, password) {
+
+ console.log('Checking secondary auth for ' + username);
+
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.staff.secondary_auth.ldap',
+ egCore.auth.token(), username, password
+ ).then(function(result) {
+ var evt = egCore.evt.parse(result);
+ console.log('2nd auth returned', result);
+
+ if (evt) {
+ if (evt.textcode === 'LDAP_AUTH_FAILED') {
+ console.log("Secondary auth failed for " + username);
+ } else {
+ alert(evt);
+ }
+ } else if (typeof result === 'string') {
+ console.debug('Secondary auth succeeded with ' + result);
+ return result;
+ }
+
+ return null;
+ });
+ }
+
+
// generates payments, collects user note if needed, and sends payment
// to server.
function sendPayment(note, cc_args) {
// KCLS prompt for lost payment authorization.
handleLostPayAuth(make_payments)
- .then(function(make_payments) {
+ .then(function(refundable_args) {
// NOTE: avoiding indentation to reduce variation with stock.
- billSvc.applyPayment($scope.payment_type,
- make_payments, note, $scope.check_number, cc_args, patron_credit)
+ billSvc.applyPayment($scope.payment_type, make_payments, note,
+ $scope.check_number, cc_args, patron_credit, refundable_args)
.then(
function(payment_ids) {