|
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 => 71; |
22 |
use Test::More tests => 72; |
| 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 783-792
subtest 'ModReceiveOrder and subscription' => sub {
Link Here
|
| 783 |
is( $received_order->order_internalnote, |
783 |
is( $received_order->order_internalnote, |
| 784 |
$second_note, "No price set if none passed in" ); |
784 |
$second_note, "No price set if none passed in" ); |
| 785 |
|
785 |
|
| 786 |
$order->get_from_storage; |
|
|
| 787 |
is( $order->get_from_storage->order_internalnote, $first_note ); |
786 |
is( $order->get_from_storage->order_internalnote, $first_note ); |
| 788 |
}; |
787 |
}; |
| 789 |
|
788 |
|
|
|
789 |
subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { |
| 790 |
plan tests => 2; |
| 791 |
|
| 792 |
my $builder = t::lib::TestBuilder->new; |
| 793 |
subtest 'partial order' => sub { |
| 794 |
plan tests => 2; |
| 795 |
|
| 796 |
subtest 'no invoice_unitprice' => sub { |
| 797 |
plan tests => 4; |
| 798 |
my $order = $builder->build_object( |
| 799 |
{ |
| 800 |
class => 'Koha::Acquisition::Orders', |
| 801 |
value => { |
| 802 |
quantity => 5, |
| 803 |
quantityreceived => 0, |
| 804 |
ecost_tax_excluded => 42, |
| 805 |
unitprice_tax_excluded => 42, |
| 806 |
} |
| 807 |
} |
| 808 |
); |
| 809 |
my $order_info = { |
| 810 |
%{ $order->unblessed }, |
| 811 |
invoice_unitprice => undef, |
| 812 |
invoice_currency => undef, |
| 813 |
}; |
| 814 |
my ( undef, $received_ordernumber ) = ModReceiveOrder( |
| 815 |
{ |
| 816 |
biblionumber => $order->biblionumber, |
| 817 |
order => $order_info, |
| 818 |
quantityreceived => 1, # We receive only 1 |
| 819 |
budget_id => $order->budget_id, |
| 820 |
} |
| 821 |
); |
| 822 |
my $received_order = |
| 823 |
Koha::Acquisition::Orders->find($received_ordernumber); |
| 824 |
is( $received_order->invoice_unitprice, |
| 825 |
undef, 'no price should be stored if none passed' ); |
| 826 |
is( $received_order->invoice_currency, |
| 827 |
undef, 'no currency should be stored if none passed' ); |
| 828 |
$order = $order->get_from_storage; |
| 829 |
is( $order->invoice_unitprice, undef, |
| 830 |
'no price should be stored if none passed' ); |
| 831 |
is( $order->invoice_currency, undef, |
| 832 |
'no currency should be stored if none passed' ); |
| 833 |
}; |
| 834 |
subtest 'with invoice_unitprice' => sub { |
| 835 |
plan tests => 4; |
| 836 |
my $order = $builder->build_object( |
| 837 |
{ |
| 838 |
class => 'Koha::Acquisition::Orders', |
| 839 |
value => { |
| 840 |
quantity => 5, |
| 841 |
quantityreceived => 0, |
| 842 |
ecost_tax_excluded => 42, |
| 843 |
unitprice_tax_excluded => 42, |
| 844 |
} |
| 845 |
} |
| 846 |
); |
| 847 |
my $order_info = { |
| 848 |
%{ $order->unblessed }, |
| 849 |
invoice_unitprice => 37, |
| 850 |
invoice_currency => 'GBP', |
| 851 |
}; |
| 852 |
my ( undef, $received_ordernumber ) = ModReceiveOrder( |
| 853 |
{ |
| 854 |
biblionumber => $order->biblionumber, |
| 855 |
order => $order_info, |
| 856 |
quantityreceived => 1, |
| 857 |
budget_id => $order->budget_id, |
| 858 |
} |
| 859 |
); |
| 860 |
my $received_order = |
| 861 |
Koha::Acquisition::Orders->find($received_ordernumber); |
| 862 |
is( $received_order->invoice_unitprice + 0, |
| 863 |
37, 'price should be stored in new order' ); |
| 864 |
is( $received_order->invoice_currency, |
| 865 |
'GBP', 'currency should be stored in new order' ); |
| 866 |
$order = $order->get_from_storage; |
| 867 |
is( $order->invoice_unitprice + 0, |
| 868 |
37, 'price should be stored in existing order' ); |
| 869 |
is( $order->invoice_currency, 'GBP', |
| 870 |
'currency should be stored in existing order' ); |
| 871 |
|
| 872 |
}; |
| 873 |
}; |
| 874 |
|
| 875 |
subtest 'full received order' => sub { |
| 876 |
plan tests => 2; |
| 877 |
|
| 878 |
subtest 'no invoice_unitprice' => sub { |
| 879 |
plan tests => 4; |
| 880 |
my $builder = t::lib::TestBuilder->new; |
| 881 |
my $order = $builder->build_object( |
| 882 |
{ |
| 883 |
class => 'Koha::Acquisition::Orders', |
| 884 |
value => { |
| 885 |
quantity => 5, |
| 886 |
quantityreceived => 0, |
| 887 |
ecost_tax_excluded => 42, |
| 888 |
unitprice_tax_excluded => 42, |
| 889 |
} |
| 890 |
} |
| 891 |
); |
| 892 |
my $order_info = { |
| 893 |
%{ $order->unblessed }, |
| 894 |
invoice_unitprice => undef, |
| 895 |
invoice_currency => undef, |
| 896 |
}; |
| 897 |
my ( undef, $received_ordernumber ) = ModReceiveOrder( |
| 898 |
{ |
| 899 |
biblionumber => $order->biblionumber, |
| 900 |
order => $order_info, |
| 901 |
quantityreceived => 5, # We receive them all! |
| 902 |
budget_id => $order->budget_id, |
| 903 |
} |
| 904 |
); |
| 905 |
my $received_order = |
| 906 |
Koha::Acquisition::Orders->find($received_ordernumber); |
| 907 |
is( $received_order->invoice_unitprice, |
| 908 |
undef, 'no price should be stored if none passed' ); |
| 909 |
is( $received_order->invoice_currency, |
| 910 |
undef, 'no currency should be stored if none passed' ); |
| 911 |
$order = $order->get_from_storage; |
| 912 |
is( $order->invoice_unitprice, undef, |
| 913 |
'no price should be stored if none passed' ); |
| 914 |
is( $order->invoice_currency, undef, |
| 915 |
'no currency should be stored if none passed' ); |
| 916 |
}; |
| 917 |
|
| 918 |
subtest 'with invoice_unitprice' => sub { |
| 919 |
plan tests => 4; |
| 920 |
my $order = $builder->build_object( |
| 921 |
{ |
| 922 |
class => 'Koha::Acquisition::Orders', |
| 923 |
value => { |
| 924 |
quantity => 5, |
| 925 |
quantityreceived => 0, |
| 926 |
ecost_tax_excluded => 42, |
| 927 |
unitprice_tax_excluded => 42, |
| 928 |
} |
| 929 |
} |
| 930 |
); |
| 931 |
my $order_info = { |
| 932 |
%{ $order->unblessed }, |
| 933 |
invoice_unitprice => 37, |
| 934 |
invoice_currency => 'GBP', |
| 935 |
}; |
| 936 |
my ( undef, $received_ordernumber ) = ModReceiveOrder( |
| 937 |
{ |
| 938 |
biblionumber => $order->biblionumber, |
| 939 |
order => $order_info, |
| 940 |
quantityreceived => 1, |
| 941 |
budget_id => $order->budget_id, |
| 942 |
} |
| 943 |
); |
| 944 |
my $received_order = |
| 945 |
Koha::Acquisition::Orders->find($received_ordernumber); |
| 946 |
is( $received_order->invoice_unitprice + 0, |
| 947 |
37, 'price should be stored in new order' ); |
| 948 |
is( $received_order->invoice_currency, |
| 949 |
'GBP', 'currency should be stored in new order' ); |
| 950 |
$order = $order->get_from_storage; |
| 951 |
is( $order->invoice_unitprice + 0, |
| 952 |
37, 'price should be stored in existing order' ); |
| 953 |
is( $order->invoice_currency, 'GBP', |
| 954 |
'currency should be stored in existing order' ); |
| 955 |
|
| 956 |
}; |
| 957 |
}; |
| 958 |
|
| 959 |
}; |
| 960 |
|
| 790 |
subtest 'GetHistory with additional fields' => sub { |
961 |
subtest 'GetHistory with additional fields' => sub { |
| 791 |
plan tests => 3; |
962 |
plan tests => 3; |
| 792 |
my $builder = t::lib::TestBuilder->new; |
963 |
my $builder = t::lib::TestBuilder->new; |
| 793 |
- |
|
|