Revert "Bug 17902: Fix possible SQL injection in serials editing"
[koha.git] / C4 / Accounts.pm
index f20ea2f..3942c39 100644 (file)
@@ -26,26 +26,26 @@ use C4::Members;
 use C4::Circulation qw(ReturnLostItem);
 use C4::Log qw(logaction);
 use Koha::Account;
+use Koha::Account::Lines;
 
 use Data::Dumper qw(Dumper);
 
 use vars qw(@ISA @EXPORT);
 
 BEGIN {
-       require Exporter;
-       @ISA    = qw(Exporter);
-       @EXPORT = qw(
-               &manualinvoice
-               &getnextacctno
-               &getcharges
-               &ModNote
-               &getcredits
-               &getrefunds
-               &chargelostitem
-               &ReversePayment
-        &WriteOffFee
-        &purge_zero_balance_fees
-       );
+    require Exporter;
+    @ISA    = qw(Exporter);
+    @EXPORT = qw(
+      &manualinvoice
+      &getnextacctno
+      &getcharges
+      &ModNote
+      &getcredits
+      &getrefunds
+      &chargelostitem
+      &ReversePayment
+      &purge_zero_balance_fees
+    );
 }
 
 =head1 NAME
@@ -349,81 +349,6 @@ sub ReversePayment {
 
 }
 
-=head2 WriteOffFee
-
-  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
-
-Write off a fine for a patron.
-C<$borrowernumber> is the patron's borrower number.
-C<$accountline_id> is the accountline_id of the fee to write off.
-C<$itemnum> is the itemnumber of of item whose fine is being written off.
-C<$accounttype> is the account type of the fine being written off.
-C<$amount> is a floating-point number, giving the amount that is being written off.
-C<$branch> is the branchcode of the library where the writeoff occurred.
-C<$payment_note> is the note to attach to this payment
-
-=cut
-
-sub WriteOffFee {
-    my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_;
-    $payment_note //= "";
-    $branch ||= C4::Context->userenv->{branch};
-    my $manager_id = 0;
-    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
-
-    # if no item is attached to fine, make sure to store it as a NULL
-    $itemnum ||= undef;
-
-    my ( $sth, $query );
-    my $dbh = C4::Context->dbh();
-
-    $query = "
-        UPDATE accountlines SET amountoutstanding = 0
-        WHERE accountlines_id = ? AND borrowernumber = ?
-    ";
-    $sth = $dbh->prepare( $query );
-    $sth->execute( $accountlines_id, $borrowernumber );
-
-    if ( C4::Context->preference("FinesLog") ) {
-        logaction("FINES", 'MODIFY', $borrowernumber, Dumper({
-            action                => 'fee_writeoff',
-            borrowernumber        => $borrowernumber,
-            accountlines_id       => $accountlines_id,
-            manager_id            => $manager_id,
-        }));
-    }
-
-    $query ="
-        INSERT INTO accountlines
-        ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note )
-        VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? )
-    ";
-    $sth = $dbh->prepare( $query );
-    my $acct = getnextacctno($borrowernumber);
-    $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note );
-
-    if ( C4::Context->preference("FinesLog") ) {
-        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
-            action            => 'create_writeoff',
-            borrowernumber    => $borrowernumber,
-            accountno         => $acct,
-            amount            => 0 - $amount,
-            accounttype       => 'W',
-            itemnumber        => $itemnum,
-            accountlines_paid => [ $accountlines_id ],
-            manager_id        => $manager_id,
-        }));
-    }
-
-    UpdateStats({
-                branch => $branch,
-                type => 'writeoff',
-                amount => $amount,
-                borrowernumber => $borrowernumber}
-    );
-
-}
-
 =head2 purge_zero_balance_fees
 
   purge_zero_balance_fees( $days );