Bugzilla – Attachment 61042 Details for
Bug 16461
Add barcode and item type in fine description for overdue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16461 - Add branch and barcode in accountline table for overdues
Bug-16461---Add-branch-and-barcode-in-accountline-.patch (text/plain), 15.05 KB, created by
Alex Arnaud
on 2017-03-13 16:21:18 UTC
(
hide
)
Description:
Bug 16461 - Add branch and barcode in accountline table for overdues
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-03-13 16:21:18 UTC
Size:
15.05 KB
patch
obsolete
>From 58f30cdd8726566dcf1b77e8daa13b88483cdf4e Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 11 May 2016 16:57:11 +0200 >Subject: [PATCH] Bug 16461 - Add branch and barcode in accountline table for > overdues > >--- > C4/Overdues.pm | 8 +- > ...h-and-barcode-columns-in-accountlines-table.sql | 4 + > installer/data/mysql/kohastructure.sql | 6 +- > .../intranet-tmpl/prog/en/modules/members/pay.tt | 4 + > t/db_dependent/Circulation.t | 75 ++++++++++++----- > t/db_dependent/Circulation/UpdateFine.t | 94 ++++++++++++++++++++++ > 6 files changed, 165 insertions(+), 26 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_16461-Add-branch-and-barcode-columns-in-accountlines-table.sql > create mode 100644 t/db_dependent/Circulation/UpdateFine.t > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index c26b5f0..9b49516 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -595,14 +595,14 @@ sub UpdateFine { > } else { > if ( $amount ) { # Don't add new fines with an amount of 0 > my $sth4 = $dbh->prepare( >- "SELECT title FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?" >+ "SELECT title,holdingbranch,barcode FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?" > ); > $sth4->execute($itemnum); >- my $title = $sth4->fetchrow; >+ my ($title,$holdingbranch,$barcode) = $sth4->fetchrow; > > my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber); > >- my $desc = ( $type ? "$type " : '' ) . "$title $due"; # FIXEDME, avoid whitespace prefix on empty $type >+ my $desc = ( $type ? "$type " : '' ) . "$title $due"; # FIXEDME, avoid whitespace prefix on empty $type; > > my $accountline = Koha::Account::Line->new( > { >@@ -616,6 +616,8 @@ sub UpdateFine { > lastincrement => $amount, > accountno => $nextaccntno, > issue_id => $issue_id, >+ barcode => $barcode, >+ branchcode => $holdingbranch > } > )->store(); > } >diff --git a/installer/data/mysql/atomicupdate/bug_16461-Add-branch-and-barcode-columns-in-accountlines-table.sql b/installer/data/mysql/atomicupdate/bug_16461-Add-branch-and-barcode-columns-in-accountlines-table.sql >new file mode 100644 >index 0000000..f3f8e67 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_16461-Add-branch-and-barcode-columns-in-accountlines-table.sql >@@ -0,0 +1,4 @@ >+ALTER TABLE accountlines ADD barcode varchar(20) NULL DEFAULT NULL; >+ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_3 FOREIGN KEY (barcode) REFERENCES items (barcode) ON DELETE SET NULL ON UPDATE SET NULL; >+ALTER TABLE accountlines ADD branchcode varchar(10) NULL DEFAULT NULL; >+ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_4 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE SET NULL; >\ No newline at end of file >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 91e6119..2cbba6c 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2703,12 +2703,16 @@ CREATE TABLE `accountlines` ( > `notify_level` int(2) NOT NULL default 0, > `note` text NULL default NULL, > `manager_id` int(11) NULL, >+ `barcode` varchar(20) NULL default '', >+ `branchcode` varchar(10) NULL default '', > PRIMARY KEY (`accountlines_id`), > KEY `acctsborridx` (`borrowernumber`), > KEY `timeidx` (`timestamp`), > KEY `itemnumber` (`itemnumber`), > CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL >+ CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL, >+ CONSTRAINT `accountlines_ibfk_3` FOREIGN KEY (`barcode`) REFERENCES `items` (`barcode`) ON DELETE SET NULL ON UPDATE SET NULL, >+ CONSTRAINT `accountlines_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE SET NULL > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >index b37ce3c..556661d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt >@@ -76,6 +76,8 @@ function enableCheckboxActions(){ > <th> </th> > <th>Fines & charges</th> > <th>Description</th> >+ <th>Barcode</th> >+ <th>Library</th> > <th>Payment note</th> > <th>Account type</th> > <th>Notify id</th> >@@ -141,6 +143,8 @@ function enableCheckboxActions(){ > [%- IF line.description %], [% line.description %][% END %] > [% IF line.title %]([% line.title %])[% END %] > </td> >+ <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=93&itemnumber=[% line.itemnumber %]">[% line.barcode %]</a></td> >+ <td>[% Branches.GetName( line.branchcode ) %]</td> > <td><input type="text" name="payment_note_[% line.accountlines_id %]" /></td> > <td>[% line.accounttype %]</td> > <td>[% line.notify_id %]</td> >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 352abf8..05465e9 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -60,6 +60,10 @@ my $itemtype = $builder->build( > value => { notforloan => undef, rentalcharge => 0 } > } > )->{itemtype}; >+my $category = $builder->build({ >+ source => 'Category', >+}); >+my $categorycode = $category->{categorycode}; > > my $CircControl = C4::Context->preference('CircControl'); > my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); >@@ -192,7 +196,7 @@ my $sth = C4::Context->dbh->prepare("SELECT COUNT(*) FROM accountlines WHERE amo > $sth->execute(); > my ( $original_count ) = $sth->fetchrow_array(); > >-C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', 'S', ? )", undef, $library2->{branchcode} ); >+C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', ?, ? )", undef, $categorycode, $library2->{branchcode} ); > > C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' }); > >@@ -210,10 +214,18 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > # Generate test biblio > my $biblio = MARC::Record->new(); > my $title = 'Silence in the library'; >- $biblio->append_fields( >- MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), >- MARC::Field->new('245', ' ', ' ', a => $title), >- ); >+ >+ if (C4::Context->preference('marcflavour') eq 'UNIMARC') { >+ $biblio->append_fields( >+ MARC::Field->new('200', ' ', ' ', f => 'Moffat, Steven'), >+ MARC::Field->new('200', ' ', ' ', a => $title), >+ ); >+ } else { >+ $biblio->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), >+ MARC::Field->new('245', ' ', ' ', a => $title), >+ ); >+ } > > my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); > >@@ -262,28 +274,28 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my %renewing_borrower_data = ( > firstname => 'John', > surname => 'Renewal', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > > my %reserving_borrower_data = ( > firstname => 'Katrin', > surname => 'Reservation', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > > my %hold_waiting_borrower_data = ( > firstname => 'Kyle', > surname => 'Reservation', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > > my %restricted_borrower_data = ( > firstname => 'Alice', > surname => 'Reservation', >- categorycode => 'S', >+ categorycode => $categorycode, > debarred => '3228-01-01', > branchcode => $branch, > ); >@@ -674,6 +686,11 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > undef, $renewing_borrower->{borrowernumber} > ); > >+ my $accountlines = Koha::Account::Lines->search({itemnumber => $itemnumber, borrowernumber => $renewing_borrower->{borrowernumber}, amount => '15.00'}); >+ my $accouline = $accountlines->next(); >+ my $itembranch = $item->get_column('holdingbranch'); >+ ok($accouline->description =~ /Silence in the library Branch:$itembranch Barcode:R00000342/); >+ > ok( $total_due == 12, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); > > C4::Context->dbh->do("DELETE FROM accountlines"); >@@ -728,10 +745,17 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > #Create another record > my $biblio2 = MARC::Record->new(); > my $title2 = 'Something is worng here'; >- $biblio2->append_fields( >- MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), >- MARC::Field->new('245', ' ', ' ', a => $title2), >- ); >+ if (C4::Context->preference('marcflavour') eq 'UNIMARC') { >+ $biblio2->append_fields( >+ MARC::Field->new('200', ' ', ' ', f => 'Anonymous'), >+ MARC::Field->new('200', ' ', ' ', a => $title2), >+ ); >+ } else { >+ $biblio2->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), >+ MARC::Field->new('245', ' ', ' ', a => $title2), >+ ); >+ } > my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, ''); > > #Create third item >@@ -749,7 +773,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my %a_borrower_data = ( > firstname => 'Fridolyn', > surname => 'SOMERS', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > >@@ -829,7 +853,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my %a_borrower_data = ( > firstname => 'Kyle', > surname => 'Hall', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > >@@ -895,13 +919,13 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my $borrowernumber1 = AddMember( > firstname => 'Kyle', > surname => 'Hall', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $library2->{branchcode}, > ); > my $borrowernumber2 = AddMember( > firstname => 'Chelsea', > surname => 'Hall', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $library2->{branchcode}, > ); > >@@ -953,10 +977,17 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > #Create another record > my $biblio = MARC::Record->new(); >- $biblio->append_fields( >- MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), >- MARC::Field->new('245', ' ', ' ', a => 'A title'), >- ); >+ if (C4::Context->preference('marcflavour') eq 'UNIMARC') { >+ $biblio->append_fields( >+ MARC::Field->new('200', ' ', ' ', f => 'Anonymous'), >+ MARC::Field->new('200', ' ', ' ', a => 'A title'), >+ ); >+ } else { >+ $biblio->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), >+ MARC::Field->new('245', ' ', ' ', a => 'A title'), >+ ); >+ } > my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); > > my (undef, undef, $itemnumber) = AddItem( >@@ -972,7 +1003,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my $borrowernumber = AddMember( > firstname => 'fn', > surname => 'dn', >- categorycode => 'S', >+ categorycode => $categorycode, > branchcode => $branch, > ); > >diff --git a/t/db_dependent/Circulation/UpdateFine.t b/t/db_dependent/Circulation/UpdateFine.t >new file mode 100644 >index 0000000..2df133c >--- /dev/null >+++ b/t/db_dependent/Circulation/UpdateFine.t >@@ -0,0 +1,94 @@ >+#!/usr/bin/perl >+ >+# 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 3 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use C4::Circulation; >+use C4::Overdues; >+ >+use t::lib::TestBuilder; >+ >+use Test::More tests => 4; >+ >+BEGIN { >+ require_ok('C4::Circulation'); >+} >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+my $builder = t::lib::TestBuilder->new; >+ >+my $library = $builder->build({ >+ source => 'Branch', >+}); >+C4::Context->_new_userenv('xxx'); >+C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >+my $category = $builder->build({ >+ source => 'Category', >+}); >+my $patron = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode => $category->{categorycode}, >+ branchcode => $library->{branchcode}, >+ }, >+}); >+my $biblio = $builder->build({ >+ source => 'Biblio', >+ value => { >+ branchcode => $library->{branchcode}, >+ }, >+}); >+my $item = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ replacementprice => '5.00', >+ }, >+}); >+ >+my $issue = AddIssue( >+ $patron, >+ $item->{barcode}, >+ '2013-06-01', >+ undef, >+ '2013-05-01' >+); >+ >+UpdateFine({ >+ issue_id => $issue->id, >+ itemnumber => $item->{itemnumber}, >+ borrowernumber => $patron->{borrowernumber}, >+ amount => 10, >+ type => 'F', >+ due => '2013-06-01' >+}); >+ >+my $accountline = Koha::Account::Lines->search({ >+ borrowernumber => $patron->{borrowernumber}, >+ issue_id => $issue->id, >+ itemnumber => $item->{itemnumber}, >+})->next(); >+ >+is($accountline->amount, '10.000000', 'Accountline amount should be 10'); >+is($accountline->barcode, $item->{barcode}, 'Accountline barcode should be as expeted'); >+is($accountline->branchcode, $item->{holdingbranch}, 'Accountline barcode should be as expeted'); >+ >+ >+$schema->storage->txn_rollback; >-- >2.7.4
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 16461
:
51443
|
52052
| 61042