Bugzilla – Attachment 81878 Details for
Bug 21748
Update C4::Overdues::UpdateFine to use Koha::Account->update_debit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21748: Add ->adjust to Koha::Account::Line
Bug-21748-Add--adjust-to-KohaAccountLine.patch (text/plain), 4.04 KB, created by
Martin Renvoize (ashimema)
on 2018-11-02 10:44:49 UTC
(
hide
)
Description:
Bug 21748: Add ->adjust to Koha::Account::Line
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-11-02 10:44:49 UTC
Size:
4.04 KB
patch
obsolete
>From 90e2bbb66750132d0c3a292912b04799aa8e59bb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 1 Nov 2018 17:12:14 +0000 >Subject: [PATCH] Bug 21748: Add ->adjust to Koha::Account::Line > >--- > Koha/Account/Line.pm | 111 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 111 insertions(+) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 3573e604e6..c1ccdb681b 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -205,6 +205,95 @@ sub apply { > return $available_credit; > } > >+=head3 adjust >+ >+This method allows updating a debit or credit on a patron's account >+ >+my $account_line = Koha::Account->find({ accountlines_id => $line_id })->update( >+ { >+ amount => $amount, >+ type => $update_type, >+ } >+); >+ >+$update_type can be any of: >+ - fine_increment >+ >+=cut >+ >+sub adjust { >+ my ( $self, $params ) = @_; >+ >+ my $amount = $params->{amount}; >+ my $update_type = $params->{type}; >+ >+ unless ( exists($Koha::Account::Line::offset_type->{$update_type}) ) { >+ Koha::Exceptions::Account::UnrecognisedType->throw( >+ error => 'Update type not recognised' >+ ); >+ } >+ >+ my $account_type = $self->accounttype; >+ unless ( $Koha::Account::Line::allowed_update->{$update_type} eq $account_type ) { >+ Koha::Exceptions::Account::UnrecognisedType->throw( >+ error => 'Update type not allowed on this accounttype' >+ ); >+ } >+ >+ my $schema = Koha::Database->new->schema; >+ >+ $schema->txn_do( >+ sub { >+ >+ my $amount_before = $self->amount; >+ my $amount_outstanding_before = $self->amountoutstanding; >+ my $difference = $amount - $amount_before; >+ my $new_outstanding = $amount_outstanding_before + $difference; >+ >+ # Update the account line >+ $self->set( >+ { >+ date => \'NOW()', >+ amount => $amount, >+ amountoutstanding => $new_outstanding, >+ ( $update_type eq 'fine_increment' ? ( lastincrement => $difference ) : ()), >+ } >+ )->store(); >+ >+ # Record the account offset >+ my $account_offset = Koha::Account::Offset->new( >+ { >+ debit_id => $self->id, >+ type => $Koha::Account::Line::offset_type->{$update_type}, >+ amount => $difference >+ } >+ )->store(); >+ >+ if ( C4::Context->preference("FinesLog") ) { >+ logaction( >+ "FINES", 'UPDATE', #undef becomes UPDATE in UpdateFine >+ $self->borrowernumber, >+ Dumper( >+ { action => $update_type, >+ borrowernumber => $self->borrowernumber, >+ accountno => $self->accountno, >+ amount => $amount, >+ description => undef, >+ amountoutstanding => $new_outstanding, >+ accounttype => $self->accounttype, >+ note => undef, >+ itemnumber => $self->itemnumber, >+ manager_id => undef, >+ } >+ ) >+ ) if ( $update_type eq 'fine_increment' ); >+ } >+ } >+ ); >+ >+ return $self; >+} >+ > =head3 is_credit > > my $bool = $line->is_credit; >@@ -242,3 +331,25 @@ sub _type { > } > > 1; >+ >+=head2 Name mappings >+ >+=head3 $offset_type >+ >+=cut >+ >+our $offset_type = { 'fine_increment' => 'Fine Update', }; >+ >+=head3 $allowed_update >+ >+=cut >+ >+our $allowed_update = { 'fine_increment' => 'FU', }; >+ >+=head1 AUTHORS >+ >+Kyle M Hall <kyle.m.hall@gmail.com> >+Tomás Cohen Arazi <tomascohen@gmail.com> >+Martin Renvoize <martin.renvoize@ptfs-europe.com> >+ >+=cut >-- >2.19.1
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 21748
: 81878