@@ -, +, @@ $ kshell k$ prove t/db_dependent/api/v1/acquisitions_funds.t --- Koha/Acquisition/Fund.pm | 29 ++++++++++++++++++++++++++++ Koha/REST/V1/Acquisitions/Funds.pm | 9 +++++---- api/v1/swagger/definitions/fund.json | 4 ++++ 3 files changed, 38 insertions(+), 4 deletions(-) --- a/Koha/Acquisition/Fund.pm +++ a/Koha/Acquisition/Fund.pm @@ -27,6 +27,35 @@ Koha::Acquisition::Fund object class =head1 API +=head2 Class methods + +=head3 to_api_mapping + +This method returns the mapping for representing a Koha::Acquisition::Fund object +on the API. + +=cut + +sub to_api_mapping { + return { + budget_id => 'fund_id', + budget_code => 'code', + budget_name => 'name', + budget_branchcode => 'library_id', + budget_amount => 'total_amount', + budget_encumb => 'warn_at_percentage', + budget_expend => 'warn_at_amount', + budget_notes => 'notes', + budget_period_id => 'budget_id', + timestamp => 'timestamp', + budget_owner_id => 'fund_owner_id', + budget_permission => 'fund_access', + sort1_authcat => 'statistic1_auth_value_category', + sort2_authcat => 'statistic2_auth_value_category', + budget_parent_id => 'parent_fund_id', + }; +} + =head2 Internal methods =head3 _type --- a/Koha/REST/V1/Acquisitions/Funds.pm +++ a/Koha/REST/V1/Acquisitions/Funds.pm @@ -56,10 +56,11 @@ sub list_funds { } return try { - my @funds = Koha::Acquisition::Funds->search($filter); - @funds = map { _to_api($_->TO_JSON) } @funds; - return $c->render( status => 200, - openapi => \@funds); + my $funds = Koha::Acquisition::Funds->search($filter); + return $c->render( + status => 200, + openapi => $funds->to_api + ); } catch { if ( $_->isa('DBIx::Class::Exception') ) { --- a/api/v1/swagger/definitions/fund.json +++ a/api/v1/swagger/definitions/fund.json @@ -81,6 +81,10 @@ ], "description": "Level of permission for this fund (1: owner, 2: owner, users and library, 3: owner and users)" }, + "parent_fund_id": { + "type": [ "integer", "null" ], + "description": "Internal identifier for parent fund" + }, "statistic1_auth_value_category": { "type": [ "string", --