Bugzilla – Attachment 86539 Details for
Bug 19661
Add route for fund retrieval
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19661: Add and change properties and parameters to conform to the funds RFC.
Bug-19661-Add-and-change-properties-and-parameters.patch (text/plain), 7.12 KB, created by
Martin Renvoize (ashimema)
on 2019-03-12 13:33:45 UTC
(
hide
)
Description:
Bug 19661: Add and change properties and parameters to conform to the funds RFC.
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-03-12 13:33:45 UTC
Size:
7.12 KB
patch
obsolete
>From bef555cdf4ba9a02c22ca56d47bab12928ec9c31 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 15 Jan 2019 10:46:04 +0100 >Subject: [PATCH] Bug 19661: Add and change properties and parameters to > conform to the funds RFC. > >Also, perform an exact search when searching on the fund owner id. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/REST/V1/Acquisitions/Funds.pm | 45 +++++++++-- > api/v1/swagger/definitions/fund.json | 83 +++++++++++++++++++- > api/v1/swagger/paths/acquisitions_funds.json | 4 +- > 3 files changed, 119 insertions(+), 13 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Funds.pm b/Koha/REST/V1/Acquisitions/Funds.pm >index 2ba300d9c7..c789e7fd56 100644 >--- a/Koha/REST/V1/Acquisitions/Funds.pm >+++ b/Koha/REST/V1/Acquisitions/Funds.pm >@@ -20,7 +20,6 @@ use Modern::Perl; > use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Acquisition::Funds; >-use JSON qw(to_json); > > use Try::Tiny; > >@@ -45,8 +44,15 @@ sub list_funds { > my $filter; > > for my $filter_param ( keys %$args ) { >- $filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" } >- if $args->{$filter_param}; >+ if ($args->{$filter_param}) { >+ if ($filter_param eq "budget_owner_id") { >+ # Perform an exact search on the borrowernumber >+ $filter->{$filter_param} = { "=" => $args->{$filter_param} } >+ } else { >+ # And a "start with" search on the budget name >+ $filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" } >+ } >+ } > } > > return try { >@@ -77,9 +83,20 @@ the attribute names the exposed REST api spec. > sub _to_api { > my $fund = shift; > my $returnfund; >- $returnfund->{id} = delete $fund->{budget_id}; >+ $returnfund->{fund_id} = delete $fund->{budget_id}; > $returnfund->{code} = delete $fund->{budget_code}; > $returnfund->{name} = delete $fund->{budget_name}; >+ $returnfund->{library_id} = delete $fund->{budget_branchcode}; >+ $returnfund->{total_amount} = delete $fund->{budget_amount}; >+ $returnfund->{warn_at_percentage} = delete $fund->{budget_encumb}; >+ $returnfund->{warn_at_amount} = delete $fund->{budget_expend}; >+ $returnfund->{notes} = delete $fund->{budget_notes}; >+ $returnfund->{budget_id} = delete $fund->{budget_period_id}; >+ $returnfund->{timestamp} = delete $fund->{timestamp}; >+ $returnfund->{fund_owner_id} = delete $fund->{budget_owner_id}; >+ $returnfund->{fund_access} = delete $fund->{budget_permission}; >+ $returnfund->{statistic1_auth_value_category} = delete $fund->{sort1_authcat}; >+ $returnfund->{statistic2_auth_value_category} = delete $fund->{sort2_authcat}; > > return $returnfund; > } >@@ -93,13 +110,25 @@ attribute names. > > sub _to_model { > my $fund = shift; >+ my $returnfund; > > # Rename back >- $fund->{budget_id} = delete $fund->{id}; >- $fund->{budget_code} = delete $fund->{code}; >- $fund->{budget_name} = delete $fund->{name}; >+ $returnfund->{budget_id} = delete $fund->{fund_id}; >+ $returnfund->{budget_code} = delete $fund->{code}; >+ $returnfund->{budget_name} = delete $fund->{name}; >+ $returnfund->{budget_branchcode} = delete $fund->{library_id}; >+ $returnfund->{budget_amount} = delete $fund->{total_amount}; >+ $returnfund->{budget_encumb} = delete $fund->{warn_at_percentage}; >+ $returnfund->{budget_expend} = delete $fund->{warn_at_amount}; >+ $returnfund->{budget_notes} = delete $fund->{notes}; >+ $returnfund->{budget_period_id} = delete $fund->{budget_id}; >+ $returnfund->{budget_owner_id} = delete $fund->{fund_owner_id}; >+ $returnfund->{timestamp} = delete $fund->{timestamp}; >+ $returnfund->{budget_permission} = delete $fund->{fund_access}; >+ $returnfund->{sort1_authcat} = delete $fund->{statistic1_auth_value_category}; >+ $returnfund->{sort2_authcat} = delete $fund->{statistic2_auth_value_category}; > >- return $fund; >+ return $returnfund; > } > > 1; >diff --git a/api/v1/swagger/definitions/fund.json b/api/v1/swagger/definitions/fund.json >index f184d8a45e..a7e34d619d 100644 >--- a/api/v1/swagger/definitions/fund.json >+++ b/api/v1/swagger/definitions/fund.json >@@ -1,7 +1,7 @@ > { > "type": "object", > "properties": { >- "id": { >+ "fund_id": { > "$ref": "../x-primitives.json#/fund_id" > }, > "code": { >@@ -9,14 +9,91 @@ > "string", > "null" > ], >- "description": "Fund code" >+ "description": "Code assigned to the fund by the user" > }, > "name": { > "type": [ > "string", > "null" > ], >- "description": "Fund name" >+ "description": "Name assigned to the fund by the user" >+ }, >+ "library_id": { >+ "type": [ >+ "string", >+ "null" >+ ], >+ "description": "Internal identifier for the library that this fund belongs to" >+ }, >+ "total_amount": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Total amount for this fund" >+ }, >+ "warn_at_percentage": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Warning at percentage" >+ }, >+ "warn_at_amount": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Warning at amount" >+ }, >+ "notes": { >+ "type": [ >+ "string", >+ "null" >+ ], >+ "description": "Notes related to this fund" >+ }, >+ "budget_id": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Internal identifier for the budget" >+ }, >+ "timestamp": { >+ "type": [ >+ "string" >+ ], >+ "format": "date-time", >+ "description": "Timestamp" >+ }, >+ "fund_owner_id": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Internal identifier for the fund owner" >+ }, >+ "fund_access": { >+ "type": [ >+ "number", >+ "null" >+ ], >+ "description": "Level of permission for this fund (1: owner, 2: owner, users and library, 3: owner and users)" >+ }, >+ "statistic1_auth_value_category": { >+ "type": [ >+ "string", >+ "null" >+ ], >+ "description": "Statistical category for this fund" >+ }, >+ "statistic2_auth_value_category": { >+ "type": [ >+ "string", >+ "null" >+ ], >+ "description": "Second statistical category for this fund" > } > }, > "additionalProperties": false, >diff --git a/api/v1/swagger/paths/acquisitions_funds.json b/api/v1/swagger/paths/acquisitions_funds.json >index de0a12f83f..44f72774a2 100644 >--- a/api/v1/swagger/paths/acquisitions_funds.json >+++ b/api/v1/swagger/paths/acquisitions_funds.json >@@ -15,9 +15,9 @@ > "type": "string" > }, > { >- "name": "budget_owner_id", >+ "name": "fund_owner_id", > "in": "query", >- "description": "Display only the funds that belongs to the given borrowernumber", >+ "description": "Display only the funds that belongs to the given patron ID", > "required": false, > "type": "integer" > } >-- >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 19661
:
69243
|
69833
|
70603
|
83941
|
83970
|
85693
|
85694
|
85695
|
85696
|
86537
|
86538
| 86539 |
86540