Lines 19-25
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
21 |
|
21 |
|
22 |
use Test::More tests => 70; |
22 |
use Test::More tests => 71; |
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
use Koha::DateUtils qw(dt_from_string output_pref); |
25 |
use Koha::DateUtils qw(dt_from_string output_pref); |
Lines 28-34
use Koha::Acquisition::Basket;
Link Here
|
28 |
use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' ); |
28 |
use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' ); |
29 |
|
29 |
|
30 |
BEGIN { |
30 |
BEGIN { |
31 |
use_ok('C4::Acquisition', qw( NewBasket GetBasket AddInvoice GetInvoice ModReceiveOrder SearchOrders GetOrder GetHistory ModOrder get_rounding_sql get_rounded_price ReopenBasket ModBasket ModBasketHeader ModBasketUsers )); |
31 |
use_ok('C4::Acquisition', qw( NewBasket GetBasket AddInvoice GetInvoice GetInvoices ModReceiveOrder SearchOrders GetOrder GetHistory ModOrder get_rounding_sql get_rounded_price ReopenBasket ModBasket ModBasketHeader ModBasketUsers )); |
32 |
use_ok('C4::Biblio', qw( AddBiblio GetMarcSubfieldStructure )); |
32 |
use_ok('C4::Biblio', qw( AddBiblio GetMarcSubfieldStructure )); |
33 |
use_ok('C4::Budgets', qw( AddBudgetPeriod AddBudget GetBudget GetBudgetByOrderNumber GetBudgetsReport GetBudgets GetBudgetReport )); |
33 |
use_ok('C4::Budgets', qw( AddBudgetPeriod AddBudget GetBudget GetBudgetByOrderNumber GetBudgetsReport GetBudgets GetBudgetReport )); |
34 |
use_ok('Koha::Acquisition::Orders'); |
34 |
use_ok('Koha::Acquisition::Orders'); |
Lines 983-985
subtest 'Acquisition logging' => sub {
Link Here
|
983 |
}; |
983 |
}; |
984 |
|
984 |
|
985 |
$schema->storage->txn_rollback(); |
985 |
$schema->storage->txn_rollback(); |
986 |
- |
986 |
|
|
|
987 |
subtest 'GetInvoices() tests with additional fields' => sub { |
988 |
|
989 |
plan tests => 7; |
990 |
|
991 |
$schema->storage->txn_begin; |
992 |
|
993 |
my $builder = t::lib::TestBuilder->new; |
994 |
|
995 |
my $invoice_1 = $builder->build_object( |
996 |
{ |
997 |
class => 'Koha::Acquisition::Invoices', |
998 |
value => { |
999 |
invoicenumber => 'whataretheodds1' |
1000 |
} |
1001 |
} |
1002 |
); |
1003 |
my $invoice_2 = $builder->build_object( |
1004 |
{ |
1005 |
class => 'Koha::Acquisition::Invoices', |
1006 |
value => { |
1007 |
invoicenumber => 'whataretheodds2' |
1008 |
} |
1009 |
} |
1010 |
); |
1011 |
|
1012 |
|
1013 |
my $invoices = [ GetInvoices( invoicenumber => 'whataretheodds' ) ]; |
1014 |
is( scalar @{$invoices}, 2, 'Two invoices retrieved' ); |
1015 |
is( $invoices->[0]->{invoiceid}, $invoice_1->id ); |
1016 |
is( $invoices->[1]->{invoiceid}, $invoice_2->id ); |
1017 |
|
1018 |
my $additional_field_1 = $builder->build_object( |
1019 |
{ class => 'Koha::AdditionalFields', |
1020 |
value => { |
1021 |
tablename => 'aqinvoices', |
1022 |
authorised_value_category => "", |
1023 |
} |
1024 |
} |
1025 |
); |
1026 |
|
1027 |
my $additional_field_2 = $builder->build_object( |
1028 |
{ class => 'Koha::AdditionalFields', |
1029 |
value => { |
1030 |
tablename => 'aqinvoices', |
1031 |
authorised_value_category => "", |
1032 |
} |
1033 |
} |
1034 |
); |
1035 |
|
1036 |
$invoice_1->set_additional_fields([ { id => $additional_field_1->id, value => 'Ya-Hey' } ]); |
1037 |
$invoice_2->set_additional_fields([ { id => $additional_field_2->id, value => "Hey ho let's go" } ]); |
1038 |
|
1039 |
$invoices = [ GetInvoices( |
1040 |
invoicenumber => 'whataretheodds', |
1041 |
additional_fields => [{ id => $additional_field_1->id, value => 'Ya-Hey' }] |
1042 |
)]; |
1043 |
is( scalar @{$invoices}, 1, 'One invoice retrieved' ); |
1044 |
is( $invoices->[0]->{invoiceid}, $invoice_1->id, 'Ya-Hey' ); |
1045 |
|
1046 |
$invoices = [ GetInvoices( |
1047 |
invoicenumber => 'whataretheodds', |
1048 |
additional_fields => [{ id => $additional_field_2->id, value => "Hey ho let's go" }] |
1049 |
)]; |
1050 |
is( scalar @{$invoices}, 1, 'One invoice retrieved' ); |
1051 |
is( $invoices->[0]->{invoiceid}, $invoice_2->id, "Hey ho let's go" ); |
1052 |
|
1053 |
$schema->storage->txn_rollback; |
1054 |
}; |