Bugzilla – Attachment 129125 Details for
Bug 23352
Define serial's collection in the subscription
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23352: Set default collection code when creating subscription
Bug-23352-Set-default-collection-code-when-creatin.patch (text/plain), 13.78 KB, created by
Alex Buckley
on 2022-01-07 00:08:14 UTC
(
hide
)
Description:
Bug 23352: Set default collection code when creating subscription
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2022-01-07 00:08:14 UTC
Size:
13.78 KB
patch
obsolete
>From 1b37d2326af072102c9dc58d51b6f63195c17812 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 13 Dec 2021 15:28:36 +0000 >Subject: [PATCH] Bug 23352: Set default collection code when creating > subscription > >The default collection code set in the subscription will be applied if >item records are created when receiving the serial. > >Test plan: >1. Apply 3 patches >2. Run updatedatabase.pl and restart services >3. Create a subscription: >- Tick the 'Create an item record when receiving this serial' radio >button >- Select values in the Location, Collection code and Item type dropdowns >- Save the subscription >4. Confirm the Location, and Collection code default values >you choose in #3 are displaying in the 'Information' tab of page that's >loaded >5. Receive the serial: >- Click 'Receive' >- Change the status dropdown from 'Expected' to 'Arrived' >- Confirm the 'Collection Code', 'Shelving location' and 'Koha item >type' dropdowns are pre-filled with the values you defined in #3 >6. Run unit test t/db_dependent/Serials.t > >Sponsored-By: Brimbank Library, Australia >--- > C4/Items.pm | 12 ++++++++++++ > C4/Serials.pm | 6 ++++-- > .../prog/en/modules/serials/subscription-add.tt | 12 ++++++++++++ > .../prog/en/modules/serials/subscription-detail.tt | 1 + > serials/subscription-add.pl | 8 ++++++-- > serials/subscription-detail.pl | 2 ++ > t/db_dependent/Serials.t | 15 ++++++++++++--- > 7 files changed, 49 insertions(+), 7 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index ce285577bd..3fb78840ee 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1673,6 +1673,18 @@ sub PrepareItemrecordDisplay { > $defaultvalue = $defaultvalues->{location}; > } > } >+ if ( ( $subfield->{kohafield} eq 'items.ccode' ) >+ && $defaultvalues >+ && $defaultvalues->{'ccode'} ) { >+ >+ if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ) { >+ # if the item record exists, only use default value if the item has no ccode >+ $defaultvalue = $defaultvalues->{ccode}; >+ } elsif ( !$itemrecord and $defaultvalues ) { >+ # if the item record *doesn't* exists, always use the default value >+ $defaultvalue = $defaultvalues->{ccode}; >+ } >+ } > if ( $subfield->{authorised_value} ) { > my @authorised_values; > my %authorised_lib; >diff --git a/C4/Serials.pm b/C4/Serials.pm >index d840bf24b7..d3b81673e2 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1318,7 +1318,7 @@ sub ModSubscription { > $biblionumber, $callnumber, $notes, $letter, $manualhistory, > $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, > $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, >- $itemtype, $previousitemtype, $mana_id >+ $itemtype, $previousitemtype, $mana_id, $ccode > ) = @_; > > my $subscription = Koha::Subscriptions->find($subscriptionid); >@@ -1361,6 +1361,7 @@ sub ModSubscription { > itemtype => $itemtype, > previousitemtype => $previousitemtype, > mana_id => $mana_id, >+ ccode => $ccode, > } > )->store; > # FIXME Must be $subscription->serials >@@ -1398,7 +1399,7 @@ sub NewSubscription { > $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, > $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, > $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id >+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode > ) = @_; > my $dbh = C4::Context->dbh; > >@@ -1441,6 +1442,7 @@ sub NewSubscription { > itemtype => $itemtype, > previousitemtype => $previousitemtype, > mana_id => $mana_id, >+ ccode => $ccode > } > )->store; > $subscription->discard_changes; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index 6c22b7cdd1..bd739325f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -200,6 +200,18 @@ fieldset.rows table { clear: none; margin: 0; } > </select> > </li> > <li> >+ <label for="ccode">Collection code:</label> >+ <select name="ccode" id="ccode"> >+ [% FOREACH ccode_loo IN ccodes_loop %] >+ [% IF (ccode_loo.selected) %] >+ <option value="[% ccode_loo.authorised_value | html %]" selected="selected">[% ccode_loo.lib | html %]</option> >+ [% ELSE %] >+ <option value="[% ccode_loo.authorised_value | html %]">[% ccode_loo.lib | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> > <label for="itemtype">Item type:</label> > <select name="itemtype" id="itemtype"> > <option value=""></option> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index 2ec7fefd52..7d937d3f3a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -143,6 +143,7 @@ > <ol> > [% IF ( location ) %]<li><span class="label">Location:</span> [% location | html %]</li>[% END %] > [% IF ( callnumber ) %]<li><span class="label">Call number:</span> [% callnumber | html %]</li>[% END %] >+ [% IF ( ccode ) %]<li><span class="label">Collection code:</span> [% ccode | html %]</li>[% END %] > [% IF ( staffdisplaycount ) %]<li><span class="label">Number of issues to display to staff:</span>[% staffdisplaycount | html %]</li>[% END %] > [% IF ( opacdisplaycount ) %]<li><span class="label">Number of issues to display in OPAC:</span>[% opacdisplaycount | html %]</li>[% END %] > [% IF ( letter ) %] >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 39426a6253..c7bd98ec96 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -124,10 +124,12 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { > } > > my $locations_loop = GetAuthorisedValues("LOC"); >+my $ccodes_loop = GetAuthorisedValues("CCODE"); > > $template->param( > branchcode => $subs->{branchcode}, > locations_loop=>$locations_loop, >+ ccodes_loop=>$ccodes_loop > ); > > my @additional_fields = Koha::AdditionalFields->search({ tablename => 'subscription' }); >@@ -328,6 +330,7 @@ sub redirect_add_subscription { > my $itemtype = $query->param('itemtype'); > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); >+ my $ccode = $query->param('ccode'); > > my $mana_id; > if ( $query->param('mana_id') ne "" ) { >@@ -354,7 +357,7 @@ sub redirect_add_subscription { > join(";",@irregularity), $numberpattern, $locale, $callnumber, > $manualhistory, $internalnotes, $serialsadditems, > $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >- $skip_serialseq, $itemtype, $previousitemtype, $mana_id >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode > ); > if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){ > my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription'); >@@ -441,6 +444,7 @@ sub redirect_mod_subscription { > my $itemtype = $query->param('itemtype'); > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); >+ my $ccode = $query->param('ccode'); > > my $mana_id; > if ( $query->param('mana_id') ne "" ) { >@@ -476,7 +480,7 @@ sub redirect_mod_subscription { > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, > $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >- $skip_serialseq, $itemtype, $previousitemtype, $mana_id >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode > ); > > my @additional_fields; >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index 6e8204810f..76e0bc2ccd 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -114,6 +114,8 @@ for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) > } > my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} }); > $subs->{location} = $av->count ? $av->next->lib : ''; >+$av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $subs->{ccode} }); >+$subs->{ccode} = $av->count ? $av->next->lib : ''; > $subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid}); > $template->param(%{ $subs }); > $template->param(biblionumber_for_new_subscription => $subs->{bibnum}); >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 816a8a9714..416a159bcf 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -16,7 +16,7 @@ use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Booksellers; > use t::lib::Mocks; > use t::lib::TestBuilder; >-use Test::More tests => 49; >+use Test::More tests => 51; > > BEGIN { > use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate )); >@@ -74,19 +74,23 @@ my $pattern_id = AddSubscriptionNumberpattern({ > > my $notes = "a\nnote\non\nseveral\nlines"; > my $internalnotes = 'intnotes'; >+my $ccode = 'FIC'; > my $subscriptionid = NewSubscription( > undef, "", undef, undef, $budget_id, $biblionumber, > '2013-01-01', $frequency_id, undef, undef, undef, > undef, undef, undef, undef, undef, undef, > 1, $notes, ,undef, '2013-01-01', undef, $pattern_id, > undef, undef, 0, $internalnotes, 0, >- undef, undef, 0, undef, '2013-12-31', 0 >+ undef, undef, 0, undef, '2013-12-31', 0, >+ undef, undef, undef, $ccode >+ > ); > > my $subscriptioninformation = GetSubscription( $subscriptionid ); > > is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' ); > is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' ); >+is( $subscriptioninformation->{ccode}, $ccode, 'NewSubscription should set ccode' ); > > my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid); > is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' ); >@@ -114,6 +118,7 @@ if (not $frequency->{unit}) { > $frequency->{description} = "Frequency created by t/db_dependant/Serials.t"; > $subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency); > $subscriptioninformation->{serialsadditems} = 1; >+ $subscriptioninformation->{ccode} = 'NFIC'; > > ModSubscription( @$subscriptioninformation{qw( > librarian branchcode aqbooksellerid cost aqbudgetid startdate >@@ -122,12 +127,16 @@ if (not $frequency->{unit}) { > innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes > letter manualhistory internalnotes serialsadditems staffdisplaycount > opacdisplaycount graceperiod location enddate subscriptionid >- skip_serialseq >+ skip_serialseq itemtype previousitemtype mana_id ccode > )} ); > } > my $expirationdate = GetExpirationDate($subscriptionid) ; > ok( $expirationdate, "expiration date is not NULL" ); > >+# Check ModSubscription has updated the ccode >+my $subscriptioninformation2 = GetSubscription($subscriptionid); >+is( $subscriptioninformation2->{ccode}, 'NFIC', 'ModSubscription should update ccode' ); >+ > ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription'); > > my ($serials_count, @serials) = GetSerials($subscriptionid); >-- >2.11.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 23352
:
91678
|
91679
|
91901
|
91985
|
91986
|
92149
|
92165
|
92166
|
95662
|
101913
|
101914
|
101916
|
129123
|
129124
|
129125
|
129225
|
129226
|
129227
|
129228
|
131426
|
131427
|
131435
|
131437
|
131438
|
131439
|
132920
|
133679
|
133680
|
133681
|
133682
|
133683
|
133786
|
133787
|
133788
|
133789
|
133790
|
163965