@@ -, +, @@ missing from \$ prove t/db_dependent/Circulation/_CalculateAndUpdateFine.t \$ prove t/db_dependent/Circulation/TooMany.t fine of 1 per day and B having a fine of 0 per day. CircControl = the library the items is from finesMode = Calculate and charge HomeOrHoldingBranch = holdingbranch specified by clicking "Checkout settings" in the checkout page) and make sure the branch you are checking from is B. B (holdingbranch of the checked-out item) specific rule is used. fine of 1 per day and B having a fine of 0 per day. CircControl = the library the items is from finesMode = Calculate and charge HomeOrHoldingBranch = holdingbranch specified by clicking "Checkout settings" in the checkout page) and make sure the branch you are checking from is B. and notice that now there is inccorectly fines and notice the fines are now not generated --- C4/Circulation.pm | 13 ++++++++----- C4/Overdues.pm | 4 ++-- misc/cronjobs/fines.pl | 3 ++- misc/cronjobs/staticfines.pl | 5 +++-- 4 files changed, 15 insertions(+), 10 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -457,9 +457,10 @@ sub TooMany { } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { \$checkouts = \$patron->checkouts; # if branch is the patron's home branch, then count all loans by patron } else { + my \$branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; \$checkouts = \$patron->checkouts->search( - { 'item.homebranch' => \$maxissueqty_rule->branchcode }, - { prefetch => 'item' } ); + { "item.\$branch_type" => \$maxissueqty_rule->branchcode }, + { prefetch => 'item' } ); } } else { \$checkouts = \$patron->checkouts; # if rule is not branch specific then count all loans by patron @@ -545,9 +546,10 @@ sub TooMany { } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { \$checkouts = \$patron->checkouts; # if branch is the patron's home branch, then count all loans by patron } else { + my \$branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; \$checkouts = \$patron->checkouts->search( - { 'item.homebranch' => \$branch}, - { prefetch => 'item' } ); + { "item.\$branch_type" => \$branch}, + { prefetch => 'item' } ); } my \$checkout_count = \$checkouts->count; @@ -4341,8 +4343,9 @@ sub _CalculateAndUpdateFine { # we only need to calculate and change the fines if we want to do that on return # Should be on for hourly loans my \$control = C4::Context->preference('CircControl'); + my \$branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; my \$control_branchcode = - ( \$control eq 'ItemHomeLibrary' ) ? \$item->{homebranch} + ( \$control eq 'ItemHomeLibrary' ) ? \$item->{\$branch_type} : ( \$control eq 'PatronLibrary' ) ? \$borrower->{branchcode} : \$issue->branchcode; --- a/C4/Overdues.pm +++ a/C4/Overdues.pm @@ -96,14 +96,14 @@ sub Getoverdues { my \$statement; if ( C4::Context->preference('item-level_itypes') ) { \$statement = " - SELECT issues.*, items.itype as itemtype, items.homebranch, items.barcode, items.itemlost, items.replacementprice + SELECT issues.*, items.itype as itemtype, items.homebranch, items.barcode, items.itemlost, items.replacementprice, items.holdingbranch FROM issues LEFT JOIN items USING (itemnumber) WHERE date_due < NOW() "; } else { \$statement = " - SELECT issues.*, biblioitems.itemtype, items.itype, items.homebranch, items.barcode, items.itemlost, replacementprice + SELECT issues.*, biblioitems.itemtype, items.itype, items.homebranch, items.barcode, items.itemlost, replacementprice, items.holdingbranch FROM issues LEFT JOIN items USING (itemnumber) LEFT JOIN biblioitems USING (biblioitemnumber) --- a/misc/cronjobs/fines.pl +++ a/misc/cronjobs/fines.pl @@ -98,6 +98,7 @@ my @item_fields = qw(itemnumber barcode date_due); my @other_fields = qw(days_overdue fine); my \$libname = C4::Context->preference('LibraryName'); my \$control = C4::Context->preference('CircControl'); +my \$branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; my \$mode = C4::Context->preference('finesMode'); my \$delim = "\t"; # ? C4::Context->preference('delimiter') || "\t"; @@ -128,7 +129,7 @@ for my \$overdue ( @{\$overdues} ) { } my \$patron = Koha::Patrons->find( \$overdue->{borrowernumber} ); my \$branchcode = - ( \$control eq 'ItemHomeLibrary' ) ? \$overdue->{homebranch} + ( \$control eq 'ItemHomeLibrary' ) ? \$overdue->{\$branch_type} : ( \$control eq 'PatronLibrary' ) ? \$patron->branchcode : \$overdue->{branchcode}; --- a/misc/cronjobs/staticfines.pl +++ a/misc/cronjobs/staticfines.pl @@ -104,7 +104,7 @@ foreach (@pcategories) { } use vars qw(@borrower_fields @item_fields @other_fields); -use vars qw(\$fldir \$libname \$control \$mode \$delim \$dbname \$today \$today_iso \$today_days); +use vars qw(\$fldir \$libname \$control \$branch_type \$mode \$delim \$dbname \$today \$today_iso \$today_days); use vars qw(\$filename); CHECK { @@ -113,6 +113,7 @@ CHECK { @other_fields = qw(type days_overdue fine); \$libname = C4::Context->preference('LibraryName'); \$control = C4::Context->preference('CircControl'); + \$branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; \$mode = C4::Context->preference('finesMode'); \$dbname = C4::Context->config('database'); \$delim = "\t"; # ? C4::Context->preference('delimiter') || "\t"; @@ -166,7 +167,7 @@ for ( my \$i = 0 ; \$i < scalar(@\$data) ; \$i++ ) { my \$branchcode = ( \$useborrowerlibrary ) ? \$patron->branchcode - : ( \$control eq 'ItemHomeLibrary' ) ? \$data->[\$i]->{homebranch} + : ( \$control eq 'ItemHomeLibrary' ) ? \$data->[\$i]->{\$branch_type} : ( \$control eq 'PatronLibrary' ) ? \$patron->branchcode : \$data->[\$i]->{branchcode}; # In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). --