Bugzilla – Attachment 27868 Details for
Bug 12168
Spent and ordered budget values are wrong if deep > 2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered
Bug-12168-Add-unit-tests-for-GetBudgetHierarchySpe.patch (text/plain), 7.18 KB, created by
Jonathan Druart
on 2014-05-01 12:31:06 UTC
(
hide
)
Description:
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-05-01 12:31:06 UTC
Size:
7.18 KB
patch
obsolete
>From e3524289c2c3005cdf3ff843d75a0d179d88536d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 1 May 2014 14:23:51 +0200 >Subject: [PATCH] Bug 12168: Add unit tests for GetBudgetHierarchySpent > GetBudgetHierarchyOrdered > >Test plan: >prove t/db_dependent/Budgets.t > >Note: This addition may sound overkill but I found this bug developping >bug 12164 and I will reuse all of that. >--- > t/db_dependent/Budgets.t | 195 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 192 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index bfb910b..e62ca92 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,8 +1,10 @@ >-use strict; >-use warnings; >-use Test::More tests=>20; >+use Modern::Perl; >+use Test::More tests => 23; > > BEGIN {use_ok('C4::Budgets') } >+use C4::Biblio; >+use C4::Bookseller; >+use C4::Acquisition; > use C4::Dates; > use C4::Context; > >@@ -128,3 +130,190 @@ ok($budgets->[0]->{budget_name} lt $budgets->[1]->{budget_name}, 'default sort o > ok($del_status=DelBudget($budget_id), > "DelBudget returned $del_status"); > >+ >+# GetBudgetHierarchySpent and GetBudgetHierarchyOrdered >+my $budget_period_total = 10_000; >+my $budget_1_total = 1_000; >+my $budget_11_total = 100; >+my $budget_111_total = 50; >+my $budget_12_total = 100; >+my $budget_2_total = 2_000; >+ >+my $budget_period_id = AddBudgetPeriod( >+ { >+ budget_period_startdate => '2013-01-01', >+ budget_period_enddate => '2014-12-31', >+ budget_description => 'Budget Period', >+ budget_period_active => 1, >+ budget_period_total => $budget_period_total, >+ } >+); >+my $budget_id1 = AddBudget( >+ { >+ budget_code => 'budget_1', >+ budget_name => 'budget_1', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => undef, >+ budget_amount => $budget_1_total, >+ } >+); >+my $budget_id2 = AddBudget( >+ { >+ budget_code => 'budget_2', >+ budget_name => 'budget_2', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => undef, >+ budget_amount => $budget_2_total, >+ } >+); >+my $budget_id11 = AddBudget( >+ { >+ budget_code => 'budget_11', >+ budget_name => 'budget_11', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => $budget_id1, >+ budget_amount => $budget_11_total, >+ } >+); >+my $budget_id12 = AddBudget( >+ { >+ budget_code => 'budget_12', >+ budget_name => 'budget_12', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => $budget_id1, >+ budget_amount => $budget_12_total, >+ } >+); >+my $budget_id111 = AddBudget( >+ { >+ budget_code => 'budget_111', >+ budget_name => 'budget_111', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => $budget_id11, >+ owner_id => 1, >+ budget_amount => $budget_111_total, >+ } >+); >+my $budget_id21 = AddBudget( >+ { >+ budget_code => 'budget_21', >+ budget_name => 'budget_21', >+ budget_active => 1, >+ budget_period_id => $budget_period_id, >+ budget_parent_id => $budget_id2, >+ } >+); >+ >+my $booksellerid = C4::Bookseller::AddBookseller( >+ { >+ name => "my vendor", >+ address1 => "bookseller's address", >+ phone => "0123456", >+ active => 1, >+ deliverytime => 5, >+ } >+); >+ >+my $basketno = C4::Acquisition::NewBasket( $booksellerid, 1 ); >+my ( $biblionumber, $biblioitemnumber ) = >+ C4::Biblio::AddBiblio( MARC::Record->new, '' ); >+ >+my @order_infos = ( >+ { >+ budget_id => $budget_id1, >+ pending_quantity => 1, >+ spent_quantity => 0, >+ }, >+ { >+ budget_id => $budget_id2, >+ pending_quantity => 2, >+ spent_quantity => 1, >+ }, >+ { >+ budget_id => $budget_id11, >+ pending_quantity => 3, >+ spent_quantity => 4, >+ }, >+ { >+ budget_id => $budget_id12, >+ pending_quantity => 4, >+ spent_quantity => 3, >+ }, >+ { >+ budget_id => $budget_id111, >+ pending_quantity => 2, >+ spent_quantity => 1, >+ }, >+ >+ # No order for budget_21 >+ >+); >+ >+my $number_of_orders_to_move = 0; >+my %budgets; >+my $invoiceid = AddInvoice(invoicenumber => 'invoice_test_clone', booksellerid => $booksellerid, unknown => "unknown"); >+my $item_price = 10; >+my $item_quantity = 2; >+for my $infos (@order_infos) { >+ for ( 1 .. $infos->{pending_quantity} ) { >+ my ( undef, $ordernumber ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno, >+ biblionumber => $biblionumber, >+ budget_id => $infos->{budget_id}, >+ order_internalnote => "internal note", >+ order_vendornote => "vendor note", >+ quantity => 2, >+ cost => $item_price, >+ rrp => $item_price, >+ listprice => $item_price, >+ ecost => $item_price, >+ rrp => $item_price, >+ discount => 0, >+ uncertainprice => 0, >+ gstrate => 0, >+ } >+ ); >+ push @{ $budgets{$infos->{budget_id}} }, $ordernumber; >+ $number_of_orders_to_move++; >+ } >+ for ( 1 .. $infos->{spent_quantity} ) { >+ my ( undef, $ordernumber ) = C4::Acquisition::NewOrder( >+ { >+ basketno => $basketno, >+ biblionumber => $biblionumber, >+ budget_id => $infos->{budget_id}, >+ order_internalnote => "internal note", >+ order_vendornote => "vendor note", >+ quantity => $item_quantity, >+ cost => $item_price, >+ rrp => $item_price, >+ listprice => $item_price, >+ ecost => $item_price, >+ rrp => $item_price, >+ discount => 0, >+ uncertainprice => 0, >+ gstrate => 0, >+ } >+ ); >+ ModReceiveOrder({ >+ biblionumber => $biblionumber, >+ ordernumber => $ordernumber, >+ budget_id => $infos->{budget_id}, >+ quantityreceived => $item_quantity, >+ cost => $item_price, >+ ecost => $item_price, >+ invoiceid => $invoiceid, >+ rrp => $item_price, >+ received_items => [], >+ } ); >+ } >+} >+is( GetBudgetHierarchySpent( $budget_id1 ), 160, "total spent for budget1 is 160" ); >+is( GetBudgetHierarchySpent( $budget_id11 ), 100, "total spent for budget1 is 100" ); >+is( GetBudgetHierarchySpent( $budget_id111 ), 20, "total spent for budget1 is 20" ); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12168
:
27867
|
27868
|
27877
|
28102
|
28103
|
28289
|
28290