<eg-grid-field path="cash_payment.cash_drawer.name" parent-idl-class="mbp"
label="[% l('Cash Drawer') %]"></eg-grid-field>
- <eg-grid-field path="accepting_usr">{{item.staff_name}} ({{item.staff_barcode}}) @ {{item.staff_org}}</eg-grid-field>
+ <eg-grid-field path="accepting_usr" label="[% l('Login') %]">
+ {{item.staff_name}} ({{item.staff_barcode}})
+ </eg-grid-field>
+
+ <eg-grid-field path="refundable_payment_staff" label="[% l('Staff') %]">
+ </eg-grid-field>
<eg-grid-field path="amount"></eg-grid-field>
<eg-grid-field path="id"></eg-grid-field>
label="[% l('Staff Barcode') %]" hidden required></eg-grid-field>
<eg-grid-field path="accepting_usr.home_ou.shortname" name="staff_org"
- label="[% l('Staff Org Unit') %]" hidden required></eg-grid-field>
+ label="[% l('Staff Home Org Unit') %]" hidden required></eg-grid-field>
</eg-grid>
}
+ // Reprints the lost/paid (refundable payment) receipt for the
+ // most recent payment on a refundable transaction.
+ $scope.printLostPaidReceipt = function(items) {
+ if (items.length == 0) return;
+
+ var ids = items.map(function(item) {return item.id});
+
+ function printOne() {
+ var id = ids.shift();
+ if (!id) return $q.when();
+
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.refundable_payment.receipt.by_xact.html',
+ egCore.auth.token(), id
+ ).then(function(receipt) {
+
+ if (receipt &&
+ receipt.textcode == 'MONEY_REFUNDABLE_XACT_SUMMARY_NOT_FOUND') {
+ alert('Cannot generate lost/paid receipt for transaction #' + id);
+ return;
+ }
+
+ if (!receipt || !receipt.template_output()) {
+ return alert(
+ 'Error creating refundable payment receipt for transaction #' + id);
+ }
+
+ var html = receipt.template_output().data();
+ return egCore.print.print({
+ context : 'default',
+ content_type: 'text/html',
+ content: html,
+ show_dialog: true,
+ scope : {}
+ });
+ }).then(printOne);
+ }
+
+ printOne();
+ }
+
// note this is functionally equivalent to selecting a neg. transaction
// then clicking Apply Payment -- this just adds a speed bump (ditto
// the XUL client).
var paymentGrid = $scope.paymentGridControls = {
setQuery : function() { return {xact : xact_id} },
- setSort : function() { return ['payment_ts'] }
+ setSort : function() { return ['payment_ts'] },
+ allItemsRetrieved: function() {
+ // See if any of these payments are refundable.
+ // If so, fetch the staff A/D login name for display.
+ var items = $scope.paymentGridControls.allItems().concat([]);
+
+ function fetchOne() {
+ var item = items.shift();
+ if (!item) { return $q.when(); }
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.refundable_payment.retrieve.by_payment',
+ egCore.auth.token(), item.id
+ ).then(function(rfPayment) {
+ if (rfPayment) {
+ item.refundable_payment_staff =
+ rfPayment.staff_email().replace(/@.*/g, ''); // remove @kcls.org
+ }
+ fetchOne();
+ })
+ }
+ fetchOne();
+ }
}
// -- actions
if (end == today) end = 'now';
return [start, end];
}
+
+ // Reprints the lost/paid (refundable payment) receipt for selected payments
+ $scope.printLostPaidReceipt = function(items) {
+ if (items.length == 0) return;
+
+ var ids = items.map(function(item) {return item.id});
+
+ function printOne() {
+ var id = ids.shift();
+ if (!id) return $q.when();
+
+ return egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.refundable_payment.receipt.by_pay.html',
+ egCore.auth.token(), id
+ ).then(function(receipt) {
+
+ if (receipt &&
+ receipt.textcode == 'MONEY_REFUNDABLE_PAYMENT_SUMMARY_NOT_FOUND') {
+ alert('Cannot generate lost/paid receipt for payment #' + id);
+ return;
+ }
+
+ if (!receipt || !receipt.template_output()) {
+ return alert(
+ 'Error creating refundable payment receipt for payment #' + id);
+ }
+
+ var html = receipt.template_output().data();
+ return egCore.print.print({
+ context : 'default',
+ content_type: 'text/html',
+ content: html,
+ show_dialog: true,
+ scope : {}
+ });
+ }).then(printOne);
+ }
+
+ printOne();
+ }
}])