Bugzilla – Attachment 150764 Details for
Bug 29453
Add GET endpoints to fetch patron credits and debits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29453: (follow-up) Add tests and fix minimum amount in credit.yaml definition
Bug-29453-follow-up-Add-tests-and-fix-minimum-amou.patch (text/plain), 3.48 KB, created by
Kyle M Hall (khall)
on 2023-05-05 14:39:11 UTC
(
hide
)
Description:
Bug 29453: (follow-up) Add tests and fix minimum amount in credit.yaml definition
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-05-05 14:39:11 UTC
Size:
3.48 KB
patch
obsolete
>From 26fb0e35c0f5b92dc7bc582f70e29c51155f9de2 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Thu, 4 May 2023 14:09:10 +0000 >Subject: [PATCH] Bug 29453: (follow-up) Add tests and fix minimum amount in > credit.yaml definition > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > api/v1/swagger/definitions/credit.yaml | 1 - > t/db_dependent/api/v1/patrons_accounts.t | 79 +++++++++++++++++++++++- > 2 files changed, 78 insertions(+), 2 deletions(-) > >diff --git a/api/v1/swagger/definitions/credit.yaml b/api/v1/swagger/definitions/credit.yaml >index df76473308..6e997d5f12 100644 >--- a/api/v1/swagger/definitions/credit.yaml >+++ b/api/v1/swagger/definitions/credit.yaml >@@ -9,7 +9,6 @@ properties: > description: Internal account line identifier > amount: > type: number >- minimum: 0 > description: Credit amount > amount_outstanding: > type: number >diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t >index cada141ef3..3118171b7a 100755 >--- a/t/db_dependent/api/v1/patrons_accounts.t >+++ b/t/db_dependent/api/v1/patrons_accounts.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 4; > > use Test::Mojo; > >@@ -268,3 +268,80 @@ subtest 'add_credit() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'list_credits() test' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ }); >+ my $password = 'thePassword123'; >+ $patron->set_password({ password => $password, skip_validation => 1 }); >+ my $userid = $patron->userid; >+ my $patron_id = $patron->borrowernumber; >+ my $account = $patron->account; >+ >+ $account->add_credit({ >+ type => 'PAYMENT', >+ amount => 35, >+ interface => 'staff', >+ }); >+ $account->add_credit({ >+ type => 'PAYMENT', >+ amount => 70, >+ interface => 'staff', >+ }); >+ >+ my $ret = $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ is(-105, $ret->[0]->{amount} + $ret->[1]->{amount}, 'Total credits are -105'); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+ >+subtest 'list_debits() test' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ }); >+ my $password = 'thePassword123'; >+ $patron->set_password({ password => $password, skip_validation => 1 }); >+ my $userid = $patron->userid; >+ my $patron_id = $patron->borrowernumber; >+ my $account = $patron->account; >+ >+ $account->add_debit( >+ { amount => 100, >+ description => "A description", >+ type => "NEW_CARD", >+ user_id => $patron->borrowernumber, >+ interface => 'test', >+ } >+ ); >+ $account->add_debit( >+ { amount => 40, >+ description => "A description", >+ type => "NEW_CARD", >+ user_id => $patron->borrowernumber, >+ interface => 'test', >+ } >+ ); >+ >+ my $ret = $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/debits") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ is(140, $ret->[0]->{amount} + $ret->[1]->{amount}, 'Total debits are 140'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 29453
:
130350
|
144619
|
144713
|
144718
|
147565
|
147570
|
147644
|
150670
|
150671
|
150763
| 150764