|
Lines 5-26
Link Here
|
| 5 |
|
5 |
|
| 6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
| 7 |
|
7 |
|
| 8 |
use C4::Serials qw( getroutinglist 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 ); |
8 |
use C4::Serials |
|
|
9 |
qw( getroutinglist 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 GetSeasonsTranslations ); |
| 9 |
use C4::Serials::Frequency; |
10 |
use C4::Serials::Frequency; |
| 10 |
use C4::Serials::Numberpattern; |
11 |
use C4::Serials::Numberpattern; |
| 11 |
use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); |
12 |
use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); |
| 12 |
use C4::Budgets qw( AddBudgetPeriod AddBudget ); |
13 |
use C4::Budgets qw( AddBudgetPeriod AddBudget ); |
|
|
14 |
use C4::Context; |
| 13 |
use C4::Items qw( AddItemFromMarc ); |
15 |
use C4::Items qw( AddItemFromMarc ); |
|
|
16 |
use Encode qw( encode ); |
| 17 |
use File::Temp; |
| 14 |
use Koha::Database; |
18 |
use Koha::Database; |
| 15 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
19 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
| 16 |
use Koha::Acquisition::Booksellers; |
20 |
use Koha::Acquisition::Booksellers; |
| 17 |
use t::lib::Mocks; |
21 |
use t::lib::Mocks; |
| 18 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
| 19 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 20 |
use Test::More tests => 63; |
24 |
use Test::More tests => 64; |
| 21 |
|
25 |
|
| 22 |
BEGIN { |
26 |
BEGIN { |
| 23 |
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 )); |
27 |
use_ok( |
|
|
28 |
'C4::Serials', |
| 29 |
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 GetSeasonsTranslations ) |
| 30 |
); |
| 24 |
} |
31 |
} |
| 25 |
|
32 |
|
| 26 |
# Auth required for cataloguing plugins |
33 |
# Auth required for cataloguing plugins |
|
Lines 37-87
my $builder = t::lib::TestBuilder->new();
Link Here
|
| 37 |
|
44 |
|
| 38 |
# This could/should be used for all untested methods |
45 |
# This could/should be used for all untested methods |
| 39 |
my @methods = ('updateClaim'); |
46 |
my @methods = ('updateClaim'); |
| 40 |
can_ok('C4::Serials', @methods); |
47 |
can_ok( 'C4::Serials', @methods ); |
| 41 |
|
48 |
|
| 42 |
$dbh->do(q|UPDATE marc_subfield_structure SET value_builder="callnumber.pl" where kohafield="items.itemcallnumber" and frameworkcode=''|); |
49 |
$dbh->do( |
|
|
50 |
q|UPDATE marc_subfield_structure SET value_builder="callnumber.pl" where kohafield="items.itemcallnumber" and frameworkcode=''| |
| 51 |
); |
| 43 |
|
52 |
|
| 44 |
my $bookseller = Koha::Acquisition::Bookseller->new( |
53 |
my $bookseller = Koha::Acquisition::Bookseller->new( |
| 45 |
{ |
54 |
{ |
| 46 |
name => "my vendor", |
55 |
name => "my vendor", |
| 47 |
address1 => "bookseller's address", |
56 |
address1 => "bookseller's address", |
| 48 |
phone => "0123456", |
57 |
phone => "0123456", |
| 49 |
active => 1 |
58 |
active => 1 |
|
|
59 |
} |
| 60 |
); |
| 61 |
|
| 62 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( MARC::Record->new, '' ); |
| 63 |
|
| 64 |
my $bpid = AddBudgetPeriod( |
| 65 |
{ |
| 66 |
budget_period_startdate => '2015-01-01', |
| 67 |
budget_period_enddate => '2015-12-31', |
| 68 |
budget_period_description => "budget desc" |
| 50 |
} |
69 |
} |
| 51 |
); |
70 |
); |
| 52 |
|
71 |
|
| 53 |
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); |
72 |
my $budget_id = AddBudget( |
| 54 |
|
73 |
{ |
| 55 |
my $bpid = AddBudgetPeriod({ |
74 |
budget_code => "ABCD", |
| 56 |
budget_period_startdate => '2015-01-01', |
75 |
budget_amount => "123.132", |
| 57 |
budget_period_enddate => '2015-12-31', |
76 |
budget_name => "Périodiques", |
| 58 |
budget_period_description => "budget desc" |
77 |
budget_notes => "This is a note", |
| 59 |
}); |
78 |
budget_period_id => $bpid |
| 60 |
|
79 |
} |
| 61 |
my $budget_id = AddBudget({ |
80 |
); |
| 62 |
budget_code => "ABCD", |
81 |
|
| 63 |
budget_amount => "123.132", |
82 |
my $frequency_id = AddSubscriptionFrequency( { description => "Test frequency 1" } ); |
| 64 |
budget_name => "Périodiques", |
83 |
my $pattern_id = AddSubscriptionNumberpattern( |
| 65 |
budget_notes => "This is a note", |
84 |
{ |
| 66 |
budget_period_id => $bpid |
85 |
label => 'Test numberpattern 1', |
| 67 |
}); |
86 |
description => 'Description for numberpattern 1', |
| 68 |
|
87 |
numberingmethod => '{X}', |
| 69 |
my $frequency_id = AddSubscriptionFrequency({ description => "Test frequency 1" }); |
88 |
label1 => q{}, |
| 70 |
my $pattern_id = AddSubscriptionNumberpattern({ |
89 |
add1 => 1, |
| 71 |
label => 'Test numberpattern 1', |
90 |
every1 => 1, |
| 72 |
description => 'Description for numberpattern 1', |
91 |
every1 => 1, |
| 73 |
numberingmethod => '{X}', |
92 |
numbering1 => 1, |
| 74 |
label1 => q{}, |
93 |
whenmorethan1 => 1, |
| 75 |
add1 => 1, |
94 |
} |
| 76 |
every1 => 1, |
95 |
); |
| 77 |
every1 => 1, |
96 |
|
| 78 |
numbering1 => 1, |
97 |
my $notes = "a\nnote\non\nseveral\nlines"; |
| 79 |
whenmorethan1 => 1, |
98 |
my $internalnotes = 'intnotes'; |
| 80 |
}); |
99 |
my $ccode = 'FIC'; |
| 81 |
|
|
|
| 82 |
my $notes = "a\nnote\non\nseveral\nlines"; |
| 83 |
my $internalnotes = 'intnotes'; |
| 84 |
my $ccode = 'FIC'; |
| 85 |
my $subscriptionid = NewSubscription( |
100 |
my $subscriptionid = NewSubscription( |
| 86 |
undef, |
101 |
undef, |
| 87 |
"", |
102 |
"", |
|
Lines 163-198
NewSubscription(
Link Here
|
| 163 |
$ccode |
178 |
$ccode |
| 164 |
); |
179 |
); |
| 165 |
|
180 |
|
| 166 |
my $subscriptioninformation = GetSubscription( $subscriptionid ); |
181 |
my $subscriptioninformation = GetSubscription($subscriptionid); |
| 167 |
|
182 |
|
| 168 |
is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' ); |
183 |
is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' ); |
| 169 |
is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' ); |
184 |
is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' ); |
| 170 |
is( $subscriptioninformation->{ccode}, $ccode, 'NewSubscription should set ccode' ); |
185 |
is( $subscriptioninformation->{ccode}, $ccode, 'NewSubscription should set ccode' ); |
| 171 |
|
186 |
|
| 172 |
my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid); |
187 |
my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid); |
| 173 |
is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' ); |
188 |
is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' ); |
| 174 |
is( $subscription_history->{librariannote}, undef, 'NewSubscription should not set subscriptionhistory librariannotes' ); |
189 |
is( |
|
|
190 |
$subscription_history->{librariannote}, undef, |
| 191 |
'NewSubscription should not set subscriptionhistory librariannotes' |
| 192 |
); |
| 175 |
|
193 |
|
| 176 |
my @subscriptions = SearchSubscriptions({string => $subscriptioninformation->{bibliotitle}, orderby => 'title' }); |
194 |
my @subscriptions = SearchSubscriptions( { string => $subscriptioninformation->{bibliotitle}, orderby => 'title' } ); |
| 177 |
isa_ok( \@subscriptions, 'ARRAY' ); |
195 |
isa_ok( \@subscriptions, 'ARRAY' ); |
| 178 |
|
196 |
|
| 179 |
@subscriptions = SearchSubscriptions({ issn => $subscriptioninformation->{issn}, orderby => 'title' }); |
197 |
@subscriptions = SearchSubscriptions( { issn => $subscriptioninformation->{issn}, orderby => 'title' } ); |
| 180 |
isa_ok( \@subscriptions, 'ARRAY' ); |
198 |
isa_ok( \@subscriptions, 'ARRAY' ); |
| 181 |
|
199 |
|
| 182 |
@subscriptions = SearchSubscriptions({ ean => $subscriptioninformation->{ean}, orderby => 'title' }); |
200 |
@subscriptions = SearchSubscriptions( { ean => $subscriptioninformation->{ean}, orderby => 'title' } ); |
| 183 |
isa_ok( \@subscriptions, 'ARRAY' ); |
201 |
isa_ok( \@subscriptions, 'ARRAY' ); |
| 184 |
|
202 |
|
| 185 |
@subscriptions = SearchSubscriptions({ biblionumber => $subscriptioninformation->{bibnum}, orderby => 'title' }); |
203 |
@subscriptions = SearchSubscriptions( { biblionumber => $subscriptioninformation->{bibnum}, orderby => 'title' } ); |
| 186 |
isa_ok( \@subscriptions, 'ARRAY' ); |
204 |
isa_ok( \@subscriptions, 'ARRAY' ); |
| 187 |
|
205 |
|
| 188 |
@subscriptions = SearchSubscriptions({}); |
206 |
@subscriptions = SearchSubscriptions( {} ); |
| 189 |
is( |
207 |
is( |
| 190 |
@subscriptions, |
208 |
@subscriptions, |
| 191 |
2, |
209 |
2, |
| 192 |
'SearchSubscriptions returned the expected number of subscriptions when results_limit is not set' |
210 |
'SearchSubscriptions returned the expected number of subscriptions when results_limit is not set' |
| 193 |
); |
211 |
); |
| 194 |
|
212 |
|
| 195 |
@subscriptions = SearchSubscriptions({}, { results_limit => 1 }); |
213 |
@subscriptions = SearchSubscriptions( {}, { results_limit => 1 } ); |
| 196 |
is( |
214 |
is( |
| 197 |
@subscriptions, |
215 |
@subscriptions, |
| 198 |
1, |
216 |
1, |
|
Lines 254-309
is(
Link Here
|
| 254 |
'SearchSubscriptions returned the correct subscription' |
272 |
'SearchSubscriptions returned the correct subscription' |
| 255 |
); |
273 |
); |
| 256 |
|
274 |
|
| 257 |
my $frequency = GetSubscriptionFrequency($subscriptioninformation->{periodicity}); |
275 |
my $frequency = GetSubscriptionFrequency( $subscriptioninformation->{periodicity} ); |
| 258 |
my $old_frequency; |
276 |
my $old_frequency; |
| 259 |
if (not $frequency->{unit}) { |
277 |
if ( not $frequency->{unit} ) { |
| 260 |
$old_frequency = $frequency->{id}; |
278 |
$old_frequency = $frequency->{id}; |
| 261 |
$frequency->{unit} = "month"; |
279 |
$frequency->{unit} = "month"; |
| 262 |
$frequency->{unitsperissue} = 1; |
280 |
$frequency->{unitsperissue} = 1; |
| 263 |
$frequency->{issuesperunit} = 1; |
281 |
$frequency->{issuesperunit} = 1; |
| 264 |
$frequency->{description} = "Frequency created by t/db_dependant/Serials.t"; |
282 |
$frequency->{description} = "Frequency created by t/db_dependant/Serials.t"; |
| 265 |
$subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency); |
283 |
$subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency); |
| 266 |
$subscriptioninformation->{serialsadditems} = 1; |
284 |
$subscriptioninformation->{serialsadditems} = 1; |
| 267 |
$subscriptioninformation->{ccode} = 'NFIC'; |
285 |
$subscriptioninformation->{ccode} = 'NFIC'; |
| 268 |
|
286 |
|
| 269 |
ModSubscription( @$subscriptioninformation{qw( |
287 |
ModSubscription( |
| 270 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
288 |
@$subscriptioninformation{ |
| 271 |
periodicity firstacquidate irregularity numberpattern locale |
289 |
qw( |
| 272 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
290 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
| 273 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
291 |
periodicity firstacquidate irregularity numberpattern locale |
| 274 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
292 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
| 275 |
opacdisplaycount graceperiod location enddate subscriptionid |
293 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
| 276 |
skip_serialseq itemtype previousitemtype mana_id ccode |
294 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
| 277 |
)} ); |
295 |
opacdisplaycount graceperiod location enddate subscriptionid |
|
|
296 |
skip_serialseq itemtype previousitemtype mana_id ccode |
| 297 |
) |
| 298 |
} |
| 299 |
); |
| 278 |
} |
300 |
} |
| 279 |
my $expirationdate = GetExpirationDate($subscriptionid) ; |
301 |
my $expirationdate = GetExpirationDate($subscriptionid); |
| 280 |
ok( $expirationdate, "expiration date is not NULL" ); |
302 |
ok( $expirationdate, "expiration date is not NULL" ); |
| 281 |
|
303 |
|
| 282 |
# Check ModSubscription has updated the ccode |
304 |
# Check ModSubscription has updated the ccode |
| 283 |
my $subscriptioninformation2 = GetSubscription($subscriptionid); |
305 |
my $subscriptioninformation2 = GetSubscription($subscriptionid); |
| 284 |
is( $subscriptioninformation2->{ccode}, 'NFIC', 'ModSubscription should update ccode' ); |
306 |
is( $subscriptioninformation2->{ccode}, 'NFIC', 'ModSubscription should update ccode' ); |
| 285 |
|
307 |
|
| 286 |
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription'); |
308 |
ok( C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription' ); |
| 287 |
|
309 |
|
| 288 |
my ($serials_count, @serials) = GetSerials($subscriptionid); |
310 |
my ( $serials_count, @serials ) = GetSerials($subscriptionid); |
| 289 |
ok($serials_count > 0, 'Subscription has at least one serial'); |
311 |
ok( $serials_count > 0, 'Subscription has at least one serial' ); |
| 290 |
my $serial = $serials[0]; |
312 |
my $serial = $serials[0]; |
| 291 |
|
313 |
|
| 292 |
isa_ok(C4::Serials::GetSerialInformation($serial->{serialid}), 'HASH', 'test getting Serial Information'); |
314 |
isa_ok( C4::Serials::GetSerialInformation( $serial->{serialid} ), 'HASH', 'test getting Serial Information' ); |
| 293 |
|
315 |
|
| 294 |
subtest 'Values should not be erased on editing' => sub { |
316 |
subtest 'Values should not be erased on editing' => sub { |
| 295 |
|
317 |
|
| 296 |
plan tests => 1; |
318 |
plan tests => 1; |
| 297 |
|
319 |
|
| 298 |
my $biblio = $builder->build_sample_biblio(); |
320 |
my $biblio = $builder->build_sample_biblio(); |
| 299 |
my $biblionumber = $biblio->biblionumber; |
321 |
my $biblionumber = $biblio->biblionumber; |
| 300 |
my ( $icn_tag, $icn_sf ) = GetMarcFromKohaField( 'items.itemcallnumber' ); |
322 |
my ( $icn_tag, $icn_sf ) = GetMarcFromKohaField('items.itemcallnumber'); |
| 301 |
my ( $it_tag, $it_sf ) = GetMarcFromKohaField( 'items.itype' ); |
323 |
my ( $it_tag, $it_sf ) = GetMarcFromKohaField('items.itype'); |
| 302 |
|
324 |
|
| 303 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
325 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
| 304 |
my $itemcallnumber = 'XXXmy itemcallnumberXXX'; |
326 |
my $itemcallnumber = 'XXXmy itemcallnumberXXX'; |
| 305 |
|
327 |
|
| 306 |
my $item_record = MARC::Record->new; |
328 |
my $item_record = MARC::Record->new; |
| 307 |
|
329 |
|
| 308 |
$item_record->append_fields( |
330 |
$item_record->append_fields( |
| 309 |
MARC::Field->new( '080', '', '', "a" => "default" ), |
331 |
MARC::Field->new( '080', '', '', "a" => "default" ), |
|
Lines 314-325
subtest 'Values should not be erased on editing' => sub {
Link Here
|
| 314 |
) |
336 |
) |
| 315 |
); |
337 |
); |
| 316 |
my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber ); |
338 |
my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber ); |
| 317 |
my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber, |
339 |
my $serialid = C4::Serials::NewIssue( |
| 318 |
1, undef, undef, "publisheddatetext", "notes", "routingnotes" ); |
340 |
"serialseq", $subscriptionid, $biblionumber, |
|
|
341 |
1, undef, undef, "publisheddatetext", "notes", "routingnotes" |
| 342 |
); |
| 319 |
C4::Serials::AddItem2Serial( $serialid, $itemnumber ); |
343 |
C4::Serials::AddItem2Serial( $serialid, $itemnumber ); |
| 320 |
my $serial_info = C4::Serials::GetSerialInformation($serialid); |
344 |
my $serial_info = C4::Serials::GetSerialInformation($serialid); |
| 321 |
my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' } |
345 |
my ($itemcallnumber_info) = |
| 322 |
@{ $serial_info->{items}[0]->{iteminformation} }; |
346 |
grep { $_->{kohafield} eq 'items.itemcallnumber' } @{ $serial_info->{items}[0]->{iteminformation} }; |
| 323 |
like( $itemcallnumber_info->{marc_value}, qr|value="$itemcallnumber"| ); |
347 |
like( $itemcallnumber_info->{marc_value}, qr|value="$itemcallnumber"| ); |
| 324 |
}; |
348 |
}; |
| 325 |
|
349 |
|
|
Lines 328-411
if ($old_frequency) {
Link Here
|
| 328 |
my $freq_to_delete = $subscriptioninformation->{periodicity}; |
352 |
my $freq_to_delete = $subscriptioninformation->{periodicity}; |
| 329 |
$subscriptioninformation->{periodicity} = $old_frequency; |
353 |
$subscriptioninformation->{periodicity} = $old_frequency; |
| 330 |
|
354 |
|
| 331 |
ModSubscription( @$subscriptioninformation{qw( |
355 |
ModSubscription( |
| 332 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
356 |
@$subscriptioninformation{ |
| 333 |
periodicity firstacquidate irregularity numberpattern locale |
357 |
qw( |
| 334 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
358 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
| 335 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
359 |
periodicity firstacquidate irregularity numberpattern locale |
| 336 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
360 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
| 337 |
opacdisplaycount graceperiod location enddate subscriptionid |
361 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
| 338 |
skip_serialseq |
362 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
| 339 |
)} ); |
363 |
opacdisplaycount graceperiod location enddate subscriptionid |
|
|
364 |
skip_serialseq |
| 365 |
) |
| 366 |
} |
| 367 |
); |
| 340 |
|
368 |
|
| 341 |
DelSubscriptionFrequency($freq_to_delete); |
369 |
DelSubscriptionFrequency($freq_to_delete); |
| 342 |
} |
370 |
} |
| 343 |
|
371 |
|
| 344 |
# Test calling subs without parameters |
372 |
# Test calling subs without parameters |
| 345 |
is(C4::Serials::AddItem2Serial(), undef, 'test adding item to serial'); |
373 |
is( C4::Serials::AddItem2Serial(), undef, 'test adding item to serial' ); |
| 346 |
is(C4::Serials::GetFullSubscription(), undef, 'test getting full subscription'); |
374 |
is( C4::Serials::GetFullSubscription(), undef, 'test getting full subscription' ); |
| 347 |
is(C4::Serials::PrepareSerialsData(), undef, 'test preparing serial data'); |
375 |
is( C4::Serials::PrepareSerialsData(), undef, 'test preparing serial data' ); |
| 348 |
|
376 |
|
| 349 |
subtest 'GetSubscriptionsFromBiblionumber' => sub { |
377 |
subtest 'GetSubscriptionsFromBiblionumber' => sub { |
| 350 |
plan tests => 4; |
378 |
plan tests => 4; |
| 351 |
|
379 |
|
| 352 |
is( C4::Serials::GetSubscriptionsFromBiblionumber(), |
380 |
is( |
| 353 |
undef, 'test getting subscriptions form biblio number' ); |
381 |
C4::Serials::GetSubscriptionsFromBiblionumber(), |
|
|
382 |
undef, 'test getting subscriptions form biblio number' |
| 383 |
); |
| 354 |
|
384 |
|
| 355 |
my $subscriptions = C4::Serials::GetSubscriptionsFromBiblionumber($biblionumber); |
385 |
my $subscriptions = C4::Serials::GetSubscriptionsFromBiblionumber($biblionumber); |
| 356 |
ModSubscriptionHistory( $subscriptions->[0]->{subscriptionid}, |
386 |
ModSubscriptionHistory( |
| 357 |
undef, undef, $notes, $notes, $notes ); |
387 |
$subscriptions->[0]->{subscriptionid}, |
|
|
388 |
undef, undef, $notes, $notes, $notes |
| 389 |
); |
| 358 |
|
390 |
|
| 359 |
$subscriptions = C4::Serials::GetSubscriptionsFromBiblionumber($biblionumber); |
391 |
$subscriptions = C4::Serials::GetSubscriptionsFromBiblionumber($biblionumber); |
| 360 |
is( $subscriptions->[0]->{opacnote}, $notes, |
392 |
is( |
|
|
393 |
$subscriptions->[0]->{opacnote}, $notes, |
| 361 |
'GetSubscriptionsFromBiblionumber should have returned the opacnote as it is in DB, ie. without br tags' |
394 |
'GetSubscriptionsFromBiblionumber should have returned the opacnote as it is in DB, ie. without br tags' |
| 362 |
); |
395 |
); |
| 363 |
is( $subscriptions->[0]->{recievedlist}, $notes, |
396 |
is( |
|
|
397 |
$subscriptions->[0]->{recievedlist}, $notes, |
| 364 |
'GetSubscriptionsFromBiblionumber should have returned recievedlist as it is in DB, ie. without br tags' |
398 |
'GetSubscriptionsFromBiblionumber should have returned recievedlist as it is in DB, ie. without br tags' |
| 365 |
); |
399 |
); |
| 366 |
is( $subscriptions->[0]->{missinglist}, $notes, |
400 |
is( |
|
|
401 |
$subscriptions->[0]->{missinglist}, $notes, |
| 367 |
'GetSubscriptionsFromBiblionumber should have returned missinglist as it is in DB, ie. without br tags' |
402 |
'GetSubscriptionsFromBiblionumber should have returned missinglist as it is in DB, ie. without br tags' |
| 368 |
); |
403 |
); |
| 369 |
}; |
404 |
}; |
| 370 |
|
405 |
|
| 371 |
is(C4::Serials::GetSerials(), undef, 'test getting serials when you enter nothing'); |
406 |
is( C4::Serials::GetSerials(), undef, 'test getting serials when you enter nothing' ); |
| 372 |
is(C4::Serials::GetSerials2(), undef, 'test getting serials when you enter nothing'); |
407 |
is( C4::Serials::GetSerials2(), undef, 'test getting serials when you enter nothing' ); |
| 373 |
|
408 |
|
| 374 |
is(C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials'); |
409 |
is( C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials' ); |
| 375 |
|
410 |
|
| 376 |
is(C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing'); |
411 |
is( C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing' ); |
| 377 |
|
412 |
|
| 378 |
is(C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing'); |
413 |
is( C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing' ); |
| 379 |
|
414 |
|
| 380 |
is(C4::Serials::CountSubscriptionFromBiblionumber(), undef, 'test counting subscription when nothing is entered'); |
415 |
is( C4::Serials::CountSubscriptionFromBiblionumber(), undef, 'test counting subscription when nothing is entered' ); |
| 381 |
|
416 |
|
| 382 |
is(C4::Serials::ModSubscriptionHistory(), undef, 'test modding subscription history'); |
417 |
is( C4::Serials::ModSubscriptionHistory(), undef, 'test modding subscription history' ); |
| 383 |
|
418 |
|
| 384 |
is(C4::Serials::ModSerialStatus(),undef, 'test modding serials'); |
419 |
is( C4::Serials::ModSerialStatus(), undef, 'test modding serials' ); |
| 385 |
|
420 |
|
| 386 |
is(C4::Serials::findSerialsByStatus(), 0, 'test finding serial by status with no parameters'); |
421 |
is( C4::Serials::findSerialsByStatus(), 0, 'test finding serial by status with no parameters' ); |
| 387 |
|
422 |
|
| 388 |
is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered'); |
423 |
is( C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered' ); |
| 389 |
|
424 |
|
| 390 |
is(C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired'); |
425 |
is( C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired' ); |
| 391 |
is(C4::Serials::HasSubscriptionExpired(), undef, 'test if the subscriptions has expired'); |
426 |
is( C4::Serials::HasSubscriptionExpired(), undef, 'test if the subscriptions has expired' ); |
| 392 |
|
427 |
|
| 393 |
is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing issues'); |
428 |
is( C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing issues' ); |
| 394 |
|
429 |
|
| 395 |
subtest 'test_updateClaim' => sub { |
430 |
subtest 'test_updateClaim' => sub { |
| 396 |
plan tests => 11; |
431 |
plan tests => 11; |
| 397 |
|
432 |
|
| 398 |
my $today = output_pref({ dt => dt_from_string, dateonly => 1 }); |
433 |
my $today = output_pref( { dt => dt_from_string, dateonly => 1 } ); |
|
|
434 |
|
| 399 |
# Given ... nothing much |
435 |
# Given ... nothing much |
| 400 |
# When ... Then ... |
436 |
# When ... Then ... |
| 401 |
my $result_0 = C4::Serials::updateClaim(undef); |
437 |
my $result_0 = C4::Serials::updateClaim(undef); |
| 402 |
is($result_0, undef, 'Got the expected undef from update claim with nothin'); |
438 |
is( $result_0, undef, 'Got the expected undef from update claim with nothin' ); |
| 403 |
|
439 |
|
| 404 |
# Given ... 3 serial. 2 of them updated. |
440 |
# Given ... 3 serial. 2 of them updated. |
| 405 |
my $claimdate_1 = dt_from_string('2001-01-13'); # arbitrary date some time in the past. |
441 |
my $claimdate_1 = dt_from_string('2001-01-13'); # arbitrary date some time in the past. |
| 406 |
my $claim_count_1 = 5; |
442 |
my $claim_count_1 = 5; |
| 407 |
my $biblio = $builder->build_sample_biblio; |
443 |
my $biblio = $builder->build_sample_biblio; |
| 408 |
my $serial1 = $builder->build_object( |
444 |
my $serial1 = $builder->build_object( |
| 409 |
{ |
445 |
{ |
| 410 |
class => 'Koha::Serials', |
446 |
class => 'Koha::Serials', |
| 411 |
value => { |
447 |
value => { |
|
Lines 446-536
subtest 'test_updateClaim' => sub {
Link Here
|
| 446 |
); |
482 |
); |
| 447 |
|
483 |
|
| 448 |
# When ... |
484 |
# When ... |
| 449 |
my $result_1 = C4::Serials::updateClaim([$serial1->serialid, $serial2->serialid]); |
485 |
my $result_1 = C4::Serials::updateClaim( [ $serial1->serialid, $serial2->serialid ] ); |
| 450 |
|
486 |
|
| 451 |
# Then ... |
487 |
# Then ... |
| 452 |
is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids'); |
488 |
is( $result_1, 2, 'Got the expected 2 from update claim with 2 serial ids' ); |
| 453 |
|
489 |
|
| 454 |
my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serial1->serialid); |
490 |
my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues( undef, $serial1->serialid ); |
| 455 |
is(output_pref({str => $late_or_missing_issues_1_0[0]->{claimdate}, dateonly => 1}), $today, 'Got the expected first different claim date from update claim'); |
491 |
is( |
| 456 |
is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim'); |
492 |
output_pref( { str => $late_or_missing_issues_1_0[0]->{claimdate}, dateonly => 1 } ), $today, |
| 457 |
is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim'); |
493 |
'Got the expected first different claim date from update claim' |
| 458 |
|
494 |
); |
| 459 |
my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serial2->serialid); |
495 |
is( |
| 460 |
is(output_pref({str => $late_or_missing_issues_1_1[0]->{claimdate}, dateonly => 1}), $today, 'Got the expected second different claim date from update claim'); |
496 |
$late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1 + 1, |
| 461 |
is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim'); |
497 |
'Got the expected first claim count from update claim' |
| 462 |
is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim'); |
498 |
); |
| 463 |
|
499 |
is( $late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim' ); |
| 464 |
my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, $serial3->serialid); |
500 |
|
| 465 |
is(output_pref({str => $late_or_missing_issues_1_2[0]->{claimdate}, dateonly => 1}), output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim'); |
501 |
my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues( undef, $serial2->serialid ); |
| 466 |
is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim'); |
502 |
is( |
| 467 |
is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); |
503 |
output_pref( { str => $late_or_missing_issues_1_1[0]->{claimdate}, dateonly => 1 } ), $today, |
|
|
504 |
'Got the expected second different claim date from update claim' |
| 505 |
); |
| 506 |
is( |
| 507 |
$late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1 + 1, |
| 508 |
'Got the expected second claim count from update claim' |
| 509 |
); |
| 510 |
is( $late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim' ); |
| 511 |
|
| 512 |
my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues( undef, $serial3->serialid ); |
| 513 |
is( |
| 514 |
output_pref( { str => $late_or_missing_issues_1_2[0]->{claimdate}, dateonly => 1 } ), |
| 515 |
output_pref( { dt => $claimdate_1, dateonly => 1 } ), |
| 516 |
'Got the expected unchanged claim date from update claim' |
| 517 |
); |
| 518 |
is( |
| 519 |
$late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, |
| 520 |
'Got the expected unchanged claim count from update claim' |
| 521 |
); |
| 522 |
is( $late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim' ); |
| 468 |
}; |
523 |
}; |
| 469 |
|
524 |
|
| 470 |
is(C4::Serials::check_routing(), undef, 'test checking route'); |
525 |
is( C4::Serials::check_routing(), undef, 'test checking route' ); |
| 471 |
is(C4::Serials::check_routing($subscriptionid), 0, 'There should not have any routing list for the subscription'); |
526 |
is( C4::Serials::check_routing($subscriptionid), 0, 'There should not have any routing list for the subscription' ); |
| 472 |
# TODO really test this check_routing subroutine |
|
|
| 473 |
|
527 |
|
| 474 |
is(C4::Serials::addroutingmember(),undef, 'test adding route member'); |
528 |
# TODO really test this check_routing subroutine |
| 475 |
|
529 |
|
|
|
530 |
is( C4::Serials::addroutingmember(), undef, 'test adding route member' ); |
| 476 |
|
531 |
|
| 477 |
# Unit tests for statuses management (Bug 11689) |
532 |
# Unit tests for statuses management (Bug 11689) |
| 478 |
$subscriptionid = NewSubscription( |
533 |
$subscriptionid = NewSubscription( |
| 479 |
undef, "", undef, undef, $budget_id, $biblionumber, |
534 |
undef, "", undef, undef, $budget_id, $biblionumber, |
| 480 |
'2013-01-01', $frequency_id, undef, undef, undef, |
535 |
'2013-01-01', $frequency_id, undef, undef, undef, |
| 481 |
undef, undef, undef, undef, undef, undef, |
536 |
undef, undef, undef, undef, undef, undef, |
| 482 |
1, $notes,undef, '2013-01-01', undef, $pattern_id, |
537 |
1, $notes, undef, '2013-01-01', undef, $pattern_id, |
| 483 |
undef, undef, 0, $internalnotes, 0, |
538 |
undef, undef, 0, $internalnotes, 0, |
| 484 |
undef, undef, 0, undef, '2013-12-31', 0 |
539 |
undef, undef, 0, undef, '2013-12-31', 0 |
| 485 |
); |
540 |
); |
| 486 |
my $total_issues; |
541 |
my $total_issues; |
| 487 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); |
542 |
( $total_issues, @serials ) = C4::Serials::GetSerials($subscriptionid); |
| 488 |
is( $total_issues, 1, "NewSubscription created a first serial" ); |
543 |
is( $total_issues, 1, "NewSubscription created a first serial" ); |
| 489 |
is( @serials, 1, "GetSerials returns the serial" ); |
544 |
is( @serials, 1, "GetSerials returns the serial" ); |
| 490 |
my $subscription = C4::Serials::GetSubscription($subscriptionid); |
545 |
my $subscription = C4::Serials::GetSubscription($subscriptionid); |
| 491 |
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); |
546 |
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern( $subscription->{numberpattern} ); |
| 492 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); |
547 |
( $total_issues, @serials ) = C4::Serials::GetSerials($subscriptionid); |
| 493 |
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
548 |
my $publisheddate = output_pref( { dt => dt_from_string, dateformat => 'iso', dateonly => 1 } ); |
| 494 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); |
549 |
( $total_issues, @serials ) = C4::Serials::GetSerials($subscriptionid); |
| 495 |
$frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); |
550 |
$frequency = C4::Serials::Frequency::GetSubscriptionFrequency( $subscription->{periodicity} ); |
| 496 |
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1); |
551 |
my $nextpublisheddate = C4::Serials::GetNextDate( $subscription, $publisheddate, $frequency, 1 ); |
| 497 |
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 ); |
552 |
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 ); |
|
|
553 |
|
| 498 |
# Add 14 serials |
554 |
# Add 14 serials |
| 499 |
my $counter = 0; |
555 |
my $counter = 0; |
| 500 |
for my $status ( @statuses ) { |
556 |
for my $status (@statuses) { |
| 501 |
my $serialseq = "No.".$counter; |
557 |
my $serialseq = "No." . $counter; |
| 502 |
my ( $expected_serial ) = GetSerials2( $subscriptionid, [1] ); |
558 |
my ($expected_serial) = GetSerials2( $subscriptionid, [1] ); |
| 503 |
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, $serialseq, $publisheddate, $publisheddate, $publisheddate, $statuses[$counter], 'an useless note' ); |
559 |
C4::Serials::ModSerialStatus( |
|
|
560 |
$expected_serial->{serialid}, $serialseq, $publisheddate, $publisheddate, |
| 561 |
$publisheddate, $statuses[$counter], 'an useless note' |
| 562 |
); |
| 504 |
$counter++; |
563 |
$counter++; |
| 505 |
} |
564 |
} |
|
|
565 |
|
| 506 |
# 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 |
566 |
# 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 |
| 507 |
my @serialsByStatus = C4::Serials::findSerialsByStatus(2,$subscriptionid); |
567 |
my @serialsByStatus = C4::Serials::findSerialsByStatus( 2, $subscriptionid ); |
| 508 |
is(@serialsByStatus,2,"findSerialsByStatus returns all serials with chosen status"); |
568 |
is( @serialsByStatus, 2, "findSerialsByStatus returns all serials with chosen status" ); |
| 509 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); |
569 |
( $total_issues, @serials ) = C4::Serials::GetSerials($subscriptionid); |
| 510 |
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" ); |
570 |
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" ); |
| 511 |
my @arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials; |
571 |
my @arrived_missing = map { |
| 512 |
my @others = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ } @serials; |
572 |
my $status = $_->{status}; |
|
|
573 |
( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () |
| 574 |
} @serials; |
| 575 |
my @others = map { |
| 576 |
my $status = $_->{status}; |
| 577 |
( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ |
| 578 |
} @serials; |
| 513 |
is( @arrived_missing, 5, "GetSerials returns 5 arrived/missing by default" ); |
579 |
is( @arrived_missing, 5, "GetSerials returns 5 arrived/missing by default" ); |
| 514 |
is( @others, 6, "GetSerials returns all serials not arrived and not missing" ); |
580 |
is( @others, 6, "GetSerials returns all serials not arrived and not missing" ); |
| 515 |
|
581 |
|
| 516 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid, 10 ); |
582 |
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid, 10 ); |
| 517 |
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" ); |
583 |
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" ); |
| 518 |
@arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials; |
584 |
@arrived_missing = map { |
| 519 |
@others = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ } @serials; |
585 |
my $status = $_->{status}; |
|
|
586 |
( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () |
| 587 |
} @serials; |
| 588 |
@others = map { |
| 589 |
my $status = $_->{status}; |
| 590 |
( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ |
| 591 |
} @serials; |
| 520 |
is( @arrived_missing, 9, "GetSerials returns all arrived/missing if count given" ); |
592 |
is( @arrived_missing, 9, "GetSerials returns all arrived/missing if count given" ); |
| 521 |
is( @others, 6, "GetSerials returns all serials not arrived and not missing if count given" ); |
593 |
is( @others, 6, "GetSerials returns all serials not arrived and not missing if count given" ); |
| 522 |
|
594 |
|
| 523 |
$subscription = C4::Serials::GetSubscription($subscriptionid); # Retrieve the updated subscription |
595 |
$subscription = C4::Serials::GetSubscription($subscriptionid); # Retrieve the updated subscription |
| 524 |
|
596 |
|
| 525 |
my @serialseqs; |
597 |
my @serialseqs; |
| 526 |
for my $am ( @arrived_missing ) { |
598 |
for my $am (@arrived_missing) { |
| 527 |
if ( grep {/^$am->{status}$/} qw( 4 41 42 43 44 ) ) { |
599 |
if ( grep { /^$am->{status}$/ } qw( 4 41 42 43 44 ) ) { |
| 528 |
push @serialseqs, $am->{serialseq} |
600 |
push @serialseqs, $am->{serialseq}; |
| 529 |
} elsif ( grep {/^$am->{status}$/} qw( 5 ) ) { |
601 |
} elsif ( grep { /^$am->{status}$/ } qw( 5 ) ) { |
| 530 |
push @serialseqs, 'not issued ' . $am->{serialseq}; |
602 |
push @serialseqs, 'not issued ' . $am->{serialseq}; |
| 531 |
} |
603 |
} |
| 532 |
} |
604 |
} |
| 533 |
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" ); |
605 |
is( |
|
|
606 |
$subscription->{missinglist}, join( '; ', @serialseqs ), |
| 607 |
"subscription missinglist is updated after ModSerialStatus" |
| 608 |
); |
| 534 |
|
609 |
|
| 535 |
subtest "Do not generate an expected if one already exists" => sub { |
610 |
subtest "Do not generate an expected if one already exists" => sub { |
| 536 |
plan tests => 2; |
611 |
plan tests => 2; |
|
Lines 540-555
subtest "Do not generate an expected if one already exists" => sub {
Link Here
|
| 540 |
my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0]; |
615 |
my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0]; |
| 541 |
|
616 |
|
| 542 |
#delete serial with status Expected |
617 |
#delete serial with status Expected |
| 543 |
C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); |
618 |
C4::Serials::ModSerialStatus( |
|
|
619 |
$serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, |
| 620 |
$publisheddate, $publisheddate, '1', 'an useless note' |
| 621 |
); |
| 544 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
622 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
| 545 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and create another if not exist" ); |
623 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and create another if not exist" ); |
| 546 |
|
624 |
|
| 547 |
# add 1 serial with status=Expected 1 |
625 |
# add 1 serial with status=Expected 1 |
| 548 |
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); |
626 |
C4::Serials::ModSerialStatus( |
|
|
627 |
$expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, |
| 628 |
$publisheddate, '1', 'an useless note' |
| 629 |
); |
| 549 |
|
630 |
|
| 550 |
#Now we have two serials it have status expected |
631 |
#Now we have two serials it have status expected |
| 551 |
#put status delete for last serial |
632 |
#put status delete for last serial |
| 552 |
C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); |
633 |
C4::Serials::ModSerialStatus( |
|
|
634 |
$serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, |
| 635 |
$publisheddate, $publisheddate, '1', 'an useless note' |
| 636 |
); |
| 553 |
|
637 |
|
| 554 |
#try if create or not another serial with status is expected |
638 |
#try if create or not another serial with status is expected |
| 555 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
639 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
|
Lines 562-610
subtest "PreserveSerialNotes preference" => sub {
Link Here
|
| 562 |
|
646 |
|
| 563 |
t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 1 ); |
647 |
t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 1 ); |
| 564 |
|
648 |
|
| 565 |
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); |
649 |
C4::Serials::ModSerialStatus( |
|
|
650 |
$expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, |
| 651 |
$publisheddate, '1', 'an useless note' |
| 652 |
); |
| 566 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
653 |
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid ); |
| 567 |
is( $serialsByStatus[0]->{note},$expected_serial->{note}, "note passed through if supposed to"); |
654 |
is( $serialsByStatus[0]->{note}, $expected_serial->{note}, "note passed through if supposed to" ); |
| 568 |
|
655 |
|
| 569 |
t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 0 ); |
656 |
t::lib::Mocks::mock_preference( 'PreserveSerialNotes', 0 ); |
| 570 |
$expected_serial = $serialsByStatus[0]; |
657 |
$expected_serial = $serialsByStatus[0]; |
| 571 |
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' ); |
658 |
C4::Serials::ModSerialStatus( |
| 572 |
is( $serialsByStatus[0]->{note},$expected_serial->{note}, "note not passed through if not supposed to"); |
659 |
$expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, |
|
|
660 |
$publisheddate, '1', 'an useless note' |
| 661 |
); |
| 662 |
is( $serialsByStatus[0]->{note}, $expected_serial->{note}, "note not passed through if not supposed to" ); |
| 573 |
|
663 |
|
| 574 |
}; |
664 |
}; |
| 575 |
|
665 |
|
| 576 |
subtest "NewSubscription|ModSubscription" => sub { |
666 |
subtest "NewSubscription|ModSubscription" => sub { |
| 577 |
plan tests => 4; |
667 |
plan tests => 4; |
| 578 |
my $subscriptionid = NewSubscription( |
668 |
my $subscriptionid = NewSubscription( |
| 579 |
"", "", "", "", $budget_id, $biblionumber, |
669 |
"", "", "", "", $budget_id, $biblionumber, |
| 580 |
'2013-01-01', $frequency_id, "", "", "", |
670 |
'2013-01-01', $frequency_id, "", "", "", |
| 581 |
"", "", "", "", "", "", |
671 |
"", "", "", "", "", "", |
| 582 |
1, $notes,"", '2013-01-01', "", $pattern_id, |
672 |
1, $notes, "", '2013-01-01', "", $pattern_id, |
| 583 |
"", "", 0, $internalnotes, 0, |
673 |
"", "", 0, $internalnotes, 0, |
| 584 |
"", "", 0, "", '2013-12-31', 0 |
674 |
"", "", 0, "", '2013-12-31', 0 |
| 585 |
); |
675 |
); |
| 586 |
ok($subscriptionid, "Sending empty string instead of undef to reflect use of the interface"); |
676 |
ok( $subscriptionid, "Sending empty string instead of undef to reflect use of the interface" ); |
| 587 |
|
677 |
|
| 588 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
678 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
| 589 |
my $serials = Koha::Serials->search({ subscriptionid => $subscriptionid }); |
679 |
my $serials = Koha::Serials->search( { subscriptionid => $subscriptionid } ); |
| 590 |
is( $serials->count, 1, "NewSubscription created a first serial" ); |
680 |
is( $serials->count, 1, "NewSubscription created a first serial" ); |
| 591 |
|
681 |
|
| 592 |
my $biblio_2 = $builder->build_sample_biblio; |
682 |
my $biblio_2 = $builder->build_sample_biblio; |
| 593 |
my $subscription_info = $subscription->unblessed; |
683 |
my $subscription_info = $subscription->unblessed; |
| 594 |
$subscription_info->{biblionumber} = $biblio_2->biblionumber; |
684 |
$subscription_info->{biblionumber} = $biblio_2->biblionumber; |
| 595 |
ModSubscription( @$subscription_info{qw( |
685 |
ModSubscription( |
| 596 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
686 |
@$subscription_info{ |
| 597 |
periodicity firstacquidate irregularity numberpattern locale |
687 |
qw( |
| 598 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
688 |
librarian branchcode aqbooksellerid cost aqbudgetid startdate |
| 599 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
689 |
periodicity firstacquidate irregularity numberpattern locale |
| 600 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
690 |
numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 |
| 601 |
opacdisplaycount graceperiod location enddate subscriptionid |
691 |
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes |
| 602 |
skip_serialseq |
692 |
letter manualhistory internalnotes serialsadditems staffdisplaycount |
| 603 |
)} ); |
693 |
opacdisplaycount graceperiod location enddate subscriptionid |
| 604 |
|
694 |
skip_serialseq |
| 605 |
$serials = Koha::Serials->search({ subscriptionid => $subscriptionid }); |
695 |
) |
|
|
696 |
} |
| 697 |
); |
| 698 |
|
| 699 |
$serials = Koha::Serials->search( { subscriptionid => $subscriptionid } ); |
| 606 |
is( $serials->count, 1, "Still only one serial" ); |
700 |
is( $serials->count, 1, "Still only one serial" ); |
| 607 |
is( $serials->next->biblionumber, $biblio_2->biblionumber, 'ModSubscription should have updated serial.biblionumber'); |
701 |
is( |
|
|
702 |
$serials->next->biblionumber, $biblio_2->biblionumber, |
| 703 |
'ModSubscription should have updated serial.biblionumber' |
| 704 |
); |
| 608 |
}; |
705 |
}; |
| 609 |
|
706 |
|
| 610 |
subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { |
707 |
subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { |
|
Lines 645-663
subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub {
Link Here
|
| 645 |
|
742 |
|
| 646 |
subtest "_numeration" => sub { |
743 |
subtest "_numeration" => sub { |
| 647 |
|
744 |
|
| 648 |
plan tests => 6; |
745 |
plan tests => 8; |
| 649 |
|
746 |
|
| 650 |
my $s = C4::Serials::_numeration(0, 'monthname', 'cat'); |
747 |
my $s = C4::Serials::_numeration( 0, 'monthname', 'cat' ); |
| 651 |
is( $s, "gener" ); |
748 |
is( $s, "gener" ); |
| 652 |
$s = C4::Serials::_numeration(0, 'monthname', 'es'); |
749 |
$s = C4::Serials::_numeration( 0, 'monthname', 'es' ); |
| 653 |
is( $s, "enero" ); |
750 |
is( $s, "enero" ); |
| 654 |
$s = C4::Serials::_numeration(0, 'monthname', 'fr'); |
751 |
$s = C4::Serials::_numeration( 0, 'monthname', 'fr' ); |
| 655 |
is( $s, "janvier" ); |
752 |
is( $s, "janvier" ); |
| 656 |
|
753 |
|
| 657 |
$s = C4::Serials::_numeration(0, 'monthabrv', 'cat'); |
754 |
$s = C4::Serials::_numeration( 0, 'monthabrv', 'cat' ); |
| 658 |
is( $s, "de gen." ); |
755 |
is( $s, "de gen." ); |
| 659 |
$s = C4::Serials::_numeration(0, 'monthabrv', 'es'); |
756 |
$s = C4::Serials::_numeration( 0, 'monthabrv', 'es' ); |
| 660 |
like( $s, qr{^ene\.?} ); |
757 |
like( $s, qr{^ene\.?} ); |
| 661 |
$s = C4::Serials::_numeration(0, 'monthabrv', 'fr'); |
758 |
$s = C4::Serials::_numeration( 0, 'monthabrv', 'fr' ); |
| 662 |
is( $s, "janv." ); |
759 |
is( $s, "janv." ); |
|
|
760 |
|
| 761 |
my $translations = { |
| 762 |
seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ], |
| 763 |
seasonsabrv => [ 'Spr', 'Sum', 'Fal', 'Win' ], |
| 764 |
}; |
| 765 |
|
| 766 |
$s = C4::Serials::_numeration( 0, 'season', 'en', $translations ); |
| 767 |
is( $s, "Spring" ); |
| 768 |
$s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations ); |
| 769 |
is( $s, "Spr" ); |
| 770 |
}; |
| 771 |
|
| 772 |
subtest "GetSeasonsTranslations" => sub { |
| 773 |
|
| 774 |
plan tests => 8; |
| 775 |
|
| 776 |
my @seasons = qw( Printemps Été Automne Hiver ); |
| 777 |
my @seasonsabrv = qw( Pri Été Aut Hiv ); |
| 778 |
|
| 779 |
my $dir = C4::Context->config('intranetdir') . '/misc/translator/po/'; |
| 780 |
my $fh = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' ); |
| 781 |
my $filename = $fh->filename; |
| 782 |
|
| 783 |
my $txt = ' |
| 784 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 |
| 785 |
#, c-format |
| 786 |
msgid "Spring" |
| 787 |
msgstr "Printemps" |
| 788 |
|
| 789 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 |
| 790 |
#, c-format |
| 791 |
msgid "Summer" |
| 792 |
msgstr "Été" |
| 793 |
|
| 794 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 |
| 795 |
#, c-format |
| 796 |
msgid "Fall" |
| 797 |
msgstr "Automne" |
| 798 |
|
| 799 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 |
| 800 |
#, c-format |
| 801 |
msgid "Winter" |
| 802 |
msgstr "Hiver" |
| 803 |
|
| 804 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208 |
| 805 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210 |
| 806 |
#, c-format |
| 807 |
msgid "Sum" |
| 808 |
msgstr "Total" |
| 809 |
|
| 810 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248 |
| 811 |
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43 |
| 812 |
#, c-format |
| 813 |
msgid "" |
| 814 |
"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s " |
| 815 |
"%s %sFal%s %s %sWin%s %s %s %s " |
| 816 |
msgstr "" |
| 817 |
"%s %sPrintemps%s %s %sÉté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÉté" |
| 818 |
"%s %s %sAut%s %s %sHiv%s %s %s %s " |
| 819 |
'; |
| 820 |
|
| 821 |
print $fh encode( 'utf-8', $txt ); |
| 822 |
close($fh); |
| 823 |
|
| 824 |
my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr ); |
| 825 |
|
| 826 |
for my $idx ( 0 .. $#{ $translations->{seasons} } ) { |
| 827 |
is( $translations->{seasons}->[$idx], $seasons[$idx] ); |
| 828 |
is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] ); |
| 829 |
} |
| 663 |
}; |
830 |
}; |