Bugzilla – Attachment 38607 Details for
Bug 12178
Serial claims: exporting late issues with the CSV profile doesn't set the issue claimed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12178: Update serial status to "claimed" when exporting to CSV
Bug-12178-Update-serial-status-to-claimed-when-exp.patch (text/plain), 6.58 KB, created by
Jonathan Druart
on 2015-04-28 15:06:41 UTC
(
hide
)
Description:
Bug 12178: Update serial status to "claimed" when exporting to CSV
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-04-28 15:06:41 UTC
Size:
6.58 KB
patch
obsolete
>From c52d5b5020ed1abc6736decc841b60a5db028558 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 28 Apr 2015 17:00:44 +0200 >Subject: [PATCH] Bug 12178: Update serial status to "claimed" when exporting > to CSV > >On the same way as late issues, the serial status should be updated to >'claimed' when the issues as exported as csv. > >QA note: The updateClaim and UpdateClaimdateIssues subroutine did almost the >same thing, I kick the second on off to centralize the code. > >Test plan: >1/ Export some late issues as CSV (serials/claims.pl). >2/ Refresh the page (the export does not do it) and confirm that the >status, the claim date and the claim count have been updated. >3/ Select some others issues, select a notice and send the notification. >Confirm that the behavior is the same. >--- > C4/Serials.pm | 47 ++++++++++------------------------------- > serials/claims.pl | 2 +- > t/db_dependent/Serials.t | 3 --- > t/db_dependent/Serials/Claims.t | 14 +++++++++++- > 4 files changed, 25 insertions(+), 41 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 72dc44b..c77826d 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -52,7 +52,6 @@ BEGIN { > &GetSerialInformation &AddItem2Serial > &PrepareSerialsData &GetNextExpected &ModNextExpected > >- &UpdateClaimdateIssues > &GetSuppliersWithLateIssues &getsupplierbyserialid > &GetDistributedTo &SetDistributedTo > &getroutinglist &delroutingmember &addroutingmember >@@ -235,34 +234,6 @@ sub AddItem2Serial { > return $rq->rows; > } > >-=head2 UpdateClaimdateIssues >- >-UpdateClaimdateIssues($serialids,[$date]); >- >-Update Claimdate for issues in @$serialids list with date $date >-(Take Today if none) >- >-=cut >- >-sub UpdateClaimdateIssues { >- my ( $serialids, $date ) = @_; >- >- return unless ($serialids); >- >- my $dbh = C4::Context->dbh; >- $date = strftime( "%Y-%m-%d", localtime ) unless ($date); >- my $query = " >- UPDATE serial >- SET claimdate = ?, >- status = 7, >- claims_count = claims_count + 1 >- WHERE serialid in (" . join( ",", map { '?' } @$serialids ) . ") >- "; >- my $rq = $dbh->prepare($query); >- $rq->execute($date, @$serialids); >- return $rq->rows; >-} >- > =head2 GetSubscription > > $subs = GetSubscription($subscriptionid) >@@ -1963,15 +1934,19 @@ called from claims.pl file > =cut > > sub updateClaim { >- my ($serialid) = @_; >- my $dbh = C4::Context->dbh; >- $dbh->do(q| >+ my ($serialids) = @_; >+ return unless $serialids; >+ unless ( ref $serialids ) { >+ $serialids = [ $serialids ]; >+ } >+ my $dbh = C4::Context->dbh; >+ return $dbh->do(q| > UPDATE serial > SET claimdate = NOW(), >- claims_count = claims_count + 1 >- WHERE serialid = ? >- |, {}, $serialid ); >- return; >+ claims_count = claims_count + 1, >+ status = 7 >+ WHERE serialid in (| . join( q|,|, (q|?|) x @$serialids ) . q|)|, >+ {}, @$serialids ); > } > > =head2 getsupplierbyserialid >diff --git a/serials/claims.pl b/serials/claims.pl >index fb3bcd9..d85dd51 100755 >--- a/serials/claims.pl >+++ b/serials/claims.pl >@@ -64,7 +64,7 @@ if (@serialnums) { # i.e. they have been flagged to generate claims > eval { > $err = SendAlerts('claimissues',\@serialnums,$input->param("letter_code")); > if ( not ref $err or not exists $err->{error} ) { >- UpdateClaimdateIssues(\@serialnums); >+ C4::Serials::updateClaim( \@serialnums ); > } > }; > if ( $@ ) { >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 4777116..132a682 100644 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -151,7 +151,6 @@ if ($old_frequency) { > > # Test calling subs without parameters > is(C4::Serials::AddItem2Serial(), undef, 'test adding item to serial'); >-is(C4::Serials::UpdateClaimdateIssues(), undef, 'test updating claim date'); > is(C4::Serials::GetFullSubscription(), undef, 'test getting full subscription'); > is(C4::Serials::PrepareSerialsData(), undef, 'test preparing serial data'); > is(C4::Serials::GetSubscriptionsFromBiblionumber(), undef, 'test getting subscriptions form biblio number'); >@@ -184,8 +183,6 @@ is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing i > > is(C4::Serials::removeMissingIssue(), undef, 'test removing a missing issue'); > >-is(C4::Serials::updateClaim(),undef, 'test updating claim'); >- > is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea'); > > is(C4::Serials::check_routing(), undef, 'test checking route'); >diff --git a/t/db_dependent/Serials/Claims.t b/t/db_dependent/Serials/Claims.t >index 622f910..b887d78 100644 >--- a/t/db_dependent/Serials/Claims.t >+++ b/t/db_dependent/Serials/Claims.t >@@ -1,5 +1,5 @@ > use Modern::Perl; >-use Test::More tests => 13; >+use Test::More tests => 17; > > use C4::Acquisition; > use C4::Bookseller; >@@ -135,6 +135,7 @@ is( exists $late_or_missing_issues[0]->{claimdate}, 1, 'GetLateOrMissingIssues r > is( exists $late_or_missing_issues[0]->{claims_count}, 1, 'GetLateOrMissingIssues returns claims_count' ); > is( $late_or_missing_issues[0]->{claims_count}, 0, 'The issues should not habe been claimed yet' ); > >+is( updateClaim(), undef, 'updateClaim should return undef if not param passed' ); > my $serialid_to_claim = $late_or_missing_issues[0]->{serialid}; > updateClaim( $serialid_to_claim ); > >@@ -144,6 +145,17 @@ is( scalar(@late_or_missing_issues), 2, 'supplier 2 should have 2 issues in late > my ( $serial_claimed ) = grep { ($_->{serialid} == $serialid_to_claim) ? $_ : () } @late_or_missing_issues; > is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' ); > >+my @serials_to_claim = map { $_->{serialid} } @late_or_missing_issues; >+updateClaim( \@serials_to_claim ); >+@late_or_missing_issues = GetLateOrMissingIssues( $supplier_id2); >+is( scalar(@late_or_missing_issues), 2, 'supplier 2 should have 2 issues in late' ); >+ >+( $serial_claimed ) = grep { ($_->{serialid} == $serials_to_claim[0]) ? $_ : () } @late_or_missing_issues; >+is( $serial_claimed->{claims_count}, 2, 'The serial should have been claimed' ); >+( $serial_claimed ) = grep { ($_->{serialid} == $serials_to_claim[1]) ? $_ : () } @late_or_missing_issues; >+is( $serial_claimed->{claims_count}, 1, 'The serial should have been claimed' ); >+ >+ > my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > # FIXME: This test should pass. The GetLateOrMissingIssues should not deal with date format! > #is( $serial_claimed->{claimdate}, $today, 'The serial should have been claimed today' ); >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12178
:
38607
|
45983
|
49559
|
51732
|
52637
|
52638
|
52639
|
52801
|
52802
|
52803