From 637f83a9563c6a27f035050680737c481410c8db Mon Sep 17 00:00:00 2001 From: Blou Date: Thu, 17 Jul 2014 15:06:31 -0400 Subject: [PATCH] bug 5620 - Capture Mode of payment, receipt number and notes in pay fines. --- C4/Accounts.pm | 33 +++++++++++----------- .../atomicupdate/bug5620_Add_Mode_Of_Payment.perl | 14 +++++++++ .../prog/en/modules/members/boraccount.tt | 2 ++ .../prog/en/modules/members/paycollect.tt | 18 ++++++++++++ members/paycollect.pl | 20 ++++++++++--- 5 files changed, 67 insertions(+), 20 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 5243712..4fbbb81 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -25,6 +25,7 @@ use C4::Stats; use C4::Members; use C4::Circulation qw(ReturnLostItem); use C4::Log qw(logaction); +use C4::Koha qw(GetKohaAuthorisedValueLib); use Data::Dumper qw(Dumper); @@ -88,7 +89,7 @@ will be credited to the next one. sub recordpayment { #here we update the account lines - my ( $borrowernumber, $data, $sip_paytype, $payment_note ) = @_; + my ( $borrowernumber, $data, $sip_paytype, $payment_note, $paymentmode ) = @_; my $dbh = C4::Context->dbh; my $newamtos = 0; my $accdata = ""; @@ -148,13 +149,13 @@ sub recordpayment { # create new line my $usth = $dbh->prepare( "INSERT INTO accountlines - (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note) - VALUES (?,?,now(),?,'',?,?,?,?)" + (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note, paymentmode) + VALUES (?,?,now(),?,'',?,?,?,?,?)" ); my $paytype = "Pay"; $paytype .= $sip_paytype if defined $sip_paytype; - $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note ); + $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode) ); $usth->finish; UpdateStats({ @@ -204,7 +205,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; @@ -243,10 +244,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") ) { @@ -594,7 +595,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; @@ -654,9 +655,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', @@ -684,7 +685,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) { @@ -718,11 +719,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/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl new file mode 100755 index 0000000..b0730cb --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl @@ -0,0 +1,14 @@ +#! /usr/bin/perl + +use strict; +use warnings; +use C4::Context; +my $dbh=C4::Context->dbh; + +### Payment mode + +$dbh->do("alter table accountlines add column paymentmode text not null"); +$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','CASH','Cash', 'Cash')"); +$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','CC','Credit Card', 'Credit Card')"); +$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','DEBIG','Debit', 'Debit')"); +print "bug5620 - add mode of payment"; 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 43a6702..a7e12bb 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() { Date Description of charges Note + Payment mode Amount Outstanding [% IF ( reverse_col ) %] @@ -104,6 +105,7 @@ $(document).ready(function() { [%- IF account.description %], [% account.description %][% END %]  [% IF ( account.itemnumber ) %][% account.title |html %][% END %] [% account.note | html_line_break %] + [% account.paymentmode %] [% IF ( account.amountcredit ) %][% ELSE %][% END %][% account.amount %] [% IF ( account.amountoutstandingcredit ) %][% ELSE %][% END %][% account.amountoutstanding %] 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 cb6902c..fd58d9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -147,6 +147,15 @@ function moneyFormat(textObj) { +
  • + + +
  • + @@ -212,6 +221,15 @@ function moneyFormat(textObj) { +
  • + + +
  • +
  • diff --git a/members/paycollect.pl b/members/paycollect.pl index c68d205..5d78b78 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -44,6 +44,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +# get authorised values with category of PAYMODE +my @paymentmodes; +my $dbh = C4::Context->dbh; +my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "PAYMODE"'); +$sth->execute(); +while ( my $row = $sth->fetchrow_hashref() ) { + push @paymentmodes, $row; +} +$template->param( paymentmodes => \@paymentmodes ); + + # get borrower details my $borrowernumber = $input->param('borrowernumber'); my $borrower = GetMember( borrowernumber => $borrowernumber ); @@ -53,6 +64,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'); @@ -110,10 +122,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"); @@ -124,10 +136,10 @@ 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'); - recordpayment( $borrowernumber, $total_paid, '', $note ); + recordpayment( $borrowernumber, $total_paid, '', $note, $paymentmode ); } # recordpayment does not return success or failure so lets redisplay the boraccount -- 1.9.1