<script>
angular.module('egCoreMod').run(['egStrings', function(s) {
s.ANNOTATE_PAYMENT_MSG = "[% l('Please annotate this payment') %]";
+ s.CONFIRM_ADJUST_TO_ZERO =
+ "[% |l('{{xactIds}}') -%]Are you sure you would like to adjust to zero the balance on bills [_1]?[% END %]";
s.CONFIRM_REFUND_PAYMENT =
"[% |l('{{xactIds}}') -%]Are you sure you would like to refund excess payment on bills [_1]? This action will simply put the amount in the Payment Pending column as a negative value. You must still select Apply Payment! Certain types of payments may not be refunded. The refund may be applied to checked transactions that follow the refunded transaction.[% END %]";
s.EDIT_BILL_PAY_NOTE = "[% l('Enter new note for #[_1]:','{{ids}}') %]";
<eg-grid-action label="[% l('Void All Billings') %]"
handler="voidAllBillings"></eg-grid-action>
+ <eg-grid-action label="[% l('Adjust to Zero') %]"
+ handler="adjustToZero"></eg-grid-action>
+
<eg-grid-action label="[% l('Refund') %]"
handler="refundXact"></eg-grid-action>
});
}
+ service.adjustBillsToZero = function(bill_ids) {
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.money.billable_xact.adjust_to_zero',
+ egCore.auth.token(),
+ bill_ids
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) return alert(evt);
+ return resp;
+ });
+ }
+
service.updateBillNotes = function(note, ids) {
return egCore.net.requestWithParamList(
'open-ils.circ',
});
}
+ $scope.adjustToZero = function(items) {
+ if (items.length == 0) return;
+
+ var ids = items.map(function(item) {return item.id});
+
+ egCore.audio.play('warning.circ.adjust_to_zero_confirmation');
+ egConfirmDialog.open(
+ egCore.strings.CONFIRM_ADJUST_TO_ZERO, '',
+ { xactIds : ''+ids,
+ ok : function() {
+ billSvc.adjustBillsToZero(ids).then(function() {
+ refreshDisplay();
+ });
+ }
+ }
+ );
+
+ }
+
// note this is functionally equivalent to selecting a neg. transaction
// then clicking Apply Payment -- this just adds a speed bump (ditto
// the XUL client).