|
Lines 12-18
use C4::Members qw( AddMember );
Link Here
|
| 12 |
|
12 |
|
| 13 |
use Koha::Acquisition::Booksellers; |
13 |
use Koha::Acquisition::Booksellers; |
| 14 |
use Koha::Acquisition::Orders; |
14 |
use Koha::Acquisition::Orders; |
|
|
15 |
use Koha::Acquisition::Funds; |
| 15 |
use Koha::Number::Price; |
16 |
use Koha::Number::Price; |
|
|
17 |
use Koha::Items; |
| 16 |
|
18 |
|
| 17 |
use t::lib::TestBuilder; |
19 |
use t::lib::TestBuilder; |
| 18 |
|
20 |
|
|
Lines 803-813
is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting cat
Link Here
|
| 803 |
|
805 |
|
| 804 |
# /Test GetBudgetAuthCats |
806 |
# /Test GetBudgetAuthCats |
| 805 |
|
807 |
|
| 806 |
subtest 'GetBudgetSpent GetBudgetOrdered tests' => sub { |
808 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
| 807 |
|
809 |
|
| 808 |
plan tests => 8; |
810 |
plan tests => 12; |
| 809 |
|
811 |
|
| 810 |
#Let's build an order, we need a couple things though |
812 |
#Let's build an order, we need a couple things though |
|
|
813 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
| 811 |
|
814 |
|
| 812 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
815 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
| 813 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
816 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
|
Lines 854-859
subtest 'GetBudgetSpent GetBudgetOrdered tests' => sub {
Link Here
|
| 854 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
857 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
| 855 |
is($spent_ordered,'78.8000',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
858 |
is($spent_ordered,'78.8000',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
| 856 |
|
859 |
|
|
|
860 |
#Let's test some budget planning |
| 861 |
#Regression tests for bug 18736 |
| 862 |
#We need an item to test by BRANCHES |
| 863 |
my $item_1 = $builder->build({ source => 'Item' }); |
| 864 |
my $order_item_1 = $builder->build({ source => 'AqordersItem', value => { ordernumber => $spent_order->{ordernumber}, itemnumber => $item_1->{itemnumber} } }); |
| 865 |
my $spent_fund = Koha::Acquisition::Funds->find( $spent_order->{budget_id} ); |
| 866 |
my $cell = { |
| 867 |
authcat => 'MONTHS', |
| 868 |
cell_authvalue => $spent_order->{entrydate}, #normally this is just the year/month but full won't hurt us here |
| 869 |
budget_id => $spent_order->{budget_id}, |
| 870 |
budget_period_id => $spent_fund->budget_period_id, |
| 871 |
}; |
| 872 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
| 873 |
my ( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
| 874 |
is ( $actual, '9.854200', "We expect this to be an exact order cost"); #really we should expect cost*quantity but we don't |
| 875 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
| 876 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
| 877 |
is ( $actual, '9.8500', "We expect this to be a rounded order cost"); #really we should expect cost*quantity but we don't |
| 878 |
$cell->{authcat} = 'BRANCHES'; |
| 879 |
$cell->{authvalue} = $item_1->{homebranch}; |
| 880 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
| 881 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
| 882 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
| 883 |
is ( $actual, '9.854200', "We expect this to be full cost for items from the branch"); #here we rely on items having been created for each order, again quantity should be considered |
| 884 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
| 885 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
| 886 |
is ( $actual, '9.8500', "We expect this to be rounded cost for items from the branch"); #here we rely on items having been created for each order, again quantity should be considered |
| 887 |
|
| 888 |
|
| 857 |
#Okay, now we can receive the order, giving the price as the user would |
889 |
#Okay, now we can receive the order, giving the price as the user would |
| 858 |
|
890 |
|
| 859 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
891 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
| 860 |
- |
|
|