This commit does several things to complete the adjustment UI changes.
1) Adds "Adjust to Zero" to the "Actions" menu. It was previously only
on the right-click popup.
2) Shows or hides the void/adjustment controls based on permissions.
3) Generates a new force-verified warning if you attempt to void, but
there is also some chance that doing so would be contrary to your
negative balance policy settings.
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
staff.patron.bills.void_all_billings.void.confirm_message=Check here to confirm this message
staff.patron.bills.void_all_billings.error_voiding_bills=Error voiding bills.
staff.patron.bills.void_all_billings.billings_voided=Billings voided.
+staff.patron.bills.void_warning.title=Void Policy Warning
+staff.patron.bills.void_warning.message=WARNING: Voiding these bills may violate local policy. Are you sure you wish to continue?
staff.patron.bill_wizard.patron_bill_finish.billing_added=Billing added.
staff.patron.display.cmd_search_form.no_patron=No Patron Selected
staff.patron.display.cmd_patron_delete.dialog.title=Delete Patron Account
}
function handle_void_all() {
+ var prohibit_default = g.data.hash.aous['bill.prohibit_negative_balance_default'];
+ var prohibit_on_overdues = g.data.hash.aous['bill.prohibit_negative_balance_on_overdues'];
+ if (prohibit_on_overdues === undefined) prohibit_on_overdues = prohibit_default;
+ var prohibit_on_lost = g.data.hash.aous['bill.prohibit_negative_balance_on_lost'];
+ if (prohibit_on_lost === undefined) prohibit_on_lost = prohibit_default;
+
+ if (prohibit_on_overdues || prohibit_on_lost) {
+ var choice = g.error.yns_alert_original(
+ $("patronStrings").getString('staff.patron.bills.void_warning.message'),
+ $("patronStrings").getString('staff.patron.bills.void_warning.title'),
+ $('commonStrings').getString('common.yes'),
+ $('commonStrings').getString('common.no'),
+ null,
+ $('commonStrings').getString('common.confirm')
+ );
+ if (choice != 0) return;
+ }
if(g.bill_list_selection.length > 1) {
var msg = $("patronStrings").getFormattedString('staff.patron.bill_history.handle_void.message_plural', [g.bill_list_selection]);
} else {
if (typeof au_obj.ilsevent == 'undefined') {
g.patron = au_obj;
$('credit_forward').setAttribute('value',util.money.sanitize( g.patron.credit_forward_balance() ));
+ set_patron_based_menu_options();
}
});
}
+
+function set_patron_based_menu_options() {
+ ['voidall', 'adjust_to_zero'].forEach(function (commandname) {
+ show_hide_menu_by_class(commandname + '_command', true);
+ });
+
+ $('voidall').setAttribute('hidden','true');
+ $('adjust_to_zero').setAttribute('hidden','true');
+ if (check_perms_for_patron_ou(['VOID_BILLING'])) {
+ show_hide_menu_by_class('voidall_command', false);
+ }
+ if (check_perms_for_patron_ou(['ADJUST_BILLS'])) {
+ show_hide_menu_by_class('adjust_to_zero_command', false);
+ }
+}
+
+function show_hide_menu_by_class(class_name, hidden) {
+ var nodes = document.getElementsByClassName(class_name);
+ for (var i = 0; i < nodes.length; i++) {
+ nodes[i].setAttribute('hidden', hidden);
+ }
+}
+
+function check_perms_for_patron_ou(perms) {
+ try {
+ var check = g.network.simple_request('PERM_CHECK',[ses(),ses('staff_id'),g.patron.home_ou(),perms]);
+ if (typeof check.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert('check_perms_for_patron_ou()',check);
+ return false;
+ }
+ return check.length == 0 ? true : false;
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('check_perms_for_patron_ou()',E);
+ }
+}
<menupopup id="actions_popup">
<menuitem command="opac" />
<menuitem command="copy_details" />
- <menuitem command="voidall" />
- <menuitem command="adjust_to_zero" />
+ <menuitem class="voidall_command" command="voidall" />
+ <menuitem class="adjust_to_zero_command" command="adjust_to_zero" />
<menuitem command="refund" />
<menuitem command="add" />
<menuitem command="details" />
<menupopup>
<menuitem command="opac" />
<menuitem command="copy_details" />
- <menuitem command="voidall" />
+ <menuitem class="voidall_command" command="voidall" />
+ <menuitem class="adjust_to_zero_command" command="adjust_to_zero" />
<menuitem command="refund" />
<menuitem command="add" />
<menuitem command="details" />
init_lists();
+ check_void_button();
+
retrieve_mb();
retrieve_mp();
if (mb_list.length == 0) { alert($("patronStrings").getString('staff.patron.bill_details.handle_void.voided_billings.alert')); return; }
var sum = 0;
- for (var i = 0; i < mb_list.length; i++) sum += util.money.dollars_float_to_cents_integer( mb_list[i].amount() );
- sum = util.money.cents_as_dollars( sum );
+ var has_overdue = false;
+ var has_lost_or_lo = false;
+ for (var i = 0; i < mb_list.length; i++) {
+ var bill = mb_list[i];
+ sum += util.money.dollars_float_to_cents_integer( bill.amount() );
+ var btype = bill.btype();
+ if (!has_overdue && btype == 1) {
+ has_overdue = true;
+ } else if (!has_lost_or_lo && (btype == 3 || btype == 4 || btype == 10 || btype == 11)) {
+ has_lost_or_lo = true;
+ }
+ }
+ var prohibit_default = g.data.hash.aous['bill.prohibit_negative_balance_default'];
+ var prohibit_on_overdues = g.data.hash.aous['bill.prohibit_negative_balance_on_overdues'];
+ if (prohibit_on_overdues === undefined) prohibit_on_overdues = prohibit_default;
+ var prohibit_on_lost = g.data.hash.aous['bill.prohibit_negative_balance_on_lost'];
+ if (prohibit_on_lost === undefined) prohibit_on_lost = prohibit_default;
+ if (has_overdue && prohibit_on_overdues || has_lost_or_lo && prohibit_on_lost) {
+ var choice = g.error.yns_alert_original(
+ $("patronStrings").getString('staff.patron.bills.void_warning.message'),
+ $("patronStrings").getString('staff.patron.bills.void_warning.title'),
+ $('commonStrings').getString('common.yes'),
+ $('commonStrings').getString('common.no'),
+ null,
+ $('commonStrings').getString('common.confirm')
+ );
+ if (choice != 0) return;
+ }
+ sum = util.money.cents_as_dollars( sum );
var msg = $("patronStrings").getFormattedString('staff.patron.bill_details.handle_void.confirm_void_billing', sum);
var r = g.error.yns_alert(msg,
$("patronStrings").getString('staff.patron.bill_details.handle_void.confirm_void_billing_title'),
}
}
+function check_void_button() {
+ try {
+ var check = g.network.simple_request('PERM_CHECK',[ses(),ses('staff_id'),g.au_obj.home_ou(),['VOID_BILLING']]);
+ if (typeof check.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert('check_void_button()',check);
+ return;
+ }
+ if (check.length != 0) $('void').setAttribute('hidden', true);
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('check_void_button()',E);
+ }
+}