From: erickson Date: Fri, 7 Jul 2006 17:03:09 +0000 (+0000) Subject: making progress toward a real circ matrix X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=42e15c50bfef5f869aff523a2beb7f13ba00f5ca;p=Evergreen.git making progress toward a real circ matrix git-svn-id: svn://svn.open-ils.org/ILS/trunk@4929 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/javascript/backend/circ/circ_duration.js b/Open-ILS/src/javascript/backend/circ/circ_duration.js index 98ae70da46..5c61aa69b3 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_duration.js +++ b/Open-ILS/src/javascript/backend/circ/circ_duration.js @@ -1,13 +1,308 @@ +function go(){ -function go() { - -/* load the lib script */ -load_lib('circ_lib.js'); +load_lib('circ/circ_lib.js'); log_vars('circ_duration'); -/* set sane defaults */ +/* ----------------------------------------------------------------------------- + Configure the duration rules for the various item types and circ modifiers + + MARC Fixed Field info: + http://www.oclc.org/bibformats/en/fixedfield/ + + ----------------------------------------------------------------------------- */ + + + + + +var MARC_ITEM_TYPE_MAP = { + + a : { /* Language material [Books] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + t : { /* Manuscript language material [Books] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + g : { /* Projected medium [Videos, etc.] */ + durationRule : '7_days_0_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + k : { /* Two-dimensional nonprojectable graphic [Card, charts, etc.] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + r : { /* Three-dimensional artifact or naturally occurring object [Models, games, etc.] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + o : { /* Kit [Mixture of item types] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + p : { /* Mixed materials [Mixture of item types] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + e : { /* Cartographic material [Map] */ + durationRule : '3_days_1_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + f : { /* Manuscript cartographic material [Map] */ + durationRule : '3_days_1_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + c : { /* Notated music [Printed music] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + d : { /* Manuscript notated music [Printed music] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + i : { /* Nonmusical sound recording [Audiobooks, sound effects, etc.] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + j : { /* Musical sound recording [Music] */ + durationRule : '14_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + m : { /* Computer file */ + durationRule : '7_days_2_renew', + recurringFinesRule : '10_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + } +} + + +var CIRC_MOD_MAP = { + + 'Atlas' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Bestseller (high demand)' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Bestseller not high demand' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Bestseller-not holdable' : { + durationRule : '7_days_2_renew', + recurringFinesLevel : 'normal', + recurringFinesRule : '50_cent_per_day', + maxFine : 'overdue_mid' + }, + + 'Compact Disc' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'DVD' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'DVD with long loan period' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Filmstrip' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Laserdisc' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Magazine-Circulating' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'New AV material' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'New Book' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Pamphlet' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Record' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Talkingbook' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Toy' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Video (high demand)' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + }, + + 'Video public performance' : { + durationRule : '7_days_2_renew', + recurringFinesRule : '50_cent_per_day', + recurringFinesLevel : 'normal', + maxFine : 'overdue_mid' + + } +} + + + + + + +/* Get the load duration level directly from the copy */ result.durationLevel = copy.loan_duration; -result.durationRule = "2wk_default"; + + +/* ----------------------------------------------------------------------------- + If a circ_modifier is defined on the copy and we have config info for the + provided circ_modifier, use that config. Otherwise fall back on the MARC + item type + ----------------------------------------------------------------------------- */ +var marcType = getMARCItemType(); +var circMod = copy.circ_modifier; +var config = + ( circMod && CIRC_MOD_MAP[circMod] ) ? + CIRC_MOD_MAP[circMod] : + MARC_ITEM_TYPE_MAP[marcType]; + + +if( CIRC_MOD_MAP[circMod] ) + log_debug("a circ_mod config exists for the copy"); + +if( MARC_ITEM_TYPE_MAP[marcType] ) + log_debug("an item_type config exists for the copy"); + + +log_debug("Copy circ modifier = " + circMod + " and item type = " + marcType ); + + + + +/* ----------------------------------------------------------------------------- + Now set the rule values based on the config. If there is no configured info + on this copy, fall back on defaults. + ----------------------------------------------------------------------------- */ +if( config ) { + log_debug("circ_duration found a config for the copy"); + result.durationRule = config.durationRule; + result.recurringFinesRule = config.recurringFinesRule; + result.recurringFinesLevel = config.recurringFinesLevel; + result.maxFine = config.maxFine; + +} else { + result.durationRule = '14_days_2_renew'; + result.recurringFinesRule = "10_cent_per_day"; + result.recurringFinesLevel = 'normal'; + result.maxFine = "overdue_mid"; +} + + +/* ----------------------------------------------------------------------------- + Add custom rules here. + ----------------------------------------------------------------------------- */ diff --git a/Open-ILS/src/javascript/backend/circ/circ_lib.js b/Open-ILS/src/javascript/backend/circ/circ_lib.js index cbcf0d70b5..8b80cb68b3 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_lib.js +++ b/Open-ILS/src/javascript/backend/circ/circ_lib.js @@ -1,5 +1,5 @@ -load_lib('../catalog/record_type.js'); -load_lib('../circ/circ_groups.js'); +load_lib('catalog/record_type.js'); +load_lib('circ/circ_groups.js'); /* ----------------------------------------------------------------------------- Collect all of the global variables @@ -147,8 +147,22 @@ function __isGroupDescendant( parent, child ) { } +function getMARCItemType() { + + if( copy && + copy.circ_as_type && + copy.circ_as_type != 'undef' ) + return copy.circ_as_type; + + return extractFixedField(marcXMLDoc, 'Type'); +} +function isOrgDescendent( parentName, childId ) { + var val = environment.__OILS_FUNC_isOrgDescendent(parentName, childId); + if( val == '1' ) return true; + return false; +} @@ -164,7 +178,6 @@ var form_name = item_form_map[env.record_descriptor.item_form]; /* logs a load of info */ function log_vars( prefix ) { - var str = prefix + ' : '; if(patron) { diff --git a/Open-ILS/src/javascript/backend/circ/circ_max_fines.js b/Open-ILS/src/javascript/backend/circ/circ_max_fines.js index ec22cf0078..e931fd4260 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_max_fines.js +++ b/Open-ILS/src/javascript/backend/circ/circ_max_fines.js @@ -2,7 +2,7 @@ function go() { /* load the lib script */ -load_lib('circ_lib.js'); +load_lib('circ/circ_lib.js'); log_vars('circ_max_fine'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js b/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js index d9c37613e2..178e144597 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js @@ -1,10 +1,7 @@ function go() { /* load the lib script */ -load_lib('circ_lib.js'); -load_lib('circ_groups.js'); -load_lib('../catalog/record_type.js'); - +load_lib('circ/circ_lib.js'); log_vars('circ_permit_copy'); @@ -21,12 +18,13 @@ if(copyStatus != 'Available' && result.events.push('COPY_NOT_AVAILABLE'); } -var type = extractFixedField(marcXMLDoc, 'Type'); -log_stdout('type = ' + type); -/* this should happen very rarely .. but it should at least require an override */ -if( extractFixedField(marcXMLDoc, 'Type') == 'g' - && copy.circ_lib != patron.home_ou.id ) +/* this should happen very rarely .. + but it should at least require an override */ + + +if( getMARCItemType() == 'g' + && copy.circ_lib.id != patron.home_ou.id ) result.events.push('CIRC_EXCEEDS_COPY_RANGE'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js index e871a8064a..a24f8584bc 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js @@ -1,15 +1,13 @@ function go() { -load_lib('circ_lib.js'); -load_lib('circ_groups.js'); -load_lib('../catalog/record_type.js'); +load_lib('circ/circ_lib.js'); log_vars('circ_permit_hold'); /* projected medium */ -if( extractFixedField(marcXMLDoc, 'Type') == 'g' +if( getMARCItemType() == 'g' && copy.circ_lib != patron.home_ou.id ) result.events.push('CIRC_EXCEEDS_COPY_RANGE'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js b/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js index a7748d7cbc..20152285c7 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js @@ -1,9 +1,7 @@ function go() { /* load the script library */ -load_lib('circ_lib.js'); -load_lib('circ_groups.js'); - +load_lib('circ/circ_lib.js'); log_vars('circ_permit_patron'); @@ -12,15 +10,16 @@ if( isTrue(patron.barred) ) result.events.push('PATRON_BARRED'); - - /* --------------------------------------------------------------------- Check the items out count --------------------------------------------------------------------- */ var config = findGroupConfig(patronProfile); if( config ) { - if( patronItemsOut >= 0 && patronItemsOut > config.maxIitemsOut ) + + if( (config.maxItemsOut >= 0) && (patronItemsOut >= config.maxItemsOut) ) { result.events.push('PATRON_EXCEEDS_CHECKOUT_COUNT'); + } + } else { log_warn("** profile has no configured information: " + patronProfile); } diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js b/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js index 4193c18590..7fad3ee169 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js @@ -1,7 +1,7 @@ function go() { /* load the lib script */ -load_lib('circ_lib.js'); +load_lib('circ/circ_lib.js'); /* collect some useful variables */ var copy = environment.copy; diff --git a/Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js b/Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js index 7bcc352472..73a38c31f8 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js +++ b/Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js @@ -2,7 +2,7 @@ function go() { /* load the lib script */ -load_lib('circ_lib.js'); +load_lib('circ/circ_lib.js'); log_vars('circ_recurring_fines'); /** diff --git a/Open-ILS/src/javascript/backend/penalty/patron_penalty.js b/Open-ILS/src/javascript/backend/penalty/patron_penalty.js index e82752b23e..880f64fd93 100644 --- a/Open-ILS/src/javascript/backend/penalty/patron_penalty.js +++ b/Open-ILS/src/javascript/backend/penalty/patron_penalty.js @@ -1,9 +1,7 @@ function go() { /* load the lib script */ -load_lib('../circ/circ_lib.js'); -load_lib('../catalog/record_type.js'); -load_lib('../circ/circ_groups.js'); +load_lib('circ/circ_lib.js'); log_vars('patron_penalty'); var config = findGroupConfig(patronProfile);