|
Lines 17-25
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 4; |
20 |
use Test::More tests => 5; |
| 21 |
|
21 |
|
| 22 |
use Koha::MarcOrder; |
22 |
use Koha::MarcOrder; |
|
|
23 |
use Koha::MarcOrderAccount; |
| 23 |
use Koha::Acquisition::Baskets; |
24 |
use Koha::Acquisition::Baskets; |
| 24 |
use Koha::Acquisition::Bookseller; |
25 |
use Koha::Acquisition::Bookseller; |
| 25 |
use MARC::Record; |
26 |
use MARC::Record; |
|
Lines 29-34
use Koha::Database;
Link Here
|
| 29 |
use t::lib::Mocks; |
30 |
use t::lib::Mocks; |
| 30 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 31 |
|
32 |
|
|
|
33 |
use File::Temp qw|tempfile|; |
| 34 |
use MARC::Field; |
| 35 |
use MARC::File::XML; |
| 36 |
|
| 32 |
my $schema = Koha::Database->new->schema; |
37 |
my $schema = Koha::Database->new->schema; |
| 33 |
my $builder = t::lib::TestBuilder->new; |
38 |
my $builder = t::lib::TestBuilder->new; |
| 34 |
|
39 |
|
|
Lines 320-368
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 320 |
my $client_item_fields = { |
325 |
my $client_item_fields = { |
| 321 |
'notforloans' => [ |
326 |
'notforloans' => [ |
| 322 |
'', |
327 |
'', |
| 323 |
'' |
|
|
| 324 |
], |
328 |
], |
| 325 |
'c_budget_id' => 2, |
329 |
'c_budget_id' => 2, |
| 326 |
'replacementprices' => [ |
330 |
'replacementprices' => [ |
| 327 |
'0.00', |
331 |
'0.00', |
| 328 |
'0.00' |
|
|
| 329 |
], |
332 |
], |
| 330 |
'uris' => [ |
333 |
'uris' => [ |
| 331 |
'', |
334 |
'', |
| 332 |
'' |
|
|
| 333 |
], |
335 |
], |
| 334 |
'c_replacement_price' => '0.00', |
336 |
'c_replacement_price' => '0.00', |
| 335 |
'public_notes' => [ |
337 |
'public_notes' => [''], |
| 336 |
'', |
338 |
'itemcallnumbers' => [ |
| 337 |
'' |
|
|
| 338 |
], |
| 339 |
'itemcallnumbers' => [ |
| 340 |
'', |
339 |
'', |
| 341 |
'' |
|
|
| 342 |
], |
340 |
], |
| 343 |
'budget_codes' => [ |
341 |
'budget_codes' => [ |
| 344 |
'', |
342 |
'', |
| 345 |
'' |
|
|
| 346 |
], |
343 |
], |
| 347 |
'nonpublic_notes' => [ |
344 |
'nonpublic_notes' => [ |
| 348 |
'', |
345 |
'', |
| 349 |
'' |
|
|
| 350 |
], |
346 |
], |
| 351 |
'homebranches' => [ |
347 |
'homebranches' => [ |
| 352 |
'CPL', |
348 |
'CPL', |
| 353 |
'CPL' |
|
|
| 354 |
], |
349 |
], |
| 355 |
'copynos' => [ |
350 |
'copynos' => [ |
| 356 |
'', |
351 |
'', |
| 357 |
'' |
|
|
| 358 |
], |
352 |
], |
| 359 |
'holdingbranches' => [ |
353 |
'holdingbranches' => [ |
| 360 |
'CPL', |
354 |
'CPL', |
| 361 |
'CPL' |
|
|
| 362 |
], |
355 |
], |
| 363 |
'ccodes' => [ |
356 |
'ccodes' => [ |
| 364 |
'', |
357 |
'', |
| 365 |
'' |
|
|
| 366 |
], |
358 |
], |
| 367 |
'locs' => [ |
359 |
'locs' => [ |
| 368 |
'', |
360 |
'', |
|
Lines 370-376
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 370 |
], |
362 |
], |
| 371 |
'itemprices' => [ |
363 |
'itemprices' => [ |
| 372 |
'10.00', |
364 |
'10.00', |
| 373 |
'10.00' |
|
|
| 374 |
], |
365 |
], |
| 375 |
'c_discount' => '', |
366 |
'c_discount' => '', |
| 376 |
'c_price' => '0.00', |
367 |
'c_price' => '0.00', |
|
Lines 379-385
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 379 |
'c_quantity' => '1', |
370 |
'c_quantity' => '1', |
| 380 |
'itypes' => [ |
371 |
'itypes' => [ |
| 381 |
'BK', |
372 |
'BK', |
| 382 |
'BK' |
|
|
| 383 |
], |
373 |
], |
| 384 |
'coded_location_qualifiers' => [], |
374 |
'coded_location_qualifiers' => [], |
| 385 |
'barcodes' => [], |
375 |
'barcodes' => [], |
|
Lines 408-414
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 408 |
"Listprice has been created successfully" |
398 |
"Listprice has been created successfully" |
| 409 |
); |
399 |
); |
| 410 |
is( |
400 |
is( |
| 411 |
@{$orders}[0]->{quantity}, 2, |
401 |
@{$orders}[0]->{quantity}, 1, |
| 412 |
"Quantity has been read correctly" |
402 |
"Quantity has been read correctly" |
| 413 |
); |
403 |
); |
| 414 |
is( |
404 |
is( |
|
Lines 430-432
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 430 |
$schema->storage->txn_rollback; |
420 |
$schema->storage->txn_rollback; |
| 431 |
}; |
421 |
}; |
| 432 |
|
422 |
|
| 433 |
- |
423 |
subtest 'match_file_to_account' => sub { |
|
|
424 |
plan tests => 2; |
| 425 |
|
| 426 |
$schema->storage->txn_begin; |
| 427 |
|
| 428 |
my ( $fh, $name ) = tempfile( SUFFIX => '.marcxml' ); |
| 429 |
|
| 430 |
my $rec = MARC::Record->new; |
| 431 |
my $fld = MARC::Field->new( '975', '', '', 'p', '12345' ); |
| 432 |
$rec->append_fields($fld); |
| 433 |
my $str = $rec->as_xml; |
| 434 |
|
| 435 |
print $fh $str; |
| 436 |
|
| 437 |
close $fh; |
| 438 |
|
| 439 |
my $account1 = Koha::MarcOrderAccount->new( |
| 440 |
{ |
| 441 |
match_field => '975$p', |
| 442 |
match_value => '12345', |
| 443 |
encoding => 'UTF-8', |
| 444 |
description => 'test', |
| 445 |
} |
| 446 |
)->store; |
| 447 |
|
| 448 |
my $file_match = Koha::MarcOrder->match_file_to_account( |
| 449 |
{ |
| 450 |
filename => $name, |
| 451 |
filepath => $name, |
| 452 |
profile => $account1, |
| 453 |
} |
| 454 |
); |
| 455 |
|
| 456 |
is( $file_match, 1, 'File matched correctly to the account' ); |
| 457 |
|
| 458 |
my $account2 = Koha::MarcOrderAccount->new( |
| 459 |
{ |
| 460 |
match_field => '975$p', |
| 461 |
match_value => 'abcde', |
| 462 |
encoding => 'UTF-8', |
| 463 |
description => 'test', |
| 464 |
} |
| 465 |
)->store; |
| 466 |
|
| 467 |
my $file_match2 = Koha::MarcOrder->match_file_to_account( |
| 468 |
{ |
| 469 |
filename => $name, |
| 470 |
filepath => $name, |
| 471 |
profile => $account2, |
| 472 |
} |
| 473 |
); |
| 474 |
|
| 475 |
is( $file_match2, 0, 'File not matched to the account' ); |
| 476 |
|
| 477 |
$schema->storage->txn_rollback; |
| 478 |
}; |