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

(-)a/Koha/Account/Offset.pm (+23 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Carp;
20
use Carp;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Account::Line;
23
24
24
use base qw(Koha::Object);
25
use base qw(Koha::Object);
25
26
Lines 35-40 Account offsets are used to track the changes in account lines Link Here
35
36
36
=cut
37
=cut
37
38
39
=head3 debit
40
41
=cut
42
43
sub debit {
44
    my ( $self ) = @_;
45
    my $debit_rs = $self->_result->debit;
46
    return unless $debit_rs;
47
    return Koha::Account::Line->_new_from_dbic( $debit_rs );
48
}
49
50
=head3 credit
51
52
=cut
53
54
sub credit {
55
    my ( $self ) = @_;
56
    my $credit_rs = $self->_result->credit;
57
    return unless $credit_rs;
58
    return Koha::Account::Line->_new_from_dbic( $credit_rs );
59
}
60
38
=head3 _type
61
=head3 _type
39
62
40
=cut
63
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc (+8 lines)
Line 0 Link Here
1
[% SWITCH account_offset.type %]
2
    [% CASE 'Payment' %]Payment
3
    [% CASE 'Manual Debit' %]Manual invoice
4
    [% CASE 'Lost Item Return' %]Lost item returned
5
    [% CASE 'Writeoff' %]Writeoff
6
    [% CASE 'Void Payment' %]Void payment
7
    [% CASE %][% account_offset.type %]
8
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/accounttype.inc (+24 lines)
Line 0 Link Here
1
[% SWITCH account.accounttype %]
2
    [% CASE 'Pay' %]Payment, thanks
3
    [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
4
    [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
5
    [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
6
    [% CASE 'VOID' %]Payment, Voided
7
    [% CASE 'N' %]New card
8
    [% CASE 'F' %]Fine
9
    [% CASE 'A' %]Account management fee
10
    [% CASE 'M' %]Sundry
11
    [% CASE 'L' %]Lost item
12
    [% CASE 'W' %]Writeoff
13
    [% CASE 'FU' %]Accruing fine
14
    [% CASE 'HE' %]Hold waiting too long
15
    [% CASE 'Rent' %]Rental fee
16
    [% CASE 'FOR' %]Forgiven
17
    [% CASE 'LR' %]Lost item fee refund
18
    [% CASE 'PF' %]Processing fee
19
    [% CASE 'PAY' %]Payment
20
    [% CASE 'WO' %]Writeoff
21
    [% CASE 'C' %]Credit
22
    [% CASE 'CR' %]Credit
23
    [% CASE %][% account.accounttype %]
24
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt (+137 lines)
Line 0 Link Here
1
[%- USE Price -%]
2
[%- USE KohaDates -%]
3
[%- USE AuthorisedValues -%]
4
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
</head>
9
<body id="pat_discharges" class="pat">
10
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'patron-search.inc' %]
12
13
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Account for [% INCLUDE 'patron-title.inc' %]</a> &rsaquo; Details for account line [% accountline.id %]</div>
14
15
<div id="doc3" class="yui-t2">
16
<div id="bd">
17
    <div id="yui-main">
18
        <div class="yui-b">
19
            [% IF accountline %]
20
                [% IF type == 'credit' %]
21
                    <h2>Details for payment</h2>
22
                [% ELSIF type == 'debit' %]
23
                    <h2>Details for fee</h2>
24
                [% END %]
25
26
                <table id="table_account_fines">
27
                    <thead>
28
                        <tr>
29
                            <th class="title-string">Date</th>
30
                            <th>Description of charges</th>
31
                            <th>Note</th>
32
                            <th>Amount</th>
33
                            <th>Outstanding</th>
34
                        </tr>
35
                    </thead>
36
37
                    <tbody>
38
                        <tr>
39
                            <td>
40
                                <span title="[% accountline.date %]">[% accountline.date |$KohaDates %]</span>
41
                            </td>
42
                            <td>
43
                                [% INCLUDE 'accounttype.inc' accountline => accountline %]
44
                                [%- IF accountline.payment_type -%]
45
                                    , [% AuthorisedValues.GetByCode('PAYMENT_TYPE', accountline.payment_type) %]
46
                                [%- END =%]
47
                                [%- IF accountline.description -%]
48
                                    , [% accountline.description %]
49
                                [%- END -%]
50
51
                                &nbsp;
52
                                [% IF ( accountline.itemnumber ) %]
53
                                    <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% accountline.biblionumber %]&amp;itemnumber=[% accountline.itemnumber %]">[% accountline.title |html %]</a>
54
                                [% END %]
55
                            </td>
56
57
                            <td>
58
                                [% accountline.note | html_line_break %]
59
                            </td>
60
61
                            <td>
62
                                [% accountline.amount | $Price %]
63
                            </td>
64
65
                            <td>
66
                                [% accountline.amountoutstanding | $Price %]
67
                            </td>
68
                        </tr>
69
                    </tbody>
70
                </table>
71
72
                [% IF type == 'credit' %]
73
                    <h3>Fees paid</h3>
74
                [% ELSIF type == 'debit' %]
75
                    <h3>Payments</h3>
76
                [% END %]
77
78
                [% IF account_offsets %]
79
                    <table class="accountline-offsets-table" id="accountline-debits-table">
80
                        <thead>
81
                            <tr>
82
                                <th>Date created</th>
83
                                <th>Date updated</th>
84
                                <th>Amount</th>
85
                                <th>Amount outstanding</th>
86
                                <th>Type</th>
87
                                <th>Note</th>
88
                                <th>Transacting<br/>librarian id</th>
89
                                <th>Date/Time of change</th>
90
                                <th>Amount of change</th>
91
                                <th>Type of change</th>
92
                                <th>&nbsp;</th>
93
                            </tr>
94
                        </thead>
95
96
                        <tbody>
97
                            [% FOREACH ao IN account_offsets.sort('created_on') %]
98
                                [% IF type == 'credit' %]
99
                                    [% SET offset_accountline = ao.debit %]
100
                                [% ELSIF type == 'debit' %]
101
                                    [% SET offset_accountline = ao.credit %]
102
                                [% END %]
103
104
                                [% IF offset_accountline %]
105
                                    <tr>
106
                                        <td>[% offset_accountline.date | $KohaDates %]</td>
107
                                        <td>[% offset_accountline.timestamp | $KohaDates with_hours => 1 %]</td>
108
                                        <td>[% offset_accountline.amount | $Price %]</td>
109
                                        <td>[% offset_accountline.amountoutstanding | $Price %]</td>
110
                                        <td>[% INCLUDE 'accounttype.inc' accountline => offset_accountline %]</td>
111
                                        <td>[% offset_accountline.note %]</td>
112
                                        <td>[% IF offset_accountline.manager_id %]<a href="moremember.pl?borrowernumber=[% offset_accountline.manager_id %]">[% offset_accountline.manager_id %]</a>[% END %]</td>
113
                                        <td>[% ao.created_on | $KohaDates with_hours => 1 %]</td>
114
                                        <td>[% ao.amount | $Price %]</td>
115
                                        <td>[% INCLUDE 'account_offset_type.inc' account_offset => ao %]</td>
116
                                        <td><a href="accountline-details.pl?accountlines_id=[% offset_accountline.id %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a></td>
117
                                    </tr>
118
                                [% END %]
119
                            [% END %]
120
                        </tbody>
121
                    </table>
122
                [% ELSE %]
123
                    No details available for this payment.
124
                [% END %]
125
            [% ELSE %]
126
                <div class="dialog message">
127
                    <p>Account line not found.</p>
128
                </div>
129
            [% END %]
130
        </div>
131
    </div>
132
133
    <div class="yui-b">
134
        [% INCLUDE 'circ-menu.inc' %]
135
    </div>
136
</div>
137
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-24 / +2 lines)
Lines 56-85 Link Here
56
   <tr>
56
   <tr>
57
   <td><span title="[% account.date %]">[% account.date |$KohaDates %]</span></td>
57
   <td><span title="[% account.date %]">[% account.date |$KohaDates %]</span></td>
58
      <td>
58
      <td>
59
        [% SWITCH account.accounttype %]
59
        [% INCLUDE 'accounttype.inc' accountline => account %]
60
          [% CASE 'Pay' %]Payment, thanks
61
          [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
62
          [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
63
          [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
64
          [% CASE 'VOID' %]Payment, voided
65
          [% CASE 'N' %]New card
66
          [% CASE 'F' %]Fine
67
          [% CASE 'A' %]Account management fee
68
          [% CASE 'M' %]Sundry
69
          [% CASE 'L' %]Lost item
70
          [% CASE 'W' %]Writeoff
71
          [% CASE 'FU' %]Accruing fine
72
          [% CASE 'HE' %]Hold waiting too long
73
          [% CASE 'Rent' %]Rental fee
74
          [% CASE 'FOR' %]Forgiven
75
          [% CASE 'LR' %]Lost item fee refund
76
          [% CASE 'PF' %]Processing fee
77
          [% CASE 'PAY' %]Payment
78
          [% CASE 'WO' %]Writeoff
79
          [% CASE 'C' %]Credit
80
          [% CASE 'CR' %]Credit
81
          [% CASE %][% account.accounttype %]
82
        [%- END -%]
83
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
60
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
84
        [%- IF account.description %], [% account.description %][% END %]
61
        [%- IF account.description %], [% account.description %][% END %]
85
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
62
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
Lines 92-97 Link Here
92
        [% ELSE %]
69
        [% ELSE %]
93
          <a target="_blank" href="printinvoice.pl?action=print&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print</a>
70
          <a target="_blank" href="printinvoice.pl?action=print&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print</a>
94
        [% END %]
71
        [% END %]
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>
95
        [% IF ( reverse_col) %]
73
        [% IF ( reverse_col) %]
96
          [% IF ( account.payment ) %]
74
          [% IF ( account.payment ) %]
97
            <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>
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>
(-)a/members/accountline-details.pl (+66 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 ByWater Solutions
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI;
23
use C4::Auth;
24
use C4::Output;
25
use C4::Context;
26
use C4::Members qw( GetMember );
27
use Koha::Account::Lines;
28
29
my $input = new CGI;
30
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => "members/accountline-details.tt",
34
        query           => $input,
35
        type            => "intranet",
36
        authnotrequired => 0,
37
        flagsrequired   => {
38
            borrowers     => 1,
39
            updatecharges => 'remaining_permissions'
40
        },
41
    }
42
);
43
44
my $accountlines_id = $input->param('accountlines_id');
45
46
my $accountline = Koha::Account::Lines->find($accountlines_id);
47
48
if ($accountline) {
49
    my $type = $accountline->amount < 0 ? 'credit' : 'debit';
50
    my $column = $type eq 'credit' ? 'credit_id' : 'debit_id';
51
52
    my @account_offsets = Koha::Account::Offsets->search( { $column => $accountlines_id } );
53
54
    $template->param(
55
        type            => $type,
56
        accountline     => $accountline,
57
        account_offsets => \@account_offsets,
58
59
        finesview => 1,
60
    );
61
62
    my $data = GetMember( 'borrowernumber' => $accountline->borrowernumber );
63
    $template->param(%$data);
64
}
65
66
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/t/db_dependent/Accounts.t (-2 / +7 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 => 14;
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 876-881 subtest "Koha::Account::Line::void tests" => sub { Link Here
876
            amount => 30,
876
            amount => 30,
877
        }
877
        }
878
    );
878
    );
879
880
    # Test debit and credit methods fo Koha::Account::Offset
881
    my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } );
882
    is( $account_offset->debit->id, $line1->id, "Koha::Account::Offset->debit gets correct accountline" );
883
    is( $account_offset->credit->id, $id, "Koha::Account::Offset->credit gets correct accountline" );
884
879
    my $account_payment = Koha::Account::Lines->find( $id );
885
    my $account_payment = Koha::Account::Lines->find( $id );
880
886
881
    is( $account->balance(), 0, "Account balance is 0" );
887
    is( $account->balance(), 0, "Account balance is 0" );
882
- 

Return to bug 2696