From 04eafc1b93ad9936f478229ac6ae723c46bd1f76 Mon Sep 17 00:00:00 2001
From: Blou <philippe.blouin@inlibro.com>
Date: Thu, 17 Jul 2014 15:06:31 -0400
Subject: [PATCH] bug 5620 - Capture Mode of payment, receipt number and notes
in pay fines.
- Replace all sub deleted
- Using Koha::Template::Plugin::AuthorisedValues
- Delete unit tests
---
Koha/Account.pm | 4 ++++
Koha/Schema/Result/Accountline.pm | 2 ++
.../atomicupdate/bug5620_Add_Mode_Of_Payment.sql | 6 ++++++
installer/data/mysql/kohastructure.sql | 1 +
.../prog/en/modules/members/boraccount.tt | 3 +++
.../prog/en/modules/members/paycollect.tt | 19 +++++++++++++++++++
members/paycollect.pl | 8 +++++---
7 files changed, 40 insertions(+), 3 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql
diff --git a/Koha/Account.pm b/Koha/Account.pm
index 28b789f..0b7bfa9 100644
--- a/Koha/Account.pm
+++ b/Koha/Account.pm
@@ -68,6 +68,7 @@ sub pay {
my $library_id = $params->{library_id};
my $lines = $params->{lines};
my $type = $params->{type} || 'payment';
+ my $paymentmode = $params->{paymentmode};
my $userenv = C4::Context->userenv;
@@ -121,6 +122,7 @@ sub pay {
accountno => $fine->accountno,
manager_id => $manager_id,
note => $note,
+ paymentmode => $paymentmode,
}
)
);
@@ -164,6 +166,7 @@ sub pay {
accountno => $fine->accountno,
manager_id => $manager_id,
note => $note,
+ paymentmode => $paymentmode,
}
)
);
@@ -192,6 +195,7 @@ sub pay {
amountoutstanding => 0 - $balance_remaining,
manager_id => $manager_id,
note => $note,
+ paymentmode => $paymentmode,
}
)->store();
diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm
index d3fa5b3..cd50c5c 100644
--- a/Koha/Schema/Result/Accountline.pm
+++ b/Koha/Schema/Result/Accountline.pm
@@ -169,6 +169,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"manager_id",
{ data_type => "integer", is_nullable => 1 },
+ "paymentmode",
+ {data_type => "text", is_nullable => 0 },
);
=head1 PRIMARY KEY
diff --git a/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql
new file mode 100644
index 0000000..2dc58ea
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql
@@ -0,0 +1,6 @@
+ALTER table accountlines ADD COLUMN paymentmode TEXT NOT NULL;
+INSERT INTO authorised_value_categories VALUES ('PAYMODE');
+INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES
+('PAYMODE','CASH','Cash', 'Cash'),
+('PAYMODE','CC','Credit Card', 'Credit Card'),
+('PAYMODE','DEBIG','Debit', 'Debit');
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 91e6119..899e05e 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2703,6 +2703,7 @@ CREATE TABLE `accountlines` (
`notify_level` int(2) NOT NULL default 0,
`note` text NULL default NULL,
`manager_id` int(11) NULL,
+ `paymentmode` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`accountlines_id`),
KEY `acctsborridx` (`borrowernumber`),
KEY `timeidx` (`timestamp`),
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 a8e3667..53f36b4 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 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %]</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -67,6 +68,7 @@ $(document).ready(function() {
<th class="title-string">Date</th>
<th>Description of charges</th>
<th>Note</th>
+ <th>Payment mode</th>
<th>Amount</th>
<th>Outstanding</th>
[% IF ( reverse_col ) %]
@@ -108,6 +110,7 @@ $(document).ready(function() {
[%- 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>
+ <td>[% AuthorisedValues.GetByCode('PAYMODE',account.paymentmode) %]</td>
[% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount %]</td>
[% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding %]</td>
<td class="actions">
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 069ad69..f9695a9 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' %]
@@ -148,6 +149,15 @@ function moneyFormat(textObj) {
<!-- default to paying all -->
<input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
</li>
+ <li>
+ <label for="paymentmode">Payment mode: </label>
+ <select name="paymentmode" id="paymentmode">
+ [% FOREACH paymentmode IN AuthorisedValues.GetAuthValueDropbox('PAYMODE') %]
+ <option value="[% paymentmode.value %]">[% paymentmode.label %]</option>
+ [% END %]
+ </select>
+ </li>
+
</ol>
</fieldset>
@@ -213,6 +223,15 @@ function moneyFormat(textObj) {
<!-- default to paying all -->
<input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
</li>
+ <li>
+ <label for="paymentmode">Payment mode: </label>
+ <select name="paymentmode" id="paymentmode">
+ [% FOREACH paymentmode IN AuthorisedValues.GetAuthValueDropbox('PAYMODE') %]
+ <option value="[% paymentmode.value %]">[% paymentmode.label %]</option>
+ [% END %]
+ </select>
+ </li>
+
<li>
<label for="selected_accts_notes">Note: </label>
<textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
diff --git a/members/paycollect.pl b/members/paycollect.pl
index ac1c281..bb8040a 100755
--- a/members/paycollect.pl
+++ b/members/paycollect.pl
@@ -55,6 +55,7 @@ my $branch = C4::Context->userenv->{'branch'};
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
my $total_paid = $input->param('paid');
+my $paymentmode = $input->param('paymentmode');
my $individual = $input->param('pay_individual');
my $writeoff = $input->param('writeoff_individual');
@@ -117,7 +118,8 @@ if ( $total_paid and $total_paid ne '0.00' ) {
lines => [$line],
amount => $total_paid,
library_id => $branch,
- note => $payment_note
+ note => $payment_note,
+ paymentmode => $paymentmode,
}
);
print $input->redirect(
@@ -129,7 +131,6 @@ if ( $total_paid and $total_paid ne '0.00' ) {
}
my @acc = split /,/, $select;
my $note = $input->param('selected_accts_notes');
-
my @lines = Koha::Account::Lines->search(
{
borrowernumber => $borrowernumber,
@@ -148,13 +149,14 @@ if ( $total_paid and $total_paid ne '0.00' ) {
amount => $total_paid,
lines => \@lines,
note => $note,
+ paymentmode => $paymentmode,
}
);
}
else {
my $note = $input->param('selected_accts_notes');
Koha::Account->new( { patron_id => $borrowernumber } )
- ->pay( { amount => $total_paid, note => $note } );
+ ->pay( { amount => $total_paid, note => $note, paymentmode => $paymentmode } );
}
print $input->redirect(
--
1.9.1