BUG: fix patron search
[koha.git] / C4 / Accounts.pm
index eb31f6c..3fdf2d7 100644 (file)
@@ -29,6 +29,7 @@ use Koha::Account::Lines;
 use Koha::Account::Offsets;
 use Koha::Items;
 
+use Mojo::Util qw(deprecated);
 use Data::Dumper qw(Dumper);
 
 use vars qw(@ISA @EXPORT);
@@ -37,8 +38,6 @@ BEGIN {
     require Exporter;
     @ISA    = qw(Exporter);
     @EXPORT = qw(
-      &manualinvoice
-      &getnextacctno
       &chargelostitem
       &purge_zero_balance_fees
     );
@@ -60,29 +59,6 @@ patron.
 
 =head1 FUNCTIONS
 
-=head2 getnextacctno
-
-  $nextacct = &getnextacctno($borrowernumber);
-
-Returns the next unused account number for the patron with the given
-borrower number.
-
-=cut
-
-#'
-# FIXME - Okay, so what does the above actually _mean_?
-sub getnextacctno {
-    my ($borrowernumber) = shift or return;
-    my $sth = C4::Context->dbh->prepare(
-        "SELECT accountno+1 FROM accountlines
-            WHERE    (borrowernumber = ?)
-            ORDER BY accountno DESC
-            LIMIT 1"
-    );
-    $sth->execute($borrowernumber);
-    return ($sth->fetchrow || 1);
-}
-
 =head2 chargelostitem
 
 In a default install of Koha the following lost values are set
@@ -161,34 +137,19 @@ sub chargelostitem{
   &manualinvoice($borrowernumber, $itemnumber, $description, $type,
                  $amount, $note);
 
-C<$borrowernumber> is the patron's borrower number.
-C<$description> is a description of the transaction.
-C<$type> may be one of C<CS>, C<CB>, C<CW>, C<CF>, C<CL>, C<N>, C<L>,
-or C<REF>.
-C<$itemnumber> is the item involved, if pertinent; otherwise, it
-should be the empty string.
+This function is now deprecated and not used anywhere within koha. It is due for complete removal in 19.11
 
 =cut
 
-#'
-# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
-# are:
-#              'C' = CREDIT
-#              'FOR' = FORGIVEN  (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
-#              'N' = New Card fee
-#              'F' = Fine
-#              'A' = Account Management fee
-#              'M' = Sundry
-#              'L' = Lost Item
-#
-
 sub manualinvoice {
     my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
+
+    deprecated "C4::Accounts::manualinvoice is deprecated in favor of Koha::Account->add_debit";
+
     my $manager_id = 0;
     $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
     my $dbh      = C4::Context->dbh;
     my $insert;
-    my $accountno  = getnextacctno($borrowernumber);
     my $amountleft = $amount;
 
     my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
@@ -196,7 +157,6 @@ sub manualinvoice {
     my $accountline = Koha::Account::Line->new(
         {
             borrowernumber    => $borrowernumber,
-            accountno         => $accountno,
             date              => \'NOW()',
             amount            => $amount,
             description       => $desc,
@@ -221,7 +181,6 @@ sub manualinvoice {
         logaction("FINES", 'CREATE',$borrowernumber,Dumper({
             action            => 'create_fee',
             borrowernumber    => $borrowernumber,
-            accountno         => $accountno,
             amount            => $amount,
             description       => $desc,
             accounttype       => $type,