From 65813c7d466e5309e6eb74b755cae36ad210fe78 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 14 May 2021 15:39:03 +0100 Subject: [PATCH] Bug 22435: Update accountline-details page to show all history The accountline-details page took a simplistic approach to displaying the history of an accountline. This patch drops the now defunct offset_type_description template block from it's respective include files, and then updates the accountline-details template and controller to show the full history of what's happend to the accountline passed. This includes the creation, any increments/decrements (for fines), and finally any offsets against the total (payments, cancellations, voids). Test plan 1/ Create some credits and debits and apply them to each other in various combinations. 2/ View the 'Details' page for some of the debit/credits 3/ Compare before patch and after for the Details page. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Nick Clemens --- Koha/Account/Line.pm | 13 ++ .../prog/en/includes/accounts.inc | 14 --- .../en/modules/members/accountline-details.tt | 119 ++++++++++-------- .../bootstrap/en/includes/accounts.inc | 14 --- members/accountline-details.pl | 17 +-- 5 files changed, 92 insertions(+), 85 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 1d91cef2f7..949bd23c09 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -58,6 +58,19 @@ sub patron { return Koha::Patron->_new_from_dbic( $rs ); } +=head3 manager + +Return the manager linked to this account line + +=cut + +sub manager { + my ( $self ) = @_; + my $rs = $self->_result->manager; + return unless $rs; + return Koha::Patron->_new_from_dbic( $rs ); +} + =head3 item Return the item linked to this account line if exists diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc index 6c5450b0de..e57195717c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc @@ -56,17 +56,3 @@ [%- CASE -%] [%- END -%] [%- END -%] - -[%- BLOCK offset_type_description -%] - [%- SWITCH account_offset.type -%] - [%- CASE 'Credit Applied' -%]Credit applied - [%- CASE 'Payment' -%]Payment - [%- CASE 'Manual Credit' -%]Manual credit - [%- CASE 'Manual Debit' -%]Manual invoice - [%- CASE 'Lost Item' -%]Lost item returned - [%- CASE 'Writeoff' -%]Writeoff - [%- CASE 'Void Payment' -%]Void payment - [%- CASE 'CANCELLATION' -%]Cancelled charge - [%- CASE -%][% account_offset.type | html %] - [%- END -%] -[%- END -%] 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 c8d50f0a5e..c6e9fb6285 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 @@ -7,7 +7,7 @@ [% SET footerjs = 1 %] [% PROCESS 'accounts.inc' %] [% INCLUDE 'doc-head-open.inc' %] -Details of fee › [% INCLUDE 'patron-title.inc' no_html = 1 %] › Patrons › Koha +Details of [% IF type == 'credit' %]credit[% ELSE %]debit[% END %] › [% INCLUDE 'patron-title.inc' no_html = 1 %] › Patrons › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -24,24 +24,27 @@ Patrons - [% IF type == 'credit' %] + + [% IF accountline %] + [% IF accountline.credit_type_code %]
  • Account for [% INCLUDE 'patron-title.inc' %]
  • - Details of payment + Details of credit ([% accountline.id | html %])
  • - [% ELSIF type == 'debit' %] + [% ELSIF accountline.debit_type_code %]
  • Account for [% INCLUDE 'patron-title.inc' %]
  • - Details of fee + Details of debit ([% accountline.id | html %])
  • + [% END %] [% ELSE %]
  • @@ -60,17 +63,17 @@ [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %] [% IF accountline %] - [% IF type == 'credit' %] -

    Details of payment

    - [% ELSIF type == 'debit' %] -

    Details of fee

    + [% IF accountline.credit_type_code %] +

    Details of credit

    + [% ELSIF accountline.debit_type_code %] +

    Details of debit

    [% END %] - + @@ -83,7 +86,7 @@
    DateDescription of chargesDescription Barcode Due date Return date
    - [% accountline.date |$KohaDates %] + [% accountline.date | $KohaDates %] [%- PROCESS account_type_description account=accountline -%] @@ -134,63 +137,81 @@
    - - [% IF type == 'credit' %] -

    Fees paid

    - [% ELSIF type == 'debit' %] -

    Payments

    - [% END %] - +

    History

    - - - - + + + + + + + + + + - - - - - [% FOREACH ao IN account_offsets %] - [% IF type == 'credit' %] - [% SET offset_accountline = ao.debit %] - [% ELSIF type == 'debit' %] - [% SET offset_accountline = ao.credit %] - [% END %] + [% IF ao.credit_id == accountline.accountlines_id %] + [% SET offset_accountline = ao.debit %] + [% ELSIF ao.debit_id == accountline.accountlines_id %] + [% SET offset_accountline = ao.credit %] + [% END %] + + [%- BLOCK ao_description -%] + [%- SWITCH ao.type -%] + [%- CASE 'CREATE' -%]Created + [%- CASE 'OVERDUE_INCREASE' -%]Increase + [%- CASE 'OVERDUE_DECREASE' -%]Decrease + [%- CASE 'APPLY' -%]Applied + [%- CASE 'VOID' -%]Reversed + [%- END -%] + [%- END -%] - [% IF offset_accountline %] - - - - - + + + + + [%- IF offset_accountline -%] + + + + [%- ELSE -%] + + + + [%- END -%] - - - - - - [% END %] [% END %]
    Date createdDate updatedAmountAmount outstandingDateChangeActionRelated transaction
    IncreaseDecrease TypeAmountLibrarian NoteTransacting librarianDate/time of changeAmount of changeType of change 
    [% offset_accountline.date | $KohaDates %][% offset_accountline.timestamp | $KohaDates with_hours => 1 %][% offset_accountline.amount | $Price %][% offset_accountline.amountoutstanding | $Price %][% PROCESS account_type_description account=offset_accountline %][% ao.created_on | $KohaDates with_hours => 1%][%- IF ao.amount > 0 -%][% ao.amount | $Price %][% END %][%- IF ao.amount < 0 -%][% ao.amount | $Price %][% END %] + [% PROCESS ao_description ao=ao %] + + [% PROCESS account_type_description account=offset_accountline %] ([% offset_accountline.id | html %]) + + [% offset_accountline.amount | $Price %] + + [% IF offset_accountline.manager_id %] + + [% IF offset_accountline.manager.firstname %] + [% offset_accountline.manager.firstname | html %] [% offest_accountline.manager.surname | html %] + [% ELSE %] + [% offset_accountline.manager.surname | html %] + [% END %] + + [% END %] + [% offset_accountline.note | html %][% IF offset_accountline.manager_id %][% offset_accountline.manager_id | html %][% END %][% ao.created_on | $KohaDates with_hours => 1 %][% ao.amount | $Price %][% PROCESS offset_type_description account_offset=ao %] Details
    [% ELSE %]
    - [% IF type == 'credit' %] - Payment not found - [% ELSIF type == 'debit' %] - Fee not found - [% END %] + Account not found
    [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/accounts.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/accounts.inc index 6c5450b0de..e57195717c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/accounts.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/accounts.inc @@ -56,17 +56,3 @@ [%- CASE -%] [%- END -%] [%- END -%] - -[%- BLOCK offset_type_description -%] - [%- SWITCH account_offset.type -%] - [%- CASE 'Credit Applied' -%]Credit applied - [%- CASE 'Payment' -%]Payment - [%- CASE 'Manual Credit' -%]Manual credit - [%- CASE 'Manual Debit' -%]Manual invoice - [%- CASE 'Lost Item' -%]Lost item returned - [%- CASE 'Writeoff' -%]Writeoff - [%- CASE 'Void Payment' -%]Void payment - [%- CASE 'CANCELLATION' -%]Cancelled charge - [%- CASE -%][% account_offset.type | html %] - [%- END -%] -[%- END -%] diff --git a/members/accountline-details.pl b/members/accountline-details.pl index a5c37079aa..ee2b9fc758 100755 --- a/members/accountline-details.pl +++ b/members/accountline-details.pl @@ -45,20 +45,21 @@ my $accountlines_id = $input->param('accountlines_id'); my $accountline = Koha::Account::Lines->find($accountlines_id); if ($accountline) { - my $type = $accountline->amount < 0 ? 'credit' : 'debit'; - my $column = $type eq 'credit' ? 'credit_id' : 'debit_id'; - my $account_offsets = Koha::Account::Offsets->search( - { $column => $accountlines_id }, - { order_by => 'created_on' }, + [ + { + credit_id => $accountline->accountlines_id + }, + { + debit_id => $accountline->accountlines_id + } + ], + { order_by => 'created_on' } ); $template->param( - type => $type, accountline => $accountline, account_offsets => $account_offsets, - - finesview => 1, ); my $patron = Koha::Patrons->find( $accountline->borrowernumber ); -- 2.20.1