From d1a009d232166a5e3172859e513e70c405935a6f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 11 Dec 2013 11:14:14 -0500 Subject: [PATCH] Bug 6427 [Part 14] - Delete unused and unnecessary files This patch re-engineers Koha's accounting system to be faster, more stable, and have a better historical accounting of fees and payments while also unifying much of the payment logic and simplifying the code behind it. Three new tables have been created: account_debits stores fines and fees owed by the patron. account_credits stores payments, write-offs, and other line items that reduce the amount owed by a patron. account_offsets stores data about changes to debits and credits, including which credits paid which debits. borrowers.account_balance stores the current balance of the patron, so it does not have to be calculated each time it needs to be displayed. issues.issue_id has been added so that individual fines can be directly linked to the issue that caused them without ambiguity. The various accounting code strings ( F, FU, Rent, etc ), some of which have little or no documentation have been replaced by what enumerated data types which are documented via POD. There are three, one for each of Debits ( fees/fines ), Credits ( payments ), and Offsets. The system continues to allow custom fee types ( moving MANUAL_INV to MANUAL_DEBIT ) while additionally allowing custom payment types ( MANUAL_CREDIT ). The system also allows for overpayment, the the outstanding credit being applied to future fees as they are created. The system also allows for a librarian to accept a different amount of money than what is to be paid, and will calculate the change to be given. Test Plan: 1) Apply this patch 2) Create some manual fees 3) Test the fee payments * Pay one fee * Pay multiple fees * Make a partial payment * Write off a fee 4) View the fees/payments, verify they are correct 5) Check out some items as overdue that should have fines 6) Run fines.pl, verify fines were generated 7) Pay on an accruing fine 8) Run fines.pl again, verify the fine hasn't changed 9) Increase the daily fine in issuing rules 10) Run fines.pl again, verify the fine has increased 11) Decrease the daily fine in issuing rules 12) Run fines.pl again, verify the fine has decreased 13) Test dropbox mode 14) Test WhenLostChargeReplacementFee both ways 15) Test RefundLostItemFeeOnReturn both ways 16) Test WhenLostForgiveFine both ways 17) Test CalculateFinesOnReturn both ways --- C4/Accounts.pm | 804 -------------------- Koha/Schema/Result/Accountline.pm | 222 ------ Koha/Schema/Result/Accountoffset.pm | 106 --- .../prog/en/modules/members/boraccount.tt | 111 --- .../prog/en/modules/members/maninvoice.tt | 87 --- .../intranet-tmpl/prog/en/modules/members/pay.tt | 166 ---- .../prog/en/modules/members/paycollect.tt | 233 ------ .../prog/en/modules/members/printfeercpt.tt | 63 -- .../prog/en/modules/members/printinvoice.tt | 65 -- members/boraccount.pl | 135 ---- members/mancredit.pl | 114 --- members/maninvoice.pl | 141 ---- members/pay.pl | 261 ------- members/paycollect.pl | 179 ----- members/printfeercpt.pl | 143 ---- members/printinvoice.pl | 142 ---- misc/maintenance/fix_accountlines_date.pl | 171 ----- 17 files changed, 0 insertions(+), 3143 deletions(-) delete mode 100644 C4/Accounts.pm delete mode 100644 Koha/Schema/Result/Accountline.pm delete mode 100644 Koha/Schema/Result/Accountoffset.pm delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt delete mode 100755 members/boraccount.pl delete mode 100755 members/mancredit.pl delete mode 100755 members/maninvoice.pl delete mode 100755 members/pay.pl delete mode 100755 members/paycollect.pl delete mode 100755 members/printfeercpt.pl delete mode 100755 members/printinvoice.pl delete mode 100755 misc/maintenance/fix_accountlines_date.pl diff --git a/C4/Accounts.pm b/C4/Accounts.pm deleted file mode 100644 index 3fbb2ad..0000000 --- a/C4/Accounts.pm +++ /dev/null @@ -1,804 +0,0 @@ -package C4::Accounts; - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -use strict; -#use warnings; FIXME - Bug 2505 -use C4::Context; -use C4::Stats; -use C4::Members; -use C4::Circulation qw(ReturnLostItem); -use C4::Log qw(logaction); - -use Data::Dumper qw(Dumper); - -use vars qw($VERSION @ISA @EXPORT); - -BEGIN { - # set the version for version checking - $VERSION = 3.07.00.049; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw( - &recordpayment - &makepayment - &manualinvoice - &getnextacctno - &getcharges - &ModNote - &getcredits - &getrefunds - &chargelostitem - &ReversePayment - &makepartialpayment - &recordpayment_selectaccts - &WriteOffFee - ); -} - -=head1 NAME - -C4::Accounts - Functions for dealing with Koha accounts - -=head1 SYNOPSIS - -use C4::Accounts; - -=head1 DESCRIPTION - -The functions in this module deal with the monetary aspect of Koha, -including looking up and modifying the amount of money owed by a -patron. - -=head1 FUNCTIONS - -=head2 recordpayment - - &recordpayment($borrowernumber, $payment); - -Record payment by a patron. C<$borrowernumber> is the patron's -borrower number. C<$payment> is a floating-point number, giving the -amount that was paid. - -Amounts owed are paid off oldest first. That is, if the patron has a -$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment -of $1.50, then the oldest fine will be paid off in full, and $0.50 -will be credited to the next one. - -=cut - -#' -sub recordpayment { - - #here we update the account lines - my ( $borrowernumber, $data ) = @_; - my $dbh = C4::Context->dbh; - my $newamtos = 0; - my $accdata = ""; - my $branch = C4::Context->userenv->{'branch'}; - my $amountleft = $data; - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - - # begin transaction - my $nextaccntno = getnextacctno($borrowernumber); - - # get lines with outstanding amounts to offset - my $sth = $dbh->prepare( - "SELECT * FROM accountlines - WHERE (borrowernumber = ?) AND (amountoutstanding<>0) - ORDER BY date" - ); - $sth->execute($borrowernumber); - - # offset transactions - my @ids; - while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft > 0 ) ) { - if ( $accdata->{'amountoutstanding'} < $amountleft ) { - $newamtos = 0; - $amountleft -= $accdata->{'amountoutstanding'}; - } - else { - $newamtos = $accdata->{'amountoutstanding'} - $amountleft; - $amountleft = 0; - } - my $thisacct = $accdata->{accountlines_id}; - my $usth = $dbh->prepare( - "UPDATE accountlines SET amountoutstanding= ? - WHERE (accountlines_id = ?)" - ); - $usth->execute( $newamtos, $thisacct ); - - if ( C4::Context->preference("FinesLog") ) { - $accdata->{'amountoutstanding_new'} = $newamtos; - logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ - action => 'fee_payment', - borrowernumber => $accdata->{'borrowernumber'}, - old_amountoutstanding => $accdata->{'amountoutstanding'}, - new_amountoutstanding => $newamtos, - amount_paid => $accdata->{'amountoutstanding'} - $newamtos, - accountlines_id => $accdata->{'accountlines_id'}, - accountno => $accdata->{'accountno'}, - manager_id => $manager_id, - })); - push( @ids, $accdata->{'accountlines_id'} ); - } - } - - # create new line - my $usth = $dbh->prepare( - "INSERT INTO accountlines - (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) - VALUES (?,?,now(),?,'','Pay',?,?)" - ); - $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id ); - - UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); - - if ( C4::Context->preference("FinesLog") ) { - $accdata->{'amountoutstanding_new'} = $newamtos; - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_payment', - borrowernumber => $borrowernumber, - accountno => $nextaccntno, - amount => $data * -1, - amountoutstanding => $amountleft * -1, - accounttype => 'Pay', - accountlines_paid => \@ids, - manager_id => $manager_id, - })); - } - -} - -=head2 makepayment - - &makepayment($accountlines_id, $borrowernumber, $acctnumber, $amount, $branchcode); - -Records the fact that a patron has paid off the entire amount he or -she owes. - -C<$borrowernumber> is the patron's borrower number. C<$acctnumber> is -the account that was credited. C<$amount> is the amount paid (this is -only used to record the payment. It is assumed to be equal to the -amount owed). C<$branchcode> is the code of the branch where payment -was made. - -=cut - -#' -# FIXME - I'm not at all sure about the above, because I don't -# understand what the acct* tables in the Koha database are for. -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 $dbh = C4::Context->dbh; - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - - # begin transaction - my $nextaccntno = getnextacctno($borrowernumber); - my $newamtos = 0; - my $sth = $dbh->prepare("SELECT * FROM accountlines WHERE accountlines_id=?"); - $sth->execute( $accountlines_id ); - my $data = $sth->fetchrow_hashref; - - my $payment; - if ( $data->{'accounttype'} eq "Pay" ){ - my $udp = - $dbh->prepare( - "UPDATE accountlines - SET amountoutstanding = 0 - WHERE accountlines_id = ? - " - ); - $udp->execute($accountlines_id); - }else{ - my $udp = - $dbh->prepare( - "UPDATE accountlines - SET amountoutstanding = 0 - WHERE accountlines_id = ? - " - ); - $udp->execute($accountlines_id); - - # create new line - my $payment = 0 - $amount; - $payment_note //= ""; - - my $ins = - $dbh->prepare( - "INSERT - INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note) - VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)" - ); - $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); - } - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ - action => 'fee_payment', - borrowernumber => $borrowernumber, - old_amountoutstanding => $data->{'amountoutstanding'}, - new_amountoutstanding => 0, - amount_paid => $data->{'amountoutstanding'}, - accountlines_id => $data->{'accountlines_id'}, - accountno => $data->{'accountno'}, - manager_id => $manager_id, - })); - - - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_payment', - borrowernumber => $borrowernumber, - accountno => $nextaccntno, - amount => $payment, - amountoutstanding => 0,, - accounttype => 'Pay', - accountlines_paid => [$data->{'accountlines_id'}], - manager_id => $manager_id, - })); - } - - - # FIXME - The second argument to &UpdateStats is supposed to be the - # branch code. - # UpdateStats is now being passed $accountno too. MTJ - UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, - $accountno ); - - #check to see what accounttype - if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { - C4::Circulation::ReturnLostItem( $borrowernumber, $data->{'itemnumber'} ); - } - my $sthr = $dbh->prepare("SELECT max(accountlines_id) AS lastinsertid FROM accountlines"); - $sthr->execute(); - my $datalastinsertid = $sthr->fetchrow_hashref; - return $datalastinsertid->{'lastinsertid'}; -} - -=head2 getnextacctno - - $nextacct = &getnextacctno($borrowernumber); - -Returns the next unused account number for the patron with the given -borrower number. - -=cut - -#' -# FIXME - Okay, so what does the above actually _mean_? -sub getnextacctno { - my ($borrowernumber) = shift or return; - my $sth = C4::Context->dbh->prepare( - "SELECT accountno+1 FROM accountlines - WHERE (borrowernumber = ?) - ORDER BY accountno DESC - LIMIT 1" - ); - $sth->execute($borrowernumber); - return ($sth->fetchrow || 1); -} - -=head2 fixaccounts (removed) - - &fixaccounts($accountlines_id, $borrowernumber, $accountnumber, $amount); - -#' -# FIXME - I don't understand what this function does. -sub fixaccounts { - my ( $accountlines_id, $borrowernumber, $accountno, $amount ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines WHERE accountlines_id=?" - ); - $sth->execute( $accountlines_id ); - my $data = $sth->fetchrow_hashref; - - # FIXME - Error-checking - my $diff = $amount - $data->{'amount'}; - my $outstanding = $data->{'amountoutstanding'} + $diff; - $sth->finish; - - $dbh->do(<dbh(); - my ($borrowernumber, $itemnumber, $amount, $description) = @_; - - # first make sure the borrower hasn't already been charged for this item - my $sth1=$dbh->prepare("SELECT * from accountlines - WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); - $sth1->execute($borrowernumber,$itemnumber); - my $existing_charge_hashref=$sth1->fetchrow_hashref(); - - # OK, they haven't - unless ($existing_charge_hashref) { - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - # This item is on issue ... add replacement cost to the borrower's record and mark it returned - # Note that we add this to the account even if there's no replacement price, allowing some other - # process (or person) to update it, since we don't handle any defaults for replacement prices. - my $accountno = getnextacctno($borrowernumber); - my $sth2=$dbh->prepare("INSERT INTO accountlines - (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id) - VALUES (?,?,now(),?,?,'L',?,?,?)"); - $sth2->execute($borrowernumber,$accountno,$amount, - $description,$amount,$itemnumber,$manager_id); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE', $borrowernumber, Dumper({ - action => 'create_fee', - borrowernumber => $borrowernumber, - accountno => $accountno, - amount => $amount, - amountoutstanding => $amount, - description => $description, - accounttype => 'L', - itemnumber => $itemnumber, - manager_id => $manager_id, - })); - } - - } -} - -=head2 manualinvoice - - &manualinvoice($borrowernumber, $itemnumber, $description, $type, - $amount, $note); - -C<$borrowernumber> is the patron's borrower number. -C<$description> is a description of the transaction. -C<$type> may be one of C, C, C, C, C, C, C, -or C. -C<$itemnumber> is the item involved, if pertinent; otherwise, it -should be the empty string. - -=cut - -#' -# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function -# are : -# 'C' = CREDIT -# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) -# 'N' = New Card fee -# 'F' = Fine -# 'A' = Account Management fee -# 'M' = Sundry -# 'L' = Lost Item -# - -sub manualinvoice { - my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - my $dbh = C4::Context->dbh; - my $notifyid = 0; - my $insert; - my $accountno = getnextacctno($borrowernumber); - my $amountleft = $amount; - - if ( ( $type eq 'L' ) - or ( $type eq 'F' ) - or ( $type eq 'A' ) - or ( $type eq 'N' ) - or ( $type eq 'M' ) ) - { - $notifyid = 1; - } - - if ( $itemnum ) { - $desc .= ' ' . $itemnum; - my $sth = $dbh->prepare( - 'INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id) - VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)'); - $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr; - } else { - my $sth=$dbh->prepare("INSERT INTO accountlines - (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id) - VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)" - ); - $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, - $amountleft, $notifyid, $note, $manager_id ); - } - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_fee', - borrowernumber => $borrowernumber, - accountno => $accountno, - amount => $amount, - description => $desc, - accounttype => $type, - amountoutstanding => $amountleft, - notify_id => $notifyid, - note => $note, - itemnumber => $itemnum, - manager_id => $manager_id, - })); - } - - return 0; -} - -sub getcharges { - my ( $borrowerno, $timestamp, $accountno ) = @_; - my $dbh = C4::Context->dbh; - my $timestamp2 = $timestamp - 1; - my $query = ""; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" - ); - $sth->execute( $borrowerno, $accountno ); - - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results,$data; - } - return (@results); -} - -sub ModNote { - my ( $accountlines_id, $note ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE accountlines_id = ?'); - $sth->execute( $note, $accountlines_id ); -} - -sub getcredits { - my ( $date, $date2 ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines,borrowers - WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber - AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)" - ); - - $sth->execute( $date, $date2 ); - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - $data->{'date'} = $data->{'timestamp'}; - push @results,$data; - } - return (@results); -} - - -sub getrefunds { - my ( $date, $date2 ) = @_; - my $dbh = C4::Context->dbh; - - my $sth = $dbh->prepare( - "SELECT *,timestamp AS datetime - FROM accountlines,borrowers - WHERE (accounttype = 'REF' - AND accountlines.borrowernumber = borrowers.borrowernumber - AND date >=? AND date execute( $date, $date2 ); - - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results,$data; - - } - return (@results); -} - -sub ReversePayment { - my ( $accountlines_id ) = @_; - my $dbh = C4::Context->dbh; - - my $sth = $dbh->prepare('SELECT * FROM accountlines WHERE accountlines_id = ?'); - $sth->execute( $accountlines_id ); - my $row = $sth->fetchrow_hashref(); - my $amount_outstanding = $row->{'amountoutstanding'}; - - if ( $amount_outstanding <= 0 ) { - $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); - $sth->execute( $accountlines_id ); - } else { - $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE accountlines_id = ?'); - $sth->execute( $accountlines_id ); - } - - if ( C4::Context->preference("FinesLog") ) { - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - - if ( $amount_outstanding <= 0 ) { - $row->{'amountoutstanding'} *= -1; - } else { - $row->{'amountoutstanding'} = '0'; - } - $row->{'description'} .= ' Reversed -'; - logaction("FINES", 'MODIFY', $row->{'borrowernumber'}, Dumper({ - action => 'reverse_fee_payment', - borrowernumber => $row->{'borrowernumber'}, - old_amountoutstanding => $row->{'amountoutstanding'}, - new_amountoutstanding => 0 - $amount_outstanding,, - accountlines_id => $row->{'accountlines_id'}, - accountno => $row->{'accountno'}, - manager_id => $manager_id, - })); - - } - -} - -=head2 recordpayment_selectaccts - - recordpayment_selectaccts($borrowernumber, $payment,$accts); - -Record payment by a patron. C<$borrowernumber> is the patron's -borrower number. C<$payment> is a floating-point number, giving the -amount that was paid. C<$accts> is an array ref to a list of -accountnos which the payment can be recorded against - -Amounts owed are paid off oldest first. That is, if the patron has a -$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment -of $1.50, then the oldest fine will be paid off in full, and $0.50 -will be credited to the next one. - -=cut - -sub recordpayment_selectaccts { - my ( $borrowernumber, $amount, $accts, $note ) = @_; - - my $dbh = C4::Context->dbh; - my $newamtos = 0; - my $accdata = q{}; - my $branch = C4::Context->userenv->{branch}; - my $amountleft = $amount; - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - my $sql = 'SELECT * FROM accountlines WHERE (borrowernumber = ?) ' . - 'AND (amountoutstanding<>0) '; - if (@{$accts} ) { - $sql .= ' AND accountno IN ( ' . join ',', @{$accts}; - $sql .= ' ) '; - } - $sql .= ' ORDER BY date'; - # begin transaction - my $nextaccntno = getnextacctno($borrowernumber); - - # get lines with outstanding amounts to offset - my $rows = $dbh->selectall_arrayref($sql, { Slice => {} }, $borrowernumber); - - # offset transactions - my $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding= ? ' . - 'WHERE accountlines_id=?'); - - my @ids; - for my $accdata ( @{$rows} ) { - if ($amountleft == 0) { - last; - } - if ( $accdata->{amountoutstanding} < $amountleft ) { - $newamtos = 0; - $amountleft -= $accdata->{amountoutstanding}; - } - else { - $newamtos = $accdata->{amountoutstanding} - $amountleft; - $amountleft = 0; - } - my $thisacct = $accdata->{accountlines_id}; - $sth->execute( $newamtos, $thisacct ); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ - action => 'fee_payment', - borrowernumber => $borrowernumber, - old_amountoutstanding => $accdata->{'amountoutstanding'}, - new_amountoutstanding => $newamtos, - amount_paid => $accdata->{'amountoutstanding'} - $newamtos, - accountlines_id => $accdata->{'accountlines_id'}, - accountno => $accdata->{'accountno'}, - manager_id => $manager_id, - })); - push( @ids, $accdata->{'accountlines_id'} ); - } - - } - - # 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 ); - UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_payment', - borrowernumber => $borrowernumber, - accountno => $nextaccntno, - amount => 0 - $amount, - amountoutstanding => 0 - $amountleft, - accounttype => 'Pay', - accountlines_paid => \@ids, - manager_id => $manager_id, - })); - } - - return; -} - -# 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 $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - if (!$amount || $amount < 0) { - return; - } - $payment_note //= ""; - my $dbh = C4::Context->dbh; - - my $nextaccntno = getnextacctno($borrowernumber); - my $newamtos = 0; - - my $data = $dbh->selectrow_hashref( - 'SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); - my $new_outstanding = $data->{amountoutstanding} - $amount; - - my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; - $dbh->do( $update, undef, $new_outstanding, $accountlines_id); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ - action => 'fee_payment', - borrowernumber => $borrowernumber, - old_amountoutstanding => $data->{'amountoutstanding'}, - new_amountoutstanding => $new_outstanding, - amount_paid => $data->{'amountoutstanding'} - $new_outstanding, - accountlines_id => $data->{'accountlines_id'}, - accountno => $data->{'accountno'}, - manager_id => $manager_id, - })); - } - - # create new line - my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' - . 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' - . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; - - $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, - "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); - - UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_payment', - borrowernumber => $user, - accountno => $nextaccntno, - amount => 0 - $amount, - accounttype => 'Pay', - itemnumber => $data->{'itemnumber'}, - accountlines_paid => [ $data->{'accountlines_id'} ], - manager_id => $manager_id, - })); - } - - return; -} - -=head2 WriteOffFee - - WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); - -Write off a fine for a patron. -C<$borrowernumber> is the patron's borrower number. -C<$accountline_id> is the accountline_id of the fee to write off. -C<$itemnum> is the itemnumber of of item whose fine is being written off. -C<$accounttype> is the account type of the fine being written off. -C<$amount> is a floating-point number, giving the amount that is being written off. -C<$branch> is the branchcode of the library where the writeoff occurred. -C<$payment_note> is the note to attach to this payment - -=cut - -sub WriteOffFee { - my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_; - $payment_note //= ""; - $branch ||= C4::Context->userenv->{branch}; - my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; - - # if no item is attached to fine, make sure to store it as a NULL - $itemnum ||= undef; - - my ( $sth, $query ); - my $dbh = C4::Context->dbh(); - - $query = " - UPDATE accountlines SET amountoutstanding = 0 - WHERE accountlines_id = ? AND borrowernumber = ? - "; - $sth = $dbh->prepare( $query ); - $sth->execute( $accountlines_id, $borrowernumber ); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ - action => 'fee_writeoff', - borrowernumber => $borrowernumber, - accountlines_id => $accountlines_id, - manager_id => $manager_id, - })); - } - - $query =" - INSERT INTO accountlines - ( borrowernumber, accountno, itemnumber, date, amount, description, accounttype, manager_id, note ) - VALUES ( ?, ?, ?, NOW(), ?, 'Writeoff', 'W', ?, ? ) - "; - $sth = $dbh->prepare( $query ); - my $acct = getnextacctno($borrowernumber); - $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note ); - - if ( C4::Context->preference("FinesLog") ) { - logaction("FINES", 'CREATE',$borrowernumber,Dumper({ - action => 'create_writeoff', - borrowernumber => $borrowernumber, - accountno => $acct, - amount => 0 - $amount, - accounttype => 'W', - itemnumber => $itemnum, - accountlines_paid => [ $accountlines_id ], - manager_id => $manager_id, - })); - } - - UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); - -} - -END { } # module clean-up code here (global destructor) - -1; -__END__ - -=head1 SEE ALSO - -DBI(3) - -=cut - diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm deleted file mode 100644 index 3b977fa..0000000 --- a/Koha/Schema/Result/Accountline.pm +++ /dev/null @@ -1,222 +0,0 @@ -use utf8; -package Koha::Schema::Result::Accountline; - -# Created by DBIx::Class::Schema::Loader -# DO NOT MODIFY THE FIRST PART OF THIS FILE - -=head1 NAME - -Koha::Schema::Result::Accountline - -=cut - -use strict; -use warnings; - -use base 'DBIx::Class::Core'; - -=head1 TABLE: C - -=cut - -__PACKAGE__->table("accountlines"); - -=head1 ACCESSORS - -=head2 accountlines_id - - data_type: 'integer' - is_auto_increment: 1 - is_nullable: 0 - -=head2 borrowernumber - - data_type: 'integer' - default_value: 0 - is_foreign_key: 1 - is_nullable: 0 - -=head2 accountno - - data_type: 'smallint' - default_value: 0 - is_nullable: 0 - -=head2 itemnumber - - data_type: 'integer' - is_foreign_key: 1 - is_nullable: 1 - -=head2 date - - data_type: 'date' - datetime_undef_if_invalid: 1 - is_nullable: 1 - -=head2 amount - - data_type: 'decimal' - is_nullable: 1 - size: [28,6] - -=head2 description - - data_type: 'mediumtext' - is_nullable: 1 - -=head2 dispute - - data_type: 'mediumtext' - is_nullable: 1 - -=head2 accounttype - - data_type: 'varchar' - is_nullable: 1 - size: 5 - -=head2 amountoutstanding - - data_type: 'decimal' - is_nullable: 1 - size: [28,6] - -=head2 lastincrement - - data_type: 'decimal' - is_nullable: 1 - size: [28,6] - -=head2 timestamp - - data_type: 'timestamp' - datetime_undef_if_invalid: 1 - default_value: current_timestamp - is_nullable: 0 - -=head2 notify_id - - data_type: 'integer' - default_value: 0 - is_nullable: 0 - -=head2 notify_level - - data_type: 'integer' - default_value: 0 - is_nullable: 0 - -=head2 note - - data_type: 'text' - is_nullable: 1 - -=head2 manager_id - - data_type: 'integer' - is_nullable: 1 - -=cut - -__PACKAGE__->add_columns( - "accountlines_id", - { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, - "borrowernumber", - { - data_type => "integer", - default_value => 0, - is_foreign_key => 1, - is_nullable => 0, - }, - "accountno", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "itemnumber", - { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, - "date", - { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, - "amount", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "description", - { data_type => "mediumtext", is_nullable => 1 }, - "dispute", - { data_type => "mediumtext", is_nullable => 1 }, - "accounttype", - { data_type => "varchar", is_nullable => 1, size => 5 }, - "amountoutstanding", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "lastincrement", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "timestamp", - { - data_type => "timestamp", - datetime_undef_if_invalid => 1, - default_value => \"current_timestamp", - is_nullable => 0, - }, - "notify_id", - { data_type => "integer", default_value => 0, is_nullable => 0 }, - "notify_level", - { data_type => "integer", default_value => 0, is_nullable => 0 }, - "note", - { data_type => "text", is_nullable => 1 }, - "manager_id", - { data_type => "integer", is_nullable => 1 }, -); - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=cut - -__PACKAGE__->set_primary_key("accountlines_id"); - -=head1 RELATIONS - -=head2 borrowernumber - -Type: belongs_to - -Related object: L - -=cut - -__PACKAGE__->belongs_to( - "borrowernumber", - "Koha::Schema::Result::Borrower", - { borrowernumber => "borrowernumber" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, -); - -=head2 itemnumber - -Type: belongs_to - -Related object: L - -=cut - -__PACKAGE__->belongs_to( - "itemnumber", - "Koha::Schema::Result::Item", - { itemnumber => "itemnumber" }, - { - is_deferrable => 1, - join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", - }, -); - - -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VLEuOBmnS+xgk7LXAqxtLw - - -# You can replace this text with custom content, and it will be preserved on regeneration -1; diff --git a/Koha/Schema/Result/Accountoffset.pm b/Koha/Schema/Result/Accountoffset.pm deleted file mode 100644 index e9d8c2f..0000000 --- a/Koha/Schema/Result/Accountoffset.pm +++ /dev/null @@ -1,106 +0,0 @@ -use utf8; -package Koha::Schema::Result::Accountoffset; - -# Created by DBIx::Class::Schema::Loader -# DO NOT MODIFY THE FIRST PART OF THIS FILE - -=head1 NAME - -Koha::Schema::Result::Accountoffset - -=cut - -use strict; -use warnings; - -use base 'DBIx::Class::Core'; - -=head1 TABLE: C - -=cut - -__PACKAGE__->table("accountoffsets"); - -=head1 ACCESSORS - -=head2 borrowernumber - - data_type: 'integer' - default_value: 0 - is_foreign_key: 1 - is_nullable: 0 - -=head2 accountno - - data_type: 'smallint' - default_value: 0 - is_nullable: 0 - -=head2 offsetaccount - - data_type: 'smallint' - default_value: 0 - is_nullable: 0 - -=head2 offsetamount - - data_type: 'decimal' - is_nullable: 1 - size: [28,6] - -=head2 timestamp - - data_type: 'timestamp' - datetime_undef_if_invalid: 1 - default_value: current_timestamp - is_nullable: 0 - -=cut - -__PACKAGE__->add_columns( - "borrowernumber", - { - data_type => "integer", - default_value => 0, - is_foreign_key => 1, - is_nullable => 0, - }, - "accountno", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetaccount", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetamount", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "timestamp", - { - data_type => "timestamp", - datetime_undef_if_invalid => 1, - default_value => \"current_timestamp", - is_nullable => 0, - }, -); - -=head1 RELATIONS - -=head2 borrowernumber - -Type: belongs_to - -Related object: L - -=cut - -__PACKAGE__->belongs_to( - "borrowernumber", - "Koha::Schema::Result::Borrower", - { borrowernumber => "borrowernumber" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, -); - - -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OTfcUiJCPb5aU/gjqAb/bA - - -# You can replace this text with custom content, and it will be preserved on regeneration -1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt deleted file mode 100644 index ca9c63a..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ /dev/null @@ -1,111 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %] -[% INCLUDE 'doc-head-close.inc' %] - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'patron-search.inc' %] - - - -
- -
-
-
-[% INCLUDE 'members-toolbar.inc' %] -
- - -
- -
- - - - - - - - - [% IF ( reverse_col ) %] - - [% END %] - - - - - [% FOREACH account IN accounts %] - - [% IF ( loop.odd ) %][% ELSE %][% END %] - - - - [% IF ( account.amountcredit ) %] - [% IF ( account.amountoutstandingcredit ) %] - [% IF ( reverse_col ) %] - - [% END %] - - - - [% END %] - - - - [% IF ( totalcredit ) %] - [% IF ( reverse_col ) %] - - - -
DateDescription of chargesNoteAmountOutstanding Print
[% account.date %] - [% SWITCH account.accounttype %] - [% CASE 'Pay' %]Payment,thanks - [% CASE 'N' %]New Card - [% CASE 'F' %]Fine - [% CASE 'A' %]Account management fee - [% CASE 'M' %]Sundry - [% CASE 'L' %]Lost Item - [% CASE 'W' %]Writeoff - [% CASE %][% account.accounttype %] - [%- END -%] - [%- IF account.description %], [% account.description %][% END %] -  [% IF ( account.itemnumber ) %]View item [% END %][% account.title |html %][% account.note | html_line_break %][% ELSE %][% END %][% account.amount %][% ELSE %][% END %][% account.amountoutstanding %] - [% IF ( account.payment ) %] - Reverse - [% ELSE %] -   - [% END %] - - [% IF ( account.payment ) %] - Print - [% ELSE %] - Print - [% END %] -
Total due - [% ELSE %] - - [% END %] - [% ELSE %] - [% IF ( reverse_col ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% total %]
-
- -
-
- -
-[% INCLUDE 'circ-menu.inc' %] -
-
-[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt deleted file mode 100644 index 30a4e20..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt +++ /dev/null @@ -1,87 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Borrowers › Create manual invoice -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'patron-search.inc' %] - - - -
- -
-
-
-[% INCLUDE 'members-toolbar.inc' %] - - -
- -
- -[% IF ( ERROR ) %] -[% IF ( ITEMNUMBER ) %] - ERROR an invalid itemnumber was entered, please hit back and try again -[% END %] -[% ELSE %] -
-
- Manual Invoice -
    -
  1. - - - -
  2. -
  3. -
  4. -
  5. -
  6. Example: 5.00
  7. -
-
Cancel
-
- -[% END %] -
- -
-
- -
-[% INCLUDE 'circ-menu.inc' %] -
-
-[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt deleted file mode 100644 index 23203b1..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ /dev/null @@ -1,166 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Patrons › Pay Fines for [% borrower.firstname %] [% borrower.surname %] -[% INCLUDE 'doc-head-close.inc' %] - - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'patron-search.inc' %] - - - -
- -
-
-
-[% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %] - - -
- -
- -[% IF ( accounts ) %] -
- -

Select all | Clear all

- - - - - - - - - - - - - - - - - - - - - -[% FOREACH account_grp IN accounts %] - [% FOREACH line IN account_grp.accountlines %] - - - - - - - - - - - -[% END %] -[% IF ( account_grp.total ) %] - - - - - -[% END %] -[% END %] - -
 Fines & chargesDescriptionPayment noteAccount typeNotify idLevelAmountAmount outstanding
Total Due:[% total | format('%.2f') %]
- [% IF ( line.amountoutstanding > 0 ) %] - - [% END %] - - [% IF ( line.amountoutstanding > 0 ) %] - - - [% END %] - - - - - - - - - - - - - [% SWITCH line.accounttype %] - [% CASE 'Pay' %]Payment,thanks - [% CASE 'N' %]New Card - [% CASE 'F' %]Fine - [% CASE 'A' %]Account management fee - [% CASE 'M' %]Sundry - [% CASE 'L' %]Lost Item - [% CASE 'W' %]Writeoff - [% CASE %][% line.accounttype %] - [%- END -%] - [%- IF line.description %], [% line.description %][% END %] - [% IF line.title %]([% line.title |html_entity %])[% END %] - [% line.accounttype %][% line.notify_id %][% line.notify_level %][% line.amount | format('%.2f') %][% line.amountoutstanding | format('%.2f') %]
Sub total:[% account_grp.total | format('%.2f') %]
-
- - - -Cancel -
-
-[% ELSE %] -

[% borrower.firstname %] [% borrower.surname %] has no outstanding fines.

-[% END %] -
- -
-
- -
-[% INCLUDE 'circ-menu.tt' %] -
-
-[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt deleted file mode 100644 index 9cec275..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ /dev/null @@ -1,233 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Patrons › Collect fine payment for [% borrower.firstname %] [% borrower.surname %] -[% INCLUDE 'doc-head-close.inc' %] - - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'patron-search.inc' %] - - -
- -
-
-
-[% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %] - - - -
- -
-[% IF ( error_over ) %] -
- You must pay a value less than or equal to [% total_due | format('%.2f') %]. -
-[% END %] - -[% IF ( pay_individual ) %] -
- - - - - - - - - - - - - -
- Pay an individual fine - - - - - - - - - - - - - - - - - - - - - -
DescriptionAccount typeNotify idLevelAmountAmount outstanding
Total amount payable:[% amountoutstanding | format('%.2f') %]
- [% description %] [% title %] - [% accounttype %][% notify_id %][% notify_level %][% amount | format('%.2f') %][% amountoutstanding | format('%.2f') %]
- -
    - -
  1. - - - -
  2. -
-
- - -
-[% ELSIF ( writeoff_individual ) %] -
-
- Write off an individual fine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DescriptionAccount typeNotify idLevelAmountAmount outstanding
Total amount to be written off:[% amountoutstanding | format('%.2f') %]
[% description %] [% title %][% accounttype %][% notify_id %][% notify_level %][% amount | format('%.2f') %][% amountoutstanding | format('%.2f') %]
-
- -
-[% ELSE %] - -
- - - - -
- [% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %] -
    -
  1. - Total amount outstanding: - [% total | format('%.2f') %] -
  2. -
  3. - - - -
  4. -
  5. - - -
  6. -
-
- -
-[% END %] -
-
-
- -
-[% INCLUDE 'circ-menu.tt' %] -
-
-[% INCLUDE 'intranet-bottom.inc' %] - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt deleted file mode 100644 index 26be3f4..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt +++ /dev/null @@ -1,63 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Print Receipt for [% cardnumber %] - - - - - - - -
- - -[% IF ( LibraryName ) %] - - - -[% END %] - - - - - - - - - - - - - - - - [% FOREACH account IN accounts %] - - - - [% IF ( account.amountcredit ) %] - - - [% END %] - - - - [% IF ( totalcredit ) %] - - -
-

[% LibraryName %]

-
-

Fee receipt

-
- [% IF ( branchname ) %]

[% branchname %]

[% END %] -
- Received with thanks from [% firstname %] [% surname %]
- Card number : [% cardnumber %]
-
DateDescription of chargesAmount
[% account.date %][% account.description %][% ELSE %][% END %][% account.amount %]
Total outstanding dues as on date : [% ELSE %][% END %][% total %]
-
-[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt deleted file mode 100644 index 8a19918..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt +++ /dev/null @@ -1,65 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Print Receipt for [% cardnumber %] - - - - - - - -
- - -[% IF ( LibraryName ) %] - - - -[% END %] - - - - - - - - - - - - - - - - - [% FOREACH account IN accounts %] - - - - [% IF ( account.amountcredit ) %] - [% IF ( account.amountoutstandingcredit ) %] - - - [% END %] - - - - [% IF ( totalcredit ) %] - - -
-

[% LibraryName %]

-
-

INVOICE

-
- [% IF ( branchname ) %]

[% branchname %]

[% END %] -
- Bill to: [% firstname %] [% surname %]
- Card number: [% cardnumber %]
-
DateDescription of chargesAmountAmount outstanding
[% account.date %][% account.description %][% ELSE %][% END %][% account.amount %][% ELSE %][% END %][% account.amountoutstanding %]
Total outstanding dues as on date: [% ELSE %][% END %][% total %]
-
-[% INCLUDE 'intranet-bottom.inc' %] diff --git a/members/boraccount.pl b/members/boraccount.pl deleted file mode 100755 index 255b1ff..0000000 --- a/members/boraccount.pl +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/perl - - -#writen 11/1/2000 by chris@katipo.oc.nz -#script to display borrowers account details - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use C4::Auth; -use C4::Output; -use C4::Dates qw/format_date/; -use CGI; -use C4::Members; -use C4::Branch; -use C4::Accounts; -use C4::Members::Attributes qw(GetBorrowerAttributes); - -my $input=new CGI; - - -my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/boraccount.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1, updatecharges => 1}, - debug => 1, - }); - -my $borrowernumber=$input->param('borrowernumber'); -my $action = $input->param('action') || ''; - -#get borrower details -my $data=GetMember('borrowernumber' => $borrowernumber); - -if ( $action eq 'reverse' ) { - ReversePayment( $input->param('accountlines_id') ); -} - -if ( $data->{'category_type'} eq 'C') { - my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; - $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; -} - -#get account details -my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber); -my $totalcredit; -if($total <= 0){ - $totalcredit = 1; -} - -my $reverse_col = 0; # Flag whether we need to show the reverse column -foreach my $accountline ( @{$accts}) { - $accountline->{amount} += 0.00; - if ($accountline->{amount} <= 0 ) { - $accountline->{amountcredit} = 1; - } - $accountline->{amountoutstanding} += 0.00; - if ( $accountline->{amountoutstanding} <= 0 ) { - $accountline->{amountoutstandingcredit} = 1; - } - - $accountline->{date} = format_date($accountline->{date}); - $accountline->{amount} = sprintf '%.2f', $accountline->{amount}; - $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding}; - if ($accountline->{accounttype} eq 'Pay') { - $accountline->{payment} = 1; - $reverse_col = 1; - } -} - -$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); - -my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'}); -$template->param( picture => 1 ) if $picture; - -if (C4::Context->preference('ExtendedPatronAttributes')) { - my $attributes = GetBorrowerAttributes($borrowernumber); - $template->param( - ExtendedPatronAttributes => 1, - extendedattributes => $attributes - ); -} - -$template->param( - finesview => 1, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - othernames => $data->{'othernames'}, - borrowernumber => $borrowernumber, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - categoryname => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - state => $data->{'state'}, - zipcode => $data->{'zipcode'}, - country => $data->{'country'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - branchcode => $data->{'branchcode'}, - branchname => GetBranchName($data->{'branchcode'}), - total => sprintf("%.2f",$total), - totalcredit => $totalcredit, - is_child => ($data->{'category_type'} eq 'C'), - reverse_col => $reverse_col, - accounts => $accts, - activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), - RoutingSerials => C4::Context->preference('RoutingSerials'), -); - -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/mancredit.pl b/members/mancredit.pl deleted file mode 100755 index a2c2258..0000000 --- a/members/mancredit.pl +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/perl - -#written 11/1/2000 by chris@katipo.oc.nz -#script to display borrowers account details - - -# Copyright 2000-2002 Katipo Communications -# Copyright 2010 BibLibre -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use C4::Auth; -use C4::Output; -use CGI; - -use C4::Members; -use C4::Branch; -use C4::Accounts; -use C4::Items; -use C4::Members::Attributes qw(GetBorrowerAttributes); - -my $input=new CGI; -my $flagsrequired = { borrowers => 1, updatecharges => 1 }; - -my $borrowernumber=$input->param('borrowernumber'); - -#get borrower details -my $data=GetMember('borrowernumber' => $borrowernumber); -my $add=$input->param('add'); - -if ($add){ - if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) { - my $barcode = $input->param('barcode'); - my $itemnum; - if ($barcode) { - $itemnum = GetItemnumberFromBarcode($barcode); - } - my $desc = $input->param('desc'); - my $note = $input->param('note'); - my $amount = $input->param('amount') || 0; - $amount = -$amount; - my $type = $input->param('type'); - manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); - } -} else { - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/mancredit.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => $flagsrequired, - debug => 1, - }); - - if ( $data->{'category_type'} eq 'C') { - my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; - $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; - } - - $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' ); - my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'}); - $template->param( picture => 1 ) if $picture; - -if (C4::Context->preference('ExtendedPatronAttributes')) { - my $attributes = GetBorrowerAttributes($borrowernumber); - $template->param( - ExtendedPatronAttributes => 1, - extendedattributes => $attributes - ); -} - - $template->param( - borrowernumber => $borrowernumber, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - categoryname => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - state => $data->{'state'}, - zipcode => $data->{'zipcode'}, - country => $data->{'country'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - branchcode => $data->{'branchcode'}, - branchname => GetBranchName($data->{'branchcode'}), - is_child => ($data->{'category_type'} eq 'C'), - activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), - RoutingSerials => C4::Context->preference('RoutingSerials'), - ); - output_html_with_http_headers $input, $cookie, $template->output; -} diff --git a/members/maninvoice.pl b/members/maninvoice.pl deleted file mode 100755 index c4a9294..0000000 --- a/members/maninvoice.pl +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/perl - -#written 11/1/2000 by chris@katipo.oc.nz -#script to display borrowers account details - - -# Copyright 2000-2002 Katipo Communications -# Copyright 2010 BibLibre -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use C4::Auth; -use C4::Output; -use CGI; -use C4::Members; -use C4::Accounts; -use C4::Items; -use C4::Branch; -use C4::Members::Attributes qw(GetBorrowerAttributes); - -my $input=new CGI; -my $flagsrequired = { borrowers => 1 }; - -my $borrowernumber=$input->param('borrowernumber'); - - -# get borrower details -my $data=GetMember('borrowernumber'=>$borrowernumber); -my $add=$input->param('add'); -if ($add){ - if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) { - # print $input->header; - my $barcode=$input->param('barcode'); - my $itemnum; - if ($barcode) { - $itemnum = GetItemnumberFromBarcode($barcode); - } - my $desc=$input->param('desc'); - my $amount=$input->param('amount'); - my $type=$input->param('type'); - my $note = $input->param('note'); - my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); - if ($error) { - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "members/maninvoice.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => $flagsrequired, - debug => 1, - } - ); - if ( $error =~ /FOREIGN KEY/ && $error =~ /itemnumber/ ) { - $template->param( 'ITEMNUMBER' => 1 ); - } - $template->param( 'ERROR' => $error ); - output_html_with_http_headers $input, $cookie, $template->output; - } else { - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); - exit; - } - } -} else { - - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/maninvoice.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1, updatecharges => 1}, - debug => 1, - }); - - # get authorised values with type of MANUAL_INV - my @invoice_types; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "MANUAL_INV"'); - $sth->execute(); - while ( my $row = $sth->fetchrow_hashref() ) { - push @invoice_types, $row; - } - $template->param( invoice_types_loop => \@invoice_types ); - - if ( $data->{'category_type'} eq 'C') { - my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; - $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; - } - - $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); - my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'}); - $template->param( picture => 1 ) if $picture; - -if (C4::Context->preference('ExtendedPatronAttributes')) { - my $attributes = GetBorrowerAttributes($borrowernumber); - $template->param( - ExtendedPatronAttributes => 1, - extendedattributes => $attributes - ); -} - $template->param( - borrowernumber => $borrowernumber, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - categoryname => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - state => $data->{'state'}, - zipcode => $data->{'zipcode'}, - country => $data->{'country'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - branchcode => $data->{'branchcode'}, - branchname => GetBranchName($data->{'branchcode'}), - is_child => ($data->{'category_type'} eq 'C'), - activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), - RoutingSerials => C4::Context->preference('RoutingSerials'), - ); - output_html_with_http_headers $input, $cookie, $template->output; -} diff --git a/members/pay.pl b/members/pay.pl deleted file mode 100755 index 8a8e902..0000000 --- a/members/pay.pl +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2000-2002 Katipo Communications -# Copyright 2010 BibLibre -# Copyright 2010,2011 PTFS-Europe Ltd -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -=head1 pay.pl - - written 11/1/2000 by chris@katipo.oc.nz - part of the koha library system, script to facilitate paying off fines - -=cut - -use strict; -use warnings; - -use URI::Escape; -use C4::Context; -use C4::Auth; -use C4::Output; -use CGI; -use C4::Members; -use C4::Accounts; -use C4::Stats; -use C4::Koha; -use C4::Overdues; -use C4::Branch; -use C4::Members::Attributes qw(GetBorrowerAttributes); - -our $input = CGI->new; - -our ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => 'members/pay.tmpl', - query => $input, - type => 'intranet', - authnotrequired => 0, - flagsrequired => { borrowers => 1, updatecharges => 1 }, - debug => 1, - } -); - -my @names = $input->param; - -our $borrowernumber = $input->param('borrowernumber'); -if ( !$borrowernumber ) { - $borrowernumber = $input->param('borrowernumber0'); -} - -# get borrower details -our $borrower = GetMember( borrowernumber => $borrowernumber ); -our $user = $input->remote_user; -$user ||= q{}; - -my $branches = GetBranches(); -our $branch = GetBranch( $input, $branches ); - -my $writeoff_item = $input->param('confirm_writeoff'); -my $paycollect = $input->param('paycollect'); -if ($paycollect) { - print $input->redirect( - "/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber"); -} -my $payselected = $input->param('payselected'); -if ($payselected) { - payselected(@names); -} - -my $writeoff_all = $input->param('woall'); # writeoff all fines -if ($writeoff_all) { - writeoff_all(@names); -} elsif ($writeoff_item) { - my $accountlines_id = $input->param('accountlines_id'); - my $itemno = $input->param('itemnumber'); - my $account_type = $input->param('accounttype'); - my $amount = $input->param('amountoutstanding'); - my $payment_note = $input->param("payment_note"); - WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note ); -} - -for (@names) { - if (/^pay_indiv_(\d+)$/) { - my $line_no = $1; - redirect_to_paycollect( 'pay_individual', $line_no ); - } elsif (/^wo_indiv_(\d+)$/) { - my $line_no = $1; - redirect_to_paycollect( 'writeoff_individual', $line_no ); - } -} - -$template->param( - activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), - RoutingSerials => C4::Context->preference('RoutingSerials'), -); - -add_accounts_to_template(); - -output_html_with_http_headers $input, $cookie, $template->output; - -sub add_accounts_to_template { - - my ( $total, undef, undef ) = GetMemberAccountRecords($borrowernumber); - my $accounts = []; - my @notify = NumberNotifyId($borrowernumber); - - my $notify_groups = []; - for my $notify_id (@notify) { - my ( $acct_total, $accountlines, undef ) = - GetBorNotifyAcctRecord( $borrowernumber, $notify_id ); - if ( @{$accountlines} ) { - my $totalnotify = AmountNotify( $notify_id, $borrowernumber ); - push @{$accounts}, - { accountlines => $accountlines, - notify => $notify_id, - total => $totalnotify, - }; - } - } - borrower_add_additional_fields($borrower); - $template->param( - accounts => $accounts, - borrower => $borrower, - total => $total, - ); - return; - -} - -sub get_for_redirect { - my ( $name, $name_in, $money ) = @_; - my $s = q{&} . $name . q{=}; - my $value = $input->param($name_in); - if ( !defined $value ) { - $value = ( $money == 1 ) ? 0 : q{}; - } - if ($money) { - $s .= sprintf '%.2f', $value; - } else { - $s .= $value; - } - return $s; -} - -sub redirect_to_paycollect { - my ( $action, $line_no ) = @_; - my $redirect = - "/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber"; - $redirect .= q{&}; - $redirect .= "$action=1"; - $redirect .= get_for_redirect( 'accounttype', "accounttype$line_no", 0 ); - $redirect .= get_for_redirect( 'amount', "amount$line_no", 1 ); - $redirect .= - get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 ); - $redirect .= get_for_redirect( 'accountno', "accountno$line_no", 0 ); - $redirect .= get_for_redirect( 'title', "title$line_no", 0 ); - $redirect .= get_for_redirect( 'itemnumber', "itemnumber$line_no", 0 ); - $redirect .= get_for_redirect( 'notify_id', "notify_id$line_no", 0 ); - $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 ); - $redirect .= get_for_redirect( 'accountlines_id', "accountlines_id$line_no", 0 ); - $redirect .= q{&} . 'payment_note' . q{=} . uri_escape( $input->param("payment_note_$line_no") ); - $redirect .= '&remote_user='; - $redirect .= $user; - return print $input->redirect($redirect); -} - -sub writeoff_all { - my @params = @_; - my @wo_lines = grep { /^accountno\d+$/ } @params; - for (@wo_lines) { - if (/(\d+)/) { - my $value = $1; - my $accounttype = $input->param("accounttype$value"); - - # my $borrowernum = $input->param("borrowernumber$value"); - my $itemno = $input->param("itemnumber$value"); - my $amount = $input->param("amountoutstanding$value"); - my $accountno = $input->param("accountno$value"); - my $accountlines_id = $input->param("accountlines_id$value"); - my $payment_note = $input->param("payment_note_$value"); - WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note ); - } - } - - $borrowernumber = $input->param('borrowernumber'); - print $input->redirect( - "/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); - return; -} - -sub borrower_add_additional_fields { - my $b_ref = shift; - -# some borrower info is not returned in the standard call despite being assumed -# in a number of templates. It should not be the business of this script but in lieu of -# a revised api here it is ... - if ( $b_ref->{category_type} eq 'C' ) { - my ( $catcodes, $labels ) = - GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - if ( @{$catcodes} ) { - if ( @{$catcodes} > 1 ) { - $b_ref->{CATCODE_MULTI} = 1; - } elsif ( @{$catcodes} == 1 ) { - $b_ref->{catcode} = $catcodes->[0]; - } - } - } elsif ( $b_ref->{category_type} eq 'A' ) { - $b_ref->{adultborrower} = 1; - } - my ( $picture, $dberror ) = GetPatronImage( $b_ref->{borrowernumber} ); - if ($picture) { - $b_ref->{has_picture} = 1; - } - - if (C4::Context->preference('ExtendedPatronAttributes')) { - $b_ref->{extendedattributes} = GetBorrowerAttributes($borrowernumber); - $template->param( - ExtendedPatronAttributes => 1, - ); - } - - $b_ref->{branchname} = GetBranchName( $b_ref->{branchcode} ); - return; -} - -sub payselected { - my @params = @_; - my $amt = 0; - my @lines_to_pay; - foreach (@params) { - if (/^incl_par_(\d+)$/) { - my $index = $1; - push @lines_to_pay, $input->param("accountno$index"); - $amt += $input->param("amountoutstanding$index"); - } - } - $amt = '&amt=' . $amt; - my $sel = '&selected=' . join ',', @lines_to_pay; - my $notes = '¬es=' . join("%0A", map { $input->param("payment_note_$_") } @lines_to_pay ); - my $redirect = - "/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber" - . $amt - . $sel - . $notes; - - print $input->redirect($redirect); - return; -} diff --git a/members/paycollect.pl b/members/paycollect.pl deleted file mode 100755 index 96ca0fb..0000000 --- a/members/paycollect.pl +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/perl -# Copyright 2009,2010 PTFS Inc. -# Copyright 2011 PTFS-Europe Ltd -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; -use URI::Escape; -use C4::Context; -use C4::Auth; -use C4::Output; -use CGI; -use C4::Members; -use C4::Accounts; -use C4::Koha; -use C4::Branch; - -my $input = CGI->new(); - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => 'members/paycollect.tmpl', - query => $input, - type => 'intranet', - authnotrequired => 0, - flagsrequired => { borrowers => 1, updatecharges => 1 }, - debug => 1, - } -); - -# get borrower details -my $borrowernumber = $input->param('borrowernumber'); -my $borrower = GetMember( borrowernumber => $borrowernumber ); -my $user = $input->remote_user; - -# get account details -my $branch = GetBranch( $input, GetBranches() ); - -my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber); -my $total_paid = $input->param('paid'); - -my $individual = $input->param('pay_individual'); -my $writeoff = $input->param('writeoff_individual'); -my $select_lines = $input->param('selected'); -my $select = $input->param('selected_accts'); -my $payment_note = uri_unescape $input->param('payment_note'); -my $accountno; -my $accountlines_id; -if ( $individual || $writeoff ) { - if ($individual) { - $template->param( pay_individual => 1 ); - } elsif ($writeoff) { - $template->param( writeoff_individual => 1 ); - } - my $accounttype = $input->param('accounttype'); - $accountlines_id = $input->param('accountlines_id'); - my $amount = $input->param('amount'); - my $amountoutstanding = $input->param('amountoutstanding'); - $accountno = $input->param('accountno'); - my $itemnumber = $input->param('itemnumber'); - my $description = $input->param('description'); - my $title = $input->param('title'); - my $notify_id = $input->param('notify_id'); - my $notify_level = $input->param('notify_level'); - $total_due = $amountoutstanding; - $template->param( - accounttype => $accounttype, - accountlines_id => $accountlines_id, - accountno => $accountno, - amount => $amount, - amountoutstanding => $amountoutstanding, - title => $title, - itemnumber => $itemnumber, - description => $description, - notify_id => $notify_id, - notify_level => $notify_level, - payment_note => $payment_note, - ); -} elsif ($select_lines) { - $total_due = $input->param('amt'); - $template->param( - selected_accts => $select_lines, - amt => $total_due, - selected_accts_notes => $input->param('notes'), - ); -} - -if ( $total_paid and $total_paid ne '0.00' ) { - if ( $total_paid < 0 or $total_paid > $total_due ) { - $template->param( - error_over => 1, - total_due => $total_due - ); - } else { - if ($individual) { - if ( $total_paid == $total_due ) { - makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user, - $branch, $payment_note ); - } else { - makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, - $user, $branch, $payment_note ); - } - print $input->redirect( - "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"); - } else { - if ($select) { - if ( $select =~ /^([\d,]*).*/ ) { - $select = $1; # ensure passing no junk - } - my @acc = split /,/, $select; - my $note = $input->param('selected_accts_notes'); - recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note ); - } else { - recordpayment( $borrowernumber, $total_paid ); - } - -# recordpayment does not return success or failure so lets redisplay the boraccount - - print $input->redirect( -"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber" - ); - } - } -} else { - $total_paid = '0.00'; #TODO not right with pay_individual -} - -borrower_add_additional_fields($borrower); - -$template->param( - borrowernumber => $borrowernumber, # some templates require global - borrower => $borrower, - total => $total_due, - activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), - RoutingSerials => C4::Context->preference('RoutingSerials'), -); - -output_html_with_http_headers $input, $cookie, $template->output; - -sub borrower_add_additional_fields { - my $b_ref = shift; - -# some borrower info is not returned in the standard call despite being assumed -# in a number of templates. It should not be the business of this script but in lieu of -# a revised api here it is ... - if ( $b_ref->{category_type} eq 'C' ) { - my ( $catcodes, $labels ) = - GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - if ( @{$catcodes} ) { - if ( @{$catcodes} > 1 ) { - $b_ref->{CATCODE_MULTI} = 1; - } elsif ( @{$catcodes} == 1 ) { - $b_ref->{catcode} = $catcodes->[0]; - } - } - } elsif ( $b_ref->{category_type} eq 'A' ) { - $b_ref->{adultborrower} = 1; - } - my ( $picture, $dberror ) = GetPatronImage( $b_ref->{borrowernumber} ); - if ($picture) { - $b_ref->{has_picture} = 1; - } - - $b_ref->{branchname} = GetBranchName( $b_ref->{branchcode} ); - return; -} diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl deleted file mode 100755 index 6a86bc3..0000000 --- a/members/printfeercpt.pl +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/perl - - -#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz -#script to print fee receipts - - -# Copyright Koustubha Kale -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use C4::Auth; -use C4::Output; -use C4::Dates qw/format_date/; -use CGI; -use C4::Members; -use C4::Branch; -use C4::Accounts; - -my $input=new CGI; - - -my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/printfeercpt.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1, updatecharges => 1}, - debug => 1, - }); - -my $borrowernumber=$input->param('borrowernumber'); -my $action = $input->param('action') || ''; -my $accountlines_id = $input->param('accountlines_id'); - -#get borrower details -my $data=GetMember('borrowernumber' => $borrowernumber); - -if ( $action eq 'print' ) { -# ReversePayment( $borrowernumber, $input->param('accountno') ); -} - -if ( $data->{'category_type'} eq 'C') { - my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; - $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; -} - -#get account details -my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber); -my $totalcredit; -if($total <= 0){ - $totalcredit = 1; -} -my @accountrows; # this is for the tmpl-loop - -my $toggle; -for (my $i=0;$i<$numaccts;$i++){ - next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id ); - if($i%2){ - $toggle = 0; - } else { - $toggle = 1; - } - $accts->[$i]{'toggle'} = $toggle; - $accts->[$i]{'amount'}+=0.00; - if($accts->[$i]{'amount'} <= 0){ - $accts->[$i]{'amountcredit'} = 1; - $accts->[$i]{'amount'}*=-1.00; - } - $accts->[$i]{'amountoutstanding'}+=0.00; - if($accts->[$i]{'amountoutstanding'} <= 0){ - $accts->[$i]{'amountoutstandingcredit'} = 1; - } - my %row = ( 'date' => format_date($accts->[$i]{'date'}), - 'amountcredit' => $accts->[$i]{'amountcredit'}, - 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, - 'toggle' => $accts->[$i]{'toggle'}, - 'description' => $accts->[$i]{'description'}, - 'itemnumber' => $accts->[$i]{'itemnumber'}, - 'biblionumber' => $accts->[$i]{'biblionumber'}, - 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}), - 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}), - 'accountno' => $accts->[$i]{'accountno'}, - 'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ), - - ); - - if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){ - $row{'printtitle'}=1; - $row{'title'} = $accts->[$i]{'title'}; - } - - push(@accountrows, \%row); -} - -$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); - -my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'}); -$template->param( picture => 1 ) if $picture; - -$template->param( - finesview => 1, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - borrowernumber => $borrowernumber, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - # category_description => $data->{'description'}, - categoryname => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - zipcode => $data->{'zipcode'}, - country => $data->{'country'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - branchcode => $data->{'branchcode'}, - branchname => GetBranchName($data->{'branchcode'}), - total => sprintf("%.2f",$total), - totalcredit => $totalcredit, - is_child => ($data->{'category_type'} eq 'C'), - accounts => \@accountrows ); - -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/printinvoice.pl b/members/printinvoice.pl deleted file mode 100755 index 10ae114..0000000 --- a/members/printinvoice.pl +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/perl - -#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz -#script to print fee receipts - -# Copyright Koustubha Kale -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use C4::Auth; -use C4::Output; -use C4::Dates qw/format_date/; -use CGI; -use C4::Members; -use C4::Branch; -use C4::Accounts; - -my $input = new CGI; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "members/printinvoice.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => { borrowers => 1, updatecharges => 1 }, - debug => 1, - } -); - -my $borrowernumber = $input->param('borrowernumber'); -my $action = $input->param('action') || ''; -my $accountlines_id = $input->param('accountlines_id'); - -#get borrower details -my $data = GetMember( 'borrowernumber' => $borrowernumber ); - -if ( $data->{'category_type'} eq 'C' ) { - my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; - $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; -} - -#get account details -my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber); -my $totalcredit; -if ( $total <= 0 ) { - $totalcredit = 1; -} - -my @accountrows; # this is for the tmpl-loop - -my $toggle; -for ( my $i = 0 ; $i < $numaccts ; $i++ ) { - next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id ); - - if ( $i % 2 ) { - $toggle = 0; - } else { - $toggle = 1; - } - - $accts->[$i]{'toggle'} = $toggle; - $accts->[$i]{'amount'} += 0.00; - - if ( $accts->[$i]{'amount'} <= 0 ) { - $accts->[$i]{'amountcredit'} = 1; - } - - $accts->[$i]{'amountoutstanding'} += 0.00; - if ( $accts->[$i]{'amountoutstanding'} <= 0 ) { - $accts->[$i]{'amountoutstandingcredit'} = 1; - } - - my %row = ( - 'date' => format_date( $accts->[$i]{'date'} ), - 'amountcredit' => $accts->[$i]{'amountcredit'}, - 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, - 'toggle' => $accts->[$i]{'toggle'}, - 'description' => $accts->[$i]{'description'}, - 'itemnumber' => $accts->[$i]{'itemnumber'}, - 'biblionumber' => $accts->[$i]{'biblionumber'}, - 'amount' => sprintf( "%.2f", $accts->[$i]{'amount'} ), - 'amountoutstanding' => sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ), - 'accountno' => $accts->[$i]{'accountno'}, - 'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ), - ); - - if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) { - $row{'printtitle'} = 1; - $row{'title'} = $accts->[$i]{'title'}; - } - - push( @accountrows, \%row ); -} - -$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); - -my ( $picture, $dberror ) = GetPatronImage( $data->{'borrowernumber'} ); -$template->param( picture => 1 ) if $picture; - -$template->param( - finesview => 1, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - borrowernumber => $borrowernumber, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - categoryname => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - zipcode => $data->{'zipcode'}, - country => $data->{'country'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - branchcode => $data->{'branchcode'}, - branchname => GetBranchName( $data->{'branchcode'} ), - total => sprintf( "%.2f", $total ), - totalcredit => $totalcredit, - is_child => ( $data->{'category_type'} eq 'C' ), - accounts => \@accountrows -); - -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/misc/maintenance/fix_accountlines_date.pl b/misc/maintenance/fix_accountlines_date.pl deleted file mode 100755 index 2956f57..0000000 --- a/misc/maintenance/fix_accountlines_date.pl +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (C) 2008 LibLime -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/../kohalib.pl" }; -} - -use C4::Context; -use C4::Dates; -use Getopt::Long; -use Pod::Usage; - -=head1 NAME - -fix_accountlines_date.pl - Fix date code in the description of fines - -=head1 SYNOPSIS - -fix_accountlines_date.pl -m date_format [ -n fines_to_process ] [ -d ] [ --help or -h ] - - Options: - --help or -h Brief usage message - --man Full documentation - -n fines_to_process How many fines to process; if left off will - process all - -m date_format What format the dates are currently in; 'us' - or 'metric' (REQUIRED) - -d Run in debugging mode - -=head1 DESCRIPTION - -This script fixes the date code in the description of fines. Previously, the -format of this was determined by which script you were using to update fines (see the -m option) - -=over 8 - -=item B<--help> - -Prints a brief usage message and exits. - -=item B<--man> - -Prints a full manual page and exits. - -=item B<-n> - -Process only a certain amount of fines. If this option is left off, this script -will process everything. - -=item B<-m> - -This required option tells the script what format your dates are currently in. -If you were previously using the fines2.pl or fines-sanop.pl script to update -your fines, they will be in 'metric' format. If you were using the fines-ll.pl -script, they will be in 'us' format. After this script is finished, they will -be in whatever format your 'dateformat' system preference specifies. - -=item B<-d> - -Run in debugging mode; this prints out a lot of information and should be used -only if there is a problem and with the '-n' option. - -=back - -=cut - -my $mode = ''; -my $want_help = 0; -my $limit = -1; -my $done = 0; -my $DEBUG = 0; - -# Regexes for the two date formats -our $US_DATE = '((0\d|1[0-2])\/([0-2]\d|3[01])\/(\d{4}))'; -our $METRIC_DATE = '(([0-2]\d|3[01])\/(0\d|1[0-2])\/(\d{4}))'; - -sub print_usage { - print <<_USAGE_ -$0: Fix the date code in the description of fines - -Due to the multiple scripts used to update fines in earlier versions of Koha, -this script should be used to change the format of the date codes in the -accountlines table before you start using Koha 3.0. - -Parameters: - --mode or -m This should be 'us' or 'metric', and tells the script - what format your old dates are in. - --debug or -d Run this script in debug mode. - --limit or -n How many accountlines rows to fix; useful for testing. - --help or -h Print out this help message. -_USAGE_ -} - -my $result = GetOptions( - 'm=s' => \$mode, - 'd' => \$DEBUG, - 'n=i' => \$limit, - 'help|h' => \$want_help, -); - -if (not $result or $want_help or ($mode ne 'us' and $mode ne 'metric')) { - print_usage(); - exit 0; -} - -our $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -my $sth = $dbh->prepare(" -SELECT borrowernumber, itemnumber, accountno, description - FROM accountlines - WHERE accounttype in ('FU', 'F', 'O', 'M') -;"); -$sth->execute(); - -my $update_sth = $dbh->prepare(' -UPDATE accountlines - SET description = ? - WHERE borrowernumber = ? AND itemnumber = ? AND accountno = ? -;'); - - -while (my $accountline = $sth->fetchrow_hashref) { - my $description = $accountline->{'description'}; - my $updated = 0; - - if ($mode eq 'us') { - if ($description =~ /$US_DATE/) { # mm/dd/yyyy - my $date = C4::Dates->new($1, 'us'); - print "Converting $1 (us) to " . $date->output() . "\n" if $DEBUG; - $description =~ s/$US_DATE/$date->output()/; - $updated = 1; - } - } elsif ($mode eq 'metric') { - if ($description =~ /$METRIC_DATE/) { # dd/mm/yyyy - my $date = C4::Dates->new($1, 'metric'); - print "Converting $1 (metric) to " . $date->output() . "\n" if $DEBUG; - $description =~ s/$METRIC_DATE/$date->output()/; - $updated = 2; - } - } - - print "Changing description from '" . $accountline->{'description'} . "' to '" . $description . "'\n" if $DEBUG; - $update_sth->execute($description, $accountline->{'borrowernumber'}, $accountline->{'itemnumber'}, $accountline->{'accountno'}); - - $done++; - - last if ($done == $limit); # $done can't be -1, so this works -} - -$dbh->commit(); -- 1.7.2.5