@@ -, +, @@
---
Koha/Account.pm | 2 ++
.../prog/en/modules/members/boraccount.tt | 2 ++
.../prog/en/modules/members/paycollect.tt | 36 +++++++++++++++++++
.../opac-tmpl/bootstrap/en/modules/opac-account.tt | 2 ++
members/paycollect.pl | 42 +++++++++++++---------
t/db_dependent/Accounts.t | 7 ++--
6 files changed, 72 insertions(+), 19 deletions(-)
--- a/Koha/Account.pm
+++ a/Koha/Account.pm
@@ -73,6 +73,7 @@ sub pay {
my $library_id = $params->{library_id};
my $lines = $params->{lines};
my $type = $params->{type} || 'payment';
+ my $payment_type = $params->{payment_type} || undef;
my $account_type = $params->{account_type};
my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
@@ -216,6 +217,7 @@ sub pay {
amount => 0 - $amount,
description => $description,
accounttype => $account_type,
+ payment_type => $payment_type,
amountoutstanding => 0 - $balance_remaining,
manager_id => $manager_id,
note => $note,
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
@@ -1,6 +1,7 @@
[% USE Koha %]
[% USE KohaDates %]
[% USE ColumnsSettings %]
+[% USE AuthorisedValues %]
[% USE Price %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %]
@@ -106,6 +107,7 @@ $(document).ready(function() {
[% CASE 'CR' %]Credit
[% CASE %][% account.accounttype %]
[%- END -%]
+ [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
[%- IF account.description %], [% account.description %][% END %]
[% IF ( account.itemnumber ) %][% account.title |html %][% END %]
[% account.note | html_line_break %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
@@ -1,5 +1,6 @@
[% USE Koha %]
[% USE Branches %]
+[% USE AuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Patrons › Collect fine payment for [% borrower.firstname %] [% borrower.surname %]
[% INCLUDE 'doc-head-close.inc' %]
@@ -148,6 +149,18 @@ function moneyFormat(textObj) {
+ [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
+ [% IF payment_types %]
+
+
+
+
+ [% END %]
@@ -213,10 +226,33 @@ function moneyFormat(textObj) {
+ [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
+ [% IF payment_types %]
+
+
+
+
+ [% END %]
+ [% IF payment_types.count %]
+
+
+
+
+ [% END %]
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt
@@ -1,5 +1,6 @@
[% USE Koha %]
[% USE KohaDates %]
+[% USE AuthorisedValues %]
[% USE Price %]
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') %]
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
@@ -126,6 +127,7 @@
[% CASE 'CR' %]Credit
[% CASE %][% ACCOUNT_LINE.accounttype %]
[%- END -%]
+ [%- IF ACCOUNT_LINE.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', ACCOUNT_LINE.payment_type, 1) %][% END %]
[%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
[% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
--- a/members/paycollect.pl
+++ a/members/paycollect.pl
@@ -17,21 +17,23 @@
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see .
-use strict;
-use warnings;
+use Modern::Perl;
+
use URI::Escape;
+use CGI qw ( -utf8 );
+
use C4::Context;
use C4::Auth;
use C4::Output;
-use CGI qw ( -utf8 );
use C4::Members;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Accounts;
use C4::Koha;
+
use Koha::Patron::Images;
use Koha::Account;
-
use Koha::Patron::Categories;
+use Koha::AuthorisedValues;
my $input = CGI->new();
@@ -61,6 +63,7 @@ my $writeoff = $input->param('writeoff_individual');
my $select_lines = $input->param('selected');
my $select = $input->param('selected_accts');
my $payment_note = uri_unescape $input->param('payment_note');
+my $payment_type = scalar $input->param('payment_type');
my $accountno;
my $accountlines_id;
@@ -114,10 +117,11 @@ if ( $total_paid and $total_paid ne '0.00' ) {
my $line = Koha::Account::Lines->find($accountlines_id);
Koha::Account->new( { patron_id => $borrowernumber } )->pay(
{
- lines => [$line],
- amount => $total_paid,
- library_id => $branch,
- note => $payment_note
+ lines => [$line],
+ amount => $total_paid,
+ library_id => $branch,
+ note => $payment_note,
+ payment_type => $payment_type,
}
);
print $input->redirect(
@@ -139,27 +143,31 @@ if ( $total_paid and $total_paid ne '0.00' ) {
{ order_by => 'date' }
);
- return Koha::Account->new(
+ Koha::Account->new(
{
patron_id => $borrowernumber,
}
)->pay(
{
- amount => $total_paid,
- lines => \@lines,
- note => $note,
+ amount => $total_paid,
+ lines => \@lines,
+ note => $note,
+ payment_type => $payment_type,
}
);
}
else {
my $note = $input->param('selected_accts_notes');
- Koha::Account->new( { patron_id => $borrowernumber } )
- ->pay( { amount => $total_paid, note => $note } );
+ Koha::Account->new( { patron_id => $borrowernumber } )->pay(
+ {
+ amount => $total_paid,
+ note => $note,
+ payment_type => $payment_type,
+ }
+ );
}
- print $input->redirect(
-"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
- );
+ print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
}
}
} else {
--- a/t/db_dependent/Accounts.t
+++ a/t/db_dependent/Accounts.t
@@ -136,7 +136,7 @@ $dbh->do(q|DELETE FROM accountlines|);
subtest "Koha::Account::pay tests" => sub {
- plan tests => 12;
+ plan tests => 13;
# Create a borrower
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
@@ -174,7 +174,10 @@ subtest "Koha::Account::pay tests" => sub {
my $borrowernumber = $borrower->borrowernumber;
my $data = '20.00';
my $payment_note = '$20.00 payment note';
- $account->pay( { amount => $data, note => $payment_note } );
+ my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } );
+
+ my $accountline = Koha::Account::Lines->find( $id );
+ is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" );
# There is now $280 in the account
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?");
--