View | Details | Raw Unified | Return to bug 21747
Collapse All | Expand All

(-)a/C4/Overdues.pm (-53 / +12 lines)
Lines 578-605 sub UpdateFine { Link Here
578
        # (i.e. , of accounttype 'FU').  Doing so will break accrual.
578
        # (i.e. , of accounttype 'FU').  Doing so will break accrual.
579
        if ( $data->{'amount'} != $amount ) {
579
        if ( $data->{'amount'} != $amount ) {
580
            my $accountline = Koha::Account::Lines->find( $data->{accountlines_id} );
580
            my $accountline = Koha::Account::Lines->find( $data->{accountlines_id} );
581
            my $diff = $amount - $data->{'amount'};
581
            $accountline->adjust({ amount => $amount, type => 'fine_increment' });
582
583
            #3341: diff could be positive or negative!
584
            my $out   = $data->{'amountoutstanding'} + $diff;
585
586
            $accountline->set(
587
                {
588
                    date          => dt_from_string(),
589
                    amount        => $amount,
590
                    amountoutstanding   => $out,
591
                    lastincrement => $diff,
592
                    accounttype   => 'FU',
593
                }
594
            )->store();
595
596
            Koha::Account::Offset->new(
597
                {
598
                    debit_id => $accountline->id,
599
                    type     => 'Fine Update',
600
                    amount   => $diff,
601
                }
602
            )->store();
603
        }
582
        }
604
    } else {
583
    } else {
605
        if ( $amount ) { # Don't add new fines with an amount of 0
584
        if ( $amount ) { # Don't add new fines with an amount of 0
Lines 608-649 sub UpdateFine { Link Here
608
            );
587
            );
609
            $sth4->execute($itemnum);
588
            $sth4->execute($itemnum);
610
            my $title = $sth4->fetchrow;
589
            my $title = $sth4->fetchrow;
611
612
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
613
614
            my $desc = "$title $due";
590
            my $desc = "$title $due";
615
591
616
            my $accountline = Koha::Account::Line->new(
592
            my $account = Koha::Account->new({ patron_id => $borrowernumber });
617
                {
593
            my $accountline = $account->add_debit(
618
                    borrowernumber    => $borrowernumber,
619
                    itemnumber        => $itemnum,
620
                    date              => dt_from_string(),
621
                    amount            => $amount,
622
                    description       => $desc,
623
                    accounttype       => 'FU',
624
                    amountoutstanding => $amount,
625
                    lastincrement     => $amount,
626
                    accountno         => $nextaccntno,
627
                    issue_id          => $issue_id,
628
                }
629
            )->store();
630
631
            Koha::Account::Offset->new(
632
                {
594
                {
633
                    debit_id => $accountline->id,
595
                    amount      => $amount,
634
                    type     => 'Fine',
596
                    description => $desc,
635
                    amount   => $amount,
597
                    note        => undef,
598
                    user_id     => undef,
599
                    library_id  => undef,
600
                    type        => 'fine',
601
                    item_id     => $itemnum,
602
                    issue_id    => $issue_id,
636
                }
603
                }
637
            )->store();
604
            );
638
        }
605
        }
639
    }
606
    }
640
    # logging action
641
    &logaction(
642
        "FINES",
643
        undef,
644
        $borrowernumber,
645
        "due=".$due."  amount=".$amount." itemnumber=".$itemnum
646
        ) if C4::Context->preference("FinesLog");
647
}
607
}
648
608
649
=head2 BorType
609
=head2 BorType
650
- 

Return to bug 21747