Lines 20-26
use strict;
Link Here
|
20 |
# You should have received a copy of the GNU General Public License |
20 |
# You should have received a copy of the GNU General Public License |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
22 |
|
22 |
|
23 |
use C4::Accounts qw(recordpayment makepayment); |
23 |
use C4::Accounts qw(recordpayment makepayment WriteOffFee); |
24 |
use Koha::Account::Lines; |
24 |
use Koha::Account::Lines; |
25 |
use parent qw(C4::SIP::ILS::Transaction); |
25 |
use parent qw(C4::SIP::ILS::Transaction); |
26 |
|
26 |
|
Lines 47-65
sub pay {
Link Here
|
47 |
my $amt = shift; |
47 |
my $amt = shift; |
48 |
my $type = shift; |
48 |
my $type = shift; |
49 |
my $fee_id = shift; |
49 |
my $fee_id = shift; |
|
|
50 |
my $is_writeoff = shift; |
50 |
|
51 |
|
51 |
warn("RECORD:$borrowernumber::$amt"); |
52 |
warn("RECORD:$borrowernumber::$amt"); |
52 |
|
53 |
|
53 |
if ($fee_id) { |
54 |
my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef; |
54 |
my $fee = Koha::Account::Lines->find( $fee_id ); |
55 |
|
|
|
56 |
if ($is_writeoff) { # Writeoffs require a fee id to be sent |
57 |
if ( $fee && $fee->amountoutstanding == $amt ) { |
58 |
WriteOffFee( $borrowernumber, $fee_id, undef, undef, $amt ); |
59 |
return 1; |
60 |
} |
61 |
else { |
62 |
return 0; |
63 |
} |
64 |
} |
65 |
|
66 |
if ($fee_id) { # If a given fee is to be paid, the amount must match. This is a limitation of makepayment |
55 |
if ( $fee && $fee->amountoutstanding == $amt ) { |
67 |
if ( $fee && $fee->amountoutstanding == $amt ) { |
56 |
makepayment( $fee_id, $borrowernumber, undef, $amt ); |
68 |
makepayment( $fee_id, $borrowernumber, undef, $amt ); |
57 |
return 1; |
69 |
return 1; |
58 |
} else { |
70 |
} |
|
|
71 |
else { |
59 |
return 0; |
72 |
return 0; |
60 |
} |
73 |
} |
61 |
} |
74 |
} |
62 |
else { |
75 |
else { # Simply pay by amount |
63 |
recordpayment( $borrowernumber, $amt, $type ); |
76 |
recordpayment( $borrowernumber, $amt, $type ); |
64 |
return 1; |
77 |
return 1; |
65 |
} |
78 |
} |