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

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-11-20 09:23:03 +01:00 committed by Katrin Fischer
parent 0be0f03d52
commit e868ff21ff
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
4 changed files with 37 additions and 2 deletions

View file

@ -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;

View file

@ -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,

View file

@ -233,6 +233,17 @@
<option value="50">50</option>
<option value="100">100</option>
</select></li>
<li>
<label for="filter_include_closed">
[% IF filter_include_closed %]
<input type="checkbox" id="filter_include_closed" value="1" name="filter_include_closed" checked="checked" title="Include closed invoices in the search" />
[% ELSE %]
<input type="checkbox" id="filter_include_closed" value="1" name="filter_include_closed" title="Include closed invoices in the search" />
[% END %]
Include closed invoices
</label>
</li>
</ol>
<fieldset class="action"><input type="submit" class="btn btn-default" value="Filter" /> <a href="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid | uri %]">Clear</a></fieldset>
</fieldset>

View file

@ -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');