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

(-)a/C4/Accounts.pm (-47 lines)
Lines 42-48 BEGIN { Link Here
42
      &getnextacctno
42
      &getnextacctno
43
      &getcharges
43
      &getcharges
44
      &chargelostitem
44
      &chargelostitem
45
      &ReversePayment
46
      &purge_zero_balance_fees
45
      &purge_zero_balance_fees
47
    );
46
    );
48
}
47
}
Lines 329-380 sub getcharges { Link Here
329
    return (@results);
328
    return (@results);
330
}
329
}
331
330
332
#FIXME: ReversePayment should be replaced with a Void Payment feature
333
sub ReversePayment {
334
    my ($accountlines_id) = @_;
335
    my $dbh = C4::Context->dbh;
336
337
    my $accountline        = Koha::Account::Lines->find($accountlines_id);
338
    my $amount_outstanding = $accountline->amountoutstanding;
339
340
    my $new_amountoutstanding =
341
      $amount_outstanding <= 0 ? $accountline->amount * -1 : 0;
342
343
    $accountline->description( $accountline->description . " Reversed -" );
344
    $accountline->amountoutstanding($new_amountoutstanding);
345
    $accountline->store();
346
347
    my $account_offset = Koha::Account::Offset->new(
348
        {
349
            credit_id => $accountline->id,
350
            type      => 'Reverse Payment',
351
            amount    => $amount_outstanding - $new_amountoutstanding,
352
        }
353
    )->store();
354
355
    if ( C4::Context->preference("FinesLog") ) {
356
        my $manager_id = 0;
357
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
358
359
        logaction(
360
            "FINES", 'MODIFY',
361
            $accountline->borrowernumber,
362
            Dumper(
363
                {
364
                    action                => 'reverse_fee_payment',
365
                    borrowernumber        => $accountline->borrowernumber,
366
                    old_amountoutstanding => $amount_outstanding,
367
                    new_amountoutstanding => $new_amountoutstanding,
368
                    ,
369
                    accountlines_id => $accountline->id,
370
                    accountno       => $accountline->accountno,
371
                    manager_id      => $manager_id,
372
                }
373
            )
374
        );
375
    }
376
}
377
378
=head2 purge_zero_balance_fees
331
=head2 purge_zero_balance_fees
379
332
380
  purge_zero_balance_fees( $days );
333
  purge_zero_balance_fees( $days );
(-)a/Koha/Account/Line.pm (+16 lines)
Lines 125-130 sub void { Link Here
125
125
126
}
126
}
127
127
128
=head3 is_payment
129
130
$accountline->is_payment();
131
132
=cut
133
134
sub is_payment {
135
    my ($self) = @_;
136
137
    return Koha::Account::Offsets->search(
138
        {
139
            credit_id => $self->id
140
        }
141
    )->count();
142
}
143
128
=head3 _type
144
=head3 _type
129
145
130
=cut
146
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-1 lines)
Lines 72-78 Link Here
72
        <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
72
        <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
73
        [% IF ( reverse_col) %]
73
        [% IF ( reverse_col) %]
74
          [% IF ( account.payment ) %]
74
          [% IF ( account.payment ) %]
75
            <a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-undo"></i> Reverse</a>
76
            <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-ban"></i> Void</a>
75
            <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-ban"></i> Void</a>
77
          [% ELSE %][% SET footerjs = 1 %]
76
          [% ELSE %][% SET footerjs = 1 %]
78
            &nbsp;
77
            &nbsp;
(-)a/members/boraccount.pl (-5 / +2 lines)
Lines 60-69 unless ( $patron ) { Link Here
60
60
61
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
61
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
62
62
63
if ( $action eq 'reverse' ) {
63
if ( $action eq 'void' ) {
64
  ReversePayment( scalar $input->param('accountlines_id') );
65
}
66
elsif ( $action eq 'void' ) {
67
    my $payment_id = scalar $input->param('accountlines_id');
64
    my $payment_id = scalar $input->param('accountlines_id');
68
    my $payment    = Koha::Account::Lines->find( $payment_id );
65
    my $payment    = Koha::Account::Lines->find( $payment_id );
69
    $payment->void();
66
    $payment->void();
Lines 104-110 while ( my $line = $accts->next ) { Link Here
104
101
105
    $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
102
    $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
106
    $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
103
    $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
107
    if ($accountline->{accounttype} =~ /^Pay/) {
104
    if ( $line->is_payment ) {
108
        $accountline->{payment} = 1;
105
        $accountline->{payment} = 1;
109
        $reverse_col = 1;
106
        $reverse_col = 1;
110
    }
107
    }
(-)a/members/printfeercpt.pl (-5 lines)
Lines 54-63 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" Link Here
54
my $patron         = Koha::Patrons->find( $borrowernumber );
54
my $patron         = Koha::Patrons->find( $borrowernumber );
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
56
56
57
if ( $action eq 'print' ) {
58
#  ReversePayment( $borrowernumber, $input->param('accountno') );
59
}
60
61
if ( $patron->is_child ) {
57
if ( $patron->is_child ) {
62
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
58
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
63
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
59
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
64
- 

Return to bug 20629