|
Lines 17-26
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 6; |
20 |
use Test::More tests => 10; |
| 21 |
|
21 |
|
| 22 |
use Koha::MarcOrder; |
22 |
use Koha::Acquisition::MarcOrder; |
| 23 |
use Koha::MarcOrderAccount; |
23 |
use Koha::Acquisition::MarcOrderAccount; |
| 24 |
use Koha::Acquisition::Baskets; |
24 |
use Koha::Acquisition::Baskets; |
| 25 |
use Koha::Acquisition::Bookseller; |
25 |
use Koha::Acquisition::Bookseller; |
| 26 |
use MARC::Record; |
26 |
use MARC::Record; |
|
Lines 71-77
replacementprice: 975$v'
Link Here
|
| 71 |
); |
71 |
); |
| 72 |
|
72 |
|
| 73 |
my $marc_item_fields_to_order = @{ |
73 |
my $marc_item_fields_to_order = @{ |
| 74 |
Koha::MarcOrder::_get_syspref_mappings( |
74 |
Koha::Acquisition::MarcOrder::_get_syspref_mappings( |
| 75 |
$record, 'MarcItemFieldsToOrder', |
75 |
$record, 'MarcItemFieldsToOrder', |
| 76 |
) |
76 |
) |
| 77 |
}[0]; |
77 |
}[0]; |
|
Lines 154-160
budget_code: 975$h'
Link Here
|
| 154 |
[ '975', ' ', ' ', p => 10, q => 1, h => 1 ], |
154 |
[ '975', ' ', ' ', p => 10, q => 1, h => 1 ], |
| 155 |
); |
155 |
); |
| 156 |
|
156 |
|
| 157 |
my $marc_fields_to_order = Koha::MarcOrder::_get_syspref_mappings( |
157 |
my $marc_fields_to_order = Koha::Acquisition::MarcOrder::_get_syspref_mappings( |
| 158 |
$record, 'MarcFieldsToOrder', |
158 |
$record, 'MarcFieldsToOrder', |
| 159 |
); |
159 |
); |
| 160 |
|
160 |
|
|
Lines 206-212
subtest 'add_biblio_from_import_record()' => sub {
Link Here
|
| 206 |
my $import_record_id = C4::ImportBatch::AddBiblioToBatch( $import_batch_id, 0, $record, 'utf8', 0 ); |
206 |
my $import_record_id = C4::ImportBatch::AddBiblioToBatch( $import_batch_id, 0, $record, 'utf8', 0 ); |
| 207 |
my $import_record = Koha::Import::Records->find($import_record_id); |
207 |
my $import_record = Koha::Import::Records->find($import_record_id); |
| 208 |
|
208 |
|
| 209 |
my $result = Koha::MarcOrder::add_biblio_from_import_record( |
209 |
my $result = Koha::Acquisition::MarcOrder::add_biblio_from_import_record( |
| 210 |
{ |
210 |
{ |
| 211 |
import_record => $import_record, |
211 |
import_record => $import_record, |
| 212 |
matcher_id => $sample_import_batch->{matcher_id}, |
212 |
matcher_id => $sample_import_batch->{matcher_id}, |
|
Lines 240-246
subtest 'add_biblio_from_import_record()' => sub {
Link Here
|
| 240 |
chosen => 1, |
240 |
chosen => 1, |
| 241 |
} |
241 |
} |
| 242 |
)->store; |
242 |
)->store; |
| 243 |
my $match_result = Koha::MarcOrder::add_biblio_from_import_record( |
243 |
my $match_result = Koha::Acquisition::MarcOrder::add_biblio_from_import_record( |
| 244 |
{ |
244 |
{ |
| 245 |
import_record => $match_import_record, |
245 |
import_record => $match_import_record, |
| 246 |
matcher_id => $sample_import_batch->{matcher_id}, |
246 |
matcher_id => $sample_import_batch->{matcher_id}, |
|
Lines 257-263
subtest 'add_biblio_from_import_record()' => sub {
Link Here
|
| 257 |
# Check that records are skipped if not selected when called from addorderiso2709.pl |
257 |
# Check that records are skipped if not selected when called from addorderiso2709.pl |
| 258 |
# Pass in an empty array and the record should be skipped |
258 |
# Pass in an empty array and the record should be skipped |
| 259 |
my @import_record_id_selected = (); |
259 |
my @import_record_id_selected = (); |
| 260 |
my $result2 = Koha::MarcOrder::add_biblio_from_import_record( |
260 |
my $result2 = Koha::Acquisition::MarcOrder::add_biblio_from_import_record( |
| 261 |
{ |
261 |
{ |
| 262 |
import_record => $import_record, |
262 |
import_record => $import_record, |
| 263 |
matcher_id => $sample_import_batch->{matcher_id}, |
263 |
matcher_id => $sample_import_batch->{matcher_id}, |
|
Lines 286-293
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 286 |
my $bpid = C4::Budgets::AddBudgetPeriod( |
286 |
my $bpid = C4::Budgets::AddBudgetPeriod( |
| 287 |
{ |
287 |
{ |
| 288 |
budget_period_startdate => '2008-01-01', budget_period_enddate => '2008-12-31' |
288 |
budget_period_startdate => '2008-01-01', budget_period_enddate => '2008-12-31' |
| 289 |
, budget_period_active => 1 |
289 |
, budget_period_active => 1 |
| 290 |
, budget_period_description => "MAPERI" |
290 |
|
|
|
291 |
# , budget_period_description => "MAPERI" |
| 291 |
} |
292 |
} |
| 292 |
); |
293 |
); |
| 293 |
my $budgetid = C4::Budgets::AddBudget( |
294 |
my $budgetid = C4::Budgets::AddBudget( |
|
Lines 337-343
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 337 |
my $import_record = Koha::Import::Records->find($import_record_id); |
338 |
my $import_record = Koha::Import::Records->find($import_record_id); |
| 338 |
my @import_record_id_selected = ($import_record_id); |
339 |
my @import_record_id_selected = ($import_record_id); |
| 339 |
|
340 |
|
| 340 |
my $result = Koha::MarcOrder::add_biblio_from_import_record( |
341 |
my $result = Koha::Acquisition::MarcOrder::add_biblio_from_import_record( |
| 341 |
{ |
342 |
{ |
| 342 |
import_record => $import_record, |
343 |
import_record => $import_record, |
| 343 |
matcher_id => $sample_import_batch->{matcher_id}, |
344 |
matcher_id => $sample_import_batch->{matcher_id}, |
|
Lines 428-434
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 428 |
'barcodes' => [], |
429 |
'barcodes' => [], |
| 429 |
'enumchrons' => [] |
430 |
'enumchrons' => [] |
| 430 |
}; |
431 |
}; |
| 431 |
my $itemnumbers = Koha::MarcOrder::add_items_from_import_record( |
432 |
|
|
|
433 |
my $itemnumbers = Koha::Acquisition::MarcOrder::add_items_from_import_record( |
| 432 |
{ |
434 |
{ |
| 433 |
record_result => $result->{record_result}, |
435 |
record_result => $result->{record_result}, |
| 434 |
basket_id => $basket->basketno, |
436 |
basket_id => $basket->basketno, |
|
Lines 543-549
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
Link Here
|
| 543 |
'barcodes' => [], |
545 |
'barcodes' => [], |
| 544 |
'enumchrons' => [] |
546 |
'enumchrons' => [] |
| 545 |
}; |
547 |
}; |
| 546 |
my $itemnumbers = Koha::MarcOrder::add_items_from_import_record( |
548 |
my $itemnumbers = Koha::Acquisition::MarcOrder::add_items_from_import_record( |
| 547 |
{ |
549 |
{ |
| 548 |
record_result => $result->{record_result}, |
550 |
record_result => $result->{record_result}, |
| 549 |
basket_id => $basket->basketno, |
551 |
basket_id => $basket->basketno, |
|
Lines 620-626
subtest 'match_file_to_account' => sub {
Link Here
|
| 620 |
|
622 |
|
| 621 |
close $fh; |
623 |
close $fh; |
| 622 |
|
624 |
|
| 623 |
my $account1 = Koha::MarcOrderAccount->new( |
625 |
my $account1 = Koha::Acquisition::MarcOrderAccount->new( |
| 624 |
{ |
626 |
{ |
| 625 |
match_field => '975$p', |
627 |
match_field => '975$p', |
| 626 |
match_value => '12345', |
628 |
match_value => '12345', |
|
Lines 629-635
subtest 'match_file_to_account' => sub {
Link Here
|
| 629 |
} |
631 |
} |
| 630 |
)->store; |
632 |
)->store; |
| 631 |
|
633 |
|
| 632 |
my $file_match = Koha::MarcOrder->match_file_to_account( |
634 |
my $file_match = Koha::Acquisition::MarcOrder->match_file_to_account( |
| 633 |
{ |
635 |
{ |
| 634 |
filename => $name, |
636 |
filename => $name, |
| 635 |
filepath => $name, |
637 |
filepath => $name, |
|
Lines 639-645
subtest 'match_file_to_account' => sub {
Link Here
|
| 639 |
|
641 |
|
| 640 |
is( $file_match, 1, 'File matched correctly to the account' ); |
642 |
is( $file_match, 1, 'File matched correctly to the account' ); |
| 641 |
|
643 |
|
| 642 |
my $account2 = Koha::MarcOrderAccount->new( |
644 |
my $account2 = Koha::Acquisition::MarcOrderAccount->new( |
| 643 |
{ |
645 |
{ |
| 644 |
match_field => '975$p', |
646 |
match_field => '975$p', |
| 645 |
match_value => 'abcde', |
647 |
match_value => 'abcde', |
|
Lines 648-654
subtest 'match_file_to_account' => sub {
Link Here
|
| 648 |
} |
650 |
} |
| 649 |
)->store; |
651 |
)->store; |
| 650 |
|
652 |
|
| 651 |
my $file_match2 = Koha::MarcOrder->match_file_to_account( |
653 |
my $file_match2 = Koha::Acquisition::MarcOrder->match_file_to_account( |
| 652 |
{ |
654 |
{ |
| 653 |
filename => $name, |
655 |
filename => $name, |
| 654 |
filepath => $name, |
656 |
filepath => $name, |
|
Lines 677-683
subtest '_check_file_for_basket_name' => sub {
Link Here
|
| 677 |
|
679 |
|
| 678 |
close $fh; |
680 |
close $fh; |
| 679 |
|
681 |
|
| 680 |
my $account1 = Koha::MarcOrderAccount->new( |
682 |
my $account1 = Koha::Acquisition::MarcOrderAccount->new( |
| 681 |
{ |
683 |
{ |
| 682 |
basket_name_field => '975$p', |
684 |
basket_name_field => '975$p', |
| 683 |
encoding => 'UTF-8', |
685 |
encoding => 'UTF-8', |
|
Lines 685-691
subtest '_check_file_for_basket_name' => sub {
Link Here
|
| 685 |
} |
687 |
} |
| 686 |
)->store; |
688 |
)->store; |
| 687 |
|
689 |
|
| 688 |
my $basket_name = Koha::MarcOrder::_check_file_for_basket_name( |
690 |
my $basket_name = Koha::Acquisition::MarcOrder::_check_file_for_basket_name( |
| 689 |
{ |
691 |
{ |
| 690 |
filename => $name, |
692 |
filename => $name, |
| 691 |
filepath => $name, |
693 |
filepath => $name, |
|
Lines 695-701
subtest '_check_file_for_basket_name' => sub {
Link Here
|
| 695 |
|
697 |
|
| 696 |
is( $basket_name, "This is a basket", 'Basket name identified correctly' ); |
698 |
is( $basket_name, "This is a basket", 'Basket name identified correctly' ); |
| 697 |
|
699 |
|
| 698 |
my $account2 = Koha::MarcOrderAccount->new( |
700 |
my $account2 = Koha::Acquisition::MarcOrderAccount->new( |
| 699 |
{ |
701 |
{ |
| 700 |
basket_name_field => '975$z', |
702 |
basket_name_field => '975$z', |
| 701 |
encoding => 'UTF-8', |
703 |
encoding => 'UTF-8', |
|
Lines 703-709
subtest '_check_file_for_basket_name' => sub {
Link Here
|
| 703 |
} |
705 |
} |
| 704 |
)->store; |
706 |
)->store; |
| 705 |
|
707 |
|
| 706 |
my $basket_name2 = Koha::MarcOrder::_check_file_for_basket_name( |
708 |
my $basket_name2 = Koha::Acquisition::MarcOrder::_check_file_for_basket_name( |
| 707 |
{ |
709 |
{ |
| 708 |
filename => $name, |
710 |
filename => $name, |
| 709 |
filepath => $name, |
711 |
filepath => $name, |
|
Lines 715-717
subtest '_check_file_for_basket_name' => sub {
Link Here
|
| 715 |
|
717 |
|
| 716 |
$schema->storage->txn_rollback; |
718 |
$schema->storage->txn_rollback; |
| 717 |
}; |
719 |
}; |
| 718 |
- |
720 |
|
|
|
721 |
subtest '_create_basket_for_file' => sub { |
| 722 |
plan tests => 2; |
| 723 |
|
| 724 |
$schema->storage->txn_begin; |
| 725 |
|
| 726 |
my $bookseller = Koha::Acquisition::Bookseller->new( |
| 727 |
{ |
| 728 |
name => "my vendor", |
| 729 |
address1 => "bookseller's address", |
| 730 |
phone => "0123456", |
| 731 |
active => 1, |
| 732 |
deliverytime => 5, |
| 733 |
} |
| 734 |
)->store; |
| 735 |
|
| 736 |
my $basket_count = Koha::Acquisition::Baskets->count; |
| 737 |
|
| 738 |
my $account1 = Koha::Acquisition::MarcOrderAccount->new( |
| 739 |
{ |
| 740 |
match_field => '975$p', |
| 741 |
match_value => '12345', |
| 742 |
encoding => 'UTF-8', |
| 743 |
description => 'test', |
| 744 |
basket_name_field => undef |
| 745 |
} |
| 746 |
)->store; |
| 747 |
|
| 748 |
my $basketno = Koha::Acquisition::MarcOrder::_create_basket_for_file( |
| 749 |
{ |
| 750 |
filename => 'test_marc_file.marcxml', |
| 751 |
vendor_id => $bookseller->id, |
| 752 |
profile => $account1 |
| 753 |
} |
| 754 |
); |
| 755 |
|
| 756 |
my $new_basket_count = Koha::Acquisition::Baskets->count; |
| 757 |
|
| 758 |
is( $new_basket_count, $basket_count + 1, 'Basket was successfully created' ); |
| 759 |
|
| 760 |
my $basket = Koha::Acquisition::Baskets->find($basketno); |
| 761 |
|
| 762 |
is( $basket->basketname, 'test_marc_file.marcxml', 'Basket was successfully created' ); |
| 763 |
|
| 764 |
$schema->storage->txn_rollback; |
| 765 |
}; |
| 766 |
|
| 767 |
subtest 'parse_input_into_order_line_fields' => sub { |
| 768 |
plan tests => 8; |
| 769 |
|
| 770 |
$schema->storage->txn_begin; |
| 771 |
|
| 772 |
my $bpid = C4::Budgets::AddBudgetPeriod( |
| 773 |
{ |
| 774 |
budget_period_startdate => '2008-01-01', budget_period_enddate => '2008-12-31' |
| 775 |
, budget_period_active => 1 |
| 776 |
} |
| 777 |
); |
| 778 |
my $budgetid = C4::Budgets::AddBudget( |
| 779 |
{ |
| 780 |
budget_code => "BC_1", |
| 781 |
budget_name => "budget_name_test_1", |
| 782 |
budget_period_id => $bpid, |
| 783 |
} |
| 784 |
); |
| 785 |
my $budgetid2 = C4::Budgets::AddBudget( |
| 786 |
{ |
| 787 |
budget_code => "BC_2", |
| 788 |
budget_name => "budget_name_test_2", |
| 789 |
budget_period_id => $bpid, |
| 790 |
} |
| 791 |
); |
| 792 |
my $fund1 = C4::Budgets::GetBudget($budgetid); |
| 793 |
my $fund2 = C4::Budgets::GetBudget($budgetid2); |
| 794 |
my $budget_code_1 = $fund1->{budget_code}; |
| 795 |
my $budget_code_2 = $fund2->{budget_code}; |
| 796 |
|
| 797 |
my $order_line_fields = Koha::Acquisition::MarcOrder::parse_input_into_order_line_fields( |
| 798 |
{ |
| 799 |
agent => 'cron', |
| 800 |
biblionumber => 1, |
| 801 |
budget_id => 100, |
| 802 |
basket_id => 101, |
| 803 |
fields => { |
| 804 |
quantity => 2, |
| 805 |
c_quantity => 1, |
| 806 |
homebranches => [ 1, 2 ], |
| 807 |
holdingbranches => undef, |
| 808 |
budget_codes => [ $budget_code_1, $budget_code_2 ], |
| 809 |
} |
| 810 |
} |
| 811 |
); |
| 812 |
|
| 813 |
is( |
| 814 |
$order_line_fields->{loop_limit}, 2, |
| 815 |
"Quantity has been read correctly" |
| 816 |
); |
| 817 |
is( scalar( @{ $order_line_fields->{homebranch} } ), 2, "Home branches have been read correctly" ); |
| 818 |
is( @{ $order_line_fields->{homebranch} }[0], 1, "Home branches has been read correctly" ); |
| 819 |
is( scalar( @{ $order_line_fields->{holdingbranch} } ), 0, "Holding branches have been read correctly" ); |
| 820 |
is( scalar( @{ $order_line_fields->{budget_code} } ), 2, "Budget codes have been read correctly" ); |
| 821 |
is( @{ $order_line_fields->{budget_code} }[0], $budget_code_1, "Budget codes has been read correctly" ); |
| 822 |
|
| 823 |
# Test with no budget codes to check account budget_id assigned correctly |
| 824 |
$order_line_fields = Koha::Acquisition::MarcOrder::parse_input_into_order_line_fields( |
| 825 |
{ |
| 826 |
agent => 'cron', |
| 827 |
biblionumber => 1, |
| 828 |
budget_id => 100, |
| 829 |
basket_id => 101, |
| 830 |
fields => { |
| 831 |
quantity => 2, |
| 832 |
c_quantity => 1, |
| 833 |
homebranches => [ 1, 2 ], |
| 834 |
holdingbranches => undef, |
| 835 |
budget_codes => [], |
| 836 |
} |
| 837 |
} |
| 838 |
); |
| 839 |
|
| 840 |
is( scalar( @{ $order_line_fields->{budget_code} } ), 2, "Budget codes have been read correctly" ); |
| 841 |
is( @{ $order_line_fields->{budget_code} }[0], 100, "Budget codes has been read correctly" ); |
| 842 |
|
| 843 |
$schema->storage->txn_rollback; |
| 844 |
}; |
| 845 |
|
| 846 |
subtest 'create_items_and_generate_order_hash' => sub { |
| 847 |
plan tests => 6; |
| 848 |
|
| 849 |
$schema->storage->txn_begin; |
| 850 |
|
| 851 |
my $bpid = C4::Budgets::AddBudgetPeriod( |
| 852 |
{ |
| 853 |
budget_period_startdate => '2008-01-01', budget_period_enddate => '2008-12-31' |
| 854 |
, budget_period_active => 1 |
| 855 |
} |
| 856 |
); |
| 857 |
my $budgetid = C4::Budgets::AddBudget( |
| 858 |
{ |
| 859 |
budget_code => "BC_1", |
| 860 |
budget_name => "budget_name_test_1", |
| 861 |
budget_period_id => $bpid, |
| 862 |
} |
| 863 |
); |
| 864 |
my $budgetid2 = C4::Budgets::AddBudget( |
| 865 |
{ |
| 866 |
budget_code => "BC_2", |
| 867 |
budget_name => "budget_name_test_2", |
| 868 |
budget_period_id => $bpid, |
| 869 |
} |
| 870 |
); |
| 871 |
my $fund1 = C4::Budgets::GetBudget($budgetid); |
| 872 |
my $fund2 = C4::Budgets::GetBudget($budgetid2); |
| 873 |
my $budget_id_1 = $fund1->{budget_id}; |
| 874 |
my $budget_id_2 = $fund2->{budget_id}; |
| 875 |
|
| 876 |
my $bookseller = Koha::Acquisition::Bookseller->new( |
| 877 |
{ |
| 878 |
name => "my vendor", |
| 879 |
address1 => "bookseller's address", |
| 880 |
phone => "0123456", |
| 881 |
active => 1, |
| 882 |
deliverytime => 5, |
| 883 |
} |
| 884 |
)->store; |
| 885 |
|
| 886 |
my $basket = $builder->build_object( |
| 887 |
{ |
| 888 |
class => "Koha::Acquisition::Baskets", |
| 889 |
value => { |
| 890 |
booksellerid => $bookseller->id, |
| 891 |
create_items => 'ordering', |
| 892 |
is_standing => 0, |
| 893 |
closedate => undef |
| 894 |
} |
| 895 |
} |
| 896 |
); |
| 897 |
|
| 898 |
my $biblio = $builder->build_sample_biblio; |
| 899 |
my $library = $builder->build( { source => 'Branch' } ); |
| 900 |
my $branchcode = $library->{branchcode}; |
| 901 |
|
| 902 |
my $fields = { |
| 903 |
loop_limit => 2, |
| 904 |
budget_code => [ $budget_id_1, $budget_id_2 ], |
| 905 |
budget_id => $budget_id_1, |
| 906 |
basket_id => $basket->basketno, |
| 907 |
biblionumber => $biblio->biblionumber, |
| 908 |
homebranch => [ $branchcode, $branchcode ], |
| 909 |
price => [ 10, 8 ], |
| 910 |
}; |
| 911 |
|
| 912 |
t::lib::Mocks::mock_preference( 'AcqCreateItem', 'ordering' ); |
| 913 |
|
| 914 |
my $items_count = Koha::Items->count; |
| 915 |
my $orders_count = Koha::Acquisition::Orders->count; |
| 916 |
|
| 917 |
my $order_line_details = Koha::Acquisition::MarcOrder::create_items_and_generate_order_hash( |
| 918 |
{ |
| 919 |
agent => 'cron', |
| 920 |
fields => $fields, |
| 921 |
vendor => $bookseller, |
| 922 |
active_currency => Koha::Acquisition::Currencies->get_active, |
| 923 |
} |
| 924 |
); |
| 925 |
my $new_items_count = Koha::Items->count; |
| 926 |
my $new_orders_count = Koha::Acquisition::Orders->count; |
| 927 |
|
| 928 |
is( $new_items_count, $items_count + 2, 'Items were successfully created' ); |
| 929 |
is( $new_orders_count, $orders_count + 2, 'Orders were successfully created' ); |
| 930 |
|
| 931 |
my @items = Koha::Items->search( { biblionumber => $biblio->biblionumber } )->as_list; |
| 932 |
|
| 933 |
foreach my $item (@items) { |
| 934 |
is( $item->homebranch, $branchcode, 'Item was created in correct branch' ); |
| 935 |
} |
| 936 |
|
| 937 |
my @orderlines = sort { $a->budget_id <=> $b->budget_id } |
| 938 |
Koha::Acquisition::Orders->search( { biblionumber => $biblio->biblionumber } )->as_list; |
| 939 |
|
| 940 |
for ( my $i = 0 ; $i < ( scalar(@orderlines) ) ; $i++ ) { |
| 941 |
is( $orderlines[$i]->budget_id, @{ $fields->{budget_code} }[$i], 'Orderline was created with correct budget' ); |
| 942 |
} |
| 943 |
|
| 944 |
$schema->storage->txn_rollback; |
| 945 |
}; |
| 946 |
|
| 947 |
subtest '_create_item_fields_from_syspref' => sub { |
| 948 |
plan tests => 4; |
| 949 |
|
| 950 |
$schema->storage->txn_begin; |
| 951 |
|
| 952 |
t::lib::Mocks::mock_preference( |
| 953 |
'MarcItemFieldsToOrder', 'homebranch: 975$a |
| 954 |
holdingbranch: 975$b |
| 955 |
itype: 975$y |
| 956 |
nonpublic_note: 975$x |
| 957 |
public_note: 975$z |
| 958 |
loc: 975$c |
| 959 |
ccode: 975$8 |
| 960 |
notforloan: 975$7 |
| 961 |
uri: 975$u |
| 962 |
copyno: 975$n |
| 963 |
quantity: 975$q |
| 964 |
budget_code: 975$h |
| 965 |
price: 975$p |
| 966 |
replacementprice: 975$v' |
| 967 |
); |
| 968 |
|
| 969 |
t::lib::Mocks::mock_preference( |
| 970 |
'MarcFieldsToOrder', 'price: 949$p |
| 971 |
quantity: 949$q |
| 972 |
budget_code: 949$h' |
| 973 |
); |
| 974 |
|
| 975 |
my $record = MARC::Record->new(); |
| 976 |
|
| 977 |
$record->add_fields( |
| 978 |
[ '001', '1234' ], |
| 979 |
[ |
| 980 |
'975', ' ', ' ', p => 10, q => 1, h => 1, a => 'CPL', b => 'CPL', y => 'Book', |
| 981 |
x => 'Private note', z => 'Public note', c => 'Shelf', 8 => 'ccode', 7 => 0, |
| 982 |
u => '12345abcde', n => '12345', v => 10 |
| 983 |
], |
| 984 |
); |
| 985 |
$record->add_fields( |
| 986 |
[ '001', '1234' ], |
| 987 |
|
| 988 |
[ '949', ' ', ' ', p => 10, q => 1, h => 1 ], |
| 989 |
); |
| 990 |
|
| 991 |
my $marc_item_fields_to_order = Koha::Acquisition::MarcOrder::_get_syspref_mappings( |
| 992 |
$record, 'MarcItemFieldsToOrder', |
| 993 |
); |
| 994 |
|
| 995 |
my $marc_fields_to_order = Koha::Acquisition::MarcOrder::_get_syspref_mappings( |
| 996 |
$record, 'MarcFieldsToOrder', |
| 997 |
); |
| 998 |
|
| 999 |
my $item_fields = Koha::Acquisition::MarcOrder::_create_item_fields_from_syspref( |
| 1000 |
{ |
| 1001 |
marc_fields_to_order => $marc_fields_to_order, |
| 1002 |
marc_item_fields_to_order => $marc_item_fields_to_order |
| 1003 |
} |
| 1004 |
); |
| 1005 |
|
| 1006 |
is( |
| 1007 |
@{ $item_fields->{itemprices} }[0], 10, |
| 1008 |
"Price has been read correctly" |
| 1009 |
); |
| 1010 |
is( |
| 1011 |
@{ $item_fields->{itypes} }[0], "Book", |
| 1012 |
"Itypes has been read correctly" |
| 1013 |
); |
| 1014 |
is( $item_fields->{quantity}, 1, "Quantity has been read correctly" ); |
| 1015 |
is( $item_fields->{c_price}, 10, "MarcFieldsToOrder price has been read correctly" ); |
| 1016 |
|
| 1017 |
$schema->storage->txn_rollback; |
| 1018 |
|
| 1019 |
} |