adjusting BH circ script as per rt2419
[sitka/oilspolicy.git] / circ / config_BH.js
CommitLineData
4d87131c
OU
1/** Policies for BH */
2/* record-lp doesn't exist!!! Ignore it!! */
3
4function getPolicy() {
5
6 load_lib('circ/circ_lib.js');
7 log_info("Loading policy info for BH");
8
9 var circMod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
10
11 return {
12
13 getLoanDuration : function() {
14 /* returns config.rule_circ_duration.name */
15 var circMod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
16
17 if(patronProfile == 'InterLibraryLoan'){
18 return '28_2';
19 }
20
21 var map = {
22 'holiday-special' : '14_2',
23 'compact-discs' : '7_1',
24 'talking-books' : '7_1',
25 'videos' : '7_1',
26 'dvd' : '7_1'
27 };
28
29 return map[circMod] || '21_2';
30
31 },
32
33 getRecurringFine : function() {
34 /* returns config.rule_recuring_fine.name */
35 if(patronProfile == 'InterLibraryLoan'){
36 return 'staff';
37 }
38
39 var map = {
40 'compact-discs' : 'fiftycents',
41 'talking-books' : 'fiftycents',
42 'videos' : 'fiftycents',
43 'dvd' : 'fiftycents'
44 };
0599bc6b 45 return map[circMod] || 'tencents';
4d87131c
OU
46
47 },
48
49 getMaxFine : function() {
50 /* returns config.rule_max_fine.name */
51 return 'threedollar';
52 },
53
54 exceedsMaxCheckoutsByCircMod : function() {
55 log_debug("exceedsMaxCheckoutsByCircMod()");
56 if(isGroupDescendant('Staff', patronProfile)){
57 return false;
58 }
59 var circMod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
60 if (!(circMod == 'compact-discs' || circMod == 'talking-books' || circMod == 'videos' || circMod == 'dvd')) {
61 return false;
62 }
63 var maxCount = 4;
64 var mediaCount = 0;
65 mediaCount += parseInt(checkoutsByCircModifier(patron.id)['compact-discs']) || 0;
66 mediaCount += parseInt(checkoutsByCircModifier(patron.id)['talking-books']) || 0;
67 mediaCount += parseInt(checkoutsByCircModifier(patron.id)['videos']) || 0;
68 mediaCount += parseInt(checkoutsByCircModifier(patron.id)['dvd']) || 0;
69 log_debug("found max out by circ mod "+circMod+" and checked out media total count is "+mediaCount);
70 return mediaCount >= maxCount;
71 },
72
73 isAllowedCirc : function() {
74 if(patronProfile == 'JuvenileRes') {
75 if(circMod == 'compact-discs' || circMod == 'talking-books' || circMod == 'videos' || circMod == 'dvd'){
76 return false;
77 }
78 }
79 return true;
80 },
81
82 isAllowedHold : function() {
83 return true;
84 },
85
86 getGroupConfig : function() {
87 /* returns the combined user config object */
88
89 // override some defaults
90
91 var config = findGroupConfig(patronProfile) || findGroupConfig('Patrons');
92
93 // these are global settings for BH users
94 config.fineThreshold = 5;
95 config.maxHolds = -1;
96 config.overdueThreshold = 5;
97
98 // debugging...
99 var str = "BH getGroupConfig():";
100 for( var i in config ){
101 str += i + '=' + config[i] + ' ';
102 }
103 log_debug(str);
104
105 return config;
106 }
107 };
108}
109