Bugzilla – Attachment 76462 Details for
Bug 20997
Add Koha::Account::Line::apply
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20997: (follow-up) Add Koha::Account::Line->is_debit method
Bug-20997-follow-up-Add-KohaAccountLine-isdebit-me.patch (text/plain), 2.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-06-26 17:24:41 UTC
(
hide
)
Description:
Bug 20997: (follow-up) Add Koha::Account::Line->is_debit method
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-06-26 17:24:41 UTC
Size:
2.27 KB
patch
obsolete
>From 830971099b28e15f27bb8d66cc38b876a4ccc026 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Tue, 26 Jun 2018 00:22:16 +0000 >Subject: [PATCH] Bug 20997: (follow-up) Add Koha::Account::Line->is_debit > method > >Test plan: >1) Apply this patch >2) prove t/db_dependent/Koha/Account/Lines.t >=> Test should pass > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Account/Line.pm | 14 +++++++++++++- > t/db_dependent/Koha/Account/Lines.t | 8 +++++--- > 2 files changed, 18 insertions(+), 4 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 7ee5843556..4d281cb2f7 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -144,7 +144,7 @@ sub apply { > ); > } > >- unless ( !$debit->is_credit ) { >+ unless ( $debit->is_debit ) { > Koha::Exceptions::Account::IsNotDebit->throw( > error => 'Account line ' . $debit->id . 'is not a debit' > ); >@@ -202,6 +202,18 @@ sub is_credit { > return ( $self->amount < 0 ); > } > >+=head3 is_debit >+ >+ my $bool = $line->is_debit; >+ >+=cut >+ >+sub is_debit { >+ my ($self) = @_; >+ >+ return !$self->is_credit; >+} >+ > =head2 Internal methods > > =cut >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index 05876aee9a..1f1958a1a1 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -65,9 +65,9 @@ subtest 'item() tests' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'is_credit() tests' => sub { >+subtest 'is_credit() and is_debit() tests' => sub { > >- plan tests => 2; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -77,6 +77,7 @@ subtest 'is_credit() tests' => sub { > my $credit = $account->add_credit({ amount => 100, user_id => $patron->id }); > > ok( $credit->is_credit, 'is_credit detects credits' ); >+ ok( !$credit->is_debit, 'is_debit detects credits' ); > > my $debit = Koha::Account::Line->new( > { >@@ -85,7 +86,8 @@ subtest 'is_credit() tests' => sub { > amount => 10, > })->store; > >- ok( !$debit->is_credit, 'is_credit() detects debits' ); >+ ok( !$debit->is_credit, 'is_credit detects debits' ); >+ ok( $debit->is_debit, 'is_debit detects debits'); > > $schema->storage->txn_rollback; > }; >-- >2.18.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 20997
:
76451
|
76452
|
76459
|
76460
|
76461
|
76462
|
76463
|
76464
|
76465
|
76549
|
76550
|
76551
|
76654
|
76655
|
77194
|
77195
|
77196
|
77197
|
77198
|
77199
|
77310
|
77349
|
77350
|
77351
|
77352
|
77353
|
77354
|
77355
|
77356