Fines and charges
+ [% IF credits || debits %]
+
+
+
Account balance: [% borrower.account_balance | $Currency %]
+
+
+
+
+
View payments
+
+
+
+ Fees |
+
+
+ |
+ ID |
+ Description |
+ Type |
+ Amount |
+ Outstanding |
+ Created on |
+ Updated on |
+
+
+
+
+
- [% IF ( ACCOUNT_LINES ) %]
-
-
-
- Date |
- Description |
- Fine amount |
- Amount outstanding |
-
-
-
-
-
- Total due |
- [% total %] |
-
-
-
-
- [% FOREACH ACCOUNT_LINE IN ACCOUNT_LINES %]
- [% IF ( ACCOUNT_LINE.odd ) %][% ELSE %]
[% END %]
- [% ACCOUNT_LINE.date | $KohaDates %] |
-
- [% SWITCH ACCOUNT_LINE.accounttype %]
- [% CASE 'Pay' %]Payment, thanks
- [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
- [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
- [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
- [% CASE 'N' %]New card
- [% CASE 'F' %]Fine
- [% CASE 'A' %]Account management fee
- [% CASE 'M' %]Sundry
- [% CASE 'L' %]Lost item
- [% CASE 'W' %]Writeoff
- [% CASE 'FU' %]Accruing fine
- [% CASE 'Rent' %]Rental fee
- [% CASE 'FOR' %]Forgiven
- [% CASE 'LR' %]Lost item fee refund
- [% CASE 'PAY' %]Payment
- [% CASE 'WO' %]Writeoff
- [% CASE 'C' %]Credit
- [% CASE 'CR' %]Credit
- [% CASE %][% ACCOUNT_LINE.accounttype %]
- [%- END -%]
- [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
- [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
- |
- [% IF ( ACCOUNT_LINE.amountcredit ) %][% ELSE %] | [% END %][% ACCOUNT_LINE.amount %] |
- [% IF ( ACCOUNT_LINE.amountoutstandingcredit ) %][% ELSE %] | [% END %][% ACCOUNT_LINE.amountoutstanding %] |
-
- [% END %]
-
-
-
+
+
View fees
+
+
+
+ Payments |
+
+
+ |
+ ID |
+ Notes |
+ Type |
+ Amount |
+ Remaining |
+ Created on |
+ Updated on |
+
+
+
+
+
+
[% ELSE %]
You have no fines or charges
[% END %]
@@ -90,4 +90,305 @@
[% INCLUDE 'opac-bottom.inc' %]
+
+[% INCLUDE 'datatables.inc' %]
+
+
+
[% BLOCK jsinclude %][% END %]
+
+[% BLOCK format_data %]
+ [% FOREACH key IN data.result_source.columns %]
+ [% IF key.match('^amount') %]
+ "[% key %]": "[% data.$key FILTER $Currency %]",
+ [% ELSIF key.match('_on$') %]
+ "[% key %]": "[% data.$key | $KohaDates %]",
+ [% ELSE %]
+ "[% key %]": "[% data.$key %]",
+ [% END %]
+ [% END %]
+[% END %]
--- a/opac/opac-account.pl
+++ a/opac/opac-account.pl
@@ -18,7 +18,6 @@
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
use strict;
use CGI;
use C4::Members;
@@ -39,40 +38,21 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
-# get borrower information ....
-my $borr = GetMemberDetails( $borrowernumber );
-my @bordat;
-$bordat[0] = $borr;
-
-$template->param( BORROWER_INFO => \@bordat );
-
-#get account details
-my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
-
-for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
- $accts->[$i]{'amount'} = sprintf( "%.2f", $accts->[$i]{'amount'} || '0.00');
- if ( $accts->[$i]{'amount'} >= 0 ) {
- $accts->[$i]{'amountcredit'} = 1;
- }
- $accts->[$i]{'amountoutstanding'} =
- sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} || '0.00' );
- if ( $accts->[$i]{'amountoutstanding'} >= 0 ) {
- $accts->[$i]{'amountoutstandingcredit'} = 1;
- }
-}
+my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
+ { 'me.borrowernumber' => $borrowernumber },
+ { prefetch => { account_offsets => 'credit' } }
+);
-# add the row parity
-my $num = 0;
-foreach my $row (@$accts) {
- $row->{'even'} = 1 if $num % 2 == 0;
- $row->{'odd'} = 1 if $num % 2 == 1;
- $num++;
-}
+my @credits = Koha::Database->new()->schema->resultset('AccountCredit')->search(
+ { 'me.borrowernumber' => $borrowernumber },
+ { prefetch => { account_offsets => 'debit' } }
+);
-$template->param (
- ACCOUNT_LINES => $accts,
- total => sprintf( "%.2f", $total ),
- accountview => 1
+$template->param(
+ borrower => GetMemberDetails($borrowernumber),
+ debits => \@debits,
+ credits => \@credits,
+ accountview => 1
);
output_html_with_http_headers $query, $cookie, $template->output;
--- a/opac/opac-user.pl
+++ a/opac/opac-user.pl
@@ -35,6 +35,7 @@ use C4::Items;
use C4::Letters;
use C4::Branch; # GetBranches
use Koha::DateUtils;
+use Koha::Database;
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
@@ -45,6 +46,7 @@ use Date::Calc qw(
);
my $query = new CGI;
+my $schema = Koha::Database->new()->schema();
BEGIN {
if (C4::Context->preference('BakerTaylorEnabled')) {
@@ -160,6 +162,7 @@ my @overdues;
my @issuedat;
my $itemtypes = GetItemTypes();
my $issues = GetPendingIssues($borrowernumber);
+my $account_debit_rs = $schema->resultset('AccountDebit');
if ($issues){
foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
# check for reserves
@@ -168,19 +171,7 @@ if ($issues){
$issue->{'reserved'} = 1;
}
- my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
- my $charges = 0;
- foreach my $ac (@$accts) {
- if ( $ac->{'itemnumber'} == $issue->{'itemnumber'} ) {
- $charges += $ac->{'amountoutstanding'}
- if $ac->{'accounttype'} eq 'F';
- $charges += $ac->{'amountoutstanding'}
- if $ac->{'accounttype'} eq 'FU';
- $charges += $ac->{'amountoutstanding'}
- if $ac->{'accounttype'} eq 'L';
- }
- }
- $issue->{'charges'} = $charges;
+ $issue->{'charges'} = $account_debit_rs->search({ borrowernumber => $borrowernumber, itemnumber => $issue->{'itemnumber'} })->get_column('amount_outstanding')->sum();
$issue->{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($issue->{'biblionumber'}), GetFrameworkCode($issue->{'biblionumber'}));
# check if item is renewable
my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
--