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

(-)a/Koha/Patron.pm (+16 lines)
Lines 1207-1212 sub get_overdues { Link Here
1207
    );
1207
    );
1208
}
1208
}
1209
1209
1210
sub overdues { my $self = shift; return $self->get_overdues(@_); }
1211
1210
=head3 get_routing_lists
1212
=head3 get_routing_lists
1211
1213
1212
my $routinglists = $patron->get_routing_lists
1214
my $routinglists = $patron->get_routing_lists
Lines 2063-2068 sub recalls { Link Here
2063
    return Koha::Recalls->search({ borrowernumber => $self->borrowernumber });
2065
    return Koha::Recalls->search({ borrowernumber => $self->borrowernumber });
2064
}
2066
}
2065
2067
2068
=head3 account_balance
2069
2070
    my $balance = $patron->account_balance
2071
2072
Return the patron's account balance
2073
2074
=cut
2075
2076
sub account_balance {
2077
    my ($self) = @_;
2078
    return $self->account->balance;
2079
}
2080
2081
2066
=head2 Internal methods
2082
=head2 Internal methods
2067
2083
2068
=head3 _type
2084
=head3 _type
(-)a/api/v1/swagger/definitions/patron.yaml (+10 lines)
Lines 349-354 properties: Link Here
349
      - integer
349
      - integer
350
      - "null"
350
      - "null"
351
    description: Number of checkouts
351
    description: Number of checkouts
352
  overdues_count:
353
    type:
354
      - integer
355
      - "null"
356
    description: Number of overdued checkouts
357
  account_balance:
358
    type:
359
      - number
360
      - "null"
361
    description: Balance of the patron's account
352
additionalProperties: false
362
additionalProperties: false
353
required:
363
required:
354
  - surname
364
  - surname
(-)a/api/v1/swagger/paths/patrons.yaml (+2 lines)
Lines 386-391 Link Here
386
    x-koha-embed:
386
    x-koha-embed:
387
      - extended_attributes
387
      - extended_attributes
388
      - checkouts+count
388
      - checkouts+count
389
      - overdues+count
390
      - account_balance
389
  post:
391
  post:
390
    x-mojo-to: Patrons#add
392
    x-mojo-to: Patrons#add
391
    operationId: addPatron
393
    operationId: addPatron
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-3 / +29 lines)
Lines 106-111 Link Here
106
                            [% CASE 'borrowernotes' %]<th>Notes</th>
106
                            [% CASE 'borrowernotes' %]<th>Notes</th>
107
                            [% CASE 'phone' %]<th>Phone</th>
107
                            [% CASE 'phone' %]<th>Phone</th>
108
                            [% CASE 'checkouts' %]<th>Checkouts</th>
108
                            [% CASE 'checkouts' %]<th>Checkouts</th>
109
                            [% CASE 'account_balance' %]<th>Fines</th>
109
                            [% CASE 'action' %]<th>&nbsp;</th>
110
                            [% CASE 'action' %]<th>&nbsp;</th>
110
                        [% END %]
111
                        [% END %]
111
                    [% END %]
112
                    [% END %]
Lines 385-399 Link Here
385
                                    return escape_str(data);
386
                                    return escape_str(data);
386
                                }
387
                                }
387
                            }
388
                            }
388
                            [% CASE 'checkouts' %][% embed.push('checkouts+count') %]
389
                            [% CASE 'checkouts' %][% embed.push('checkouts+count', 'overdues+count') %]
389
                            {
390
                            {
390
                                "data": "",
391
                                "data": "",
391
                                "searchable": false,
392
                                "searchable": false,
392
                                "orderable": false,
393
                                "orderable": false,
393
                                "render": function( data, type, row, meta ) {
394
                                "render": function( data, type, row, meta ) {
394
                                    return escape_str(row.checkouts_count);
395
                                    if ( row.overdues_count ) {
396
                                        return "<span class='overdue'><strong>"+row.overdues_count + "</strong></span>";
397
                                    } else {
398
                                        return "0 / " + row.checkouts_count;
399
                                    }
395
                                }
400
                                }
396
                            }
401
                            }
402
                            [% CASE 'account_balance' %][% embed.push('account_balance') %]
403
                            {
404
                                "data": "",
405
                                "searchable": false,
406
                                "orderable": false,
407
                                "render": function( data, type, row, meta ) {
408
                                    let r = "<span style='text-align: right; display: block;'><a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber="+row.patron_id+"\">";
409
                                    let balance_str = row.account_balance || 0;
410
                                    balance_str = balance_str.escapeHtml().format_price();
411
                                    if ( row.account_balance < 0 ) {
412
                                        // FIXME Format price here
413
                                        r += "<span class='credit'>" + balance_str + "</span>";
414
                                    } else if ( row.account_balance > 0 ) {
415
                                        r += "<span class='debit'><strong>" + balance_str  + "</strong></span>"
416
                                    } else {
417
                                        r += balance_str;
418
                                    }
419
                                    r += "</a></span>";
420
                                    return r;
421
                                }
422
                            }
423
397
                            [% CASE 'action' %]
424
                            [% CASE 'action' %]
398
                            {
425
                            {
399
                                "data": function( row, type, val, meta ) {
426
                                "data": function( row, type, val, meta ) {
400
- 

Return to bug 30063