|
Lines 1-6
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
use Modern::Perl; |
2 |
use Modern::Perl; |
| 3 |
use Test::More tests => 142; |
3 |
use Test::More tests => 143; |
| 4 |
|
4 |
|
| 5 |
BEGIN { |
5 |
BEGIN { |
| 6 |
use_ok('C4::Budgets') |
6 |
use_ok('C4::Budgets') |
|
Lines 12-17
use C4::Members qw( AddMember );
Link Here
|
| 12 |
|
12 |
|
| 13 |
use Koha::Acquisition::Order; |
13 |
use Koha::Acquisition::Order; |
| 14 |
use Koha::Acquisition::Booksellers; |
14 |
use Koha::Acquisition::Booksellers; |
|
|
15 |
use Koha::Number::Price; |
| 15 |
|
16 |
|
| 16 |
use t::lib::TestBuilder; |
17 |
use t::lib::TestBuilder; |
| 17 |
|
18 |
|
|
Lines 699-704
is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting cat
Link Here
|
| 699 |
|
700 |
|
| 700 |
# /Test GetBudgetAuthCats |
701 |
# /Test GetBudgetAuthCats |
| 701 |
|
702 |
|
|
|
703 |
subtest 'GetBudgetSpent GetBudgetOrdered tests' => sub { |
| 704 |
|
| 705 |
plan tests => 6; |
| 706 |
|
| 707 |
#Let's build an order, we need a couple things though |
| 708 |
|
| 709 |
my $spent_biblio = $builder->build({ source => 'Biblio' }); |
| 710 |
my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); |
| 711 |
my $spent_invoice = $builder->build({ source => 'Aqinvoice' }); |
| 712 |
my $spent_currency = $builder->build({ source => 'Currency', value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'FOO' } }); |
| 713 |
my $spent_vendor = $builder->build({ source => 'Aqbookseller',value => { listincgst => 0, listprice => $spent_currency->{currency}, invoiceprice => $spent_currency->{currency} } }); |
| 714 |
my $spent_orderinfo = { |
| 715 |
basketno => $spent_basket->{basketno}, |
| 716 |
booksellerid => $spent_vendor->{id}, |
| 717 |
rrp => 16.99, |
| 718 |
discount => .42, |
| 719 |
ecost => 16.91, |
| 720 |
biblionumber => $spent_biblio->{biblionumber}, |
| 721 |
currency => $spent_currency->{currency}, |
| 722 |
tax_rate_on_ordering => 0, |
| 723 |
tax_value_on_ordering => 0, |
| 724 |
tax_rate_on_receiving => 0, |
| 725 |
tax_value_on_receiving => 0, |
| 726 |
quantity => 8, |
| 727 |
quantityreceived => 0, |
| 728 |
datecancellationprinted => undef, |
| 729 |
datereceived => undef, |
| 730 |
}; |
| 731 |
|
| 732 |
#Okay we have basically what the user would enter, now we do some maths |
| 733 |
|
| 734 |
$spent_orderinfo = C4::Acquisition::populate_order_with_prices({ |
| 735 |
order => $spent_orderinfo, |
| 736 |
booksellerid => $spent_orderinfo->{booksellerid}, |
| 737 |
ordering => 1, |
| 738 |
}); |
| 739 |
|
| 740 |
#And let's place the order |
| 741 |
|
| 742 |
my $spent_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); |
| 743 |
my $spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
| 744 |
|
| 745 |
is($spent_orderinfo->{ecost_tax_excluded}, 9.854200,'We store extra precision in price calculation'); |
| 746 |
is( Koha::Number::Price->new($spent_orderinfo->{ecost_tax_excluded})->format(), 9.85,'But the price as formatted is two digits'); |
| 747 |
is($spent_ordered,9.85*8,"We expect the ordered amount to be equal to the estimated price times quantity"); |
| 748 |
|
| 749 |
#Okay, now we can receive the order, giving the price as the user would |
| 750 |
|
| 751 |
$spent_orderinfo->{unitprice} = 9.85; #we are paying what we expected |
| 752 |
|
| 753 |
#Do our maths |
| 754 |
|
| 755 |
$spent_orderinfo = C4::Acquisition::populate_order_with_prices({ |
| 756 |
order => $spent_orderinfo, |
| 757 |
booksellerid => $spent_orderinfo->{booksellerid}, |
| 758 |
receiving => 1, |
| 759 |
}); |
| 760 |
|
| 761 |
#And receive |
| 762 |
|
| 763 |
ModReceiveOrder({ |
| 764 |
biblionumber => $spent_orderinfo->{biblionumber}, |
| 765 |
order => $spent_orderinfo, |
| 766 |
invoice => $spent_invoice, |
| 767 |
quantityreceived => $spent_orderinfo->{quantity}, |
| 768 |
budget_id => $spent_orderinfo->{budget_id}, |
| 769 |
}); |
| 770 |
|
| 771 |
my $spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); |
| 772 |
is($spent_orderinfo->{unitprice_tax_excluded}, 9.854200,'We store extra precision in price calculation'); |
| 773 |
is( Koha::Number::Price->new($spent_orderinfo->{unitprice_tax_excluded})->format(), 9.85,'But the price as formatted is two digits'); |
| 774 |
is($spent_ordered,9.85*8,"We expect the ordered amount to be equal to the estimated price times quantity"); |
| 775 |
|
| 776 |
}; |
| 777 |
|
| 702 |
sub _get_dependencies { |
778 |
sub _get_dependencies { |
| 703 |
my ($budget_hierarchy) = @_; |
779 |
my ($budget_hierarchy) = @_; |
| 704 |
my $graph; |
780 |
my $graph; |
| 705 |
- |
|
|