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

(-)a/C4/Accounts.pm (-47 lines)
Lines 41-47 BEGIN { Link Here
41
      &getnextacctno
41
      &getnextacctno
42
      &getcharges
42
      &getcharges
43
      &chargelostitem
43
      &chargelostitem
44
      &ReversePayment
45
      &purge_zero_balance_fees
44
      &purge_zero_balance_fees
46
    );
45
    );
47
}
46
}
Lines 328-379 sub getcharges { Link Here
328
    return (@results);
327
    return (@results);
329
}
328
}
330
329
331
#FIXME: ReversePayment should be replaced with a Void Payment feature
332
sub ReversePayment {
333
    my ($accountlines_id) = @_;
334
    my $dbh = C4::Context->dbh;
335
336
    my $accountline        = Koha::Account::Lines->find($accountlines_id);
337
    my $amount_outstanding = $accountline->amountoutstanding;
338
339
    my $new_amountoutstanding =
340
      $amount_outstanding <= 0 ? $accountline->amount * -1 : 0;
341
342
    $accountline->description( $accountline->description . " Reversed -" );
343
    $accountline->amountoutstanding($new_amountoutstanding);
344
    $accountline->store();
345
346
    my $account_offset = Koha::Account::Offset->new(
347
        {
348
            credit_id => $accountline->id,
349
            type      => 'Reverse Payment',
350
            amount    => $amount_outstanding - $new_amountoutstanding,
351
        }
352
    )->store();
353
354
    if ( C4::Context->preference("FinesLog") ) {
355
        my $manager_id = 0;
356
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
357
358
        logaction(
359
            "FINES", 'MODIFY',
360
            $accountline->borrowernumber,
361
            Dumper(
362
                {
363
                    action                => 'reverse_fee_payment',
364
                    borrowernumber        => $accountline->borrowernumber,
365
                    old_amountoutstanding => $amount_outstanding,
366
                    new_amountoutstanding => $new_amountoutstanding,
367
                    ,
368
                    accountlines_id => $accountline->id,
369
                    accountno       => $accountline->accountno,
370
                    manager_id      => $manager_id,
371
                }
372
            )
373
        );
374
    }
375
}
376
377
=head2 purge_zero_balance_fees
330
=head2 purge_zero_balance_fees
378
331
379
  purge_zero_balance_fees( $days );
332
  purge_zero_balance_fees( $days );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-7 / +2 lines)
Lines 77-89 Link Here
77
        [% END %]
77
        [% END %]
78
        <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id | html %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
78
        <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id | html %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
79
        [% IF ( reverse_col) %]
79
        [% IF ( reverse_col) %]
80
          [% IF ( account.payment || account.amount < 0 ) %]
80
          [% IF account.object.is_credit %]
81
                [% IF account.payment %]
81
              <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id | html %]&amp;borrowernumber=[% account.borrowernumber | html %]" class="btn btn-default btn-xs void"><i class="fa fa-ban"></i> Void</a>
82
                    <a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id | html %]&amp;borrowernumber=[% account.borrowernumber | html %]" class="btn btn-default btn-xs"><i class="fa fa-undo"></i> Reverse</a>
83
                [% END %]
84
                [% IF account.amount < 0 %]
85
                    <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id | html %]&amp;borrowernumber=[% account.borrowernumber | html %]" class="btn btn-default btn-xs void"><i class="fa fa-ban"></i> Void</a>
86
                [% END %]
87
          [% ELSE %]
82
          [% ELSE %]
88
            &nbsp;
83
            &nbsp;
89
          [% END %]
84
          [% END %]
(-)a/members/boraccount.pl (-4 / +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 87-92 my @accountlines; Link Here
87
while ( my $line = $accts->next ) {
84
while ( my $line = $accts->next ) {
88
    # FIXME We should pass the $accts iterator to the template and do this formatting part there
85
    # FIXME We should pass the $accts iterator to the template and do this formatting part there
89
    my $accountline = $line->unblessed;
86
    my $accountline = $line->unblessed;
87
    $accountline->{object} = $line;
90
    $accountline->{amount} += 0.00;
88
    $accountline->{amount} += 0.00;
91
    if ($accountline->{amount} <= 0 ) {
89
    if ($accountline->{amount} <= 0 ) {
92
        $accountline->{amountcredit} = 1;
90
        $accountline->{amountcredit} = 1;
(-)a/members/printfeercpt.pl (-4 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
#get account details
57
#get account details
62
my $total = $patron->account->balance;
58
my $total = $patron->account->balance;
63
59
(-)a/t/db_dependent/Accounts.t (-2 lines)
Lines 45-51 can_ok( 'C4::Accounts', Link Here
45
        chargelostitem
45
        chargelostitem
46
        manualinvoice
46
        manualinvoice
47
        getcharges
47
        getcharges
48
        ReversePayment
49
        purge_zero_balance_fees )
48
        purge_zero_balance_fees )
50
);
49
);
51
50
52
- 

Return to bug 20629