|
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 => 144; |
| 4 |
|
4 |
|
| 5 |
BEGIN { |
5 |
BEGIN { |
| 6 |
use_ok('C4::Budgets') |
6 |
use_ok('C4::Budgets') |
|
Lines 394-399
is( GetBudgetHierarchySpent( $budget_id1 ), 160, "total spent for budget1 is 160
Link Here
|
| 394 |
is( GetBudgetHierarchySpent( $budget_id11 ), 100, "total spent for budget11 is 100" ); |
394 |
is( GetBudgetHierarchySpent( $budget_id11 ), 100, "total spent for budget11 is 100" ); |
| 395 |
is( GetBudgetHierarchySpent( $budget_id111 ), 20, "total spent for budget111 is 20" ); |
395 |
is( GetBudgetHierarchySpent( $budget_id111 ), 20, "total spent for budget111 is 20" ); |
| 396 |
|
396 |
|
|
|
397 |
# GetBudgetSpent and GetBudgetOrdered |
| 398 |
my $budget_period_amount = 100; |
| 399 |
my $budget_amount = 50; |
| 400 |
|
| 401 |
my $budget = AddBudgetPeriod( |
| 402 |
{ |
| 403 |
budget_period_startdate => '2017-08-22', |
| 404 |
budget_period_enddate => '2018-08-22', |
| 405 |
budget_period_description => 'Test budget', |
| 406 |
budget_period_active => 1, |
| 407 |
budget_period_total => $budget_period_amount, |
| 408 |
} |
| 409 |
); |
| 410 |
|
| 411 |
my $fund = AddBudget( |
| 412 |
{ |
| 413 |
budget_code => 'Test fund', |
| 414 |
budget_name => 'Test fund', |
| 415 |
budget_period_id => $budget, |
| 416 |
budget_parent_id => undef, |
| 417 |
budget_amount => $budget_amount, |
| 418 |
} |
| 419 |
); |
| 420 |
|
| 421 |
my $vendor = Koha::Acquisition::Bookseller->new( |
| 422 |
{ |
| 423 |
name => "test vendor", |
| 424 |
address1 => "test address", |
| 425 |
phone => "0123456", |
| 426 |
active => 1, |
| 427 |
deliverytime => 5, |
| 428 |
} |
| 429 |
)->store; |
| 430 |
|
| 431 |
my $vendorid = $vendor->id; |
| 432 |
|
| 433 |
my $basketnumber = C4::Acquisition::NewBasket( $vendorid, 1 ); |
| 434 |
my ( $biblio, $biblioitem ) = C4::Biblio::AddBiblio( MARC::Record->new, '' ); |
| 435 |
|
| 436 |
my @orders = ( |
| 437 |
{ |
| 438 |
budget_id => $fund, |
| 439 |
pending_quantity => 1, |
| 440 |
spent_quantity => 0, |
| 441 |
}, |
| 442 |
); |
| 443 |
|
| 444 |
my $invoiceident = AddInvoice( invoicenumber => 'invoice_test_clone', booksellerid => $vendorid, shipmentdate => '2017-08-22', shipmentcost => 6, shipmentcost_budgetid => $fund ); |
| 445 |
my $test_invoice = GetInvoice( $invoiceident ); |
| 446 |
my $individual_item_price = 10; |
| 447 |
|
| 448 |
my $order = Koha::Acquisition::Order->new( |
| 449 |
{ |
| 450 |
basketno => $basketnumber, |
| 451 |
biblionumber => $biblio, |
| 452 |
budget_id => $fund, |
| 453 |
order_internalnote => "internalnote", |
| 454 |
order_vendornote => "vendor note", |
| 455 |
quantity => 2, |
| 456 |
cost_tax_included => $individual_item_price, |
| 457 |
rrp_tax_included => $individual_item_price, |
| 458 |
listprice => $individual_item_price, |
| 459 |
ecost_tax_included => $individual_item_price, |
| 460 |
discount => 0, |
| 461 |
uncertainprice => 0, |
| 462 |
} |
| 463 |
)->insert; |
| 464 |
|
| 465 |
ModReceiveOrder({ |
| 466 |
bibionumber => $biblio, |
| 467 |
order => $order, |
| 468 |
budget_id => $fund, |
| 469 |
quantityreceived => 2, |
| 470 |
invoice => $test_invoice, |
| 471 |
received_items => [], |
| 472 |
} ); |
| 473 |
|
| 474 |
is ( GetBudgetSpent( $fund ), 6, "total shipping cost is 6"); |
| 475 |
is ( GetBudgetOrdered( $fund ), '20.000000', "total ordered price is 20"); |
| 476 |
|
| 477 |
|
| 397 |
# CloneBudgetPeriod |
478 |
# CloneBudgetPeriod |
| 398 |
my $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( |
479 |
my $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( |
| 399 |
{ |
480 |
{ |
| 400 |
- |
|
|