Bugzilla – Attachment 58908 Details for
Bug 17894
Remove and Replace WriteOffFee
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 17894 - Update pay() and use it internally for WriteOffFee
SIGNED-OFF-Bug-17894---Update-pay-and-use-it-inter.patch (text/plain), 5.97 KB, created by
Josef Moravec
on 2017-01-13 06:26:36 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 17894 - Update pay() and use it internally for WriteOffFee
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-01-13 06:26:36 UTC
Size:
5.97 KB
patch
obsolete
>From c76e8702d6374ac03880665f0ca5e2bf66d4a8ad Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 12 Jan 2017 14:24:02 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 17894 - Update pay() and use it internally > for WriteOffFee > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Accounts.pm | 64 +++++++++------------------------------------------------ > Koha/Account.pm | 18 ++++++++++------ > 2 files changed, 22 insertions(+), 60 deletions(-) > >diff --git a/C4/Accounts.pm b/C4/Accounts.pm >index f20ea2f..17f7e69 100644 >--- a/C4/Accounts.pm >+++ b/C4/Accounts.pm >@@ -26,6 +26,7 @@ use C4::Members; > use C4::Circulation qw(ReturnLostItem); > use C4::Log qw(logaction); > use Koha::Account; >+use Koha::Account::Lines; > > use Data::Dumper qw(Dumper); > >@@ -366,62 +367,17 @@ C<$payment_note> is the note to attach to this payment > > 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 => $branch, >- type => 'writeoff', >- amount => $amount, >- borrowernumber => $borrowernumber} >+ my $line = Koha::Account::Lines->find($accountlines_id); >+ return Koha::Account->new( { patron_id => $borrowernumber } )->pay( >+ { >+ amount => $amount, >+ lines => [$line], >+ type => 'writeoff', >+ note => $payment_note, >+ library_id => $branch, >+ } > ); >- > } > > =head2 purge_zero_balance_fees >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 2572fc4..28b789f 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -67,6 +67,7 @@ sub pay { > my $note = $params->{note} || q{}; > my $library_id = $params->{library_id}; > my $lines = $params->{lines}; >+ my $type = $params->{type} || 'payment'; > > my $userenv = C4::Context->userenv; > >@@ -154,7 +155,7 @@ sub pay { > $self->{patron_id}, > Dumper( > { >- action => 'fee_payment', >+ action => "fee_$type", > borrowernumber => $fine->borrowernumber, > old_amountoutstanding => $old_amountoutstanding, > new_amountoutstanding => $fine->amountoutstanding, >@@ -173,7 +174,12 @@ sub pay { > last unless $balance_remaining > 0; > } > >- my $account_type = defined($sip) ? "Pay$sip" : 'Pay'; >+ my $account_type = >+ $type eq 'writeoff' ? 'W' >+ : defined($sip) ? "Pay$sip" >+ : 'Pay'; >+ >+ my $description = $type eq 'writeoff' ? 'Writeoff' : q{}; > > my $payment = Koha::Account::Line->new( > { >@@ -181,7 +187,7 @@ sub pay { > accountno => $accountno, > date => dt_from_string(), > amount => 0 - $amount, >- description => q{}, >+ description => $description, > accounttype => $account_type, > amountoutstanding => 0 - $balance_remaining, > manager_id => $manager_id, >@@ -194,7 +200,7 @@ sub pay { > UpdateStats( > { > branch => $library_id, >- type => 'payment', >+ type => $type, > amount => $amount, > borrowernumber => $self->{patron_id}, > accountno => $accountno, >@@ -207,12 +213,12 @@ sub pay { > $self->{patron_id}, > Dumper( > { >- action => 'create_payment', >+ action => "create_$type", > borrowernumber => $self->{patron_id}, > accountno => $accountno, > amount => 0 - $amount, > amountoutstanding => 0 - $balance_remaining, >- accounttype => 'Pay', >+ accounttype => $account_type, > accountlines_paid => \@fines_paid, > manager_id => $manager_id, > } >-- >2.1.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 17894
:
58883
|
58884
|
58885
|
58908
|
58909
|
58910
|
59211
|
59212
|
59213