Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that borrowing privileges are allowed when patron.block_reason… #1999

Conversation

dbernstein
Copy link
Contributor

… == PatronData.NO_VALUE

Description

There was some privilege checks outside for the sirsidynix horizon auth provider that I missed on the last round of changes.
This update ensures that patron.block_reason = NO_VALUE is understood to mean do not block even if there are fines.

Motivation and Context

Follow on ticket for https://ebce-lyrasis.atlassian.net/browse/PP-1589

How Has This Been Tested?

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.63%. Comparing base (0cf8c8d) to head (581c86d).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1999   +/-   ##
=======================================
  Coverage   90.63%   90.63%           
=======================================
  Files         339      339           
  Lines       40210    40208    -2     
  Branches     8702     8701    -1     
=======================================
  Hits        36444    36444           
+ Misses       2493     2492    -1     
+ Partials     1273     1272    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dbernstein dbernstein force-pushed the fix-borrow-check-when-block-reason-ignored-but-excess-fines-present branch from 79e2ebd to 581c86d Compare August 22, 2024 14:36
@dbernstein dbernstein added the bug Something isn't working label Aug 22, 2024
@dbernstein dbernstein requested a review from a team August 22, 2024 15:44
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment below...

Comment on lines +73 to +75
if patron.block_reason == PatronData.NO_VALUE:
return

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious to me why it is okay to move this ahead of checking whether the patron's card has expired. It seems unlikely that a patron with an expired card would have borrowing privileges.

If this case is actually allowed for some reason, it would be good to both (1) add a test with this scenario, and (2) update the docstring with some explanatory text.

Copy link
Member

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its safe to assume that PatronData.NO_VALUE for blocks means that we shouldn't block on fines.

We have a separate setting max_outstanding_fines

max_outstanding_fines: PositiveFloat | None = FormField(
None,
form=LibraryConfFormItem(
label="Maximum amount in fines a patron can have before losing lending privileges",
category="Loans, Holds, & Fines",
level=Level.ALL_ACCESS,
),
)
that this change would break. Especially for ILS that don't send block information, but do send fine information.

I think what you are trying to accomplished can be done by setting max_outstanding_fines to None (no value in the config form), without any code changes.

Am I understanding what you are trying to accomplish here correctly? If not can you give some more context for this change so I can understand?

@dbernstein
Copy link
Contributor Author

@jonathangreen and @tdilauro : The context here is that Vancouver uses SirsiDynixHorizon which supports the ability to ignore blocks on non-expired cards. When that setting is enabled we are setting the patron.block_reason to PatronData.NO_VALUE when we want the circulation manager to ignore block reasons. So if there are excessive fines, we just leave them be and set the block_reason to NO_VALUE. So when the code reaches the borrow check we are looking only at the fine info and not taking into account that upstream we overwrote the block reason to avoid being blocked on excessive fines.

So yes - I believe you're right @jonathangreen that setting max_outstanding_fines to None should accomplish what we want there, but we'll have to make sure to have the user both ignore blocks AND set max fines to zero. In other words it's not clear that the ignore blocks will be overridden by a max_outstanding_fines value being exceeded.

@dbernstein
Copy link
Contributor Author

I see now what you are suggesting is also how SIP2 works - ie max_outstanding_fines is set at the library level. So maybe I can close this PR.

@jonathangreen
Copy link
Member

jonathangreen commented Aug 23, 2024

@dbernstein what we currently do in the sirsi provider is the same thing we do in the SIP provider.

if "fee_amount" in info:
fines = info["fee_amount"]
else:
fines = "0"
patrondata.fines = MoneyUtility.parse(fines)
if "sipserver_patron_class" in info:
patrondata.external_type = info["sipserver_patron_class"]
for expire_field in [
"sipserver_patron_expiration",
"polaris_patron_expiration",
]:
if expire_field in info:
value = info.get(expire_field)
value = self.parse_date(value)
if value:
patrondata.authorization_expires = value
break
if self.patron_status_should_block:
patrondata.block_reason = self.info_to_patrondata_block_reason(
info, patrondata
)
else:
patrondata.block_reason = PatronData.NO_VALUE

We set the blocks based on the configuration, and set the fines as well, with the fines being enforced later. To me this makes sense. I think it would be more confusing if setting Enforce Patron ILS Blocks to false in the patron auth settings would also stop enforcing the max fines setting in the library configuration. @dwilcox might have a opinion on this one, since its question about admin facing settings.

Edit: Sorry @dbernstein your comment happened while I was writing this reply, so I didn't see it until after I posted this one. Looks like you already found the SIP2 code I referenced here.

@dbernstein
Copy link
Contributor Author

I was confused. This PR does not need to be.

@dbernstein dbernstein closed this Aug 23, 2024
@jonathangreen jonathangreen deleted the fix-borrow-check-when-block-reason-ignored-but-excess-fines-present branch August 29, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants