From 831531d3bbd0e440693595d0b4fadc704b020d68 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 22 Feb 2019 07:12:10 -0500 Subject: [PATCH] Bug 14850: Funds from inactive budgets appear in 'Funds' dropdown on acqui/invoice.pl MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Test Plan: 1) Create some inactive and active budgets 2) View an invoice in acquisitions 4) Note the shipping fund dropdown behaves like acqui/parcels.pl Signed-off-by: Séverine QUEUNE Signed-off-by: Séverine QUEUNE Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- acqui/invoice.pl | 67 +++++++++++-------- .../prog/en/modules/acqui/invoice.tt | 46 +++++++++---- 2 files changed, 73 insertions(+), 40 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index bdf9485a87..994dca8574 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -187,43 +187,56 @@ foreach my $order (@$orders) { push @foot_loop, map {$_} values %foot; -my $budgets = GetBudgets(); -my @budgets_loop; my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; -foreach my $budget (@$budgets) { - next unless CanUserUseBudget( $loggedinuser, $budget, $flags ); - my %line = %{$budget}; - if ( $shipmentcost_budgetid - and $budget->{budget_id} == $shipmentcost_budgetid ) - { - $line{selected} = 1; + +# build budget list +my $budget_loop = []; +my $budgets = GetBudgetHierarchy(); +foreach my $r ( @{$budgets} ) { + next unless ( CanUserUseBudget( $loggedinuser, $r, $flags ) ); + + if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) { + next; } - push @budgets_loop, \%line; + + my $selected = $shipmentcost_budgetid ? $r->{budget_id} eq $shipmentcost_budgetid : 0; + + push @{$budget_loop}, + { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, + selected => $selected, + }; } +@{$budget_loop} = + sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop}; +warn Data::Dumper::Dumper( $budget_loop ); + my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} }); if ( $adjustments ) { $template->param( adjustments => $adjustments ); } $template->param( - invoiceid => $details->{'invoiceid'}, - invoicenumber => $details->{'invoicenumber'}, - suppliername => $details->{'suppliername'}, - booksellerid => $details->{'booksellerid'}, - shipmentdate => $details->{'shipmentdate'}, - billingdate => $details->{'billingdate'}, - invoiceclosedate => $details->{'closedate'}, - shipmentcost => $shipmentcost, - orders_loop => \@orders_loop, - foot_loop => \@foot_loop, - total_quantity => $total_quantity, - total_tax_excluded => $total_tax_excluded, - total_tax_included => $total_tax_included, - total_tax_value => $total_tax_value, + invoiceid => $details->{'invoiceid'}, + invoicenumber => $details->{'invoicenumber'}, + suppliername => $details->{'suppliername'}, + booksellerid => $details->{'booksellerid'}, + shipmentdate => $details->{'shipmentdate'}, + billingdate => $details->{'billingdate'}, + invoiceclosedate => $details->{'closedate'}, + shipmentcost => $shipmentcost, + orders_loop => \@orders_loop, + foot_loop => \@foot_loop, + total_quantity => $total_quantity, + total_tax_excluded => $total_tax_excluded, + total_tax_included => $total_tax_included, + total_tax_value => $total_tax_value, total_tax_excluded_shipment => $total_tax_excluded + $shipmentcost, total_tax_included_shipment => $total_tax_included + $shipmentcost, - invoiceincgst => $bookseller->invoiceincgst, - currency => Koha::Acquisition::Currencies->get_active, - budgets_loop => \@budgets_loop, + invoiceincgst => $bookseller->invoiceincgst, + currency => Koha::Acquisition::Currencies->get_active, + budgets => $budget_loop, ); defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index b866fa9d16..1351676420 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -47,19 +47,25 @@
  • -
  • -
  • + +
  • + + + + + +
  • [% IF ( invoiceclosedate ) %]
  • Status: @@ -423,6 +429,20 @@ $("a.delete_adjustment").click(function(){ return ( confirm( _("Are you sure you want to delete this file ?") ) ); }); + + //keep a copy of all budgets before removing the inactives + var budgetId = $("#shipment_budget_id"); + var disabledBudgetsCopy = budgetId.html(); + $('.b_inactive').remove(); + + $('#showallfunds').click(function() { + if ($(this).is(":checked")) { + budgetId.html(disabledBudgetsCopy); //Puts back all the funds + } + else { + $('.b_inactive').remove(); + } + }); }); [% END %] -- 2.39.5