use Koha::Account::Offsets;
use Koha::Config::SysPrefs;
use Koha::Charges::Fees;
+use Koha::Util::SystemPreferences;
use Carp;
use List::MoreUtils qw( uniq any );
use Scalar::Util qw( looks_like_number );
$count_query .= " AND borrowernumber = ? ";
push @bind_params, $borrower->{'borrowernumber'};
my $rule_branch = $maxissueqty_rule->branchcode;
- unless ($rule_branch) {
+ if ($rule_branch) {
if (C4::Context->preference('CircControl') eq 'PickupLibrary') {
$count_query .= " AND issues.branchcode = ? ";
- push @bind_params, $branch;
+ push @bind_params, $rule_branch;
} elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') {
; # if branch is the patron's home branch, then count all loans by patron
} else {
$count_query .= " AND items.homebranch = ? ";
- push @bind_params, $branch;
+ push @bind_params, $rule_branch;
}
}
$issuingimpossible{RETURN_IMPOSSIBLE} = 1;
$issuingimpossible{branch_to_return} = $message;
} else {
+ if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
+ $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
+ } else {
$needsconfirmation{ISSUED_TO_ANOTHER} = 1;
$needsconfirmation{issued_firstname} = $patron->firstname;
$needsconfirmation{issued_surname} = $patron->surname;
$needsconfirmation{issued_cardnumber} = $patron->cardnumber;
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
+ }
}
}
)->store;
}
- if ( C4::Context->preference('ReturnToShelvingCart') ) {
- # ReturnToShelvingCart is on, anything issued should be taken off the cart.
+ if ( $item_object->location eq 'CART' && $item_object->permanent_location ne 'CART' ) {
+ ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
CartToShelf( $item_object->itemnumber );
}
}
my $item_unblessed = $item->unblessed;
- if ( $item->location eq 'PROC' ) {
- if ( C4::Context->preference("InProcessingToShelvingCart") ) {
- $item_unblessed->{location} = 'CART';
- }
- else {
- $item_unblessed->{location} = $item->permanent_location;
- }
-
- ModItem( $item_unblessed, $item->biblionumber, $item->itemnumber, { log_action => 0 } );
- }
-
# full item data, but no borrowernumber or checkout info (no issue)
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
# get the proper branch to which to return the item
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not
my $patron_unblessed = $patron ? $patron->unblessed : {};
+ my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin');
+ map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays
+ if ($update_loc_rules) {
+ if (defined $update_loc_rules->{_ALL_}) {
+ if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->{permanent_location}; }
+ if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; }
+ if ( $item->{location} ne $update_loc_rules->{_ALL_}) {
+ $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{_ALL_} };
+ ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber );
+ }
+ }
+ else {
+ foreach my $key ( keys %$update_loc_rules ) {
+ if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->{permanent_location}; }
+ if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;}
+ if ( ($item->{location} eq $key && $item->{location} ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $update_loc_rules->{$key} ne '') ) {
+ $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{$key} };
+ ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber );
+ last;
+ }
+ }
+ }
+ }
+
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
if ($yaml) {
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
);
$sth->execute( $item->itemnumber );
# if we have a reservation with valid transfer, we can set it's status to 'W'
- ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") );
C4::Reserves::ModReserveStatus($item->itemnumber, 'W');
} else {
$messages->{'WrongTransfer'} = $tobranch;
$messages->{'WrongTransferItem'} = $item->itemnumber;
}
$validTransfert = 1;
- } else {
- ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") );
}
# fix up the accounts.....
{
borrowernumber => $borrowernumber,
itemnumber => $item,
- accounttype => 'FU'
+ accounttype => 'OVERDUE',
+ status => 'UNRETURNED'
}
)->next();
return 0 unless $accountline; # no warning, there's just nothing to fix
if ($exemptfine) {
my $amountoutstanding = $accountline->amountoutstanding;
- $accountline->accounttype('FFOR');
+ $accountline->status('FORGIVEN');
$accountline->amountoutstanding(0);
Koha::Account::Offset->new(
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
}
} else {
- $accountline->accounttype('F');
+ $accountline->status('RETURNED');
}
return $accountline->store();
my $accountlines = Koha::Account::Lines->search(
{
itemnumber => $itemnumber,
- accounttype => { -in => [ 'L', 'Rep', 'W' ] },
+ accounttype => { -in => [ 'L', 'W' ] },
},
{
order_by => { -desc => [ 'date', 'accountlines_id' ] }
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
dt_from_string( $issue->date_due, 'sql' ) :
DateTime->now( time_zone => C4::Context->tz());
- $datedue = CalcDateDue($datedue, $itemtype, $circ_library, $patron_unblessed, 'is a renewal');
+ $datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
}
my $fees = Koha::Charges::Fees->new(
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!"; # zero is OK, check defined
if (C4::Context->preference('WhenLostChargeReplacementFee')){
- C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'} $issues->{'itemcallnumber'}");
+ C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "$issues->{'title'} $issues->{'barcode'} $issues->{'itemcallnumber'}");
#FIXME : Should probably have a way to distinguish this from an item that really was returned.
#warn " $issues->{'borrowernumber'} / $itemnumber ";
}