Browse Source

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

Signed-off-by: Samu Heiskanen <samu.heiskanen@hypernova.fi>

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
master
Alex Buckley 5 months ago
committed by Fridolin Somers
parent
commit
ad6d1265e0
  1. 12
      C4/Items.pm
  2. 6
      C4/Serials.pm
  3. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
  4. 1
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
  5. 8
      serials/subscription-add.pl
  6. 2
      serials/subscription-detail.pl
  7. 15
      t/db_dependent/Serials.t

12
C4/Items.pm

@ -1694,6 +1694,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;

6
C4/Serials.pm

@ -1321,7 +1321,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);
@ -1364,6 +1364,7 @@ sub ModSubscription {
itemtype => $itemtype,
previousitemtype => $previousitemtype,
mana_id => $mana_id,
ccode => $ccode,
}
)->store;
# FIXME Must be $subscription->serials
@ -1401,7 +1402,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;
@ -1444,6 +1445,7 @@ sub NewSubscription {
itemtype => $itemtype,
previousitemtype => $previousitemtype,
mana_id => $mana_id,
ccode => $ccode
}
)->store;
$subscription->discard_changes;

12
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt

@ -199,6 +199,18 @@ fieldset.rows table { clear: none; margin: 0; }
[% END %]
</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">

1
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt

@ -151,6 +151,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 ) %]

8
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' })->as_list;
@ -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;

2
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});

15
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 => 50;
use Test::More tests => 52;
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);

Loading…
Cancel
Save