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 (+6 lines)
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 $amount_outstanding = Koha::Account::Lines->search({borrowernumber => $borrowernumber});
57
        return 0 if $amount_outstanding < $amt;
58
    }
59
54
    my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef;
60
    my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef;
55
61
56
    if ($is_writeoff) { # Writeoffs require a fee id to be sent
62
    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 23-28 use Modern::Perl; Link Here
23
use Carp;
23
use Carp;
24
24
25
use C4::Context;
25
use C4::Context;
26
use Koha::Account::Lines;
26
use Koha::Database;
27
use Koha::Database;
27
use Koha::Issues;
28
use Koha::Issues;
28
use Koha::OldIssues;
29
use Koha::OldIssues;
Lines 42-47 Koha::Patron - Koha Patron Object class Link Here
42
43
43
=cut
44
=cut
44
45
46
=head3 account_balance
47
48
Returns the total amount owed by this patron
49
50
=cut
51
52
sub account_balance {
53
    my ($self) = @_;
54
55
    return Koha::Account::Lines->search(
56
        {
57
            borrowernumber => $self->id
58
        }
59
    )->amount_outstanding();
60
}
61
45
=head3 guarantor
62
=head3 guarantor
46
63
47
Returns a Koha::Patron object for this patron's guarantor
64
Returns a Koha::Patron object for this patron's guarantor
(-)a/etc/SIPconfig.xml (-1 / +1 lines)
Lines 36-42 Link Here
36
  </listeners>
36
  </listeners>
37
37
38
  <accounts>
38
  <accounts>
39
      <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" />
39
      <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" disallow_overpayment="1" />
40
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
40
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
41
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
41
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
42
      <login id="lpl-sc" password="1234" institution="LPL" />
42
      <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