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

(-)a/Koha/Account/Line.pm (+14 lines)
Lines 51-56 sub item { Link Here
51
    return Koha::Item->_new_from_dbic( $rs );
51
    return Koha::Item->_new_from_dbic( $rs );
52
}
52
}
53
53
54
=head3 issue
55
56
Return the issue linked to this account line if exists
57
58
=cut
59
60
sub issue {
61
    my ( $self ) = @_;
62
    my $rs = $self->_result->issue_id;
63
    my $issue = Koha::Checkouts->find( $rs );
64
    $issue = Koha::Old::Checkouts->find( $rs ) unless $issue;
65
    return $issue;
66
}
67
54
=head3 void
68
=head3 void
55
69
56
$payment_accountline->void();
70
$payment_accountline->void();
(-)a/admin/columns_settings.yml (+6 lines)
Lines 305-310 modules: Link Here
305
        -
305
        -
306
          columnname: description
306
          columnname: description
307
        -
307
        -
308
          columnname: barcode
309
        -
310
          columnname: date_due
311
        -
312
          columnname: returndate
313
        -
308
          columnname: note
314
          columnname: note
309
        -
315
        -
310
          columnname: amount
316
          columnname: amount
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt (+18 lines)
Lines 31-36 Link Here
31
                        <tr>
31
                        <tr>
32
                            <th class="title-string">Date</th>
32
                            <th class="title-string">Date</th>
33
                            <th>Description of charges</th>
33
                            <th>Description of charges</th>
34
                            <th>Barcode</th>
35
                            <th>Due date</th>
36
                            <th>Return date</th>
34
                            <th>Note</th>
37
                            <th>Note</th>
35
                            <th>Amount</th>
38
                            <th>Amount</th>
36
                            <th>Outstanding</th>
39
                            <th>Outstanding</th>
Lines 59-64 Link Here
59
                            </td>
62
                            </td>
60
63
61
                            <td>
64
                            <td>
65
                                [% IF ( accountline.itemnumber ) %]
66
                                    <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% accountline.item.biblionumber | uri %]&amp;itemnumber=[% accountline.itemnumber | uri %]#item[% accountline.itemnumber | uri %]">[% accountline.item.barcode | html %]</a>
67
                                [% END %]
68
                            </td>
69
                            <td>
70
                                [% IF ( accountline.issue_id ) %]
71
                                    [% accountline.issue.date_due | $KohaDates with_hours => 1 | html %]
72
                                [% END %]
73
                            </td>
74
                            <td>
75
                                [% IF ( accountline.issue_id ) %]
76
                                    [% accountline.issue.returndate | $KohaDates with_hours => 1 | html %]
77
                                [% END %]
78
                            </td>
79
                            <td>
62
                                [% accountline.note | html_line_break %]
80
                                [% accountline.note | html_line_break %]
63
                            </td>
81
                            </td>
64
82
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-1 / +7 lines)
Lines 46-51 Link Here
46
      <tr>
46
      <tr>
47
          <th class="title-string">Date</th>
47
          <th class="title-string">Date</th>
48
          <th>Description of charges</th>
48
          <th>Description of charges</th>
49
          <th>Barcode</th>
50
          <th>Due date</th>
51
          <th>Return date</th>
49
          <th>Home library</th>
52
          <th>Home library</th>
50
          <th>Note</th>
53
          <th>Note</th>
51
          <th>Amount</th>
54
          <th>Amount</th>
Lines 64-69 Link Here
64
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) | html %][% END %]
67
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) | html %][% END %]
65
        [%- IF account.description %], [% account.description | html %][% END %]
68
        [%- IF account.description %], [% account.description | html %][% END %]
66
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber | uri %]&amp;itemnumber=[% account.itemnumber | uri %]">[% account.item.biblio.title | html %]</a>[% END %]</td>
69
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber | uri %]&amp;itemnumber=[% account.itemnumber | uri %]">[% account.item.biblio.title | html %]</a>[% END %]</td>
70
      <td>[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% account.itemnumber | uri %]&amp;biblionumber=[% account.item.biblionumber | uri %]#item[% account.itemnumber | uri %]">[% account.item.barcode | html %]</a>[% END %]</td>
71
      <td>[% IF ( account.issue_id ) %][% account.issue.date_due | $KohaDates with_hours => 1 | html %][% END %]</td>
72
      <td>[% IF ( account.issue_id ) %][% account.issue.returndate | $KohaDates with_hours => 1 | html %][% END %]</td>
67
      <td>[% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %]</td>
73
      <td>[% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %]</td>
68
      <td>[% account.note | html_line_break %]</td>
74
      <td>[% account.note | html_line_break %]</td>
69
      [% IF account.amount <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount | $Price %]</td>
75
      [% IF account.amount <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount | $Price %]</td>
Lines 84-90 Link Here
84
  [% END %]
90
  [% END %]
85
<tfoot>
91
<tfoot>
86
  <tr>
92
  <tr>
87
    <td colspan="5">Total due</td>
93
    <td colspan="8">Total due</td>
88
    [% IF ( totalcredit ) %]
94
    [% IF ( totalcredit ) %]
89
        <td class="credit" style="text-align: right;">[% total | $Price %]</td>
95
        <td class="credit" style="text-align: right;">[% total | $Price %]</td>
90
    [% ELSE %]
96
    [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (-1 / +23 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
5
[% USE Branches %]
6
[% USE Branches %]
6
[% USE Price %]
7
[% USE Price %]
Lines 43-48 Link Here
43
    <th>&nbsp;</th>
44
    <th>&nbsp;</th>
44
    <th>Fines &amp; charges</th>
45
    <th>Fines &amp; charges</th>
45
    <th>Description</th>
46
    <th>Description</th>
47
    <th>Barcode</th>
48
    <th>Due date</th>
49
    <th>Return date</th>
46
    <th>Payment note</th>
50
    <th>Payment note</th>
47
    <th>Account type</th>
51
    <th>Account type</th>
48
    <th>Amount</th>
52
    <th>Amount</th>
Lines 51-57 Link Here
51
</thead>
55
</thead>
52
<tfoot>
56
<tfoot>
53
<tr>
57
<tr>
54
    <td class="total" colspan="6">Total due:</td>
58
    <td class="total" colspan="9">Total due:</td>
55
    <td style="text-align: right;">[% total | $Price %]</td>
59
    <td style="text-align: right;">[% total | $Price %]</td>
56
</tr>
60
</tr>
57
</tfoot>
61
</tfoot>
Lines 70-75 Link Here
70
    [% END %]
74
    [% END %]
71
    <input type="hidden" name="itemnumber[% line.accountlines_id | html %]" value="[% line.itemnumber | html %]" />
75
    <input type="hidden" name="itemnumber[% line.accountlines_id | html %]" value="[% line.itemnumber | html %]" />
72
    <input type="hidden" name="description[% line.accountlines_id | html %]" value="[% line.description | html %]" />
76
    <input type="hidden" name="description[% line.accountlines_id | html %]" value="[% line.description | html %]" />
77
    <input type="hidden" name="barcode[% line.accountlines_id | html %]" value="[% line.item.barcode | html %]" />
78
    <input type="hidden" name="date_due[% line.accountlines_id | html %]" value="[% line.issue.date_due | html %]" />
79
    <input type="hidden" name="returndate[% line.accountlines_id | html %]" value="[% line.issue.returndate | html %]" />
73
    <input type="hidden" name="accounttype[% line.accountlines_id | html %]" value="[% line.accounttype | html %]" />
80
    <input type="hidden" name="accounttype[% line.accountlines_id | html %]" value="[% line.accounttype | html %]" />
74
    <input type="hidden" name="amount[% line.accountlines_id | html %]" value="[% line.amount | html %]" />
81
    <input type="hidden" name="amount[% line.accountlines_id | html %]" value="[% line.amount | html %]" />
75
    <input type="hidden" name="accountlines_id[% line.accountlines_id | html %]" value="[% line.accountlines_id | html %]" />
82
    <input type="hidden" name="accountlines_id[% line.accountlines_id | html %]" value="[% line.accountlines_id | html %]" />
Lines 103-108 Link Here
103
        [%- IF line.description %], [% line.description | html %][% END %]
110
        [%- IF line.description %], [% line.description | html %][% END %]
104
        [% IF line.title %]([% line.title | html %])[% END %]
111
        [% IF line.title %]([% line.title | html %])[% END %]
105
    </td>
112
    </td>
113
    <td>
114
        [% IF line.itemnumber %]
115
            <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% line.itemnumber | uri %]&amp;biblionumber=[% line.biblionumber | uri %]#item[% line.itemnumber | uri %]">[% line.item.barcode | html %]</a>
116
        [% END %]
117
    </td>
118
    <td>
119
        [% IF line.issue_id %]
120
            [% line.issue.date_due | $KohaDates with_hours => 1 | html %]
121
        [% END %]
122
    </td>
123
    <td>
124
        [% IF line.issue_id %]
125
            [% line.issue.returndate | $KohaDates with_hours => 1 | html %]
126
        [% END %]
127
    </td>
106
    <td><input type="text" name="payment_note_[% line.accountlines_id | html %]" /></td>
128
    <td><input type="text" name="payment_note_[% line.accountlines_id | html %]" /></td>
107
    <td>[% line.accounttype | html %]</td>
129
    <td>[% line.accounttype | html %]</td>
108
    <td class="debit" style="text-align: right;">[% line.amount | $Price %]</td>
130
    <td class="debit" style="text-align: right;">[% line.amount | $Price %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt (-5 / +11 lines)
Lines 21-43 Link Here
21
<table>
21
<table>
22
[% IF ( LibraryName ) %]
22
[% IF ( LibraryName ) %]
23
  <tr>
23
  <tr>
24
    <th colspan="5" class="centerednames">
24
    <th colspan="8" class="centerednames">
25
		<h3>[% LibraryName | html %]</h3>
25
		<h3>[% LibraryName | html %]</h3>
26
	</th>
26
	</th>
27
  </tr>
27
  </tr>
28
[% END %]
28
[% END %]
29
  <tr>
29
  <tr>
30
    <th colspan="5" class="centerednames">
30
    <th colspan="8" class="centerednames">
31
		<h2><u>INVOICE</u></h2>
31
		<h2><u>INVOICE</u></h2>
32
	</th>
32
	</th>
33
  </tr>
33
  </tr>
34
  <tr>
34
  <tr>
35
    <th colspan="5" class="centerednames">
35
    <th colspan="8" class="centerednames">
36
        <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
36
        <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
37
	</th>
37
	</th>
38
  </tr>
38
  </tr>
39
  <tr>
39
  <tr>
40
    <th colspan="5" >
40
    <th colspan="8" >
41
        Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
41
        Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
42
        Card number: [% patron.cardnumber | html %]<br />
42
        Card number: [% patron.cardnumber | html %]<br />
43
	</th>
43
	</th>
Lines 45-50 Link Here
45
  <tr>
45
  <tr>
46
	<th>Date</th>
46
	<th>Date</th>
47
    <th>Description of charges</th>
47
    <th>Description of charges</th>
48
    <th>Barcode</th>
49
    <th>Due date</th>
50
    <th>Return date</th>
48
    <th>Note</th>
51
    <th>Note</th>
49
    <th style="text-align:right;">Amount</th>
52
    <th style="text-align:right;">Amount</th>
50
    <th style="text-align:right;">Amount outstanding</th>
53
    <th style="text-align:right;">Amount outstanding</th>
Lines 57-62 Link Here
57
        [% PROCESS account_type_description account=account %]
60
        [% PROCESS account_type_description account=account %]
58
        [%- IF account.description %], [% account.description | html %][% END %]
61
        [%- IF account.description %], [% account.description | html %][% END %]
59
      </td>
62
      </td>
63
      <td>[% account.item.barcode | html %]</td>
64
      <td>[% account.issue.date_due | $KohaDates with_hours => 1 | html %]</td>
65
      <td>[% account.issue.returndate | $KohaDates with_hours => 1 | html %]</td>
60
      <td>[% account.note | html %]</td>
66
      <td>[% account.note | html %]</td>
61
      [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
67
      [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
62
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
68
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
Lines 65-71 Link Here
65
  [% END %]
71
  [% END %]
66
<tfoot>
72
<tfoot>
67
  <tr>
73
  <tr>
68
    <td colspan="4">Total outstanding dues as on date: </td>
74
    <td colspan="7">Total outstanding dues as on date: </td>
69
    [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
75
    [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
70
  </tr>
76
  </tr>
71
  </tfoot>
77
  </tfoot>
(-)a/members/pay.pl (-3 / +10 lines)
Lines 141-153 sub add_accounts_to_template { Link Here
141
    my $account_lines = $patron->account->outstanding_debits;
141
    my $account_lines = $patron->account->outstanding_debits;
142
    my $total = $account_lines->total_outstanding;
142
    my $total = $account_lines->total_outstanding;
143
    my @accounts;
143
    my @accounts;
144
    while ( my $account_line = $account_lines->next ) {
144
    while ( my $account_line_object = $account_lines->next ) {
145
        $account_line = $account_line->unblessed;
145
        my $account_line = $account_line_object->unblessed;
146
        if ( $account_line->{itemnumber} ) {
146
        if ( $account_line->{itemnumber} ) {
147
            my $item = Koha::Items->find( $account_line->{itemnumber} );
147
            my $item = $account_line_object->item;
148
            my $biblio = $item->biblio;
148
            my $biblio = $item->biblio;
149
            $account_line->{biblionumber} = $biblio->biblionumber;
149
            $account_line->{biblionumber} = $biblio->biblionumber;
150
            $account_line->{title}        = $biblio->title;
150
            $account_line->{title}        = $biblio->title;
151
            $account_line->{item} = $item;
152
        }
153
        if ( $account_line->{issue_id} ) {
154
            $account_line->{issue} = $account_line_object->issue;
151
        }
155
        }
152
        push @accounts, $account_line;
156
        push @accounts, $account_line;
153
    }
157
    }
Lines 191-196 sub redirect_to_paycollect { Link Here
191
    $redirect .=
195
    $redirect .=
192
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
196
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
193
    $redirect .= get_for_redirect( 'description', "description$line_no", 0 );
197
    $redirect .= get_for_redirect( 'description', "description$line_no", 0 );
198
    $redirect .= get_for_redirect( 'barcode', "barcode$line_no", 0 );
199
    $redirect .= get_for_redirect( 'date_due', "date_due$line_no", 0 );
200
    $redirect .= get_for_redirect( 'returndate', "returndate$line_no", 0 );
194
    $redirect .= get_for_redirect( 'title', "title$line_no", 0 );
201
    $redirect .= get_for_redirect( 'title', "title$line_no", 0 );
195
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
202
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
196
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
203
    $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 );
(-)a/members/printinvoice.pl (-1 / +4 lines)
Lines 55-61 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log Link Here
55
55
56
#get account details
56
#get account details
57
my $total = $patron->account->balance;
57
my $total = $patron->account->balance;
58
my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed;
58
my $accountline_object = Koha::Account::Lines->find($accountlines_id);
59
my $accountline = $accountline_object->unblessed;
60
$accountline->{'item'} = $accountline->{itemnumber} ? $accountline_object->item : "" ;
61
$accountline->{'issue'} = $accountline->{issue_id} ? $accountline_object->issue : "" ;
59
62
60
my $totalcredit;
63
my $totalcredit;
61
if ( $total <= 0 ) {
64
if ( $total <= 0 ) {
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +53 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Account;
25
use Koha::Account;
Lines 268-270 subtest 'apply() tests' => sub { Link Here
268
268
269
    $schema->storage->txn_rollback;
269
    $schema->storage->txn_rollback;
270
};
270
};
271
- 
271
272
subtest 'issue() tests' => sub {
273
274
    plan tests => 5;
275
276
    $schema->storage->txn_begin;
277
278
    my $library = $builder->build( { source => 'Branch' } );
279
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
280
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
281
    my $patron = Koha::Patron->new( {
282
            cardnumber => 'kohadevinim',
283
            surname => 'CETIN',
284
            firstname => 'Nazli',
285
            branchcode => $library->{branchcode},
286
            categorycode => $categorycode
287
        } )->store;
288
289
    my $item          = $builder->build( { source => 'Item' } );
290
291
    my $checkout  = Koha::Checkout->new(
292
        {   borrowernumber => $patron->borrowernumber,
293
            itemnumber     => $item->{itemnumber},
294
            branchcode     => $library->{branchcode},
295
        })->store;
296
297
    my $line = Koha::Account::Line->new(
298
        {
299
            borrowernumber  => $patron->borrowernumber,
300
            itemnumber      => $item->{itemnumber},
301
            issue_id        => $checkout->issue_id,
302
            accounttype     => "F",
303
            amount          => 10,
304
        })->store;
305
306
    my $line_issue = $line->issue;
307
308
    is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue' );
309
310
    my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} );
311
312
    is( $returned, 1, 'The item should have been returned' );
313
314
    my $old_line = Koha::Account::Lines->find( $line->id );
315
    my $old_line_issue = $old_line->issue;
316
317
    is( $old_checkout->issue_id, $old_line_issue->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
318
    is( $old_line_issue->issue_id, $old_line->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
319
    is( $old_checkout->issue_id, $old_line->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' );
320
321
    $schema->storage->txn_rollback;
322
};

Return to bug 19489