Bugzilla – Attachment 116394 Details for
Bug 24381
ACCOUNT_CREDIT and ACCOUNT_DEBIT slip not printing information about paid fines/fees
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24381: Add payout_amount method to Koha::Account
Bug-24381-Add-payoutamount-method-to-KohaAccount.patch (text/plain), 3.47 KB, created by
Martin Renvoize (ashimema)
on 2021-02-05 14:29:08 UTC
(
hide
)
Description:
Bug 24381: Add payout_amount method to Koha::Account
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-05 14:29:08 UTC
Size:
3.47 KB
patch
obsolete
>From 4b6b083dbc4eef2cf145f791281da3a5cd7d7910 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 5 Feb 2021 14:28:32 +0000 >Subject: [PATCH] Bug 24381: Add payout_amount method to Koha::Account > >--- > Koha/Account.pm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 88 insertions(+) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 5178d98639..685cba4f9f 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -625,6 +625,94 @@ sub add_debit { > return $line; > } > >+=head3 payout_amount >+ >+ my $debit = $account->payout_amount( >+ { >+ payout_type => $payout_type, >+ register_id => $register_id, >+ staff_id => $staff_id, >+ interface => 'intranet', >+ amount => $amount, >+ credits => $credit_lines >+ } >+ ); >+ >+This method allows an amount to be paid out from a patrons account against outstanding credits. >+ >+$payout_type can be any of the defined payment_types: >+ >+=cut >+ >+sub payout_amount { >+ my ( $self, $params ) = @_; >+ >+ # Check for mandatory parameters >+ my @mandatory = >+ ( 'interface', 'staff_id', 'branch', 'payout_type', 'amount' ); >+ for my $param (@mandatory) { >+ unless ( defined( $params->{$param} ) ) { >+ Koha::Exceptions::MissingParameter->throw( >+ error => "The $param parameter is mandatory" ); >+ } >+ } >+ >+ # amount should always be passed as a positive value >+ my $amount = $params->{amount} * -1; >+ unless ( $amount < 0 ) { >+ Koha::Exceptions::Account::AmountNotPositive->throw( >+ error => 'Debit amount passed is not positive' ); >+ } >+ >+ # amount should always be less than or equal to outstanding credit >+ my $outstanding = 0; >+ my $outstanding_credits = >+ exists( $params->{credits} ) >+ ? $params->{credits} >+ : $self->outstanding_credits->as_list; >+ for my $credit ( @{$outstanding_credits} ) { >+ $outstanding += $credit->amountoutstanding; >+ } >+ Koha::Exceptions::ParameterTooHigh->throw( error => >+"Amount to payout ($amount) is higher than amountoutstanding ($outstanding)" >+ ) unless ( $outstanding >= $amount ); >+ >+ my $payout; >+ my $schema = Koha::Database->new->schema; >+ $schema->txn_do( >+ sub { >+ >+ # A 'payout' is a 'debit' >+ $payout = Koha::Account::Line->new( >+ { >+ date => \'NOW()', >+ amount => $amount, >+ debit_type_code => 'PAYOUT', >+ payment_type => $params->{payout_type}, >+ amountoutstanding => $amount, >+ manager_id => $params->{staff_id}, >+ borrowernumber => $self->borrowernumber, >+ interface => $params->{interface}, >+ branchcode => $params->{branch}, >+ register_id => $params->{cash_register} >+ } >+ )->store(); >+ >+ # Offset against credits >+ for my $credit ( @{$outstanding_credits} ) { >+ $credit->apply( >+ { debits => [$payout], offset_type => 'PAYOUT' } ); >+ $payout->discard_changes; >+ } >+ >+ # Set payout as paid >+ $payout->status('PAID')->store; >+ } >+ ); >+ >+ return $payout->discard_changes; >+} >+ > =head3 balance > > my $balance = $self->balance >-- >2.20.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 24381
:
106946
|
106947
|
106950
|
106951
|
106952
|
106953
|
106956
|
106957
|
106958
|
106959
|
106960
|
106974
|
106975
|
106976
|
106977
|
110210
|
110211
|
110212
|
110213
|
110461
|
110462
|
110463
|
110464
|
111530
|
111531
|
111532
|
111533
|
111534
|
111590
|
111591
|
111592
|
111593
|
111594
|
111595
|
116394
|
140868
|
140869
|
140870
|
140871
|
140872
|
140873
|
141619
|
141620
|
141621
|
141622
|
141623
|
142386
|
142387
|
142388
|
142389
|
142390