From aa119dfa4bedd8cc82f80ffd1765a20b2ab70b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nazl=C4=B1=20=C3=87etin?= Date: Mon, 19 Nov 2018 17:00:12 +0000 Subject: [PATCH] Bug 19489 - (Object Method) Development for fines and Fees Module - Detailed Description of charges in Patron Account Tab/Fines Tab --- Koha/Account/Line.pm | 14 ++++++ admin/columns_settings.yml | 6 +++ .../prog/en/modules/members/accountline-details.tt | 18 ++++++++ .../prog/en/modules/members/boraccount.tt | 8 +++- .../intranet-tmpl/prog/en/modules/members/pay.tt | 24 +++++++++- .../prog/en/modules/members/printinvoice.tt | 16 +++++-- members/pay.pl | 13 ++++-- members/printinvoice.pl | 5 +- t/db_dependent/Koha/Account/Lines.t | 54 +++++++++++++++++++++- 9 files changed, 146 insertions(+), 12 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 3573e604e6..5150fa5139 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -51,6 +51,20 @@ sub item { return Koha::Item->_new_from_dbic( $rs ); } +=head3 issue + +Return the issue linked to this account line if exists + +=cut + +sub issue { + my ( $self ) = @_; + my $rs = $self->_result->issue_id; + my $issue = Koha::Checkouts->find( $rs ); + $issue = Koha::Old::Checkouts->find( $rs ) unless $issue; + return $issue; +} + =head3 void $payment_accountline->void(); diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index eacc02bdd8..a392d55859 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -305,6 +305,12 @@ modules: - columnname: description - + columnname: barcode + - + columnname: date_due + - + columnname: returndate + - columnname: note - columnname: amount diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt index ae66f7ed52..d1df40713e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt @@ -31,6 +31,9 @@ Date Description of charges + Barcode + Due date + Return date Note Amount Outstanding @@ -59,6 +62,21 @@ + [% IF ( accountline.itemnumber ) %] + [% accountline.item.barcode | html %] + [% END %] + + + [% IF ( accountline.issue_id ) %] + [% accountline.issue.date_due | $KohaDates with_hours => 1 | html %] + [% END %] + + + [% IF ( accountline.issue_id ) %] + [% accountline.issue.returndate | $KohaDates with_hours => 1 | html %] + [% END %] + + [% accountline.note | html_line_break %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index e9680a5c55..c1ac655667 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -46,6 +46,9 @@ Date Description of charges + Barcode + Due date + Return date Home library Note Amount @@ -64,6 +67,9 @@ [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) | html %][% END %] [%- IF account.description %], [% account.description | html %][% END %]  [% IF ( account.itemnumber ) %][% account.item.biblio.title | html %][% END %] + [% IF ( account.itemnumber ) %][% account.item.barcode | html %][% END %] + [% IF ( account.issue_id ) %][% account.issue.date_due | $KohaDates with_hours => 1 | html %][% END %] + [% IF ( account.issue_id ) %][% account.issue.returndate | $KohaDates with_hours => 1 | html %][% END %] [% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %] [% account.note | html_line_break %] [% IF account.amount <= 0 %][% ELSE %][% END %][% account.amount | $Price %] @@ -84,7 +90,7 @@ [% END %] - Total due + Total due [% IF ( totalcredit ) %] [% total | $Price %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index cb49492a94..636964691d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -1,6 +1,7 @@ [% USE raw %] [% USE Asset %] [% USE Koha %] +[% USE KohaDates %] [% USE AuthorisedValues %] [% USE Branches %] [% USE Price %] @@ -43,6 +44,9 @@   Fines & charges Description + Barcode + Due date + Return date Payment note Account type Amount @@ -51,7 +55,7 @@ - Total due: + Total due: [% total | $Price %] @@ -70,6 +74,9 @@ [% END %] + + + @@ -103,6 +110,21 @@ [%- IF line.description %], [% line.description | html %][% END %] [% IF line.title %]([% line.title | html %])[% END %] + + [% IF line.itemnumber %] + [% line.item.barcode | html %] + [% END %] + + + [% IF line.issue_id %] + [% line.issue.date_due | $KohaDates with_hours => 1 | html %] + [% END %] + + + [% IF line.issue_id %] + [% line.issue.returndate | $KohaDates with_hours => 1 | html %] + [% END %] + [% line.accounttype | html %] [% line.amount | $Price %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt index a28ac03e34..1e28356c48 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt @@ -21,23 +21,23 @@ [% IF ( LibraryName ) %] - [% END %] - - - @@ -45,6 +45,9 @@ + + + @@ -57,6 +60,9 @@ [% PROCESS account_type_description account=account %] [%- IF account.description %], [% account.description | html %][% END %] + + + [% IF ( account.amountcredit ) %] [% IF ( account.amountoutstandingcredit ) %] @@ -65,7 +71,7 @@ [% END %] - + [% IF ( totalcredit ) %] diff --git a/members/pay.pl b/members/pay.pl index b2216aa511..0cf13ba08e 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -141,13 +141,17 @@ sub add_accounts_to_template { my $account_lines = $patron->account->outstanding_debits; my $total = $account_lines->total_outstanding; my @accounts; - while ( my $account_line = $account_lines->next ) { - $account_line = $account_line->unblessed; + while ( my $account_line_object = $account_lines->next ) { + my $account_line = $account_line_object->unblessed; if ( $account_line->{itemnumber} ) { - my $item = Koha::Items->find( $account_line->{itemnumber} ); + my $item = $account_line_object->item; my $biblio = $item->biblio; $account_line->{biblionumber} = $biblio->biblionumber; $account_line->{title} = $biblio->title; + $account_line->{item} = $item; + } + if ( $account_line->{issue_id} ) { + $account_line->{issue} = $account_line_object->issue; } push @accounts, $account_line; } @@ -191,6 +195,9 @@ sub redirect_to_paycollect { $redirect .= get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 ); $redirect .= get_for_redirect( 'description', "description$line_no", 0 ); + $redirect .= get_for_redirect( 'barcode', "barcode$line_no", 0 ); + $redirect .= get_for_redirect( 'date_due', "date_due$line_no", 0 ); + $redirect .= get_for_redirect( 'returndate', "returndate$line_no", 0 ); $redirect .= get_for_redirect( 'title', "title$line_no", 0 ); $redirect .= get_for_redirect( 'itemnumber', "itemnumber$line_no", 0 ); $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 ); diff --git a/members/printinvoice.pl b/members/printinvoice.pl index a6d92f7e3a..25b3d7e026 100755 --- a/members/printinvoice.pl +++ b/members/printinvoice.pl @@ -55,7 +55,10 @@ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log #get account details my $total = $patron->account->balance; -my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed; +my $accountline_object = Koha::Account::Lines->find($accountlines_id); +my $accountline = $accountline_object->unblessed; +$accountline->{'item'} = $accountline->{itemnumber} ? $accountline_object->item : "" ; +$accountline->{'issue'} = $accountline->{issue_id} ? $accountline_object->issue : "" ; my $totalcredit; if ( $total <= 0 ) { diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index eb8dfdd1c0..ee6228f6a3 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Exception; use Koha::Account; @@ -268,3 +268,55 @@ subtest 'apply() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'issue() tests' => sub { + + plan tests => 5; + + $schema->storage->txn_begin; + + my $library = $builder->build( { source => 'Branch' } ); + my $biblioitem = $builder->build( { source => 'Biblioitem' } ); + my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; + my $patron = Koha::Patron->new( { + cardnumber => 'kohadevinim', + surname => 'CETIN', + firstname => 'Nazli', + branchcode => $library->{branchcode}, + categorycode => $categorycode + } )->store; + + my $item = $builder->build( { source => 'Item' } ); + + my $checkout = Koha::Checkout->new( + { borrowernumber => $patron->borrowernumber, + itemnumber => $item->{itemnumber}, + branchcode => $library->{branchcode}, + })->store; + + my $line = Koha::Account::Line->new( + { + borrowernumber => $patron->borrowernumber, + itemnumber => $item->{itemnumber}, + issue_id => $checkout->issue_id, + accounttype => "F", + amount => 10, + })->store; + + my $line_issue = $line->issue; + + is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue' ); + + my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} ); + + is( $returned, 1, 'The item should have been returned' ); + + my $old_line = Koha::Account::Lines->find( $line->id ); + my $old_line_issue = $old_line->issue; + + is( $old_checkout->issue_id, $old_line_issue->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' ); + is( $old_line_issue->issue_id, $old_line->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' ); + is( $old_checkout->issue_id, $old_line->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' ); + + $schema->storage->txn_rollback; +}; -- 2.11.0
+

[% LibraryName | html %]

+

INVOICE

+

[% Branches.GetName( patron.branchcode ) | html %]

+ Bill to: [% patron.firstname | html %] [% patron.surname | html %]
Card number: [% patron.cardnumber | html %]
Date Description of chargesBarcodeDue dateReturn date Note Amount Amount outstanding[% account.item.barcode | html %][% account.issue.date_due | $KohaDates with_hours => 1 | html %][% account.issue.returndate | $KohaDates with_hours => 1 | html %] [% account.note | html %][% ELSE %][% END %][% account.amount | $Price %][% ELSE %][% END %][% account.amountoutstanding | $Price %]
Total outstanding dues as on date: Total outstanding dues as on date: [% ELSE %][% END %][% total | $Price %]