|
Lines 20-26
use Modern::Perl;
Link Here
|
| 20 |
use Mojo::Base 'Mojolicious::Controller'; |
20 |
use Mojo::Base 'Mojolicious::Controller'; |
| 21 |
|
21 |
|
| 22 |
use Koha::Acquisition::Funds; |
22 |
use Koha::Acquisition::Funds; |
| 23 |
use JSON qw(to_json); |
|
|
| 24 |
|
23 |
|
| 25 |
use Try::Tiny; |
24 |
use Try::Tiny; |
| 26 |
|
25 |
|
|
Lines 45-52
sub list_funds {
Link Here
|
| 45 |
my $filter; |
44 |
my $filter; |
| 46 |
|
45 |
|
| 47 |
for my $filter_param ( keys %$args ) { |
46 |
for my $filter_param ( keys %$args ) { |
| 48 |
$filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" } |
47 |
if ($args->{$filter_param}) { |
| 49 |
if $args->{$filter_param}; |
48 |
if ($filter_param eq "budget_owner_id") { |
|
|
49 |
# Perform an exact search on the borrowernumber |
| 50 |
$filter->{$filter_param} = { "=" => $args->{$filter_param} } |
| 51 |
} else { |
| 52 |
# And a "start with" search on the budget name |
| 53 |
$filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" } |
| 54 |
} |
| 55 |
} |
| 50 |
} |
56 |
} |
| 51 |
|
57 |
|
| 52 |
return try { |
58 |
return try { |
|
Lines 77-85
the attribute names the exposed REST api spec.
Link Here
|
| 77 |
sub _to_api { |
83 |
sub _to_api { |
| 78 |
my $fund = shift; |
84 |
my $fund = shift; |
| 79 |
my $returnfund; |
85 |
my $returnfund; |
| 80 |
$returnfund->{id} = delete $fund->{budget_id}; |
86 |
$returnfund->{fund_id} = delete $fund->{budget_id}; |
| 81 |
$returnfund->{code} = delete $fund->{budget_code}; |
87 |
$returnfund->{code} = delete $fund->{budget_code}; |
| 82 |
$returnfund->{name} = delete $fund->{budget_name}; |
88 |
$returnfund->{name} = delete $fund->{budget_name}; |
|
|
89 |
$returnfund->{library_id} = delete $fund->{budget_branchcode}; |
| 90 |
$returnfund->{total_amount} = delete $fund->{budget_amount}; |
| 91 |
$returnfund->{warn_at_percentage} = delete $fund->{budget_encumb}; |
| 92 |
$returnfund->{warn_at_amount} = delete $fund->{budget_expend}; |
| 93 |
$returnfund->{notes} = delete $fund->{budget_notes}; |
| 94 |
$returnfund->{budget_id} = delete $fund->{budget_period_id}; |
| 95 |
$returnfund->{timestamp} = delete $fund->{timestamp}; |
| 96 |
$returnfund->{fund_owner_id} = delete $fund->{budget_owner_id}; |
| 97 |
$returnfund->{fund_access} = delete $fund->{budget_permission}; |
| 98 |
$returnfund->{statistic1_auth_value_category} = delete $fund->{sort1_authcat}; |
| 99 |
$returnfund->{statistic2_auth_value_category} = delete $fund->{sort2_authcat}; |
| 83 |
|
100 |
|
| 84 |
return $returnfund; |
101 |
return $returnfund; |
| 85 |
} |
102 |
} |
|
Lines 93-105
attribute names.
Link Here
|
| 93 |
|
110 |
|
| 94 |
sub _to_model { |
111 |
sub _to_model { |
| 95 |
my $fund = shift; |
112 |
my $fund = shift; |
|
|
113 |
my $returnfund; |
| 96 |
|
114 |
|
| 97 |
# Rename back |
115 |
# Rename back |
| 98 |
$fund->{budget_id} = delete $fund->{id}; |
116 |
$returnfund->{budget_id} = delete $fund->{fund_id}; |
| 99 |
$fund->{budget_code} = delete $fund->{code}; |
117 |
$returnfund->{budget_code} = delete $fund->{code}; |
| 100 |
$fund->{budget_name} = delete $fund->{name}; |
118 |
$returnfund->{budget_name} = delete $fund->{name}; |
|
|
119 |
$returnfund->{budget_branchcode} = delete $fund->{library_id}; |
| 120 |
$returnfund->{budget_amount} = delete $fund->{total_amount}; |
| 121 |
$returnfund->{budget_encumb} = delete $fund->{warn_at_percentage}; |
| 122 |
$returnfund->{budget_expend} = delete $fund->{warn_at_amount}; |
| 123 |
$returnfund->{budget_notes} = delete $fund->{notes}; |
| 124 |
$returnfund->{budget_period_id} = delete $fund->{budget_id}; |
| 125 |
$returnfund->{budget_owner_id} = delete $fund->{fund_owner_id}; |
| 126 |
$returnfund->{timestamp} = delete $fund->{timestamp}; |
| 127 |
$returnfund->{budget_permission} = delete $fund->{fund_access}; |
| 128 |
$returnfund->{sort1_authcat} = delete $fund->{statistic1_auth_value_category}; |
| 129 |
$returnfund->{sort2_authcat} = delete $fund->{statistic2_auth_value_category}; |
| 101 |
|
130 |
|
| 102 |
return $fund; |
131 |
return $returnfund; |
| 103 |
} |
132 |
} |
| 104 |
|
133 |
|
| 105 |
1; |
134 |
1; |