[OPEN-ILS-DEV] [RFC] Price (or percent thereof) as max fine amount.

Bill Erickson erickson at esilibrary.com
Sun Jul 27 08:52:57 EDT 2008


On Saturday 26 July 2008 10:52 Mike Rylander wrote:
> We've had requests in the past for the ability to use an item's price
> as the max fine amount on a circulation, instead of a predefined
> amount.  Because of how rules are defined and chosen in Evergreen
> today, the solution to this request had not presented itself in a
> clear and consistent manner.  However, John Craig of Alpha-G
> Consulting (another firm getting into the  Evergreen support and
> migration biz) was wondering about a specialization of this idea and
> how it might be implemented.  He has had a request to be able to use a
> percentage of the item price as the max fine amount -- and this, it
> turns out, is the twist that finally made the solution stand out,
> bright as day as if it had always been right there, as a consistent
> and general extension of the existing framework.
>
> John and I went to our separate corners and dummied up a plan for
> this, and it turns out that we both saw the same solution.  Here
> attached is an implementation of that solution, which works thusly:
>
> * The config.rule_max_fine table gets a new boolean column called
> is_percent which defaults to false
> * The IDL (and, for good measure, the storage server's ancient
> equivelant) is taught about this new field
> * OpenILS::Circ::Circulate::build_checkout_circ_object inspects this
> field on the chosen rule for truthiness, and finding a positive
> result:
>   - gets the item price from the copy and
>   - if that's null (not allowed yet, but will be in 1.4) attempts to
> find an org_unit-appropriate default item price (also used for LOST
> fee)
>   - or, if price == 0 and the "charge default on 0-price" org unit
> setting is true, attempts to find an org_unit-appropriate default item
> price (also used for LOST fee)
>   - and now, having found an appropriate full price for the item,
> interprets the max fine amount as a percentage value, scaling the full
> price as specified
>   - and finally, uses that amount as the max fine amount, instead of a
> specific value
>
> As an example, say you have an item being checked out and the max fine
> rule chosen for this circulation looks like this:
>
>   name = up_to_half_of_price
>   amount = 50.00
>   is_percent = true
>
> and the item price is 20.00.  The max fine for that circ would be set
> to 10.00 ...
>
> Another example with the same rule, but the copy has a null (in 1.4)
> price or a price of 0.00 and "charge default on 0-price" org unit
> setting is in effect, and that default price is 25.00.  The max fine
> would be set to 12.50.
>
> And, finally, if the max fine amount is 100.00, the full price of the
> copy or the default price (the original request) would be used.  We
> have come full circle.
>
> Thoughts?


I think it's a great addition.  I eyeballed the patch and it looks good.  
(comment:  instead of redefining isTrue, we can use $U->isTrue).  

One addition to consider is adding an org-setting cache (just a local data 
structure) for default item price and charge-on-0 to reduce network calls.  
That can come later, though.

Good work, guys.

-bill 

-- 
Bill Erickson
| VP, Software Development & Integration
| Equinox Software, Inc. / The Evergreen Experts
| phone: 877-OPEN-ILS (673-6457)
| email: erickson at esilibrary.com
| web: http://esilibrary.com


More information about the Open-ils-dev mailing list