Bugzilla – Attachment 96949 Details for
Bug 24321
Make objects.search use mappings from Koha::Object(s)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24321: Clean /patrons/{patron_id}/account
Bug-24321-Clean-patronspatronidaccount.patch (text/plain), 4.44 KB, created by
Kyle M Hall (khall)
on 2020-01-07 18:50:37 UTC
(
hide
)
Description:
Bug 24321: Clean /patrons/{patron_id}/account
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-01-07 18:50:37 UTC
Size:
4.44 KB
patch
obsolete
>From 85ca4152e93642bed33b566ba111370a408fed15 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Dec 2019 12:35:43 -0300 >Subject: [PATCH] Bug 24321: Clean /patrons/{patron_id}/account > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/V1/Patrons/Account.pm | 96 ------------------------ > t/db_dependent/api/v1/patrons_accounts.t | 6 +- > 2 files changed, 3 insertions(+), 99 deletions(-) > >diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm >index 63888cd082..208406aef3 100644 >--- a/Koha/REST/V1/Patrons/Account.pm >+++ b/Koha/REST/V1/Patrons/Account.pm >@@ -157,100 +157,4 @@ sub add_credit { > }; > } > >- >-=head3 _to_api >- >-Helper function that maps unblessed Koha::Account::Line objects >-into REST API attribute names. >- >-=cut >- >-sub _to_api { >- my $account_line = shift; >- >- # Rename attributes >- foreach my $column ( keys %{ $Koha::REST::V1::Patrons::Account::to_api_mapping } ) { >- my $mapped_column = $Koha::REST::V1::Patrons::Account::to_api_mapping->{$column}; >- if ( exists $account_line->{ $column } >- && defined $mapped_column ) >- { >- # key != undef >- $account_line->{ $mapped_column } = delete $account_line->{ $column }; >- } >- elsif ( exists $account_line->{ $column } >- && !defined $mapped_column ) >- { >- # key == undef >- delete $account_line->{ $column }; >- } >- } >- >- return $account_line; >-} >- >-=head3 _to_model >- >-Helper function that maps REST API objects into Koha::Account::Line >-attribute names. >- >-=cut >- >-sub _to_model { >- my $account_line = shift; >- >- foreach my $attribute ( keys %{ $Koha::REST::V1::Patrons::Account::to_model_mapping } ) { >- my $mapped_attribute = $Koha::REST::V1::Patrons::Account::to_model_mapping->{$attribute}; >- if ( exists $account_line->{ $attribute } >- && defined $mapped_attribute ) >- { >- # key => !undef >- $account_line->{ $mapped_attribute } = delete $account_line->{ $attribute }; >- } >- elsif ( exists $account_line->{ $attribute } >- && !defined $mapped_attribute ) >- { >- # key => undef / to be deleted >- delete $account_line->{ $attribute }; >- } >- } >- >- return $account_line; >-} >- >-=head2 Global variables >- >-=head3 $to_api_mapping >- >-=cut >- >-our $to_api_mapping = { >- accountlines_id => 'account_line_id', >- credit_type_code => 'credit_type', >- debit_type_code => 'debit_type', >- amountoutstanding => 'amount_outstanding', >- borrowernumber => 'patron_id', >- branchcode => 'library_id', >- issue_id => 'checkout_id', >- itemnumber => 'item_id', >- manager_id => 'user_id', >- note => 'internal_note', >-}; >- >-=head3 $to_model_mapping >- >-=cut >- >-our $to_model_mapping = { >- account_line_id => 'accountlines_id', >- credit_type => 'credit_type_code', >- debit_type => 'debit_type_code', >- amount_outstanding => 'amountoutstanding', >- checkout_id => 'issue_id', >- internal_note => 'note', >- item_id => 'itemnumber', >- library_id => 'branchcode', >- patron_id => 'borrowernumber', >- user_id => 'manager_id' >-}; >- > 1; >diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t >index 6921931c1b..773a6b2e66 100644 >--- a/t/db_dependent/api/v1/patrons_accounts.t >+++ b/t/db_dependent/api/v1/patrons_accounts.t >@@ -97,8 +97,8 @@ subtest 'get_balance() tests' => sub { > outstanding_debits => { > total => 100.01, > lines => [ >- Koha::REST::V1::Patrons::Account::_to_api( $account_line_1->TO_JSON ), >- Koha::REST::V1::Patrons::Account::_to_api( $account_line_2->TO_JSON ) >+ $account_line_1->to_api, >+ $account_line_2->to_api > ] > }, > outstanding_credits => { >@@ -144,7 +144,7 @@ subtest 'get_balance() tests' => sub { > }, > outstanding_credits => { > total => -10, >- lines => [ Koha::REST::V1::Patrons::Account::_to_api( $credit_line->TO_JSON ) ] >+ lines => [ $credit_line->to_api ] > } > } > ); >-- >2.21.0 (Apple Git-122.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 24321
:
96703
|
96704
|
96705
|
96706
|
96707
|
96708
|
96709
|
96710
|
96711
|
96712
|
96713
|
96714
|
96715
|
96716
|
96717
|
96718
|
96719
|
96720
|
96721
|
96722
|
96744
|
96840
|
96841
|
96842
|
96843
|
96844
|
96845
|
96846
|
96847
|
96848
|
96849
|
96850
|
96851
|
96852
|
96874
|
96875
|
96876
|
96877
|
96878
|
96879
|
96880
|
96881
|
96882
|
96883
|
96884
|
96885
|
96886
|
96887
|
96939
|
96940
|
96941
|
96942
|
96943
|
96944
|
96945
|
96946
|
96947
|
96948
| 96949 |
96950
|
96951
|
96952