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

(-)a/Koha/Account/Line.pm (-2 / +2 lines)
Lines 60-70 sub void { Link Here
60
    my ($self) = @_;
60
    my ($self) = @_;
61
61
62
    # Make sure it is a payment we are voiding
62
    # Make sure it is a payment we are voiding
63
    return unless $self->accounttype =~ /^Pay/;
63
    return unless $self->amount < 0;
64
64
65
    my @account_offsets =
65
    my @account_offsets =
66
      Koha::Account::Offsets->search(
66
      Koha::Account::Offsets->search(
67
        { credit_id => $self->id, type => 'Payment' } );
67
        { credit_id => $self->id, amount => { '<' => 0 }  } );
68
68
69
    $self->_result->result_source->schema->txn_do(
69
    $self->_result->result_source->schema->txn_do(
70
        sub {
70
        sub {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-4 / +8 lines)
Lines 72-81 Link Here
72
        [% END %]
72
        [% END %]
73
        <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
        <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
74
        [% IF ( reverse_col) %]
74
        [% IF ( reverse_col) %]
75
          [% IF ( account.payment ) %]
75
          [% IF ( account.payment || account.amount < 0 ) %]
76
            <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
                [% IF account.payment %]
77
            <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
                    <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>
78
          [% ELSE %][% SET footerjs = 1 %]
78
                [% END %]
79
                [% IF account.amount < 0 %]
80
                    <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>
81
                [% END %]
82
          [% ELSE %]
79
            &nbsp;
83
            &nbsp;
80
          [% END %]
84
          [% END %]
81
        [% END %]
85
        [% END %]
(-)a/members/boraccount.pl (-2 / +4 lines)
Lines 104-111 while ( my $line = $accts->next ) { Link Here
104
104
105
    $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
105
    $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
106
    $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
106
    $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
107
    if ($accountline->{accounttype} =~ /^Pay/) {
107
    if ($accountline->{amount} < 0) {
108
        $accountline->{payment} = 1;
108
        $accountline->{payment} = 1
109
          if ( $accountline->{accounttype} =~ /^Pay/ );
110
109
        $reverse_col = 1;
111
        $reverse_col = 1;
110
    }
112
    }
111
113
(-)a/t/db_dependent/Accounts.t (-3 / +11 lines)
Lines 846-852 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
846
846
847
subtest "Koha::Account::Line::void tests" => sub {
847
subtest "Koha::Account::Line::void tests" => sub {
848
848
849
    plan tests => 12;
849
    plan tests => 15;
850
850
851
    # Create a borrower
851
    # Create a borrower
852
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
852
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
Lines 886-893 subtest "Koha::Account::Line::void tests" => sub { Link Here
886
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
886
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
887
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
887
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
888
888
889
    $account_payment->void();
889
    my $ret = $account_payment->void();
890
890
891
    is( ref($ret), 'Koha::Account::Line', 'Void returns the account line' );
891
    is( $account->balance(), 30, "Account balance is again 30" );
892
    is( $account->balance(), 30, "Account balance is again 30" );
892
893
893
    $account_payment->_result->discard_changes();
894
    $account_payment->_result->discard_changes();
Lines 900-905 subtest "Koha::Account::Line::void tests" => sub { Link Here
900
901
901
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
902
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
902
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
903
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
904
905
    # Accountlines that are not credits should be un-voidable
906
    my $line1_pre = $line1->unblessed();
907
    $ret = $line1->void();
908
    $line1->_result->discard_changes();
909
    my $line1_post = $line1->unblessed();
910
    is( $ret, undef, 'Attempted void on non-credit returns undef' );
911
    is_deeply( $line1_pre, $line1_post, 'Non-credit account line cannot be voided' )
903
};
912
};
904
913
905
subtest "Koha::Account::Offset credit & debit tests" => sub {
914
subtest "Koha::Account::Offset credit & debit tests" => sub {
906
- 

Return to bug 20703