1 package Koha::Account::Line;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use C4::Log qw(logaction);
27 use Koha::Account::Offsets;
29 use base qw(Koha::Object);
33 Koha::Account::Lines - Koha accountline Object class
43 Return the item linked to this account line if exists
49 my $rs = $self->_result->itemnumber;
50 return Koha::Item->_new_from_dbic( $rs );
55 $payment_accountline->void();
62 # Make sure it is a payment we are voiding
63 return unless $self->accounttype =~ /^Pay/;
66 Koha::Account::Offsets->search(
67 { credit_id => $self->id, type => 'Payment' } );
69 $self->_result->result_source->schema->txn_do(
71 foreach my $account_offset (@account_offsets) {
73 Koha::Account::Lines->find( $account_offset->debit_id );
75 next unless $fee_paid;
77 my $amount_paid = $account_offset->amount * -1; # amount paid is stored as a negative amount
78 my $new_amount = $fee_paid->amountoutstanding + $amount_paid;
79 $fee_paid->amountoutstanding($new_amount);
82 Koha::Account::Offset->new(
84 credit_id => $self->id,
85 debit_id => $fee_paid->id,
86 amount => $amount_paid,
87 type => 'Void Payment',
92 if ( C4::Context->preference("FinesLog") ) {
95 $self->borrowernumber,
98 action => 'void_payment',
99 borrowernumber => $self->borrowernumber,
100 amount => $self->amount,
101 amountoutstanding => $self->amountoutstanding,
102 description => $self->description,
103 accounttype => $self->accounttype,
104 payment_type => $self->payment_type,
106 itemnumber => $self->itemnumber,
107 manager_id => $self->manager_id,
109 [ map { $_->unblessed } @account_offsets ],
117 accounttype => 'VOID',
118 amountoutstanding => 0,
133 return 'Accountline';