View | Details | Raw Unified | Return to bug 19661
Collapse All | Expand All

(-)a/Koha/REST/V1/Acquisitions/Funds.pm (-8 / +37 lines)
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;
(-)a/api/v1/swagger/definitions/fund.json (-3 / +80 lines)
Lines 1-7 Link Here
1
{
1
{
2
  "type": "object",
2
  "type": "object",
3
  "properties": {
3
  "properties": {
4
    "id": {
4
    "fund_id": {
5
      "$ref": "../x-primitives.json#/fund_id"
5
      "$ref": "../x-primitives.json#/fund_id"
6
    },
6
    },
7
    "code": {
7
    "code": {
Lines 9-22 Link Here
9
        "string",
9
        "string",
10
        "null"
10
        "null"
11
      ],
11
      ],
12
      "description": "Fund code"
12
      "description": "Code assigned to the fund by the user"
13
    },
13
    },
14
    "name": {
14
    "name": {
15
      "type": [
15
      "type": [
16
        "string",
16
        "string",
17
        "null"
17
        "null"
18
      ],
18
      ],
19
      "description": "Fund name"
19
      "description": "Name assigned to the fund by the user"
20
    },
21
    "library_id": {
22
      "type": [
23
        "string",
24
        "null"
25
      ],
26
      "description": "Internal identifier for the library that this fund belongs to"
27
    },
28
    "total_amount": {
29
      "type": [
30
        "number",
31
        "null"
32
      ],
33
      "description": "Total amount for this fund"
34
    },
35
    "warn_at_percentage": {
36
      "type": [
37
        "number",
38
        "null"
39
      ],
40
      "description": "Warning at percentage"
41
    },
42
    "warn_at_amount": {
43
      "type": [
44
        "number",
45
        "null"
46
      ],
47
      "description": "Warning at amount"
48
    },
49
    "notes": {
50
      "type": [
51
        "string",
52
        "null"
53
      ],
54
      "description": "Notes related to this fund"
55
    },
56
    "budget_id": {
57
      "type": [
58
        "number",
59
        "null"
60
      ],
61
      "description": "Internal identifier for the budget"
62
    },
63
    "timestamp": {
64
      "type": [
65
        "string"
66
      ],
67
      "format": "date-time",
68
      "description": "Timestamp"
69
    },
70
    "fund_owner_id": {
71
      "type": [
72
        "number",
73
        "null"
74
      ],
75
      "description": "Internal identifier for the fund owner"
76
    },
77
    "fund_access": {
78
      "type": [
79
        "number",
80
        "null"
81
      ],
82
      "description": "Level of permission for this fund (1: owner, 2: owner, users and library, 3: owner and users)"
83
    },
84
    "statistic1_auth_value_category": {
85
      "type": [
86
        "string",
87
        "null"
88
      ],
89
      "description": "Statistical category for this fund"
90
    },
91
    "statistic2_auth_value_category": {
92
      "type": [
93
        "string",
94
        "null"
95
      ],
96
      "description": "Second statistical category for this fund"
20
    }
97
    }
21
  },
98
  },
22
  "additionalProperties": false,
99
  "additionalProperties": false,
(-)a/api/v1/swagger/paths/acquisitions_funds.json (-3 / +2 lines)
Lines 15-23 Link Here
15
        "type": "string"
15
        "type": "string"
16
      },
16
      },
17
      {
17
      {
18
        "name": "budget_owner_id",
18
        "name": "fund_owner_id",
19
        "in": "query",
19
        "in": "query",
20
        "description": "Display only the funds that belongs to the given borrowernumber",
20
        "description": "Display only the funds that belongs to the given patron ID",
21
        "required": false,
21
        "required": false,
22
        "type": "integer"
22
        "type": "integer"
23
      }
23
      }
24
- 

Return to bug 19661