Bugzilla – Attachment 43879 Details for
Bug 15055
Koha generates new subscription item even when it's not necessary
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15055: Koha generates new subscription item even when it's not necessary
Bug-15055-Koha-generates-new-subscription-item-eve.patch (text/plain), 10.08 KB, created by
Joonas Kylmälä
on 2015-10-23 15:19:05 UTC
(
hide
)
Description:
Bug 15055: Koha generates new subscription item even when it's not necessary
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2015-10-23 15:19:05 UTC
Size:
10.08 KB
patch
obsolete
>From 0eb4dc83dee71feb9a69278c5bc3ec1d7b09d570 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <j.kylmala@gmail.com> >Date: Fri, 23 Oct 2015 15:09:41 +0000 >Subject: [PATCH] Bug 15055: Koha generates new subscription item even when > it's not necessary > >Do checking whether the item which is been received is already in the system >or not. If it is, then do not generate a new subscription item. > >Sponsored-by: Vaara-kirjastot >--- > C4/Serials.pm | 67 +++++++++++++++---------- > serials/serials-collection.pl | 25 +-------- > serials/serials-edit.pl | 10 +++- > serials/serials-recieve.pl | 8 ++- > t/db_dependent/Serials.t | 1 + > t/lib/TestObjects/Serial/SubscriptionFactory.pm | 2 + > 6 files changed, 61 insertions(+), 52 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 973ac46..26f0b52 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1228,37 +1228,52 @@ sub ModSerialStatus { > } > } > >- # create new waited entry if needed (ie : was a "waited" and has changed) >- if ( $oldstatus == 1 && $status != 1 ) { >- my $subscription = GetSubscription($subscriptionid); >- my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >- >- # next issue number >- my ( >- $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, >- $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) >- = GetNextSeq( $subscription, $pattern, $publisheddate ); >- >- # next date (calculated from actual date & frequency parameters) >- my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1); >- my $nextpubdate = $nextpublisheddate; >- NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate ); >- $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? >- WHERE subscriptionid = ?"; >- $sth = $dbh->prepare($query); >- $sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid ); >- >- # check if an alert must be sent... (= a letter is defined & status became "arrived" >- if ( $subscription->{letter} && $status == 2 && $oldstatus != 2 ) { >- require C4::Letters; >- C4::Letters::SendAlerts( 'issue', $subscription->{subscriptionid}, $subscription->{letter} ); >- } >+ # check if an alert must be sent... (= a letter is defined & status became "arrived" >+ my $subscription = GetSubscription($subscriptionid); >+ if ( $subscription->{letter} && $status == 2 && $oldstatus != 2 ) { >+ require C4::Letters; >+ C4::Letters::SendAlerts( 'issue', $subscription->{subscriptionid}, $subscription->{letter} ); > } > > return; > } > >+=head2 GenerateNewIssue >+ >+GenerateNewIssue($subscriptionid) >+ >+Autogenerate a new issue to serial subscription. >+ >+=cut >+ >+sub GenerateNewIssue { >+ my $dbh = C4::Context->dbh; >+ my ($subscriptionid) = @_; >+ require C4::Serials::Numberpattern; >+ my $subscription = GetSubscription($subscriptionid); >+ my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ my $expected = GetNextExpected($subscriptionid); >+ my ( >+ $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, >+ $newinnerloop1, $newinnerloop2, $newinnerloop3 >+ ) = GetNextSeq($subscription, $pattern, $expected->{publisheddate}); >+ >+ ## We generate the next publication date >+ my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); >+ ## Creating the new issue >+ NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, >+ 1, $nextpublisheddate, $nextpublisheddate ); >+ >+ ## Updating the subscription seq status >+ my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? >+ WHERE subscriptionid = ?"; >+ my $seqsth = $dbh->prepare($squery); >+ $seqsth->execute( >+ $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, >+ $newinnerloop2, $newinnerloop3, $subscriptionid >+ ); >+} >+ > =head2 GetNextExpected > > $nextexpected = GetNextExpected($subscriptionid) >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index ba97163..1e8c580 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -67,30 +67,7 @@ if($op eq 'gennext' && @subscriptionid){ > $issue->{planneddate}, $issue->{publisheddate}, > $status, "" ); > } else { >- require C4::Serials::Numberpattern; >- my $subscription = GetSubscription($subscriptionid); >- my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >- my $expected = GetNextExpected($subscriptionid); >- my ( >- $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, >- $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) = GetNextSeq($subscription, $pattern, $expected->{publisheddate}); >- >- ## We generate the next publication date >- my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); >- ## Creating the new issue >- NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, >- 1, $nextpublisheddate, $nextpublisheddate ); >- >- ## Updating the subscription seq status >- my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? >- WHERE subscriptionid = ?"; >- my $seqsth = $dbh->prepare($squery); >- $seqsth->execute( >- $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, >- $newinnerloop2, $newinnerloop3, $subscriptionid >- ); >- >+ C4::Serials::GenerateNewIssue($subscriptionid); > } > last if $nbissues == 1; > last if HasSubscriptionExpired($subscriptionid) > 0; >diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl >index c6151c7..f56d19f 100755 >--- a/serials/serials-edit.pl >+++ b/serials/serials-edit.pl >@@ -283,6 +283,8 @@ if ( $op and $op eq 'serialchangestatus' ) { > push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i]; > push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i]; > } >+ >+ my $isAdded = 0; > foreach my $item ( keys %itemhash ) { > > # Verify Itemization is "Valid", i.e. serial status is Arrived or Missing >@@ -296,7 +298,13 @@ if ( $op and $op eq 'serialchangestatus' ) { > $index = $i > } > } >- if ( $index >= 0 && $status[$index] == 2 ) { >+ if ( $index >= 0 && $status[$index] == 2 && !C4::Items::GetItem($itemid[$index]) ) { >+ if (!$isAdded) { >+ if (!abouttoexpire($subscriptionids[0])) { >+ C4::Serials::GenerateNewIssue($subscriptionids[0]); >+ $isAdded = 1; >+ } >+ } > my $xml = TransformHtmlToXml( > $itemhash{$item}->{'tags'}, > $itemhash{$item}->{'subfields'}, >diff --git a/serials/serials-recieve.pl b/serials/serials-recieve.pl >index c14e4d0..93d917e 100755 >--- a/serials/serials-recieve.pl >+++ b/serials/serials-recieve.pl >@@ -129,7 +129,13 @@ if ($op eq 'serialchangestatus') { > > my ($oldstatus) = $sth->fetchrow; > if ($serialids[$i]) { >- ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),format_date_in_iso($publisheddates[$i]),$status[$i],$notes[$i]) unless ($hassubscriptionexpired && $oldstatus == 1); >+ unless ($hassubscriptionexpired && $oldstatus == 1) { >+ ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),format_date_in_iso($publisheddates[$i]),$status[$i],$notes[$i]); >+ if (!$abouttoexpire) { >+ C4::Serials::GenerateNewIssue($subscriptionid); >+ } >+ } >+ > if (($status[$i]==2) && C4::Context->preference("serialsadditems")){ > my %info; > $info{branch}=$homebranches[$i]; >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index ab466e6..c8430ab 100644 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -214,6 +214,7 @@ for my $status ( @statuses ) { > my $serialseq = "No.".$counter; > my ( $expected_serial ) = GetSerials2( $subscriptionid, 1 ); > C4::Serials::ModSerialStatus( $expected_serial->{serialid}, $serialseq, $publisheddate, $publisheddate, $statuses[$counter], 'an useless note' ); >+ C4::Serials::GenerateNewIssue($subscriptionid); > $counter++; > } > # Here we have 15 serials with statuses : 2*2 + 5*3 + 2*4 + 1*41 + 1*42 + 1*43 + 1*44 + 1*5 + 1*1 >diff --git a/t/lib/TestObjects/Serial/SubscriptionFactory.pm b/t/lib/TestObjects/Serial/SubscriptionFactory.pm >index 521ce90..b9edfd2 100644 >--- a/t/lib/TestObjects/Serial/SubscriptionFactory.pm >+++ b/t/lib/TestObjects/Serial/SubscriptionFactory.pm >@@ -260,6 +260,8 @@ sub receiveDefaultSerials { > 2, #Status => 2 == Received > $waitingSerial->{notes}, > ); >+ C4::Serials::GenerateNewIssue($subscription->subscriptionid); >+ > my $items = t::lib::TestObjects::ItemFactory->createTestGroup({barcode => $waitingSerial->{serialid}."-".Koha::DateUtils::dt_from_string($waitingSerial->{publisheddate})->ymd('-'), > enumchron => $waitingSerial->{serialseq}, > biblionumber => $subscription->biblionumber, >-- >1.9.1
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 15055
: 43879