Bugzilla – Attachment 8162 Details for
Bug 7595
Add branchcode to accountlines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 7595 - Add branchcode to accountlines
SIGNED-OFF-Bug-7595---Add-branchcode-to-accountlin.patch (text/plain), 8.78 KB, created by
Nicole C. Engard
on 2012-03-11 19:49:55 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 7595 - Add branchcode to accountlines
Filename:
MIME Type:
Creator:
Nicole C. Engard
Created:
2012-03-11 19:49:55 UTC
Size:
8.78 KB
patch
obsolete
>From aee4a0fb6f9106e48a8230831f4ff3f18a00f840 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 24 Feb 2012 14:26:05 -0500 >Subject: [PATCH] [SIGNED-OFF] Bug 7595 - Add branchcode to accountlines > >Adds a branchcode column to the accountlines table. For payments, >this inserts the branchcode of the library where the payment was >recorded. For manual invoices, it insert the branchcode of the >library where the manual invoice was created. > >Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com> > >I tested with creating manual invoices, and paying partial fines, >entire fine lines, and writing off fines. All actions record the branch >where the action took place properly. >--- > C4/Accounts.pm | 57 +++++++++++++++++-------------- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 ++++ > 3 files changed, 39 insertions(+), 26 deletions(-) > >diff --git a/C4/Accounts.pm b/C4/Accounts.pm >index c3d121d..a67308c 100644 >--- a/C4/Accounts.pm >+++ b/C4/Accounts.pm >@@ -124,11 +124,10 @@ sub recordpayment { > > # create new line > my $usth = $dbh->prepare( >- "INSERT INTO accountlines >- (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) >- VALUES (?,?,now(),?,'Payment,thanks','Pay',?)" >+ "INSERT INTO accountlines ( borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, branchcode ) >+ VALUES ( ?, ?, now(), ?, 'Payment,thanks','Pay', ?, ? )" > ); >- $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft ); >+ $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $branch ); > $usth->finish; > UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno ); > $sth->finish; >@@ -201,10 +200,10 @@ sub makepayment { > my $ins = > $dbh->prepare( > "INSERT >- INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id) >- VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)" >+ INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, branchcode) >+ VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" > ); >- $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id); >+ $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'}); > $ins->finish; > } > >@@ -298,10 +297,10 @@ sub chargelostitem{ > # 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) >- VALUES (?,?,now(),?,?,'L',?,?)"); >+ (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,branchcode) >+ VALUES (?,?,now(),?,?,'L',?,?,?)"); > $sth2->execute($borrowernumber,$accountno,$amount, >- $description,$amount,$itemnumber); >+ $description,$amount,$itemnumber,C4::Context->userenv->{'branch'}); > $sth2->finish; > # FIXME: Log this ? > } >@@ -337,6 +336,7 @@ sub manualinvoice { > my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; > my $manager_id = 0; > $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; >+ my $branchcode = C4::Context->userenv->{'branch'}; > my $dbh = C4::Context->dbh; > my $notifyid = 0; > my $insert; >@@ -387,16 +387,16 @@ sub manualinvoice { > $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; >+ (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode) >+ VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)'); >+ $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || 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(), ?, ?, ?, ?,?,?,?)" >+ (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode) >+ VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)" > ); > $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, >- $amountleft, $notifyid, $note, $manager_id ); >+ $amountleft, $notifyid, $note, $manager_id, $branchcode ); > } > return 0; > } >@@ -713,10 +713,12 @@ sub recordpayment_selectaccts { > } > > # create new line >- $sql = 'INSERT INTO accountlines ' . >- '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding) ' . >- q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?)|; >- $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft ); >+ $sql = " >+ INSERT INTO accountlines >+ ( borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, branchcode) >+ VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?) >+ "; >+ $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $branch ); > UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno ); > return; > } >@@ -739,17 +741,20 @@ sub makepartialpayment { > 'SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?',undef,$borrowernumber,$accountno); > my $new_outstanding = $data->{amountoutstanding} - $amount; > >- my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? ' >- . ' AND accountno = ?'; >+ my $update = " >+ UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? AND accountno = ? >+ "; > $dbh->do( $update, undef, $new_outstanding, $borrowernumber, $accountno); > > # create new line >- my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' >- . 'description, accounttype, amountoutstanding, itemnumber, manager_id) ' >- . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)'; >+ my $insert = " >+ INSERT INTO accountlines (borrowernumber, accountno, date, amount, >+ description, accounttype, amountoutstanding, itemnumber, manager_id, branchcode) >+ VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?) >+ "; > > $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, >- "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id); >+ "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'}); > > UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 9dbd032..d53165d 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2383,6 +2383,7 @@ CREATE TABLE `accountlines` ( > `notify_level` int(2) NOT NULL default 0, > `note` text NULL default NULL, > `manager_id` int(11) NULL, >+ `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc. > KEY `acctsborridx` (`borrowernumber`), > KEY `timeidx` (`timestamp`), > KEY `itemnumber` (`itemnumber`), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index b844560..645208c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4892,6 +4892,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.07.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id"); >+ print "Upgrade to $DBversion done (Added column branchcode to accountlines)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 DropAllForeignKeys($table) >-- >1.7.2.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7595
:
7866
|
7867
|
7868
|
7869
|
7870
|
8037
|
8162
|
12394
|
12395
|
12717
|
12719
|
14814
|
14815
|
20808
|
20809
|
23306
|
23308
|
27337
|
30946
|
30947
|
30950
|
38150
|
38225
|
38235
|
52909
|
52910
|
52911
|
54262
|
54263
|
54264