Bugzilla – Attachment 87050 Details for
Bug 22589
Remove sub C4::Overdues::BorType
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22589: Remove C4::Overdues::BorType
Bug-22589-Remove-C4OverduesBorType.patch (text/plain), 7.52 KB, created by
Josef Moravec
on 2019-03-27 09:49:13 UTC
(
hide
)
Description:
Bug 22589: Remove C4::Overdues::BorType
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-03-27 09:49:13 UTC
Size:
7.52 KB
patch
obsolete
>From 0e40b35895095ce75cfeb885b69e354253fc9513 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Wed, 27 Mar 2019 09:44:34 +0000 >Subject: [PATCH] Bug 22589: Remove C4::Overdues::BorType > >Test plan: >0) Apply patch >1) try to run affected scripts and ensure the amounts are corectly >calculated for different patron categories: > installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl > misc/cronjobs/fines.pl > misc/cronjobs/staticfines.pl >--- > C4/Overdues.pm | 32 ---------------------- > .../fix_unclosed_nonaccruing_fines_bug17135.pl | 9 +++--- > misc/cronjobs/fines.pl | 8 ++++-- > misc/cronjobs/staticfines.pl | 15 +++++----- > 4 files changed, 18 insertions(+), 46 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index de23dd906d..f866f204a5 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -58,13 +58,6 @@ BEGIN { > &parse_overdues_letter > ); > >- # subs to remove >- push @EXPORT, qw( >- &BorType >- ); >- >- # check that an equivalent don't exist already before moving >- > # subs to move to Circulation.pm > push @EXPORT, qw( > &GetIssuesIteminfo >@@ -603,31 +596,6 @@ sub UpdateFine { > } > } > >-=head2 BorType >- >- $borrower = &BorType($borrowernumber); >- >-Looks up a patron by borrower number. >- >-C<$borrower> is a reference-to-hash whose keys are all of the fields >-from the borrowers and categories tables of the Koha database. Thus, >-C<$borrower> contains all information about both the borrower and >-category they belong to. >- >-=cut >- >-sub BorType { >- my ($borrowernumber) = @_; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( >- "SELECT * from borrowers >- LEFT JOIN categories ON borrowers.categorycode=categories.categorycode >- WHERE borrowernumber=?" >- ); >- $sth->execute($borrowernumber); >- return $sth->fetchrow_hashref; >-} >- > =head2 GetFine > > $data->{'sum(amountoutstanding)'} = &GetFine($itemnum,$borrowernumber); >diff --git a/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl b/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl >index b7f1efd088..d29b436ea2 100755 >--- a/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl >+++ b/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl >@@ -21,10 +21,11 @@ > use Modern::Perl; > > use C4::Context; >-use C4::Overdues qw/CalcFine BorType/; >+use C4::Overdues qw/CalcFine/; > use C4::Log qw/logaction/; > > use Koha::DateUtils; >+use Koha::Patrons; > use Getopt::Long; > > my ($help, $verbose, $confirm, $log, $stdout_log); >@@ -151,13 +152,13 @@ sub Bug_17135_fix { > my $overdue = $overdues->[0]; > > ### last if $overdue->{itemlost}; ## arguable >- my $borrower = BorType( $overdue->{borrowernumber} ); >+ my $patron = Koha::Patron->find( $overdue->{borrowernumber} ); > my $branchcode = > ( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch} >- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} >+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode > : $overdue->{branchcode}; > >- my ($amount) = CalcFine( $overdue, $borrower->{categorycode}, $branchcode, $datedue, $today ); >+ my ($amount) = CalcFine( $overdue, $patron->categorycode, $branchcode, $datedue, $today ); > ### Warn("CalcFine() returned '$amount'"); > last if ($amount > 0); ## accruing fine, skip closing > >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index 89ad4a2d3c..b30e174505 100755 >--- a/misc/cronjobs/fines.pl >+++ b/misc/cronjobs/fines.pl >@@ -38,6 +38,7 @@ use File::Spec; > > use Koha::Calendar; > use Koha::DateUtils; >+use Koha::Patrons; > use C4::Log; > > my $help; >@@ -105,10 +106,10 @@ for my $overdue ( @{$overdues} ) { > "ERROR in Getoverdues : issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; > next; > } >- my $borrower = BorType( $overdue->{borrowernumber} ); >+ my $patron = Koha::Patrons->find( $overdue->{borrowernumber} ); > my $branchcode = > ( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch} >- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} >+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode > : $overdue->{branchcode}; > > # In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). >@@ -123,7 +124,7 @@ for my $overdue ( @{$overdues} ) { > ++$counted; > > my ( $amount, $unitcounttotal, $unitcount ) = >- CalcFine( $overdue, $borrower->{categorycode}, >+ CalcFine( $overdue, $patron->categorycode, > $branchcode, $datedue, $today ); > > # Don't update the fine if today is a holiday. >@@ -141,6 +142,7 @@ for my $overdue ( @{$overdues} ) { > ); > } > } >+ my $borrower = $patron->unblessed; > if ($filename) { > my @cells; > push @cells, >diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl >index 5803c89a2a..6f97147b81 100755 >--- a/misc/cronjobs/staticfines.pl >+++ b/misc/cronjobs/staticfines.pl >@@ -47,6 +47,7 @@ use C4::Log; > use Getopt::Long; > use List::MoreUtils qw/none/; > use Koha::DateUtils; >+use Koha::Patrons; > > my $help = 0; > my $verbose = 0; >@@ -157,16 +158,16 @@ for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { > print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; > next; # Note: this doesn't solve everything. After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up. > } >- my $borrower = BorType( $data->[$i]->{'borrowernumber'} ); >+ my $patron = Koha::Patrons->find( $data->[$i]->{'borrowernumber'} ); > > # Skipping borrowers that are not in @categories >- $bigdebug and warn "Skipping borrower from category " . $borrower->{categorycode} if none { $borrower->{categorycode} eq $_ } @categories; >- next if none { $borrower->{categorycode} eq $_ } @categories; >+ $bigdebug and warn "Skipping borrower from category " . $patron->categorycode if none { $patron->categorycode eq $_ } @categories; >+ next if none { $patron->categorycode eq $_ } @categories; > > my $branchcode = >- ( $useborrowerlibrary ) ? $borrower->{branchcode} >+ ( $useborrowerlibrary ) ? $patron->branchcode > : ( $control eq 'ItemHomeLibrary' ) ? $data->[$i]->{homebranch} >- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} >+ : ( $control eq 'PatronLibrary' ) ? $patron->branchcode > : $data->[$i]->{branchcode}; > # In final case, CircControl must be PickupLibrary. (branchcode comes from issues table here). > >@@ -190,14 +191,14 @@ for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { > $overdueItemsCounted++; > my ( $amount, $unitcounttotal, $unitcount ) = CalcFine( > $data->[$i], >- $borrower->{'categorycode'}, >+ $patron->categorycode, > $branchcode, > $datedue, > $today, > ); > > # Reassign fine's amount if specified in command-line >- $amount = $catamounts{$borrower->{'categorycode'}} if (defined $catamounts{$borrower->{'categorycode'}}); >+ $amount = $catamounts{$patron->categorycode} if (defined $catamounts{$patron->categorycode}); > > # We check if there is already a fine for the given borrower > my $fine = GetFine(undef, $data->[$i]->{'borrowernumber'}); >-- >2.11.0
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 22589
:
87050
|
101014
|
101380