@@ -, +, @@ --- C4/Accounts.pm | 20 ++++++++++++++------ t/db_dependent/Circulation/Chargelostitem.t | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) --- a/C4/Accounts.pm +++ a/C4/Accounts.pm @@ -467,12 +467,20 @@ sub manualinvoice { sub getcharges { my ( $borrowerno, $accountno ) = @_; - my $dbh = C4::Context->dbh; - my $query = ""; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" - ); - $sth->execute( $borrowerno, $accountno ); + my $dbh = C4::Context->dbh; + + my @params; + + my $query = "SELECT * FROM accountlines WHERE borrowernumber = ?"; + push( @params, $borrowerno ); + + if ( $accountno ) { + $query .= " AND accountno = ?"; + push( @params, $accountno ); + } + + my $sth = $dbh->prepare( $query ); + $sth->execute( @params ); my @results; while ( my $data = $sth->fetchrow_hashref ) { --- a/t/db_dependent/Circulation/Chargelostitem.t +++ a/t/db_dependent/Circulation/Chargelostitem.t @@ -76,9 +76,9 @@ my $issues; $issues = C4::Circulation::GetIssues({biblionumber => $biblionumber1}); my $issue=$issues->[0]; $issue->{'processfee'} = $processfee; -my $accountlineId = C4::Accounts::chargelostitem($issue, 'test'); +C4::Accounts::chargelostitem($issue, 'test'); -my @accountline = C4::Accounts::getcharges($borrowernumber, $accountlineId); +my @accountline = C4::Accounts::getcharges($borrowernumber); is( scalar(@accountline), 1, 'accountline should have 1 row' ); is( int($accountline[0]->{amount}), $processfee, "The accountline amount should be precessfee value " ); @@ -86,4 +86,4 @@ is( $accountline[0]->{accounttype}, 'PF', "The accountline accounttype should be is( $accountline[0]->{borrowernumber}, $borrowernumber, "The accountline borrowernumber should be the exemple borrownumber" ); my $itemnumber = C4::Items::GetItemnumberFromBarcode('0101'); is( $accountline[0]->{itemnumber}, $itemnumber, "The accountline itemnumber should the linked with barcode '0101'" ); -is( $accountline[0]->{description}, 'test', "The accountline description should be 'test'" ); +is( $accountline[0]->{description}, 'test ' . $issue->{itemnumber}, "The accountline description should be 'test'" ); --