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.
24 use Koha::Account::Offsets;
26 use base qw(Koha::Object);
30 Koha::Account::Lines - Koha accountline Object class
40 Return the item linked to this account line if exists
46 my $rs = $self->_result->itemnumber;
47 return Koha::Item->_new_from_dbic( $rs );
52 $payment_accountline->void();
59 # Make sure it is a payment we are voiding
60 return unless $self->accounttype =~ /^Pay/;
63 Koha::Account::Offsets->search( { credit_id => $self->id, type => 'Payment' } );
65 foreach my $account_offset (@account_offsets) {
66 my $fee_paid = Koha::Account::Lines->find( $account_offset->debit_id );
68 next unless $fee_paid;
70 my $amount_paid = $account_offset->amount * -1; # amount paid is stored as a negative amount
71 my $new_amount = $fee_paid->amountoutstanding + $amount_paid;
72 $fee_paid->amountoutstanding($new_amount);
75 Koha::Account::Offset->new(
77 credit_id => $self->id,
78 debit_id => $fee_paid->id,
79 amount => $amount_paid,
80 type => 'Void Payment',
87 accounttype => 'VOID',
88 amountoutstanding => 0,
100 return 'Accountline';