From: Dan Wells Date: Tue, 15 Sep 2015 19:28:44 +0000 (-0400) Subject: LP#1494544 Complete XUL UI for adjustment vs. void options X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=21286645e479aef917476117ebbadb0d7b1d9458;p=evergreen%2Fequinox.git LP#1494544 Complete XUL UI for adjustment vs. void options 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 Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index e8e48dccbf..2aedce3838 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -87,6 +87,8 @@ staff.patron.bills.void_all_billings.void.no=No 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 diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index ee0cc62d52..8f0c19beaa 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -714,6 +714,23 @@ function handle_add() { } 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 { @@ -1119,6 +1136,42 @@ function refresh_patron() { 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); + } +} diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.xul b/Open-ILS/xul/staff_client/server/patron/bill2.xul index 6fbd90d507..ef781b13d5 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill2.xul @@ -51,8 +51,8 @@ - - + + @@ -146,7 +146,8 @@ - + + diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index cb5f3c2949..8bb2fcc592 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -223,6 +223,8 @@ function my_init() { init_lists(); + check_void_button(); + retrieve_mb(); retrieve_mp(); @@ -319,9 +321,36 @@ function handle_void() { 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'), @@ -359,3 +388,15 @@ function handle_void() { } } +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); + } +}