@@ -, +, @@ 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 --- a/C4/Accounts.pm +++ a/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, --- a/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl +++ a/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"; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -64,6 +64,7 @@ $(document).ready(function() {