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

(-)a/C4/SIP/ILS.pm (-2 / +2 lines)
Lines 247-253 sub end_patron_session { Link Here
247
}
247
}
248
248
249
sub pay_fee {
249
sub pay_fee {
250
    my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff) = @_;
250
    my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment ) = @_;
251
251
252
    my $trans = C4::SIP::ILS::Transaction::FeePayment->new();
252
    my $trans = C4::SIP::ILS::Transaction::FeePayment->new();
253
253
Lines 258-264 sub pay_fee { Link Here
258
        $trans->screen_msg('Invalid patron barcode.');
258
        $trans->screen_msg('Invalid patron barcode.');
259
        return $trans;
259
        return $trans;
260
    }
260
    }
261
    my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff );
261
    my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff, $disallow_overpayment );
262
    $trans->ok($ok);
262
    $trans->ok($ok);
263
263
264
    return $trans;
264
    return $trans;
(-)a/C4/SIP/ILS/Transaction/FeePayment.pm (-1 / +10 lines)
Lines 21-27 use strict; Link Here
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 WriteOffFee);
23
use C4::Accounts qw(recordpayment makepayment WriteOffFee);
24
use Koha::Account::Lines;
24
use Koha::Patrons;
25
use parent qw(C4::SIP::ILS::Transaction);
25
use parent qw(C4::SIP::ILS::Transaction);
26
26
27
27
Lines 48-56 sub pay { Link Here
48
    my $type           = shift;
48
    my $type           = shift;
49
    my $fee_id         = shift;
49
    my $fee_id         = shift;
50
    my $is_writeoff    = shift;
50
    my $is_writeoff    = shift;
51
    my $disallow_overpayment = shift;
51
52
52
    warn("RECORD:$borrowernumber::$amt");
53
    warn("RECORD:$borrowernumber::$amt");
53
54
55
    if ($disallow_overpayment) {
56
        my $patron = Koha::Patrons->find($borrowernumber);
57
        return 0 unless $patron;
58
59
        my $balance = $patron->account_balance();
60
        return 0 if $balance < $amt;
61
    }
62
54
    my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef;
63
    my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef;
55
64
56
    if ($is_writeoff) { # Writeoffs require a fee id to be sent
65
    if ($is_writeoff) { # Writeoffs require a fee id to be sent
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +2 lines)
Lines 1068-1073 sub handle_fee_paid { Link Here
1068
    my $status;
1068
    my $status;
1069
    my $resp = FEE_PAID_RESP;
1069
    my $resp = FEE_PAID_RESP;
1070
1070
1071
    my $disallow_overpayment = $server->{account}->{disallow_overpayment};
1071
    my $payment_type_writeoff = $server->{account}->{payment_type_writeoff};
1072
    my $payment_type_writeoff = $server->{account}->{payment_type_writeoff};
1072
    my $is_writeoff = $pay_type eq $payment_type_writeoff;
1073
    my $is_writeoff = $pay_type eq $payment_type_writeoff;
1073
1074
Lines 1080-1086 sub handle_fee_paid { Link Here
1080
1081
1081
    $ils->check_inst_id( $inst_id, "handle_fee_paid" );
1082
    $ils->check_inst_id( $inst_id, "handle_fee_paid" );
1082
1083
1083
    $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff );
1084
    $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
1084
1085
1085
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1086
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1086
    $resp .= add_field( FID_INST_ID,   $inst_id );
1087
    $resp .= add_field( FID_INST_ID,   $inst_id );
(-)a/Koha/Account/Lines.pm (+10 lines)
Lines 36-41 Koha::Account::Lines - Koha Account Line Object set class Link Here
36
36
37
=cut
37
=cut
38
38
39
=head3 amount_outstanding
40
41
=cut
42
43
sub amount_outstanding {
44
    my ( $self ) = @_;
45
46
    return $self->_resultset()->get_column('amountoutstanding')->sum();
47
}
48
39
=head3 type
49
=head3 type
40
50
41
=cut
51
=cut
(-)a/Koha/Patron.pm (+17 lines)
Lines 24-29 use Carp; Link Here
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Log;
26
use C4::Log;
27
use Koha::Account::Lines;
27
use Koha::Database;
28
use Koha::Database;
28
use Koha::DateUtils;
29
use Koha::DateUtils;
29
use Koha::Issues;
30
use Koha::Issues;
Lines 44-49 Koha::Patron - Koha Patron Object class Link Here
44
45
45
=cut
46
=cut
46
47
48
=head3 account_balance
49
50
Returns the total amount owed by this patron
51
52
=cut
53
54
sub account_balance {
55
    my ($self) = @_;
56
57
    return Koha::Account::Lines->search(
58
        {
59
            borrowernumber => $self->id
60
        }
61
    )->amount_outstanding();
62
}
63
47
=head3 guarantor
64
=head3 guarantor
48
65
49
Returns a Koha::Patron object for this patron's guarantor
66
Returns a Koha::Patron object for this patron's guarantor
(-)a/etc/SIPconfig.xml (-1 / +1 lines)
Lines 44-50 Link Here
44
  </listeners>
44
  </listeners>
45
45
46
  <accounts>
46
  <accounts>
47
      <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" />
47
      <login id="staff"  password="staff" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" disallow_overpayment="1" />
48
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
48
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
49
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
49
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
50
      <login id="lpl-sc" password="1234" institution="LPL" />
50
      <login id="lpl-sc" password="1234" institution="LPL" />
(-)a/t/db_dependent/Patron.t (-2 / +22 lines)
Lines 17-27 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 13;
20
use Test::More tests => 14;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Account::Line;
25
26
26
BEGIN {
27
BEGIN {
27
    use_ok('Koha::Object');
28
    use_ok('Koha::Object');
Lines 50-55 my $borrowernumber = $object->borrowernumber; Link Here
50
my $patron = $schema->resultset('Borrower')->find( $borrowernumber );
51
my $patron = $schema->resultset('Borrower')->find( $borrowernumber );
51
is( $patron->surname(), "Test Surname", "Object found in database" );
52
is( $patron->surname(), "Test Surname", "Object found in database" );
52
53
54
my $accountline_1 = Koha::Account::Line->new(
55
    {
56
        borrowernumber    => $patron->id,
57
        accountno         => 1,
58
        amount            => 10.00,
59
        amountoutstanding => 5.00,
60
    }
61
)->store();
62
63
my $accountline_2 = Koha::Account::Line->new(
64
    {
65
        borrowernumber    => $patron->id,
66
        accountno         => 2,
67
        amount            => 7.00,
68
        amountoutstanding => 7.00,
69
    }
70
)->store();
71
72
is( $object->account_balance, '12.000000', "Got correct patron account balance" );
73
53
is( $object->is_changed(), 0, "Object is unchanged" );
74
is( $object->is_changed(), 0, "Object is unchanged" );
54
$object->surname("Test Surname");
75
$object->surname("Test Surname");
55
is( $object->is_changed(), 0, "Object is still unchanged" );
76
is( $object->is_changed(), 0, "Object is still unchanged" );
56
- 

Return to bug 16899