Lines 12-18
use C4::Acquisition;
Link Here
|
12 |
use Koha::Acquisition::Booksellers; |
12 |
use Koha::Acquisition::Booksellers; |
13 |
use Koha::Acquisition::Orders; |
13 |
use Koha::Acquisition::Orders; |
14 |
use Koha::Patrons; |
14 |
use Koha::Patrons; |
|
|
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 916-926
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
916 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
918 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
917 |
}; |
919 |
}; |
918 |
|
920 |
|
919 |
subtest 'OrderPriceRounding GetBudgetSpent GetBudgetOrdered tests' => sub { |
921 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
920 |
|
922 |
|
921 |
plan tests => 8; |
923 |
plan tests => 12; |
922 |
|
924 |
|
923 |
#Let's build an order, we need a couple things though |
925 |
#Let's build an order, we need a couple things though |
|
|
926 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
924 |
|
927 |
|
925 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
928 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
926 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
929 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
Lines 967-972
subtest 'OrderPriceRounding GetBudgetSpent GetBudgetOrdered tests' => sub {
Link Here
|
967 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
970 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
968 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
971 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
969 |
|
972 |
|
|
|
973 |
#Let's test some budget planning |
974 |
#Regression tests for bug 18736 |
975 |
#We need an item to test by BRANCHES |
976 |
my $item_1 = $builder->build({ source => 'Item' }); |
977 |
my $order_item_1 = $builder->build({ source => 'AqordersItem', value => { ordernumber => $spent_order->{ordernumber}, itemnumber => $item_1->{itemnumber} } }); |
978 |
my $spent_fund = Koha::Acquisition::Funds->find( $spent_order->{budget_id} ); |
979 |
my $cell = { |
980 |
authcat => 'MONTHS', |
981 |
cell_authvalue => $spent_order->{entrydate}, #normally this is just the year/month but full won't hurt us here |
982 |
budget_id => $spent_order->{budget_id}, |
983 |
budget_period_id => $spent_fund->budget_period_id, |
984 |
}; |
985 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
986 |
my ( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
987 |
is ( $actual, '9.854200', "We expect this to be an exact order cost"); #really we should expect cost*quantity but we don't |
988 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
989 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
990 |
is ( $actual, '9.8500', "We expect this to be a rounded order cost"); #really we should expect cost*quantity but we don't |
991 |
$cell->{authcat} = 'BRANCHES'; |
992 |
$cell->{authvalue} = $item_1->{homebranch}; |
993 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
994 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
995 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
996 |
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 |
997 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
998 |
( $actual ) = GetBudgetsPlanCell( $cell, undef, undef); #we are only testing the actual for now |
999 |
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 |
1000 |
|
1001 |
|
970 |
#Okay, now we can receive the order, giving the price as the user would |
1002 |
#Okay, now we can receive the order, giving the price as the user would |
971 |
|
1003 |
|
972 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
1004 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
973 |
- |
|
|