Bugzilla – Attachment 95666 Details for
Bug 24080
Add a 'payout' process to accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24080: Add 'payout' method to Koha::Account::Line
Bug-24080-Add-payout-method-to-KohaAccountLine.patch (text/plain), 3.89 KB, created by
Martin Renvoize (ashimema)
on 2019-11-21 15:50:47 UTC
(
hide
)
Description:
Bug 24080: Add 'payout' method to Koha::Account::Line
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-11-21 15:50:47 UTC
Size:
3.89 KB
patch
obsolete
>From 178b5f1f276bd87b32f453e5b49db9f915bf86b4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Nov 2019 13:22:39 +0000 >Subject: [PATCH] Bug 24080: Add 'payout' method to Koha::Account::Line > >This enhancement adds a 'payout' method to Koha::Account::Line which can >be used to 'pay out' a credit to a patron. > >When such a credit is 'paid out' this method will create a corresponding >account debit line with an amount equal to the amountoutstanding on the >original credit and the two acocuntlines will be immediately applied against >each other. > >Test Plan: >1) Run the included tests and verify they pass. >2) Signoff >--- > Koha/Account/Line.pm | 89 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 89 insertions(+) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 571c26a986..09d4338eef 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -278,6 +278,95 @@ sub apply { > return $available_credit; > } > >+=head3 payout >+ >+ $credit_accountline->payout( >+ { >+ payout_type => $payout_type, >+ register_id => $register_id, >+ amount => $amount >+ } >+ ); >+ >+Used to 'pay out' a credit to a user. >+ >+Payout type may be one of any existing payment types >+ >+=cut >+ >+sub payout { >+ my ( $self, $params ) = @_; >+ >+ # Make sure it is a credit we are paying out >+ unless ( $self->is_credit ) { >+ Koha::Exceptions::Account::IsNotCredit->throw( >+ error => 'Account line ' . $self->id . ' is not a credit' ); >+ } >+ >+ unless ( $params->{interface} ) { >+ Koha::Exceptions::MissingParameter->throw( >+ error => 'The interface parameter is mandatory' ); >+ } >+ >+ # Make sure there is outstanding credit to pay out >+ my $amount = >+ $params->{amount} ? $params->{amount} : $self->amountoutstanding; >+ return unless $self->amountoutstanding >= $amount; >+ >+ # Make sure we record the cash register for cash transactions >+ Koha::Exceptions::Account::RegisterRequired->throw() >+ if ( C4::Context->preference("UseCashRegisters") >+ && defined( $params->{payout_type} ) >+ && ( $params->{payout_type} eq 'CASH' ) >+ && !defined( $params->{cash_register} ) ); >+ >+ $params->{branch} //= $self->branchcode; >+ >+ my $payout; >+ $self->_result->result_source->schema->txn_do( >+ sub { >+ >+ # A 'payout' is a 'debit' >+ $payout = Koha::Account::Line->new( >+ { >+ date => \'NOW()', >+ amount => 0 - $amount, >+ debit_type_code => 'PAYOUT', >+ payment_type => $params->{payout_type}, >+ amountoutstanding => 0, >+ manager_id => $params->{staff_id}, >+ borrowernumber => $params->{patron_id}, >+ interface => $params->{interface}, >+ branchcode => $params->{branch}, >+ register_id => $params->{cash_register}, >+ note => $params->{quantity} >+ } >+ )->store(); >+ >+ my $payout_offset = Koha::Account::Offset->new( >+ { >+ debit_id => $payout->accountlines_id, >+ type => 'PAYOUT', >+ amount => 0 - $amount >+ } >+ )->store(); >+ >+ my $application_offset = Koha::Account::Offset->new( >+ { >+ debit_id => $payout->accountlines_id, >+ credit_id => $self->accountlines_id, >+ type => 'PAYOUT', >+ amount => 0 - $amount >+ } >+ )->store(); >+ >+ $self->status('PAID')->store; >+ } >+ ); >+ >+ return $payout; >+} >+ > =head3 adjust > > This method allows updating a debit or credit on a patron's account >-- >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 24080
:
95665
|
95666
|
95667
|
95668
|
95669
|
95670
|
95671
|
95672
|
95793
|
95794
|
95795
|
95796
|
96332
|
96333
|
96334
|
96335
|
96519
|
96520
|
96521
|
96522
|
96523
|
96597
|
96598
|
96599
|
96600
|
96601
|
96602
|
96605
|
96606
|
96607
|
96608
|
96609
|
96610
|
96748
|
96749
|
96750
|
96751
|
96752
|
96753