LP#1496522 Restructure balance notification action trigger collab/dbwells/LP1496522_action_trigger_for_periodic_billing_statement
authorDan Wells <dbw2@calvin.edu>
Fri, 19 May 2017 19:08:55 +0000 (15:08 -0400)
committerDan Wells <dbw2@calvin.edu>
Fri, 19 May 2017 19:13:54 +0000 (15:13 -0400)
commit12c7a513fca155d3576d5f961748d463f333e974
treedb3c57e77eba2b461f137bf9f73b323953a5bd0a
parente1021070ef7f45a9e5b04455c49058154b05d9b0
LP#1496522 Restructure balance notification action trigger

This commit builds on the work that Blake had done, with two main goals.
First, it pushes some of the logic down the stack to reduce churn.
Second, it renames and relabels a number of things to better match
precedent.

For the first part, one particular concern with the existing code is
that it unavoidably generates 'invalid' events.  With the balance_owed
filter applied, this problem was reduced but not eliminated.  The
solution in this commit may be overkill, but it might also serve as a
model for similar cases.

In brief, this code extends the new view to do the necessary setting
lookup and subsequent filtering in the DB layer, thereby avoiding any
dead ends, and in fact eliminating the need for event validation at all.

For the second, the following strings were changed, mostly to match
existing precedent, but occasionally just for clarity:

Trigger name:
- was: patron_has_bills
- now: money.usr_exceeds_balance_threshold

View name:
- was: money.usr_summary_per_org_unit (still exists for future reuse)
- now: money.usr_exceeds_balance_threshold (builds on original generic
  view)

Setting name:
- was: patron.notify_bills_when_exceeds
- now: circ.notify_when_balance_exceeds

Setting label:
- was: Notify Patron bill when exceeds
- now: Notify Patron When Balance Exceeds

Event definition name:
- was: Patron recurring 1 month billing notice
- now: Monthly Patron Balance Notice

Additional notes:
- I did not understand the supplied tests as written, as they appeared
  to merely create everything, then see if those things were created.  I
  left one test which checks if the base view exists and at least
  functions.  We probably really want a live test for this if possible.

- The template in the seed file was all indented within the multi-line
  quote, which seemed likely to cause problems.  This indent is removed.

- The new view requires (I believe) PG 9.3+.  It references a previous
  column in a later join, similar to a lateral join. Version 9.3 is the
  baseline since 2.11, so this should be fine for all supported EG
  versions.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/examples/action_trigger_filters.json.example
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm
Open-ILS/src/sql/Pg/500.view.cross-schema.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/t/lp1496522_action_trigger_for_periodic_billing_statement.pg
Open-ILS/src/sql/Pg/upgrade/XXXX.action_trigger_for_periodic_billing_statement.sql
docs/RELEASE_NOTES_NEXT/LP1496522_action_trigger_for_periodic_billing_statement.txt