From 339096d05f1564ab19fa38db2026186b96a9b020 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Nov 2024 09:23:03 +0100 Subject: [PATCH] Bug 38343: Do not show closed invoices by default when receiving Filter out closed invoices by default when receiving. Test plan: 1.) go to acquisition module and search for a vendor 2.) click on button 'receive shipment' 3.) enter an invoice number and click 'next' 4.) click on button 'finish receiving' 5.) activate the checkbox 'close' 6.) click on button 'save' 7.) Check that your Invoice has been modified. The status is now "Closed on ..." and the checkbox is now 'Reopen' 8.) Click on the link to the vendor to go the vendors page 9.) click on button 'receive shipment' => The closed invoice is no longer displayed --- C4/Acquisition.pm | 8 ++++++++ acqui/parcels.pl | 5 ++++- .../prog/en/modules/acqui/parcels.tt | 11 +++++++++++ t/db_dependent/Acquisition/Invoices.t | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 296e9d32192..253c509b499 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2456,6 +2456,14 @@ sub GetInvoices { push @bind_strs, " aqinvoices.message_id = ? "; push @bind_args, $args{message_id}; } + if ( exists $args{closedate} ) { + if ( $args{closedate} ) { + push @bind_strs, " aqinvoices.closedate = ? "; + push @bind_args, $args{closedate}; + } else { + push @bind_strs, " aqinvoices.closedate IS NULL "; + } + } $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs; diff --git a/acqui/parcels.pl b/acqui/parcels.pl index 13f9b3726e2..4b36a0a7d07 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -87,6 +87,7 @@ my $code = $input->param('filter'); my $datefrom = $input->param('datefrom'); my $dateto = $input->param('dateto'); my $resultsperpage = $input->param('resultsperpage'); +my $include_closed = $input->param('filter_include_closed'); my $op = $input->param('op'); $resultsperpage ||= 20; @@ -155,7 +156,8 @@ my @parcels = GetInvoices( invoicenumber => $code, ( $datefrom ? ( shipmentdatefrom => $datefrom ) : () ), ( $dateto ? ( shipmentdateto => $dateto ) : () ), - order_by => $order + order_by => $order, + ( $include_closed ? () : ( closedate => undef ) ), ); my $count_parcels = @parcels; @@ -210,6 +212,7 @@ $template->param( datefrom => $datefrom, dateto => $dateto, resultsperpage => $resultsperpage, + filter_include_closed => $include_closed, name => $bookseller->name, shipmentdate_today => dt_from_string, booksellerid => $booksellerid, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt index 6404c1ba936..769e1c9e72c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -233,6 +233,17 @@ +
  • + + +
  • Clear
    diff --git a/t/db_dependent/Acquisition/Invoices.t b/t/db_dependent/Acquisition/Invoices.t index dc5b3d20239..aa27e3d5dfe 100755 --- a/t/db_dependent/Acquisition/Invoices.t +++ b/t/db_dependent/Acquisition/Invoices.t @@ -8,7 +8,7 @@ use Koha::Acquisition::Booksellers; use Koha::Acquisition::Orders; use Koha::Database; -use Test::More tests => 24; +use Test::More tests => 27; BEGIN { use_ok('C4::Acquisition', qw( NewBasket GetBasket AddInvoice GetInvoice ModReceiveOrder GetInvoiceDetails GetInvoices ModInvoice CloseInvoice ReopenInvoice MergeInvoices DelInvoice )); @@ -99,6 +99,14 @@ my $invoiceid1 = AddInvoice(invoicenumber => 'invoice1', booksellerid => $bookse my $invoiceid2 = AddInvoice(invoicenumber => 'invoice2', booksellerid => $booksellerid, unknown => "unknown", shipmentdate => '2012-12-24', ); +my $invoiceid_closed = AddInvoice( + invoicenumber => 'invoice_close', + booksellerid => $booksellerid, + unknown => "unknown", + shipmentdate => '2012-12-24', + closedate => '2024-12-13', +); + my $invoice1 = GetInvoice( $invoiceid1 ); my $invoice2 = GetInvoice( $invoiceid2 ); @@ -162,6 +170,11 @@ is($invoices[0]->{invoicenumber}, 'invoice1', 'GetInvoices() to search by ISBN w @invoices = GetInvoices(isbneanissn => '123456789'); is($invoices[0]->{invoicenumber}, 'invoice1', 'GetInvoices() to search by partial ISBN works (bug 8854)'); +@invoices = GetInvoices(booksellerid => $booksellerid, closedate => undef); +is(scalar @invoices, 2, ); +is($invoices[0]->{invoicenumber}, 'invoice1', 'GetInvoices()'); +is($invoices[1]->{invoicenumber}, 'invoice2', 'GetInvoices()'); + my $invoicesummary1 = GetInvoice($invoiceid1); is($invoicesummary1->{'invoicenumber'}, 'invoice1', 'GetInvoice retrieves correct invoice'); is($invoicesummary1->{'invoicenumber'}, $invoice1->{'invoicenumber'}, 'GetInvoice and GetInvoiceDetails retrieve same information'); -- 2.34.1