-# This function is deprecated in 3.0
-
-sub fixcredit {
-
- #here we update both the accountoffsets and the account lines
- my ( $borrowernumber, $data, $barcode, $type, $user ) = @_;
- my $dbh = C4::Context->dbh;
- my $newamtos = 0;
- my $accdata = "";
- my $amountleft = $data;
- if ( $barcode ne '' ) {
- my $item = GetBiblioFromItemNumber( '', $barcode );
- my $nextaccntno = getnextacctno($borrowernumber);
- my $query = "SELECT * FROM accountlines WHERE (borrowernumber=?
- AND itemnumber=? AND amountoutstanding > 0)";
- if ( $type eq 'CL' ) {
- $query .= " AND (accounttype = 'L' OR accounttype = 'Rep')";
- }
- elsif ( $type eq 'CF' ) {
- $query .= " AND (accounttype = 'F' OR accounttype = 'FU' OR
- accounttype='Res' OR accounttype='Rent')";
- }
- elsif ( $type eq 'CB' ) {
- $query .= " and accounttype='A'";
- }
-
- # print $query;
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber, $item->{'itemnumber'} );
- $accdata = $sth->fetchrow_hashref;
- $sth->finish;
- if ( $accdata->{'amountoutstanding'} < $amountleft ) {
- $newamtos = 0;
- $amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
- $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
- $amountleft = 0;
- }
- my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare(
- "UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
- );
- $usth->execute( $newamtos, $borrowernumber, $thisacct );
- $usth->finish;
- $usth = $dbh->prepare(
- "INSERT INTO accountoffsets
- (borrowernumber, accountno, offsetaccount, offsetamount)
- VALUES (?,?,?,?)"
- );
- $usth->execute( $borrowernumber, $accdata->{'accountno'},
- $nextaccntno, $newamtos );
- $usth->finish;
- }
-
- # begin transaction
- my $nextaccntno = getnextacctno($borrowernumber);
-
- # get lines with outstanding amounts to offset
- my $sth = $dbh->prepare(
- "SELECT * FROM accountlines
- WHERE (borrowernumber = ?) AND (amountoutstanding >0)
- ORDER BY date"
- );
- $sth->execute($borrowernumber);
-
- # print $query;
- # offset transactions
- while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft > 0 ) ) {
- if ( $accdata->{'amountoutstanding'} < $amountleft ) {
- $newamtos = 0;
- $amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
- $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
- $amountleft = 0;
- }
- my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare(
- "UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
- );
- $usth->execute( $newamtos, $borrowernumber, $thisacct );
- $usth->finish;
- $usth = $dbh->prepare(
- "INSERT INTO accountoffsets
- (borrowernumber, accountno, offsetaccount, offsetamount)
- VALUE (?,?,?,?)"
- );
- $usth->execute( $borrowernumber, $accdata->{'accountno'},
- $nextaccntno, $newamtos );
- $usth->finish;
+ if ( C4::Context->preference("FinesLog") ) {
+ logaction("FINES", 'CREATE',$borrowernumber,Dumper({
+ action => 'create_fee',
+ borrowernumber => $borrowernumber,
+ accountno => $accountno,
+ amount => $amount,
+ description => $desc,
+ accounttype => $type,
+ amountoutstanding => $amountleft,
+ notify_id => $notifyid,
+ note => $note,
+ itemnumber => $itemnum,
+ manager_id => $manager_id,
+ }));