YAOUS Disable Patron Credit is not respected

Bug #1810419 reported by Blake GH
14
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned
3.12
Fix Released
Medium
Unassigned

Bug Description

The web staff client does not eliminate the menu item "Patron Credit" from the dropdown menu in the patron bills interface when the library has the library setting "Disable Patron Credit" = TRUE. In addition, the interface shows the patron's credit line. XUL removed those two UI elements when the setting is set.

Similar to:
bug 1775639
and
bug 1803765

The same code would probably fix all three.

Blake GH (bmagic)
tags: added: webstaffclient
tags: added: billing
removed: webstaffclient
tags: added: circ-billing orgunitsettings patron
removed: billing
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I just ran into something similar. The logic to turn off the Credit Card Payment option based on the default payment processor also isn't working on 3.11

Doing some javascript debugging in chrome, it seems like the only billing setting in bills.js line 529 that gets set is the first one for "ui.circ.billing.uncheck_bills_and_unfocus_payment_box". When I set breakpoints for the others they are never evaluated.

https://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/web/js/ui/default/staff/circ/patron/bills.js;hb=4c82f65319a104a0180235d5a9cb015b017727d6#l529

So these never get executed.

 538 if (s['ui.circ.billing.amount_warn']) {
 539 $scope.warn_amount = Number(s['ui.circ.billing.amount_warn']);
 540 }
 541 if (s['ui.circ.billing.amount_limit']) {
 542 $scope.max_amount = Number(s['ui.circ.billing.amount_limit']);
 543 }
 544 if (s['circ.staff_client.do_not_auto_attempt_print'] && angular.isArray(s['circ.staff_client.do_not_auto_attempt_print'])) {
 545 $scope.disable_auto_print = Boolean(
 546 s['circ.staff_client.do_not_auto_attempt_print'].indexOf('Bill Pay') > -1
 547 );
 548 }
 549 if (s['circ.disable_patron_credit']) {
 550 $scope.disablePatronCredit = true;
 551 }
 552 if (!s['credit.processor.default']) {
 553 // If we don't have a CC processor, we should disable the "internal" CC form
 554 $scope.disableCreditCardForm = true;
 555 } else {
 556 // Stripe isn't supported in the staff client currently, so disable here too
 557 $scope.disableCreditCardForm = (s['credit.processor.default'] == 'Stripe');
 558 }

No idea why that is though. Some sort of optimization that is treating them like one control statement and only looking at the first one that matches?

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

If I change the ui.circ.billing.uncheck_bills_and_unfocus_payment_box to false or delete it, then the other options get evaluated.

If I comment out
$scope.gridControls.selectItems([]);

then the other if statements get executed. So the $scope.gridControls.selectItems([]); function seems to be breaking out of that function.

If I move that if statement to the end of the list, that lets all the others be evaluated first before that selectItems call causes them to be skipped.

Ahhh, that call causes a type error

TypeError: $scope.gridControls.selectItems is not a function
    at bills.js:532:33
    at l (vendor.bundle.js:6:69347)
    at vendor.bundle.js:6:69793
    at f.$digest (vendor.bundle.js:6:75526)
    at vendor.bundle.js:6:77314
    at r (vendor.bundle.js:6:22067)
    at vendor.bundle.js:6:23528 'Possibly unhandled rejection: {}'

It errors out canceling execution...

 billSvc.fetchBillSettings().then(function(s) {
        if (s['ui.circ.billing.uncheck_bills_and_unfocus_payment_box']) {
            $scope.focus_payment = false; // de-focus the payment box
            $scope.gridControls.focusRowSelector = true;
            selectOnLoad = false;
            // if somehow the grid finishes rendering before our settings
            // arrive, manually de-select everything.
            $scope.gridControls.selectItems([]);
        }

So if the grid was setup before this executed, then it would work maybe... So maybe that needs an if defined check before the attempt. or just remove it?

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

After re-reading the original bug, I don't think I'm commenting on the correct bug.

But it is slightly related, in that disablePatronCredit doesn't get set if the uncheck bills setting is true, which prevents the "Convert Change to Patron Credit" option from being disabled.

I created a new bug, bug 2069358
Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Since I cluttered up this bug with my troubleshooting notes, here is a possible fix for this bug.

Add several 'ng-hide="disablePatronCredit"' attributes to the various mentions of patron credit.

 - Payment option dropdown
 - "Credit Available:$" display.

Questions for the EG Community, should the labels for "Total Paid/Credited" and "Paid/Credited for Selected:" also be adjusted when Patron Credit is disabled? I don't want to mess with translated strings if people think it isn't needed. If "Total Paid", "Paid" and "Credited" are already translated strings then it probably won't matter. But I'm unsure of where to check that.

Also, should the Credit Available show anyway if it is > $0? To avoid hiding a pre-existing credit balance, even if it cannot be used?

Testing note: if you are using the "Uncheck bills by default" YAOUS then you will run into bug 2069358 which suppresses evaluating the Disable Patron Credit setting.

I think this will also resolve bug 1803765 if committed.

Here is a working branch that just hides the two main items
user/stompro/lp1810419_bills_disable_patron_credit_fixes

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/stompro/lp1810419_bills_disable_patron_credit_fixes

Josh

tags: added: pullrequest
Revision history for this message
Lindsay Stratton (lstratton) wrote :

Testing confirms that the Payment Type = Patron Credit, Credit Available display, and Convert Change to Patron Credit toggle are suppressed when the library setting "Disable Patron Credit" = True.

The setting "Uncheck bills by default" does not does not change the patron credit - tested true, false, and unset.

IMO, Credit Available should be hidden even if > $0. For example, if LIB-A uses credit, but LIB-B does not, the credit would show at LIB-A where it can be used (and presumably has been accounted for), but not at LIB-B.

Unless further discussion is warranted re: hiding credit available display when > $0...

I have tested this code and consent to signing off on it with my name, Lindsay Stratton and my email address, <email address hidden>.

Revision history for this message
Jane Sandberg (sandbergja) wrote :

Thanks, Josh and Lindsay. Pushed to rel_3_12 and above.

tags: added: signedoff
Changed in evergreen:
importance: Undecided → Medium
status: New → Fix Committed
milestone: none → 3.13.4
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.