How to ensure a circulation transaction matches on a specified loan rule

When testing a circulation transaction in FOLIO, it's often important to be able to know that your loan transaction is going to match on a specific loan rule.

E.g., you know that you want to test the behavior of your new loan policy named "Library Long Loan Policy", but every time you check a book out, it matches on "Library Special Policy" and you can't tell why.

This can be especially true on environments where multiple people are maintaining circulation rules, because what rule matches depends not just on the rules that a library has written, but how it has defined circulation priority and the fallback policy.

So, this page outlines a technique you can use to ensure that your transaction will match on the same rule every time.

  1. Create a patron group (in Settings > Users > Patron groups) that you can use for testing. 
  2. Assign that patron group to the user you are testing with. (You do not have to leave it assigned to that user, but change it during the testing period.)
  3. In your circulation rule set, write a rule that matches on your patron group, and uses the "all" keyword for the other circulation criteria. The use of the "all" keyword should ensure that even if patron group is not your highest priority criteria, or if another rule matches, the loan should still match on the rule you want it to match on.

Example

In order to test a circulation rule, I create a patron group called "erin test" and assign it to my test user.

Then in the circulation rule file, I would write a rule that would look something like this:

g erin-test + m all + t all + s all: l library-long-loan-policy n send-no-notices r allow-all-requests o main-overdue i main-lost

With this rule in place, any time I check an item out to a patron with the group "erin test", it should match on this rule line. 

This means that I can also test multiple circulation policy pieces just by changing this one circulation line, as long as my test user is still configured with the right group.

Also note this approach could be applied with any of the circ rules criteria - e.g., I could create a loan-type called "erin test loan type" and write a rule that looked like this, and it would do something similar:

g all + m all + t erin-test-loan-type + s all: l library-long-loan-policy n send-no-notices r allow-all-requests o main-overdue i main-lost

The difference in this case is that this rule always matches on the item, so it would be a useful technique if I had a test item that I was wanting to use but didn't necessarily care about the user I was doing the test loan with.