Lines 74-80
BEGIN {
Link Here
|
74 |
&GetItemIssues |
74 |
&GetItemIssues |
75 |
&GetBorrowerIssues |
75 |
&GetBorrowerIssues |
76 |
&GetIssuingCharges |
76 |
&GetIssuingCharges |
77 |
&GetIssuingRule |
|
|
78 |
&GetBranchBorrowerCircRule |
77 |
&GetBranchBorrowerCircRule |
79 |
&GetBranchItemRule |
78 |
&GetBranchItemRule |
80 |
&GetBiblioIssues |
79 |
&GetBiblioIssues |
Lines 356-367
sub TooMany {
Link Here
|
356 |
|
355 |
|
357 |
# given branch, patron category, and item type, determine |
356 |
# given branch, patron category, and item type, determine |
358 |
# applicable issuing rule |
357 |
# applicable issuing rule |
359 |
my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch); |
358 |
my $issuing_rule = GetIssuingRuleRecord($cat_borrower, $type, $branch, 'maxissueqty'); |
360 |
|
359 |
|
361 |
# if a rule is found and has a loan limit set, count |
360 |
# if a rule is found and has a loan limit set, count |
362 |
# how many loans the patron already has that meet that |
361 |
# how many loans the patron already has that meet that |
363 |
# rule |
362 |
# rule |
364 |
if (defined($issuing_rule) and defined($issuing_rule->{'maxissueqty'})) { |
363 |
if ( $issuing_rule ) { |
365 |
my @bind_params; |
364 |
my @bind_params; |
366 |
my $count_query = "SELECT COUNT(*) FROM issues |
365 |
my $count_query = "SELECT COUNT(*) FROM issues |
367 |
JOIN items USING (itemnumber) "; |
366 |
JOIN items USING (itemnumber) "; |
Lines 1119-1174
Get loan length for an itemtype, a borrower type and a branch
Link Here
|
1119 |
|
1118 |
|
1120 |
sub GetLoanLength { |
1119 |
sub GetLoanLength { |
1121 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1120 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1122 |
my $dbh = C4::Context->dbh; |
|
|
1123 |
my $sth = |
1124 |
$dbh->prepare( |
1125 |
"select issuelength from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" |
1126 |
); |
1127 |
# warn "in get loan lenght $borrowertype $itemtype $branchcode "; |
1128 |
# try to find issuelength & return the 1st available. |
1129 |
# check with borrowertype, itemtype and branchcode, then without one of those parameters |
1130 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1131 |
my $loanlength = $sth->fetchrow_hashref; |
1132 |
return $loanlength->{issuelength} |
1133 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1134 |
|
1135 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1136 |
$loanlength = $sth->fetchrow_hashref; |
1137 |
return $loanlength->{issuelength} |
1138 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1139 |
|
1140 |
$sth->execute( "*", $itemtype, $branchcode ); |
1141 |
$loanlength = $sth->fetchrow_hashref; |
1142 |
return $loanlength->{issuelength} |
1143 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1144 |
|
1145 |
$sth->execute( "*", "*", $branchcode ); |
1146 |
$loanlength = $sth->fetchrow_hashref; |
1147 |
return $loanlength->{issuelength} |
1148 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1149 |
|
1150 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1151 |
$loanlength = $sth->fetchrow_hashref; |
1152 |
return $loanlength->{issuelength} |
1153 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1154 |
|
1155 |
$sth->execute( $borrowertype, "*", "*" ); |
1156 |
$loanlength = $sth->fetchrow_hashref; |
1157 |
return $loanlength->{issuelength} |
1158 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1159 |
|
1160 |
$sth->execute( "*", $itemtype, "*" ); |
1161 |
$loanlength = $sth->fetchrow_hashref; |
1162 |
return $loanlength->{issuelength} |
1163 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1164 |
|
1165 |
$sth->execute( "*", "*", "*" ); |
1166 |
$loanlength = $sth->fetchrow_hashref; |
1167 |
return $loanlength->{issuelength} |
1168 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1169 |
|
1170 |
# if no rule is set => 21 days (hardcoded) |
1121 |
# if no rule is set => 21 days (hardcoded) |
1171 |
return 21; |
1122 |
return GetIssuingRuleValue( $borrowertype, $itemtype, $branchcode, 'issuelength' ) || 21; |
1172 |
} |
1123 |
} |
1173 |
|
1124 |
|
1174 |
|
1125 |
|
Lines 1182-1289
Get the Hard Due Date and it's comparison for an itemtype, a borrower type and a
Link Here
|
1182 |
|
1133 |
|
1183 |
sub GetHardDueDate { |
1134 |
sub GetHardDueDate { |
1184 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1135 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1185 |
my $dbh = C4::Context->dbh; |
1136 |
my $issuing_rule = GetIssuingRuleRecord($borrowertype, $itemtype, $branchcode, 'hardduedate') |
1186 |
my $sth = |
1137 |
or return; |
1187 |
$dbh->prepare( |
1138 |
return (C4::Dates->new($issuing_rule->{hardduedate}, 'iso'),$issuing_rule->{hardduedatecompare}); |
1188 |
"select hardduedate, hardduedatecompare from issuingrules where categorycode=? and itemtype=? and branchcode=?" |
1139 |
} |
1189 |
); |
1140 |
|
1190 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1141 |
|
1191 |
my $results = $sth->fetchrow_hashref; |
1142 |
=head2 GetIssuingRuleValue |
1192 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1143 |
|
1193 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1144 |
my $irule = &GetIssuingRuleValue($borrowertype,$itemtype,$branchcode, $rule_name) |
1194 |
|
1145 |
|
1195 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1146 |
Get the most specific non-null value issuing rule for an itemtype, a borrower type and a branch |
1196 |
$results = $sth->fetchrow_hashref; |
1147 |
|
1197 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1148 |
=cut |
1198 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1149 |
|
1199 |
|
1150 |
sub GetIssuingRuleValue { |
1200 |
$sth->execute( "*", $itemtype, $branchcode ); |
1151 |
my ( $borrowertype, $itemtype, $branchcode, $rule ) = @_; |
1201 |
$results = $sth->fetchrow_hashref; |
1152 |
my $irule = GetIssuingRuleRecord( $borrowertype, $itemtype, $branchcode, $rule ) |
1202 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1153 |
or return; |
1203 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1154 |
return $irule->{$rule}; |
1204 |
|
|
|
1205 |
$sth->execute( "*", "*", $branchcode ); |
1206 |
$results = $sth->fetchrow_hashref; |
1207 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1208 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1209 |
|
1210 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1211 |
$results = $sth->fetchrow_hashref; |
1212 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1213 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1214 |
|
1215 |
$sth->execute( $borrowertype, "*", "*" ); |
1216 |
$results = $sth->fetchrow_hashref; |
1217 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1218 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1219 |
|
1220 |
$sth->execute( "*", $itemtype, "*" ); |
1221 |
$results = $sth->fetchrow_hashref; |
1222 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1223 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1224 |
|
1225 |
$sth->execute( "*", "*", "*" ); |
1226 |
$results = $sth->fetchrow_hashref; |
1227 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1228 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1229 |
|
1230 |
# if no rule is set => return undefined |
1231 |
return (undef, undef); |
1232 |
} |
1155 |
} |
1233 |
|
1156 |
|
1234 |
=head2 GetIssuingRule |
1157 |
=head2 GetIssuingRuleRecord |
1235 |
|
1158 |
|
1236 |
my $irule = &GetIssuingRule($borrowertype,$itemtype,branchcode) |
1159 |
my $irule = &GetIssuingRuleRecord($borrowertype,$itemtype,$branchcode, $rule_name) |
1237 |
|
1160 |
|
1238 |
FIXME - This is a copy-paste of GetLoanLength |
1161 |
Get the most specific non-null value issuing rule for an itemtype, a borrower type and a branch |
1239 |
as a stop-gap. Do not wish to change API for GetLoanLength |
1162 |
If $rule_name is specified, only records with $rule_name not null are taken in account |
1240 |
this close to release, however, Overdues::GetIssuingRules is broken. |
|
|
1241 |
|
1163 |
|
1242 |
Get the issuing rule for an itemtype, a borrower type and a branch |
1164 |
Order of preference is $branchcode, $borrowertype, $itemtype |
1243 |
Returns a hashref from the issuingrules table. |
|
|
1244 |
|
1165 |
|
1245 |
=cut |
1166 |
=cut |
1246 |
|
1167 |
|
1247 |
sub GetIssuingRule { |
1168 |
sub GetIssuingRuleRecord { |
1248 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1169 |
my ( $borrowertype, $itemtype, $branchcode, $rule ) = @_; |
1249 |
my $dbh = C4::Context->dbh; |
1170 |
|
1250 |
my $sth = $dbh->prepare( "select * from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" ); |
1171 |
my $irules = GetIssuingRules($borrowertype,$itemtype,$branchcode) |
1251 |
my $irule; |
1172 |
or return; |
|
|
1173 |
|
1174 |
return unless @$irules; |
1175 |
|
1176 |
return $irules->[0] unless $rule; |
1177 |
|
1178 |
die qq{Invalid rule (field) "$rule"} unless exists $irules->[0]->{$rule}; |
1252 |
|
1179 |
|
1253 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1180 |
foreach (@$irules) { |
1254 |
$irule = $sth->fetchrow_hashref; |
1181 |
return $_ if $_->{$rule}; # XXX defined $_->{$rule} |
1255 |
return $irule if defined($irule) ; |
1182 |
} |
1256 |
|
1183 |
|
1257 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1184 |
return; |
1258 |
$irule = $sth->fetchrow_hashref; |
1185 |
} |
1259 |
return $irule if defined($irule) ; |
|
|
1260 |
|
1186 |
|
1261 |
$sth->execute( "*", $itemtype, $branchcode ); |
1187 |
=head2 GetIssuingRules |
1262 |
$irule = $sth->fetchrow_hashref; |
|
|
1263 |
return $irule if defined($irule) ; |
1264 |
|
1188 |
|
1265 |
$sth->execute( "*", "*", $branchcode ); |
1189 |
my $irules = &GetIssuingRules($borrowertype,$itemtype,$branchcode) |
1266 |
$irule = $sth->fetchrow_hashref; |
|
|
1267 |
return $irule if defined($irule) ; |
1268 |
|
1190 |
|
1269 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1191 |
Get issuing all rule records for an itemtype, a borrower type and a branch |
1270 |
$irule = $sth->fetchrow_hashref; |
1192 |
in order of preference |
1271 |
return $irule if defined($irule) ; |
|
|
1272 |
|
1193 |
|
1273 |
$sth->execute( $borrowertype, "*", "*" ); |
1194 |
Order of preference is $branchcode, $borrowertype, $itemtype |
1274 |
$irule = $sth->fetchrow_hashref; |
|
|
1275 |
return $irule if defined($irule) ; |
1276 |
|
1195 |
|
1277 |
$sth->execute( "*", $itemtype, "*" ); |
1196 |
=cut |
1278 |
$irule = $sth->fetchrow_hashref; |
|
|
1279 |
return $irule if defined($irule) ; |
1280 |
|
1197 |
|
1281 |
$sth->execute( "*", "*", "*" ); |
1198 |
sub GetIssuingRules { |
1282 |
$irule = $sth->fetchrow_hashref; |
1199 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1283 |
return $irule if defined($irule) ; |
1200 |
|
|
|
1201 |
my (@where, @params); |
1284 |
|
1202 |
|
1285 |
# if no rule matches, |
1203 |
if ( $borrowertype ) { |
1286 |
return undef; |
1204 |
push @where, "categorycode=? OR categorycode='*'"; |
|
|
1205 |
push @params, $borrowertype; |
1206 |
} else { |
1207 |
push @where, "categorycode='*'"; |
1208 |
} |
1209 |
|
1210 |
if ( $itemtype ) { |
1211 |
push @where, "itemtype=? OR itemtype='*'"; |
1212 |
push @params, $itemtype; |
1213 |
} else { |
1214 |
push @where, "itemtype='*'"; |
1215 |
} |
1216 |
|
1217 |
if ( $branchcode ) { |
1218 |
push @where, "branchcode=? OR branchcode='*'"; |
1219 |
push @params, $branchcode; |
1220 |
} else { |
1221 |
push @where, "branchcode='*'"; |
1222 |
} |
1223 |
|
1224 |
my $qry = "select * from issuingrules where " |
1225 |
.join( ' AND ', map "($_)", @where ) |
1226 |
." order by branchcode desc, categorycode desc, itemtype desc"; |
1227 |
|
1228 |
my $dbh = C4::Context->dbh; |
1229 |
return $dbh->selectall_arrayref($qry, { Slice => {} }, @params); |
1287 |
} |
1230 |
} |
1288 |
|
1231 |
|
1289 |
=head2 GetBranchBorrowerCircRule |
1232 |
=head2 GetBranchBorrowerCircRule |
Lines 2159-2205
sub CanBookBeRenewed {
Link Here
|
2159 |
|
2102 |
|
2160 |
my $sthcount = $dbh->prepare(" |
2103 |
my $sthcount = $dbh->prepare(" |
2161 |
SELECT |
2104 |
SELECT |
2162 |
borrowers.categorycode, biblioitems.itemtype, issues.renewals, renewalsallowed, $controlbranch |
2105 |
borrowers.categorycode, biblioitems.itemtype, issues.renewals, $controlbranch |
2163 |
FROM issuingrules, |
2106 |
FROM issues |
2164 |
issues |
|
|
2165 |
LEFT JOIN items USING (itemnumber) |
2107 |
LEFT JOIN items USING (itemnumber) |
2166 |
LEFT JOIN borrowers USING (borrowernumber) |
2108 |
LEFT JOIN borrowers USING (borrowernumber) |
2167 |
LEFT JOIN biblioitems USING (biblioitemnumber) |
2109 |
LEFT JOIN biblioitems USING (biblioitemnumber) |
2168 |
|
2110 |
|
2169 |
WHERE |
2111 |
WHERE |
2170 |
(issuingrules.categorycode = borrowers.categorycode OR issuingrules.categorycode = '*') |
|
|
2171 |
AND |
2172 |
(issuingrules.itemtype = $itype OR issuingrules.itemtype = '*') |
2173 |
AND |
2174 |
(issuingrules.branchcode = $controlbranch OR issuingrules.branchcode = '*') |
2175 |
AND |
2176 |
borrowernumber = ? |
2112 |
borrowernumber = ? |
2177 |
AND |
2113 |
AND |
2178 |
itemnumber = ? |
2114 |
itemnumber = ? |
2179 |
ORDER BY |
|
|
2180 |
issuingrules.categorycode desc, |
2181 |
issuingrules.itemtype desc, |
2182 |
issuingrules.branchcode desc |
2183 |
LIMIT 1; |
2115 |
LIMIT 1; |
2184 |
"); |
2116 |
"); |
2185 |
|
2117 |
|
2186 |
$sthcount->execute( $borrowernumber, $itemnumber ); |
2118 |
$sthcount->execute( $borrowernumber, $itemnumber ); |
2187 |
if ( my $data1 = $sthcount->fetchrow_hashref ) { |
2119 |
if ( my $data1 = $sthcount->fetchrow_hashref ) { |
2188 |
|
|
|
2189 |
if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) { |
2190 |
$renewokay = 1; |
2191 |
} |
2192 |
else { |
2193 |
$error="too_many"; |
2194 |
} |
2195 |
|
2196 |
my ( $resfound, $resrec ) = C4::Reserves::CheckReserves($itemnumber); |
2120 |
my ( $resfound, $resrec ) = C4::Reserves::CheckReserves($itemnumber); |
2197 |
if ($resfound) { |
2121 |
if ($resfound) { |
2198 |
$renewokay = 0; |
2122 |
$renewokay = 0; |
2199 |
$error="on_reserve" |
2123 |
$error="on_reserve" |
2200 |
} |
2124 |
} |
|
|
2125 |
elsif ( $override_limit ) { |
2126 |
$renewokay = 1; |
2127 |
} |
2128 |
elsif ( my $renewalsallowed = GetIssuingRuleValue($data1->{categorycode}, $itype, $data1->{$controlbranch}, 'renewalsallowed') ) { |
2129 |
if ( $renewalsallowed > $data1->{renewals} || $override_limit ) { |
2130 |
$renewokay = 1; |
2131 |
} |
2132 |
} |
2133 |
$error="too_many" unless $renewokay; |
2134 |
} |
2201 |
|
2135 |
|
2202 |
} |
|
|
2203 |
return ($renewokay,$error); |
2136 |
return ($renewokay,$error); |
2204 |
} |
2137 |
} |
2205 |
|
2138 |
|
Lines 2306-2313
sub GetRenewCount {
Link Here
|
2306 |
my ( $bornum, $itemno ) = @_; |
2239 |
my ( $bornum, $itemno ) = @_; |
2307 |
my $dbh = C4::Context->dbh; |
2240 |
my $dbh = C4::Context->dbh; |
2308 |
my $renewcount = 0; |
2241 |
my $renewcount = 0; |
2309 |
my $renewsallowed = 0; |
|
|
2310 |
my $renewsleft = 0; |
2311 |
|
2242 |
|
2312 |
my $borrower = C4::Members::GetMemberDetails($bornum); |
2243 |
my $borrower = C4::Members::GetMemberDetails($bornum); |
2313 |
my $item = GetItem($itemno); |
2244 |
my $item = GetItem($itemno); |
Lines 2328-2337
sub GetRenewCount {
Link Here
|
2328 |
# $item and $borrower should be calculated |
2259 |
# $item and $borrower should be calculated |
2329 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2260 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2330 |
|
2261 |
|
2331 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
2262 |
my $renewsallowed = GetIssuingRuleValue($borrower->{categorycode}, $item->{itype}, $branchcode, 'renewalsallowed') || 0; |
2332 |
|
2263 |
my $renewsleft = $renewsallowed - $renewcount; |
2333 |
$renewsallowed = $issuingrule->{'renewalsallowed'}; |
|
|
2334 |
$renewsleft = $renewsallowed - $renewcount; |
2335 |
if($renewsleft < 0){ $renewsleft = 0; } |
2264 |
if($renewsleft < 0){ $renewsleft = 0; } |
2336 |
return ( $renewcount, $renewsallowed, $renewsleft ); |
2265 |
return ( $renewcount, $renewsallowed, $renewsleft ); |
2337 |
} |
2266 |
} |
Lines 2376-2394
sub GetIssuingCharges {
Link Here
|
2376 |
$item_type = $item_data->{itemtype}; |
2305 |
$item_type = $item_data->{itemtype}; |
2377 |
$charge = $item_data->{rentalcharge}; |
2306 |
$charge = $item_data->{rentalcharge}; |
2378 |
my $branch = C4::Branch::mybranch(); |
2307 |
my $branch = C4::Branch::mybranch(); |
2379 |
my $discount_query = q|SELECT rentaldiscount, |
2308 |
my $borr_query = q|SELECT borrowers.categorycode |
2380 |
issuingrules.itemtype, issuingrules.branchcode |
|
|
2381 |
FROM borrowers |
2309 |
FROM borrowers |
2382 |
LEFT JOIN issuingrules ON borrowers.categorycode = issuingrules.categorycode |
2310 |
WHERE borrowers.borrowernumber = ?|; |
2383 |
WHERE borrowers.borrowernumber = ? |
2311 |
my $borr_cat = $dbh->selectrow_array($borr_query, undef, $borrowernumber); |
2384 |
AND (issuingrules.itemtype = ? OR issuingrules.itemtype = '*') |
2312 |
if ( my $discount = GetIssuingRuleValue($borr_cat, $item_type, $branch, 'rentaldiscount') ) { |
2385 |
AND (issuingrules.branchcode = ? OR issuingrules.branchcode = '*')|; |
|
|
2386 |
my $discount_sth = $dbh->prepare($discount_query); |
2387 |
$discount_sth->execute( $borrowernumber, $item_type, $branch ); |
2388 |
my $discount_rules = $discount_sth->fetchall_arrayref({}); |
2389 |
if (@{$discount_rules}) { |
2390 |
# We may have multiple rules so get the most specific |
2391 |
my $discount = _get_discount_from_rule($discount_rules, $branch, $item_type); |
2392 |
$charge = ( $charge * ( 100 - $discount ) ) / 100; |
2313 |
$charge = ( $charge * ( 100 - $discount ) ) / 100; |
2393 |
} |
2314 |
} |
2394 |
} |
2315 |
} |
Lines 2397-2439
sub GetIssuingCharges {
Link Here
|
2397 |
return ( $charge, $item_type ); |
2318 |
return ( $charge, $item_type ); |
2398 |
} |
2319 |
} |
2399 |
|
2320 |
|
2400 |
# Select most appropriate discount rule from those returned |
|
|
2401 |
sub _get_discount_from_rule { |
2402 |
my ($rules_ref, $branch, $itemtype) = @_; |
2403 |
my $discount; |
2404 |
|
2405 |
if (@{$rules_ref} == 1) { # only 1 applicable rule use it |
2406 |
$discount = $rules_ref->[0]->{rentaldiscount}; |
2407 |
return (defined $discount) ? $discount : 0; |
2408 |
} |
2409 |
# could have up to 4 does one match $branch and $itemtype |
2410 |
my @d = grep { $_->{branchcode} eq $branch && $_->{itemtype} eq $itemtype } @{$rules_ref}; |
2411 |
if (@d) { |
2412 |
$discount = $d[0]->{rentaldiscount}; |
2413 |
return (defined $discount) ? $discount : 0; |
2414 |
} |
2415 |
# do we have item type + all branches |
2416 |
@d = grep { $_->{branchcode} eq q{*} && $_->{itemtype} eq $itemtype } @{$rules_ref}; |
2417 |
if (@d) { |
2418 |
$discount = $d[0]->{rentaldiscount}; |
2419 |
return (defined $discount) ? $discount : 0; |
2420 |
} |
2421 |
# do we all item types + this branch |
2422 |
@d = grep { $_->{branchcode} eq $branch && $_->{itemtype} eq q{*} } @{$rules_ref}; |
2423 |
if (@d) { |
2424 |
$discount = $d[0]->{rentaldiscount}; |
2425 |
return (defined $discount) ? $discount : 0; |
2426 |
} |
2427 |
# so all and all (surely we wont get here) |
2428 |
@d = grep { $_->{branchcode} eq q{*} && $_->{itemtype} eq q{*} } @{$rules_ref}; |
2429 |
if (@d) { |
2430 |
$discount = $d[0]->{rentaldiscount}; |
2431 |
return (defined $discount) ? $discount : 0; |
2432 |
} |
2433 |
# none of the above |
2434 |
return 0; |
2435 |
} |
2436 |
|
2437 |
=head2 AddIssuingCharge |
2321 |
=head2 AddIssuingCharge |
2438 |
|
2322 |
|
2439 |
&AddIssuingCharge( $itemno, $borrowernumber, $charge ) |
2323 |
&AddIssuingCharge( $itemno, $borrowernumber, $charge ) |