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 335-367
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
335 |
my $client_item_fields = { |
340 |
my $client_item_fields = { |
336 |
'notforloans' => [ |
341 |
'notforloans' => [ |
337 |
'', |
342 |
'', |
338 |
'' |
|
|
339 |
], |
343 |
], |
340 |
'c_budget_id' => 2, |
344 |
'c_budget_id' => 2, |
341 |
'replacementprices' => [ |
345 |
'replacementprices' => [ |
342 |
'0.00', |
346 |
'0.00', |
343 |
'0.00' |
|
|
344 |
], |
347 |
], |
345 |
'uris' => [ |
348 |
'uris' => [ |
346 |
'', |
349 |
'', |
347 |
'' |
|
|
348 |
], |
350 |
], |
349 |
'c_replacement_price' => '0.00', |
351 |
'c_replacement_price' => '0.00', |
350 |
'public_notes' => [ |
352 |
'public_notes' => [''], |
351 |
'', |
353 |
'itemcallnumbers' => [ |
352 |
'' |
|
|
353 |
], |
354 |
'itemcallnumbers' => [ |
355 |
'', |
354 |
'', |
356 |
'' |
|
|
357 |
], |
355 |
], |
358 |
'budget_codes' => [ |
356 |
'budget_codes' => [ |
359 |
'', |
357 |
'', |
360 |
'' |
|
|
361 |
], |
358 |
], |
362 |
'nonpublic_notes' => [ |
359 |
'nonpublic_notes' => [ |
363 |
'', |
360 |
'', |
364 |
'' |
|
|
365 |
], |
361 |
], |
366 |
'homebranches' => [ |
362 |
'homebranches' => [ |
367 |
$branchcode, |
363 |
$branchcode, |
Lines 369-375
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
369 |
], |
365 |
], |
370 |
'copynos' => [ |
366 |
'copynos' => [ |
371 |
'', |
367 |
'', |
372 |
'' |
|
|
373 |
], |
368 |
], |
374 |
'holdingbranches' => [ |
369 |
'holdingbranches' => [ |
375 |
$branchcode, |
370 |
$branchcode, |
Lines 377-383
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
377 |
], |
372 |
], |
378 |
'ccodes' => [ |
373 |
'ccodes' => [ |
379 |
'', |
374 |
'', |
380 |
'' |
|
|
381 |
], |
375 |
], |
382 |
'locs' => [ |
376 |
'locs' => [ |
383 |
'', |
377 |
'', |
Lines 385-391
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
385 |
], |
379 |
], |
386 |
'itemprices' => [ |
380 |
'itemprices' => [ |
387 |
'10.00', |
381 |
'10.00', |
388 |
'10.00' |
|
|
389 |
], |
382 |
], |
390 |
'c_discount' => '', |
383 |
'c_discount' => '', |
391 |
'c_price' => '0.00', |
384 |
'c_price' => '0.00', |
Lines 394-400
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
394 |
'c_quantity' => '1', |
387 |
'c_quantity' => '1', |
395 |
'itypes' => [ |
388 |
'itypes' => [ |
396 |
'BK', |
389 |
'BK', |
397 |
'BK' |
|
|
398 |
], |
390 |
], |
399 |
'coded_location_qualifiers' => [], |
391 |
'coded_location_qualifiers' => [], |
400 |
'barcodes' => [], |
392 |
'barcodes' => [], |
Lines 426-432
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
426 |
"Listprice has been created successfully" |
418 |
"Listprice has been created successfully" |
427 |
); |
419 |
); |
428 |
is( |
420 |
is( |
429 |
@{$orders}[0]->{quantity}, 2, |
421 |
@{$orders}[0]->{quantity}, 1, |
430 |
"Quantity has been read correctly" |
422 |
"Quantity has been read correctly" |
431 |
); |
423 |
); |
432 |
is( |
424 |
is( |
Lines 448-450
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
448 |
$schema->storage->txn_rollback; |
440 |
$schema->storage->txn_rollback; |
449 |
}; |
441 |
}; |
450 |
|
442 |
|
451 |
- |
443 |
subtest 'match_file_to_account' => sub { |
|
|
444 |
plan tests => 2; |
445 |
|
446 |
$schema->storage->txn_begin; |
447 |
|
448 |
my ( $fh, $name ) = tempfile( SUFFIX => '.marcxml' ); |
449 |
|
450 |
my $rec = MARC::Record->new; |
451 |
my $fld = MARC::Field->new( '975', '', '', 'p', '12345' ); |
452 |
$rec->append_fields($fld); |
453 |
my $str = $rec->as_xml; |
454 |
|
455 |
print $fh $str; |
456 |
|
457 |
close $fh; |
458 |
|
459 |
my $account1 = Koha::MarcOrderAccount->new( |
460 |
{ |
461 |
match_field => '975$p', |
462 |
match_value => '12345', |
463 |
encoding => 'UTF-8', |
464 |
description => 'test', |
465 |
} |
466 |
)->store; |
467 |
|
468 |
my $file_match = Koha::MarcOrder->match_file_to_account( |
469 |
{ |
470 |
filename => $name, |
471 |
filepath => $name, |
472 |
profile => $account1, |
473 |
} |
474 |
); |
475 |
|
476 |
is( $file_match, 1, 'File matched correctly to the account' ); |
477 |
|
478 |
my $account2 = Koha::MarcOrderAccount->new( |
479 |
{ |
480 |
match_field => '975$p', |
481 |
match_value => 'abcde', |
482 |
encoding => 'UTF-8', |
483 |
description => 'test', |
484 |
} |
485 |
)->store; |
486 |
|
487 |
my $file_match2 = Koha::MarcOrder->match_file_to_account( |
488 |
{ |
489 |
filename => $name, |
490 |
filepath => $name, |
491 |
profile => $account2, |
492 |
} |
493 |
); |
494 |
|
495 |
is( $file_match2, 0, 'File not matched to the account' ); |
496 |
|
497 |
$schema->storage->txn_rollback; |
498 |
}; |