Lines 14-19
use Koha::Acquisition::Orders;
Link Here
|
14 |
use Koha::Acquisition::Funds; |
14 |
use Koha::Acquisition::Funds; |
15 |
use Koha::Patrons; |
15 |
use Koha::Patrons; |
16 |
use Koha::Number::Price; |
16 |
use Koha::Number::Price; |
|
|
17 |
use Koha::Items; |
17 |
|
18 |
|
18 |
use t::lib::TestBuilder; |
19 |
use t::lib::TestBuilder; |
19 |
use Koha::DateUtils; |
20 |
use Koha::DateUtils; |
Lines 933-943
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
933 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
934 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
934 |
}; |
935 |
}; |
935 |
|
936 |
|
936 |
subtest 'OrderPriceRounding GetBudgetSpent GetBudgetOrdered tests' => sub { |
937 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
937 |
|
938 |
|
938 |
plan tests => 8; |
939 |
plan tests => 12; |
939 |
|
940 |
|
940 |
#Let's build an order, we need a couple things though |
941 |
#Let's build an order, we need a couple things though |
|
|
942 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
941 |
|
943 |
|
942 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
944 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
943 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
945 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
Lines 984-989
subtest 'OrderPriceRounding GetBudgetSpent GetBudgetOrdered tests' => sub {
Link Here
|
984 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
986 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
985 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
987 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
986 |
|
988 |
|
|
|
989 |
#Let's test some budget planning |
990 |
#Regression tests for bug 18736 |
991 |
#We need an item to test by BRANCHES |
992 |
my $item_1 = $builder->build({ source => 'Item' }); |
993 |
my $order_item_1 = $builder->build({ source => 'AqordersItem', value => { ordernumber => $spent_order->{ordernumber}, itemnumber => $item_1->{itemnumber} } }); |
994 |
my $spent_fund = Koha::Acquisition::Funds->find( $spent_order->{budget_id} ); |
995 |
my $cell = { |
996 |
authcat => 'MONTHS', |
997 |
cell_authvalue => $spent_order->{entrydate}, #normally this is just the year/month but full won't hurt us here |
998 |
budget_id => $spent_order->{budget_id}, |
999 |
budget_period_id => $spent_fund->budget_period_id, |
1000 |
}; |
1001 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1002 |
my ( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
1003 |
is ( $actual, '9.854200', "We expect this to be an exact order cost"); #really we should expect cost*quantity but we don't |
1004 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1005 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
1006 |
is ( $actual, '9.8500', "We expect this to be a rounded order cost"); #really we should expect cost*quantity but we don't |
1007 |
$cell->{authcat} = 'BRANCHES'; |
1008 |
$cell->{authvalue} = $item_1->{homebranch}; |
1009 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
1010 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1011 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
1012 |
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 |
1013 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1014 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
1015 |
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 |
1016 |
|
1017 |
|
987 |
#Okay, now we can receive the order, giving the price as the user would |
1018 |
#Okay, now we can receive the order, giving the price as the user would |
988 |
|
1019 |
|
989 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
1020 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
990 |
- |
|
|