From b32da52e82b19d8230e87f997140ef93dfcb6595 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 15 Oct 2012 08:15:13 -0400 Subject: [PATCH] Bug 8769 - Allow SIP2 return backdating Content-Type: text/plain; charset="utf-8" Patch based on code by Scott Kushner --- C4/Circulation.pm | 6 +++++- C4/ImportBatch.pm | 32 ++++++++++++++++++++++++++++++++ C4/SIP/ILS/Transaction/Checkin.pm | 9 ++++----- etc/SIPconfig.xml | 10 +++++----- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 7485de5..e14be2f 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1678,7 +1678,7 @@ patron who last borrowed the book. =cut sub AddReturn { - my ( $barcode, $branch, $exemptfine, $dropbox ) = @_; + my ( $barcode, $branch, $exemptfine, $dropbox, $return_date) = @_; if ($branch and not GetBranchDetail($branch)) { warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; @@ -1764,6 +1764,7 @@ sub AddReturn { } if ($borrowernumber) { +<<<<<<< HEAD if($issue->{'overdue'}){ my ( $amount, $type, $unitcounttotal ) = C4::Overdues::CalcFine( $item, $borrower->{categorycode},$branch, $datedue, $today ); $type ||= q{}; @@ -1776,6 +1777,9 @@ sub AddReturn { } } MarkIssueReturned($borrowernumber, $item->{'itemnumber'}, $circControlBranch, '', $borrower->{'privacy'}); +======= + MarkIssueReturned($borrowernumber, $item->{'itemnumber'}, $circControlBranch, $return_date, $borrower->{'privacy'}); +>>>>>>> Bug 8769 - Allow SIP2 return backdating $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? This could be the borrower hash. } diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 15f1acb..62000de 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -76,6 +76,7 @@ BEGIN { SetImportRecordStatus GetImportRecordMatches SetImportRecordMatches + GetImportProfileLoop ); } @@ -1344,7 +1345,38 @@ sub SetImportRecordMatches { $sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}); } } +#added sub GetImportProfileLoop +sub GetImportProfileLoop { + my $dbh = C4::Context->dbh; + + my $results = $dbh->selectall_arrayref( " + SELECT + import_profiles.profile_id, description, matcher_id, template_id, overlay_action, nomatch_action, parse_items, item_action, COUNT( marcxml ) AS added_items, ip_actions.tag, ip_actions.subfield + FROM import_profiles + LEFT JOIN import_profile_added_items AS ip_items ON ( import_profiles.profile_id = ip_items.profile_id ) + LEFT JOIN import_profile_subfield_actions AS ip_actions ON ( import_profiles.profile_id = ip_actions.profile_id ) + GROUP BY import_profiles.profile_id, ip_actions.tag, ip_actions.subfield + ", { Slice => {} } ); + return [] unless ( @$results ); + + my @profiles; + my $current_profile; + + foreach my $result ( @$results ) { + if ( $current_profile && $current_profile->{'profile_id'} == $result->{'profile_id'} ) { + push @{ $current_profile->{'modified_subfields'} }, { tag => $result->{'tag'}, subfield => $result->{'subfield'} } + } else { + push @profiles, $result; + $current_profile = $result; + $current_profile->{'modified_subfields'} = $result->{'tag'} ? [ { tag => $result->{'tag'}, subfield => $result->{'subfield'} } ] : []; + } + delete $result->{'tag'}; + delete $result->{'subfield'}; + } + + return \@profiles; +} # internal functions diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index 47bd85d..2029a0b 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -46,13 +46,12 @@ sub new { sub do_checkin { my $self = shift; - my $branch = shift; - if (!$branch) { - $branch = 'SIP2'; - } + my $branch = shift || 'SIP2'; + my $return_date = shift; + my $barcode = $self->{item}->id; $debug and warn "do_checkin() calling AddReturn($barcode, $branch)"; - my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch); + my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date); $self->alert(!$return); # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index f229b9a..6611f3e 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -36,9 +36,9 @@ - - - + + + @@ -52,13 +52,13 @@ in our case "ILS". --> - + - +