Bugzilla – Attachment 19871 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10403: add ability to change fund on receipt
Bug-10403-add-ability-to-change-fund-on-receipt.patch (text/plain), 10.78 KB, created by
Jared Camins-Esakov
on 2013-07-23 14:10:34 UTC
(
hide
)
Description:
Bug 10403: add ability to change fund on receipt
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-07-23 14:10:34 UTC
Size:
10.78 KB
patch
obsolete
>From f62c8bb124e4cfd1adcf709fd9bff330735593ab Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Sat, 8 Jun 2013 13:27:36 -0400 >Subject: [PATCH] Bug 10403: add ability to change fund on receipt > >Right now there is no way to change the budget or fund when receiving an >item, which is annoying, particularly at the end of the fiscal year when >every item not already received has to be switched to the following >year's budget. This patch adds the ability to change the budget and fund >when receiving. > >To test: >1) Apply patch. >2) Create an order for a vendor, choosing a fund to use for that order. >3) Receive the order, leaving the fund unchanged. Make sure the fund > did not change. >4) Create another order for a vendor, choosing a fund to use for that > order. >5) Receive the order, this time changing the fund. Make sure the fund > is changed. >6) Run the unit test: > > prove t/db_dependent/Acquisition.t >7) Sign off. > >(Notes: this patch depends on the Acquisitions.t unit test improvements >in bug 10274; the seemingly-unrelated change in SQLHelper quiets an >irritating warning caused by the NewOrder call in ModReceiveOrder) >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> > >http://bugs.koha-community.org/show_bug.cgi?id=6473 >--- > C4/Acquisition.pm | 5 +- > C4/SQLHelper.pm | 2 +- > acqui/finishreceive.pl | 3 +- > acqui/orderreceive.pl | 35 +++++++++- > .../prog/en/modules/acqui/orderreceive.tt | 14 +++- > t/db_dependent/Acquisition.t | 70 +++++++++++++++++++- > 6 files changed, 121 insertions(+), 8 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 68bb2fe..f3df179 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1348,6 +1348,7 @@ sub ModReceiveOrder { > $sth->finish; > > delete $order->{'ordernumber'}; >+ $order->{'budget_id'} = ( $budget_id || $order->{'budget_id'} ); > $order->{'quantity'} = $quantrec; > $order->{'quantityreceived'} = $quantrec; > $order->{'datereceived'} = $datereceived; >@@ -1366,9 +1367,9 @@ sub ModReceiveOrder { > } else { > $sth=$dbh->prepare("update aqorders > set quantityreceived=?,datereceived=?,invoiceid=?, >- unitprice=?,rrp=?,ecost=? >+ unitprice=?,rrp=?,ecost=?,budget_id=? > where biblionumber=? and ordernumber=?"); >- $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber); >+ $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$budget_id,$biblionumber,$ordernumber); > $sth->finish; > } > return ($datereceived, $new_ordernumber); >diff --git a/C4/SQLHelper.pm b/C4/SQLHelper.pm >index 21f5fa1..f1fa7b5 100644 >--- a/C4/SQLHelper.pm >+++ b/C4/SQLHelper.pm >@@ -406,7 +406,7 @@ sub _filter_hash{ > ## supposed to be a hash of simple values, hashes of arrays could be implemented > $filter_input->{$field}=format_date_in_iso($filter_input->{$field}) > if $columns->{$field}{Type}=~/date/ && >- $filter_input->{$field} !~C4::Dates->regexp("iso"); >+ ($filter_input->{$field} && $filter_input->{$field} !~C4::Dates->regexp("iso")); > my ($tmpkeys, $localvalues)=_Process_Operands($filter_input->{$field},"$tablename.$field",$searchtype,$columns); > if (@$tmpkeys){ > push @values, @$localvalues; >diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl >index f9c8532..4196b52 100755 >--- a/acqui/finishreceive.pl >+++ b/acqui/finishreceive.pl >@@ -54,6 +54,7 @@ my $cnt = 0; > my $ecost = $input->param('ecost'); > my $rrp = $input->param('rrp'); > my $note = $input->param("note"); >+my $bookfund = $input->param("bookfund"); > my $order = GetOrder($ordernumber); > > #need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME >@@ -93,7 +94,7 @@ if ($quantityrec > $origquantityrec ) { > $order->{ecost}, > $invoiceid, > $order->{rrp}, >- undef, >+ $bookfund, > $datereceived, > \@received_items, > ); >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 8fc760b..833e402 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -69,7 +69,7 @@ use C4::Auth; > use C4::Output; > use C4::Dates qw/format_date/; > use C4::Bookseller qw/ GetBookSellerFromId /; >-use C4::Budgets qw/ GetBudget /; >+use C4::Budgets qw/ GetBudget GetBudgetHierarchy CanUserUseBudget GetBudgetPeriods /; > use C4::Members; > use C4::Branch; # GetBranches > use C4::Items; >@@ -93,7 +93,7 @@ my $bookseller = GetBookSellerFromId($booksellerid); > my $results; > $results = SearchOrder($ordernumber) if $ordernumber; > >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( > { > template_name => "acqui/orderreceive.tmpl", > query => $input, >@@ -226,6 +226,37 @@ $template->param( > firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, > ); > >+my $borrower = GetMember( 'borrowernumber' => $loggedinuser ); >+my @budget_loop; >+my $periods = GetBudgetPeriods( { 'budget_period_active' => 1 } ); >+foreach my $period (@$periods) { >+ my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} ); >+ my @funds; >+ foreach my $r ( @{$budget_hierarchy} ) { >+ next unless ( CanUserUseBudget( $borrower, $r, $userflags ) ); >+ if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) { >+ next; >+ } >+ push @funds, >+ { >+ b_id => $r->{budget_id}, >+ b_txt => $r->{budget_name}, >+ b_sel => ( $r->{budget_id} == $order->{budget_id} ) ? 1 : 0, >+ }; >+ } >+ >+ @funds = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @funds; >+ >+ push @budget_loop, >+ { >+ 'id' => $period->{'budget_period_id'}, >+ 'description' => $period->{'budget_period_description'}, >+ 'funds' => \@funds >+ }; >+} >+ >+$template->{'VARS'}->{'budget_loop'} = \@budget_loop; >+ > # regardless of the content of $unitprice e.g 0 or '' or any string will return in these cases 0.00 > # and the 'IF' in the .tt will show 0.00 and not 'ecost' (see BZ 7129) > # So if $unitprice == 0 we don't create unitprice >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 0f454c0..938575e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -274,7 +274,19 @@ > <legend>Accounting details</legend> > <ol> > <li><label for="datereceived">Date received: </label><span> [% datereceived %] </span></li> >- <li><label for="bookfund">Budget: </label><span> [% bookfund %] </span></li> >+ <li><label for="bookfund">Fund: </label><select id="bookfund" name="bookfund"> >+ <option value="">Keep current ([% bookfund %])</option> >+ [% FOREACH period IN budget_loop %] >+ <optgroup label="[% period.description %]"> >+ [% FOREACH fund IN period.funds %] >+ [% IF ( fund.b_sel ) %] >+ <option value="[% fund.b_id %]" selected="selected">[% fund.b_txt %]</option> >+ [% ELSE %] >+ <option value="[% fund.b_id %]">[% fund.b_txt %]</option> >+ [% END %] >+ [% END %] >+ [% END %] >+ </select> (Current: [% bookfund %])</li> > <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li> > <li><label for="quantity_to_receive">Quantity to receive: </label><span class="label"> > [% IF ( edit and not subscriptionid) %] >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index c7b3c4a..523e400 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -8,7 +8,7 @@ use POSIX qw(strftime); > > use C4::Bookseller qw( GetBookSellerFromId ); > >-use Test::More tests => 41; >+use Test::More tests => 56; > > BEGIN { > use_ok('C4::Acquisition'); >@@ -127,4 +127,72 @@ for my $field ( @expectedfields ) { > ok( exists( $firstorder->{ $field } ), "This order has a $field field" ); > } > >+my $invoiceid = AddInvoice(invoicenumber => 'invoice', booksellerid => 1, unknown => "unknown"); >+ >+my ($datereceived, $new_ordernumber) = ModReceiveOrder( >+ $biblionumber2, >+ $ordernumber2, >+ 2, >+ undef, >+ 12, >+ 12, >+ $invoiceid, >+ 42, >+ ); >+my $order2 = GetOrder( $ordernumber2 ); >+is($order2->{'quantityreceived'}, 0, 'Splitting up order did not receive any on original order'); >+is($order2->{'quantity'}, 40, '40 items on original order'); >+is($order2->{'budget_id'}, $budgetid, 'Budget on original order is unchanged'); >+ >+$neworder = GetOrder( $new_ordernumber ); >+is($neworder->{'quantity'}, 2, '2 items on new order'); >+is($neworder->{'quantityreceived'}, 2, 'Splitting up order received items on new order'); >+is($neworder->{'budget_id'}, $budgetid, 'Budget on new order is unchanged'); >+ >+my $budgetid2 = C4::Budgets::AddBudget( >+ { >+ budget_code => "budget_code_test_modrecv", >+ budget_name => "budget_name_test_modrecv", >+ } >+); >+ >+($datereceived, $new_ordernumber) = ModReceiveOrder( >+ $biblionumber2, >+ $ordernumber3, >+ 2, >+ undef, >+ 12, >+ 12, >+ $invoiceid, >+ 42, >+ $budgetid2 >+ ); >+ >+my $order3 = GetOrder( $ordernumber3 ); >+is($order3->{'quantityreceived'}, 0, 'Splitting up order did not receive any on original order'); >+is($order3->{'quantity'}, 2, '2 items on original order'); >+is($order3->{'budget_id'}, $budgetid, 'Budget on original order is unchanged'); >+ >+$neworder = GetOrder( $new_ordernumber ); >+is($neworder->{'quantity'}, 2, '2 items on new order'); >+is($neworder->{'quantityreceived'}, 2, 'Splitting up order received items on new order'); >+is($neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed'); >+ >+($datereceived, $new_ordernumber) = ModReceiveOrder( >+ $biblionumber2, >+ $ordernumber3, >+ 2, >+ undef, >+ 12, >+ 12, >+ $invoiceid, >+ 42, >+ $budgetid2 >+ ); >+ >+$order3 = GetOrder( $ordernumber3 ); >+is($order3->{'quantityreceived'}, 2, 'Order not split up'); >+is($order3->{'quantity'}, 2, '2 items on order'); >+is($order3->{'budget_id'}, $budgetid2, 'Budget has changed'); >+ > $dbh->rollback; >-- >1.7.9.5
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 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568