Bugzilla – Attachment 56037 Details for
Bug 5620
Capture Mode of payment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug 5620 - Capture Mode of payment, receipt number and notes in pay fines.
-bug-5620---Capture-Mode-of-payment-receipt-number.patch (text/plain), 13.12 KB, created by
Bouzid Fergani
on 2016-10-04 14:17:34 UTC
(
hide
)
Description:
bug 5620 - Capture Mode of payment, receipt number and notes in pay fines.
Filename:
MIME Type:
Creator:
Bouzid Fergani
Created:
2016-10-04 14:17:34 UTC
Size:
13.12 KB
patch
obsolete
>From ef76c957b2d1c5828524270ddc3f4d84fe8ebd25 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. > > Using sql file in atomiqueupdate > using function GetKohaAuthorisedValues >--- > C4/Accounts.pm | 25 ++++++++--------- > C4/Koha.pm | 31 +++++++++++----------- > .../atomicupdate/bug5620_Add_Mode_Of_Payment.sql | 6 +++++ > installer/data/mysql/kohastructure.sql | 1 + > .../prog/en/modules/members/boraccount.tt | 2 ++ > .../prog/en/modules/members/paycollect.tt | 18 +++++++++++++ > members/paycollect.pl | 18 ++++++++++--- > 7 files changed, 71 insertions(+), 30 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql > >diff --git a/C4/Accounts.pm b/C4/Accounts.pm >index e49becb..30cb84e 100644 >--- a/C4/Accounts.pm >+++ b/C4/Accounts.pm >@@ -26,6 +26,7 @@ use C4::Members; > use C4::Circulation qw(ReturnLostItem); > use C4::Log qw(logaction); > use Koha::Account; >+use C4::Koha qw(GetKohaAuthorisedValueLib); > > use Data::Dumper qw(Dumper); > >@@ -90,7 +91,7 @@ sub makepayment { > #here we update both the accountoffsets and the account lines > #updated to check, if they are paying off a lost item, we return the item > # from their card, and put a note on the item record >- my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; >+ my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_; > my $dbh = C4::Context->dbh; > my $manager_id = 0; > $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; >@@ -129,10 +130,10 @@ sub makepayment { > my $ins = > $dbh->prepare( > "INSERT >- INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) >- VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)" >+ INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, paymentmode) >+ VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?, ?)" > ); >- $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); >+ $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode)); > } > > if ( C4::Context->preference("FinesLog") ) { >@@ -480,7 +481,7 @@ will be credited to the next one. > =cut > > sub recordpayment_selectaccts { >- my ( $borrowernumber, $amount, $accts, $note ) = @_; >+ my ( $borrowernumber, $amount, $accts, $note, $paymentmode ) = @_; > > my $dbh = C4::Context->dbh; > my $newamtos = 0; >@@ -540,9 +541,9 @@ sub recordpayment_selectaccts { > > # create new line > $sql = 'INSERT INTO accountlines ' . >- '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' . >- q|VALUES (?,?,now(),?,'','Pay',?,?,?)|; >- $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note ); >+ '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note,paymentmode) ' . >+ q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|; >+ $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode) ); > UpdateStats({ > branch => $branch, > type => 'payment', >@@ -570,7 +571,7 @@ sub recordpayment_selectaccts { > # makepayment needs to be fixed to handle partials till then this separate subroutine > # fills in > sub makepartialpayment { >- my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; >+ my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_; > my $manager_id = 0; > $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; > if (!$amount || $amount < 0) { >@@ -604,11 +605,11 @@ sub makepartialpayment { > > # create new line > my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' >- . 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' >- . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; >+ . 'description, accounttype, amountoutstanding, itemnumber, manager_id, note, paymentmode) ' >+ . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?,?)'; > > $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, >- '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); >+ '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode)); > > UpdateStats({ > branch => $branch, >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 0ff4851..bc4fd50 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1042,21 +1042,22 @@ Returns undef if no authorised value category is defined for the kohafield. > =cut > > sub GetKohaAuthorisedValues { >- my ($kohafield,$fwcode,$opac) = @_; >- $fwcode='' unless $fwcode; >- my %values; >- my $dbh = C4::Context->dbh; >- my $avcode = GetAuthValCode($kohafield,$fwcode); >- if ($avcode) { >- my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? "); >- $sth->execute($avcode); >- while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { >- $values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib; >- } >- return \%values; >- } else { >- return; >- } >+ my ($kohafield,$fwcode,$opac, $category) = @_; >+ $fwcode='' unless $fwcode; >+ my %values; >+ my $dbh = C4::Context->dbh; >+ my $avcode = GetAuthValCode($kohafield,$fwcode); >+ $avcode = $category unless ($avcode); >+ if ($avcode) { >+ my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? "); >+ $sth->execute($avcode); >+ while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { >+ $values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib; >+ } >+ return \%values; >+ } else { >+ return; >+ } > } > > =head2 GetKohaAuthorisedValuesFromField >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..df8af99 >--- /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_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 e38efc5..8364035 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2685,6 +2685,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 ca0a804..2246b5d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >@@ -64,6 +64,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 ) %] >@@ -105,6 +106,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>[% 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..fa0249c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -148,6 +148,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 paymentmodes %] >+ <option value="[% paymentmode.authorised_value %]">[% paymentmodes.paymentmode %]</option> >+ [% END %] >+ </select> >+ </li> >+ > </ol> > </fieldset> > >@@ -213,6 +222,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 paymentmodes %] >+ <option value="[% paymentmode.authorised_value %]">[% paymentmode.lib %]</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 1cb6ad9..880bcac 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -46,6 +46,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+# get authorised values with category of PAYMODE >+my @paymentmodes; >+my $paymentmodesHash = GetKohaAuthorisedValues('', '', '', 'PAYMODE'); >+foreach my $key (keys %$paymentmodesHash) { >+ push @paymentmodes, {'authorised_value' => $key, >+ 'lib' => $paymentmodesHash->{$key}}; >+} >+$template->param( paymentmodes => \@paymentmodes ); >+ >+ > # get borrower details > my $borrowernumber = $input->param('borrowernumber'); > my $borrower = GetMember( borrowernumber => $borrowernumber ); >@@ -55,6 +65,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'); >@@ -113,10 +124,10 @@ if ( $total_paid and $total_paid ne '0.00' ) { > if ($individual) { > if ( $total_paid == $total_due ) { > makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user, >- $branch, $payment_note ); >+ $branch, $payment_note, $paymentmode ); > } else { > makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, >- $user, $branch, $payment_note ); >+ $user, $branch, $payment_note, $paymentmode ); > } > print $input->redirect( > "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"); >@@ -127,11 +138,12 @@ if ( $total_paid and $total_paid ne '0.00' ) { > } > my @acc = split /,/, $select; > my $note = $input->param('selected_accts_notes'); >- recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note ); >+ recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note, $paymentmode ); > } else { > my $note = $input->param('selected_accts_notes'); > Koha::Account->new( { patron_id => $borrowernumber } ) > ->pay( { amount => $total_paid, note => $note } ); >+ recordpayment( $borrowernumber, $total_paid, '', $note, $paymentmode ); > } > > print $input->redirect( >-- >1.9.1
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 5620
:
2997
|
51290
|
56036
|
56037
|
56080
|
60994
|
60996
|
67361
|
67362
|
67394
|
67603
|
67634
|
67661
|
69002