making progress toward a real circ matrix
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Jul 2006 17:03:09 +0000 (17:03 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Jul 2006 17:03:09 +0000 (17:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4929 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/backend/circ/circ_duration.js
Open-ILS/src/javascript/backend/circ/circ_lib.js
Open-ILS/src/javascript/backend/circ/circ_max_fines.js
Open-ILS/src/javascript/backend/circ/circ_permit_copy.js
Open-ILS/src/javascript/backend/circ/circ_permit_hold.js
Open-ILS/src/javascript/backend/circ/circ_permit_patron.js
Open-ILS/src/javascript/backend/circ/circ_permit_renew.js
Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js
Open-ILS/src/javascript/backend/penalty/patron_penalty.js

index 98ae70d..5c61aa6 100644 (file)
+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.
+       ----------------------------------------------------------------------------- */
 
 
 
index cbcf0d7..8b80cb6 100644 (file)
@@ -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) {
index ec22cf0..e931fd4 100644 (file)
@@ -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');
 
 
index d9c3761..178e144 100644 (file)
@@ -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');
 
 
index e871a80..a24f858 100644 (file)
@@ -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');
 
index a7748d7..2015228 100644 (file)
@@ -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);
 }
index 4193c18..7fad3ee 100644 (file)
@@ -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;
index 7bcc352..73a38c3 100644 (file)
@@ -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');
 
 /** 
index e82752b..880f64f 100644 (file)
@@ -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);