LP #1075167: Serials: Avoid infinite loop in holdings summarization

When receiving items with unworkable combinations of holdings and
patterns, the holdings summarization code can get stuck in an infinite
loop.  This solution prevents that, sparing the open-ils.serial
process and server resources, although it doesn't help the user out.

It will take further examination of the problem and reëvalution of how
we deal with problems reported by OpenILS::Utils::MFHD to help the
user avoid or resolve these situations.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Only consider main entry headings for bib overlay

Restrict the authority fields we will pull overlay data from to those
that do not subordinate themselves to other authority fields.  That
is, skip see-from/see-also/etc for bib overlay.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Fix a data destruction bug when authorities are updated.

Modify the two-argument form of vandelay.merge_record_xml to return
the target_marc when the add_rule, preserve_rule, replace_rule and
strip_rule are all empty.

This method is used by authority.propagate_changes and would replace
the bibliographic record's marc with the overlay template when the
above would happen. By returning the biblographic record entry's own
marc in that case, we prevent data destruction.

Additionally, protect bib and authority template overlay functions
in the same manner.

Commit includes an upgrade script for this change as well as
for the previous commit's authority.generate_overlay_template fix.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Custom/local EDI reader module for ORDRSP and INVOIC (etc)

Provides a new perl module (OpenILS::Utils::EDIReader) for reading
inbound EDI messages and producing data structures more easily
understood by the ACQ code.  Through this, extraction of EDI data is
focused in one module instead of spread through various layers.

EDIReader is a small, purpose built module focusing solely on extracting
the needed EDI data and is not meant to be a general purpose EDI library.

* Updates edi_fetcher and the ORDRSP and INVOIC handling code to use the
  new libs.

* Removes Business::EDI Evergreen dependency, since it's no longer used (and
  is quite large).

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDIReader : detect SAN vs. account number in buyer/seller

NAD+BY+XXXXXXX::31B' -- SAN
NAD+BY+YYYYYYY::91' -- Account number

For invoices, try the SAN first followed by the account number to
determine the receiving org unit.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDI: protect against invalid order response

Do not attempt to createI EDI messages for order responses which
reference nonexistent purchase orders, since it results in
transaction commit errors on invalid foreign keys, preventing
subsequent EDI files from getting processed.  Instead, log it
and skip it.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDI response honor lineitem-level status; debit cleanup

* Honor lineitem-level order status info (FTX+LIN) which indicates, in
  some cases, that all ordered copies should be cancelled because the LI
  as a whole is cancelled

* Delete fund debits for cancelled lineitem details when appropriate

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDI: ensure lineitem 'state' matches cancel state

When cancelling a lineitem becuase all linked copies are cancelled,
ensure that the lineitem state is set to "cancelled".

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDI invoice date; invoice paid quantity/amount

* capture the invoice date in EDIReader
* apply the invoice date to inbound invoices when available instead of
  defaulting to 'now'
* apply the quantity/amount billed to the quantity/amount paid to reduce
  staff data entry needs

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDIReader: improve monetary regexes

Make no attempt to enforce/decipher monetary amounts in the regexes,
simply capture the values.  If they are invalid, Postgres will let us
know.

This change allows us to capture non-numeric (\d) characters (e.g. "."),
which are of course common in monetary amounts.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Handle cancelled (back-order) lineitems in EDI invoice

Receiving an invoice for a cancelled lineitem mean the lineitem is no
longer cancelled.  Identify such lineitems and uncancel them along with
the requested number of not-yet-invoiced copies.

This work flow is common for back-order items.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDIReader release notes

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Upgrade script numbering for edireader branch

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
EDI order template improvements (no SQL upgrade script!)

Improved template for EDI purchase orders.  This theoretically just
works better where the old template worked.  Corrections made for
interactions with ULS, Midwest Tape, Baker & Taylor, and Recorded Books
especially.  GIR segments in the right place.

And also the template is just more maintainable now.

**THERE IS NO UPGRADE SCRIPT INCLUDED**.  Sites using EDI may not
necessarily want to mess with what they already have working.

If you want the changes, and maybe you do, especially if you're doing
enriched ordering and/or ordering from the vendors listed above, you can
extract the template changes easily enough yourself from the
950.data.seed-values.sql file.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Borrowing items: who, what, for how long

Adding Borrowing Items chapter from Evergreen in Action to the official
docs.`

Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Docs: minor formatting fixes for "borrowing items" chapter

* Images need to have a trailing [] ; ideally this would contain the
  alt text for the image, but the [] is needed to make the images
  show up at all
* Since we're touching the image:: tags anyway, make the filename
  extensions consistently lower case
* Fix a processing error; a bulleted list item wrapped so that > was the
  first character on a line, which made Asciidoc angry. Easiest thing to
  do to avoid this is just to indent the wrapped lines for each bullet
  item, but we'll do the minimal thing and just indent this one line
  this time.
* Fix one instance of Word "smart quotes" having replaced ye olde single
  quotes.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
ACQ invoice search persistence repaired

Use XUL cookieService / cookieManager for managing cookies in embedded
web pages, since dojo.cookie cannot manage cookies within xulrunner.

Persist cookies for 30 days.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
2.3 Release notes update

Merge the edireader and edi_order_template release notes into the 2.3
release notes files.  Added a blurb to the Upgrade Notes regarding the
lack of an automatic EDI template upgrade.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
LP#1098669: improve handling of Content Cafe external content in staff client

This patch introduces a new TPac content variable, ctx.ext_proto, to
specify whether external content should be retrieved via HTTP or HTTPS.
ctx.proto can't be used for that purpose since it's set to 'oils' when
TPac is running inside the staff client.

This fixes a bug where Content Cafe reviews wouldn't display in the staff
client bib record page and where clicking on the reviews link from search
results would open an empty window.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Fix backdate near DST changes

When the due date and the backdate date are on opposite sides of a DST
boundary we were getting an hour off on the checkin time (using the
original due date's time).

This commit changes it so that instead we just set the hour and minute
values on the backdate date to the due date's versions, leaving the time
zone alone.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>