Bugzilla – Attachment 67477 Details for
Bug 18786
Add ability to create custom payment types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18786 - Add ability to create custom payment types
Bug-18786---Add-ability-to-create-custom-payment-t.patch (text/plain), 11.50 KB, created by
Kyle M Hall (khall)
on 2017-09-29 15:26:05 UTC
(
hide
)
Description:
Bug 18786 - Add ability to create custom payment types
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-09-29 15:26:05 UTC
Size:
11.50 KB
patch
obsolete
>From c24052d8806e2a066ab11664a939d2e5df4bfd83 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 12 Jun 2017 10:09:35 -0400 >Subject: [PATCH] Bug 18786 - Add ability to create custom payment types >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > 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 | 40 +++++++++++++--------- > t/db_dependent/Accounts.t | 7 ++-- > 6 files changed, 71 insertions(+), 18 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index ed1fd3c..66673ed 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -72,6 +72,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'; > >@@ -215,6 +216,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, >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 ec79237..1fd2070 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >+++ b/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' %] > <title>Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %]</title> >@@ -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 ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td> > <td>[% account.note | html_line_break %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >index a1458b5..07dd4bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/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' %] > <title>Koha › Patrons › Collect fine payment for [% borrower.firstname %] [% borrower.surname %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -147,6 +148,18 @@ function moneyFormat(textObj) { > <!-- default to paying all --> > <input name="paid" id="paid" value="[% amountoutstanding | 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 %] > </ol> > </fieldset> > >@@ -211,10 +224,33 @@ function moneyFormat(textObj) { > <!-- 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> > </li> >+ [% IF payment_types.count %] >+ <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> > <div class="action"><input type="submit" name="submitbutton" value="Confirm" /> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >index a868d0f..04d3e38 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >+++ b/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') || plugins %] > [% 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 %] > </td> >diff --git a/members/paycollect.pl b/members/paycollect.pl >index f880f57..42dd6ee 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -17,22 +17,24 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-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::Patrons; > use Koha::Account; >- > use Koha::Patron::Categories; >+use Koha::AuthorisedValues; > > my $input = CGI->new(); > >@@ -70,6 +72,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 ) { >@@ -120,10 +123,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( >@@ -151,21 +155,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 { >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 41256fb..de3cdc7 100644 >--- a/t/db_dependent/Accounts.t >+++ b/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=?"); >-- >2.10.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18786
:
64202
|
64203
|
64204
|
64288
|
64300
|
64301
|
64302
|
67476
|
67477
|
69155
|
69156
|
69157
|
71020
|
71021
|
72015
|
72016
|
72114
|
72115
|
72282
|
73628
|
74147
|
74148
|
74149
|
74172
|
74436
|
75401