Bug 18786: Add ability to create custom payment types
Some libraries would like to be able to specify more specific payment types such as cash, check, credit card, or even canned food ( for food drives ). This feature will allow a library to specify payment types as authorised values of the type PAYMENT_TYPE. Test Plan: 1) Apply patches 2) Update database 3) Add authorised value PAYMENT_TYPE with values 'Cash', 'Check', 'Credit card' 4) Go to the fines section of a patron who has several fines 5) Tab 'Fines' 6) Click on 'Pay' for an individual fine 7) Verify that in the form a 'Pay an individual fine' dropdown appears with payment types 8) Select a payment type, confirm payment 9) Verify that payment type appears in "Description of charges" in tab 'Account' Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Bug 18786: Remove use of Koha::Patron::Images Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Bug 18786: Remove duplicate block with bad IF Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
73d2ba3188
commit
fde5ea23fc
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
[% USE Koha %]
|
||||
[% USE KohaDates %]
|
||||
[% USE ColumnsSettings %]
|
||||
[% USE AuthorisedValues %]
|
||||
[% USE Price %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
|
|
@ -78,6 +79,7 @@
|
|||
[% 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 ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
|
||||
<td>[% account.note | html_line_break %]</td>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[% USE Asset %]
|
||||
[% USE Koha %]
|
||||
[% USE Branches %]
|
||||
[% USE AuthorisedValues %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Patrons › Collect fine payment for [% patron.firstname %] [% patron.surname %]</title>
|
||||
|
|
@ -86,6 +87,18 @@
|
|||
<!-- default to paying all -->
|
||||
<input name="paid" id="paid" value="[% amountoutstanding %]" />
|
||||
</li>
|
||||
[% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
|
||||
[% IF payment_types %]
|
||||
<li>
|
||||
<label for="payment_type">Payment type: </label>
|
||||
<select name="payment_type" id="payment_type">
|
||||
<option value=""></option>
|
||||
[% FOREACH pt IN payment_types %]
|
||||
<option value="[% pt.authorised_value %]">[% pt.lib %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
</li>
|
||||
[% END %]
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
|
|
@ -153,6 +166,18 @@
|
|||
<!-- default to paying all -->
|
||||
<input name="paid" id="paid" value="[% total | format('%.2f') %]" />
|
||||
</li>
|
||||
[% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
|
||||
[% IF payment_types %]
|
||||
<li>
|
||||
<label for="payment_type">Payment type: </label>
|
||||
<select name="payment_type" id="payment_type">
|
||||
<option value=""></option>
|
||||
[% FOREACH pt IN payment_types %]
|
||||
<option value="[% pt.authorised_value %]">[% pt.lib %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
</li>
|
||||
[% END %]
|
||||
<li>
|
||||
<label for="selected_accts_notes">Note: </label>
|
||||
<textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[% USE Asset %]
|
||||
[% USE Koha %]
|
||||
[% USE KohaDates %]
|
||||
[% USE AuthorisedValues %]
|
||||
[% USE Price %]
|
||||
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
|
||||
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
|
||||
|
|
@ -128,6 +129,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 %]
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -19,20 +19,22 @@
|
|||
|
||||
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::Patrons;
|
||||
use Koha::Patron::Categories;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::Account;
|
||||
use Koha::Token;
|
||||
|
||||
use Koha::Patron::Categories;
|
||||
|
||||
my $input = CGI->new();
|
||||
|
||||
my $updatecharges_permissions = $input->param('writeoff_individual') ? 'writeoff' : 'remaining_permissions';
|
||||
|
|
@ -66,6 +68,7 @@ my $writeoff = $input->param('writeoff_individual');
|
|||
my $select_lines = $input->param('selected');
|
||||
my $select = $input->param('selected_accts');
|
||||
my $payment_note = uri_unescape scalar $input->param('payment_note');
|
||||
my $payment_type = scalar $input->param('payment_type');
|
||||
my $accountlines_id;
|
||||
|
||||
if ( $individual || $writeoff ) {
|
||||
|
|
@ -118,10 +121,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(
|
||||
|
|
@ -149,21 +153,25 @@ if ( $total_paid and $total_paid ne '0.00' ) {
|
|||
}
|
||||
)->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 {
|
||||
|
|
|
|||
|
|
@ -137,7 +137,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 };
|
||||
|
|
@ -175,7 +175,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=?");
|
||||
|
|
|
|||
Loading…
Reference in New Issue