@@ -, +, @@ date. Verify that the expected invoice(s) are returned. (of the staff member that approved the basket). Verify that the expected invoice(s) are returned. Verify that the expected invoice(s) are returned. --- C4/Acquisition.pm | 9 ++++++--- acqui/invoices.pl | 2 +- t/Acquisition/Invoice.t | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -2156,6 +2156,7 @@ sub AddClaim { my @invoices = GetInvoices( invoicenumber => $invoicenumber, + supplierid => $supplierid, suppliername => $suppliername, shipmentdatefrom => $shipmentdatefrom, # ISO format shipmentdateto => $shipmentdateto, # ISO format @@ -2200,6 +2201,8 @@ sub GetInvoices { FROM aqinvoices LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid + LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno + LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber @@ -2220,11 +2223,11 @@ sub GetInvoices { push @bind_args, "%$args{suppliername}%"; } if($args{shipmentdatefrom}) { - push @bind_strs, " aqinvoices.shipementdate >= ? "; + push @bind_strs, " aqinvoices.shipmentdate >= ? "; push @bind_args, $args{shipmentdatefrom}; } if($args{shipmentdateto}) { - push @bind_strs, " aqinvoices.shipementdate <= ? "; + push @bind_strs, " aqinvoices.shipmentdate <= ? "; push @bind_args, $args{shipmentdateto}; } if($args{billingdatefrom}) { @@ -2256,7 +2259,7 @@ sub GetInvoices { push @bind_args, $args{publicationyear}; } if($args{branchcode}) { - push @bind_strs, " aqorders.branchcode = ? "; + push @bind_strs, " borrowers.branchcode = ? "; push @bind_args, $args{branchcode}; } --- a/acqui/invoices.pl +++ a/acqui/invoices.pl @@ -71,7 +71,7 @@ if ( $op and $op eq "do_search" ) { my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso"); my @invoices = GetInvoices( invoicenumber => $invoicenumber, - suppliername => $supplier, + supplierid => $supplier, shipmentdatefrom => $shipmentdatefrom_iso, shipmentdateto => $shipmentdateto_iso, billingdatefrom => $billingdatefrom_iso, --- a/t/Acquisition/Invoice.t +++ a/t/Acquisition/Invoice.t @@ -6,8 +6,6 @@ use C4::Context; use Test::More tests => 47; use Test::MockModule; -use_ok('C4::Acquisition'); - my $module = new Test::MockModule('C4::Context'); $module->mock('_new_dbh', sub { my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) @@ -17,6 +15,8 @@ $module->mock('_new_dbh', sub { my $dbh = C4::Context->dbh; +use_ok('C4::Acquisition'); + # We need to add a resultset to avoid DBI fail # ("DBI bind_columns: invalid number of arguments...") my $rs = [ @@ -42,8 +42,8 @@ my @invoices = C4::Acquisition::GetInvoices( ); my $history = $dbh->{mock_all_history}; -is(scalar(@$history), 1); -my @bound_params = @{ $history->[0]->{bound_params} }; +ok(scalar(@$history) > 0); +my @bound_params = @{ $history->[-1]->{bound_params} }; is(scalar(@bound_params), 15); is($bound_params[0], 'supplierid'); is($bound_params[1], '%invoicenumber%'); --