[Koha-patches] [PATCH] Bug 5752 : Add note and manager_id to accountlines
Chris Cormack
chrisc at catalyst.net.nz
Mon Feb 14 00:44:39 CET 2011
Squashed commit of the following:
commit 17c7a359f549e4bc69581e49c09aec84b1106f36
Author: Stéphane Delaune <stephane.delaune at biblibre.com>
Date: Mon Aug 30 09:37:43 2010 +0200
Bug 5752 : (MT #1874) followup : adding note and manager_id fields to accountlines
commit e128e26066792bddb51878be6202dc89ac30b33a
Author: Stéphane Delaune <stephane.delaune at biblibre.com>
Date: Fri Aug 27 17:26:10 2010 +0200
Bug 5752 : (MT #1874) adding note and manager_id fields to accountlines
---
C4/Accounts.pm | 34 +++++++----
installer/data/mysql/kohastructure.sql | 2 +
installer/data/mysql/updatedatabase.pl | 16 +++++
.../prog/en/modules/members/boraccount.tmpl | 2 +
.../prog/en/modules/members/mancredit.tmpl | 1 +
.../prog/en/modules/members/maninvoice.tmpl | 1 +
.../intranet-tmpl/prog/en/modules/members/pay.tmpl | 12 +++-
kohaversion.pl | 2 +-
members/mancredit.pl | 28 +++++----
members/maninvoice.pl | 61 ++++++++++---------
members/pay.pl | 43 ++++++++------
.../lib/KohaTest/Members/GetMemberDetails.pm | 6 +-
12 files changed, 130 insertions(+), 78 deletions(-)
diff --git a/C4/Accounts.pm b/C4/Accounts.pm
index d73fc2e..d850949 100644
--- a/C4/Accounts.pm
+++ b/C4/Accounts.pm
@@ -35,10 +35,10 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&recordpayment &makepayment &manualinvoice
- &getnextacctno &reconcileaccount &getcharges &getcredits
+ &getnextacctno &reconcileaccount &getcharges &ModNote &getcredits
&getrefunds &chargelostitem
&ReversePayment
- ); # removed &fixaccounts
+ );
}
=head1 NAME
@@ -327,7 +327,7 @@ sub chargelostitem{
=head2 manualinvoice
&manualinvoice($borrowernumber, $itemnumber, $description, $type,
- $amount, $user);
+ $amount, $note);
C<$borrowernumber> is the patron's borrower number.
C<$description> is a description of the transaction.
@@ -351,7 +351,8 @@ should be the empty string.
#
sub manualinvoice {
- my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_;
+ my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
+ my $manager_id = C4::Context->userenv->{'number'};
my $dbh = C4::Context->dbh;
my $notifyid = 0;
my $insert;
@@ -403,16 +404,17 @@ sub manualinvoice {
$desc .= " " . $itemnum;
my $sth = $dbh->prepare(
"INSERT INTO accountlines
- (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id)
- VALUES (?, ?, now(), ?,?, ?,?,?,?)");
- $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr;
- } else {
- my $sth=$dbh->prepare("INSERT INTO accountlines
- (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)
- VALUES (?, ?, now(), ?, ?, ?, ?,?)"
+ (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 );
+ $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $notifyid, $note, $manager_id );
}
return 0;
}
@@ -606,6 +608,12 @@ sub getcharges {
return (@results);
}
+sub ModNote {
+ my ( $borrowernumber, $accountno, $note ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $note, $borrowernumber, $accountno );
+}
sub getcredits {
my ( $date, $date2 ) = @_;
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index e7ad97f..5923f66 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2289,6 +2289,8 @@ CREATE TABLE `accountlines` (
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`notify_id` int(11) NOT NULL default 0,
`notify_level` int(2) NOT NULL default 0,
+ `note` text NULL default NULL,
+ `manager_id` int( 11 ) NULL,
KEY `acctsborridx` (`borrowernumber`),
KEY `timeidx` (`timestamp`),
KEY `itemnumber` (`itemnumber`),
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index d9b546b..ba1a192 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -3995,6 +3995,22 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.03.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
+ print "Upgrade to $DBversion done (adding note field in accountlines table)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.03.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
+ print "Upgrade to $DBversion done (adding manager_id field in accountlines table)\n";
+ SetVersion($DBversion);
+}
+
+
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
index ef59ad2..4f66ec5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
@@ -30,6 +30,7 @@
<tr>
<th>Date</th>
<th>Description of charges</th>
+ <th>Note</th>
<th>Amount</th>
<th>Outstanding</th>
<!-- TMPL_IF NAME="reverse_col" -->
@@ -44,6 +45,7 @@
<!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
<td><!-- TMPL_VAR NAME="date" --></td>
<td><!-- TMPL_VAR NAME="description" --> <!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a> <!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
+ <td><!-- TMPL_VAR NAME="note" --></td>
<!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
<!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
<!-- TMPL_IF NAME="reverse_col" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
index 16f7a7b..995767b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
@@ -43,6 +43,7 @@ $(document).ready(function(){
</select></li>
<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
+ <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
</ol></fieldset>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
index a7c49e8..2a6af2d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
@@ -67,6 +67,7 @@ type_fees['<!-- TMPL_VAR NAME="authorised_value" -->'] = "<!-- TMPL_VAR NAME="li
</li>
<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
+ <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
</ol></fieldset>
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
index 1177ba2..3772bda 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
@@ -32,6 +32,7 @@
<tr>
<th>Fines & Charges</th>
<th>Description</th>
+ <th>Note</th>
<th>Account Type</th>
<th>Notify id</th>
<th>Level</th>
@@ -61,6 +62,13 @@
<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
</td>
<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
+ <td>
+ <!-- TMPL_IF NAME="net_balance" -->
+ <input type="text" name="note<!-- TMPL_VAR name="i" -->" value="
+ <!-- /TMPL_IF -->
+ <!-- TMPL_VAR name="note" -->
+ <!-- TMPL_IF NAME="net_balance" -->" /><!-- /TMPL_IF -->
+ </td>
<td><!-- TMPL_VAR name="accounttype" --></td>
<td><!-- TMPL_VAR name="notify_id" --></td>
<td><!-- TMPL_VAR name="notify_level" --></td>
@@ -71,13 +79,13 @@
<!-- TMPL_IF NAME="total"-->
<tr>
- <td colspan="6">Sub Total</td>
+ <td colspan="7">Sub Total</td>
<td><!-- TMPL_VAR name="total" --></td>
</tr>
<!--/TMPL_IF-->
<!-- /TMPL_LOOP -->
<tr>
- <td colspan="6">Total Due</td>
+ <td colspan="7">Total Due</td>
<td><!-- TMPL_VAR name="total" --></td>
</tr>
</table>
diff --git a/kohaversion.pl b/kohaversion.pl
index efb04c8..8330459 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
use strict;
sub kohaversion {
- our $VERSION = '3.03.00.018';
+ our $VERSION = '3.03.00.XXX';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
diff --git a/members/mancredit.pl b/members/mancredit.pl
index 51b71d6..68c0ca3 100755
--- a/members/mancredit.pl
+++ b/members/mancredit.pl
@@ -41,18 +41,22 @@ my $borrowernumber=$input->param('borrowernumber');
my $data=GetMember('borrowernumber' => $borrowernumber);
my $add=$input->param('add');
-if ($add){
- my $barcode=$input->param('barcode');
- my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
- my $desc=$input->param('desc');
- my $amount=$input->param('amount') || 0;
- $amount = -$amount;
- my $type=$input->param('type');
- manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
- 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",
+if ($add) {
+ if(checkauth($input)){
+ my $barcode = $input->param('barcode');
+ my $itemnum = GetItemnumberFromBarcode($barcode) if $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,
diff --git a/members/maninvoice.pl b/members/maninvoice.pl
index df12a2a..c9e30fd 100755
--- a/members/maninvoice.pl
+++ b/members/maninvoice.pl
@@ -36,36 +36,39 @@ my $input=new CGI;
my $borrowernumber=$input->param('borrowernumber');
-
# get borrower details
-my $data=GetMember('borrowernumber'=>$borrowernumber);
-my $add=$input->param('add');
-if ($add){
-# print $input->header;
- my $barcode=$input->param('barcode');
+my $data = GetMember( 'borrowernumber' => $borrowernumber );
+my $add = $input->param('add');
+if ($add) {
+ if(checkauth($input))
+ {
+ # print $input->header;
+ my $barcode = $input->param('barcode');
my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
- my $desc=$input->param('desc');
- my $amount=$input->param('amount');
- my $type=$input->param('type');
- my $error=manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
- if ($error){
- my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "members/maninvoice.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {borrowers => 1},
- 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;
+ 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 => { borrowers => 1 },
+ 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 {
@@ -77,7 +80,7 @@ if ($add){
flagsrequired => {borrowers => 1, updatecharges => 1},
debug => 1,
});
-
+
# get authorised values with type of MANUAL_INV
my @invoice_types;
my $dbh = C4::Context->dbh;
diff --git a/members/pay.pl b/members/pay.pl
index 5a36bd7..d0fba35 100755
--- a/members/pay.pl
+++ b/members/pay.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
# Copyright 2000-2002 Katipo Communications
+# Parts Copyright Biblibre 2010
#
# This file is part of Koha.
#
@@ -41,6 +42,7 @@ use C4::Branch; # GetBranches
my $input = new CGI;
+#warn Data::Dumper::Dumper $input;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "members/pay.tmpl",
@@ -83,7 +85,14 @@ for ( my $i = 0 ; $i < @names ; $i++ ) {
makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
$check = 2;
}
+ if ( $temp eq 'no'||$temp eq 'yes'||$temp eq 'wo') {
+ my $borrowernumber = $input->param( $names[ $i + 5 ] );
+ my $accountno = $input->param( $names[ $i + 6 ] );
+ my $note = $input->param( $names[ $i + 10 ] );
+ ModNote( $borrowernumber, $accountno, $note );
+ }
}
+
my $total = $input->param('total') || '';
if ( $check == 0 ) {
if ( $total ne '' ) {
@@ -105,19 +114,19 @@ if ( $check == 0 ) {
if ( $accts->[$i]{'amountoutstanding'} != 0 ) {
$accts->[$i]{'amount'} += 0.00;
$accts->[$i]{'amountoutstanding'} += 0.00;
- $line{i} = $j . "" . $i;
- $line{itemnumber} = $accts->[$i]{'itemnumber'};
- $line{accounttype} = $accts->[$i]{'accounttype'};
- $line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} );
- $line{amountoutstanding} =
- sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} );
- $line{borrowernumber} = $borrowernumber;
- $line{accountno} = $accts->[$i]{'accountno'};
- $line{description} = $accts->[$i]{'description'};
- $line{title} = $accts->[$i]{'title'};
- $line{notify_id} = $accts->[$i]{'notify_id'};
- $line{notify_level} = $accts->[$i]{'notify_level'};
- $line{net_balance} = 1 if($accts->[$i]{'amountoutstanding'} > 0); # you can't pay a credit.
+ $line{i} = $j . "" . $i;
+ $line{itemnumber} = $accts->[$i]{'itemnumber'};
+ $line{accounttype} = $accts->[$i]{'accounttype'};
+ $line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} );
+ $line{amountoutstanding} = sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} );
+ $line{borrowernumber} = $borrowernumber;
+ $line{accountno} = $accts->[$i]{'accountno'};
+ $line{description} = $accts->[$i]{'description'};
+ $line{note} = $accts->[$i]{'note'};
+ $line{title} = $accts->[$i]{'title'};
+ $line{notify_id} = $accts->[$i]{'notify_id'};
+ $line{notify_level} = $accts->[$i]{'notify_level'};
+ $line{net_balance} = 1 if ( $accts->[$i]{'amountoutstanding'} > 0 ); # you can't pay a credit.
push( @loop_pay, \%line );
}
}
@@ -129,21 +138,21 @@ if ( $check == 0 ) {
'loop_pay' => \@loop_pay,
'notify' => $notify[$j],
'total' => sprintf( "%.2f",$totalnotify),
-
+
};
}
-
+
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->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
-
+
$template->param(
allfile => \@allfile,
firstname => $data->{'firstname'},
diff --git a/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm b/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm
index e93742b..b50d279 100644
--- a/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm
+++ b/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm
@@ -50,11 +50,9 @@ sub startup_create_detailed_borrower : Test( startup => 2 ) {
$description = 'Test account';
$type = 'M';
$amount = 5.00;
- $user = '';
+ $note = '';
- my $acct_added =
- C4::Accounts::manualinvoice( $borrowernumber, undef, $description, $type, $amount,
- $user );
+ my $acct_added = C4::Accounts::manualinvoice( $borrowernumber, undef, $description, $type, $amount, $note );
ok( $acct_added == 0, 'added account for borrower' );
--
1.7.1
More information about the Koha-patches
mailing list