Skip to content

Commit 05bdd62

Browse files
authored
feat: allocation setting shortcuts for spend and budgeted amount of last month (#303)
1 parent ea0c310 commit 05bdd62

File tree

11 files changed

+494
-35
lines changed

11 files changed

+494
-35
lines changed

api/docs.go

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,55 @@ const docTemplate = `{
10091009
}
10101010
},
10111011
"/v1/budgets/{budgetId}/{month}/allocations": {
1012+
"post": {
1013+
"description": "Sets allocations for a month for all envelopes that do not have an allocation yet",
1014+
"tags": [
1015+
"Budgets"
1016+
],
1017+
"summary": "Set allocations for a month",
1018+
"parameters": [
1019+
{
1020+
"type": "string",
1021+
"description": "The month in YYYY-MM format",
1022+
"name": "month",
1023+
"in": "path",
1024+
"required": true
1025+
},
1026+
{
1027+
"type": "string",
1028+
"description": "Budget ID formatted as string",
1029+
"name": "budgetId",
1030+
"in": "path",
1031+
"required": true
1032+
},
1033+
{
1034+
"description": "Budget",
1035+
"name": "mode",
1036+
"in": "body",
1037+
"required": true,
1038+
"schema": {
1039+
"$ref": "#/definitions/controllers.BudgetAllocationMode"
1040+
}
1041+
}
1042+
],
1043+
"responses": {
1044+
"204": {
1045+
"description": "No Content"
1046+
},
1047+
"400": {
1048+
"description": "Bad Request",
1049+
"schema": {
1050+
"$ref": "#/definitions/httperrors.HTTPError"
1051+
}
1052+
},
1053+
"500": {
1054+
"description": "Internal Server Error",
1055+
"schema": {
1056+
"$ref": "#/definitions/httperrors.HTTPError"
1057+
}
1058+
}
1059+
}
1060+
},
10121061
"delete": {
10131062
"description": "Deletes all allocation for the specified month",
10141063
"tags": [
@@ -2211,6 +2260,15 @@ const docTemplate = `{
22112260
}
22122261
}
22132262
},
2263+
"controllers.BudgetAllocationMode": {
2264+
"type": "object",
2265+
"properties": {
2266+
"mode": {
2267+
"type": "string",
2268+
"example": "ALLOCATE_LAST_MONTH_SPEND"
2269+
}
2270+
}
2271+
},
22142272
"controllers.BudgetLinks": {
22152273
"type": "object",
22162274
"properties": {
@@ -2227,12 +2285,12 @@ const docTemplate = `{
22272285
"example": "https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"
22282286
},
22292287
"month": {
2230-
"description": "This 'YYYY-MM' for clients to use replace with the actual year and month.",
2288+
"description": "This 'YYYY-MM' for clients to replace with the actual year and month.",
22312289
"type": "string",
22322290
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM"
22332291
},
22342292
"monthAllocations": {
2235-
"description": "This uses 'YYYY-MM' for clients to use replace with the actual year and month.",
2293+
"description": "This uses 'YYYY-MM' for clients to replace with the actual year and month.",
22362294
"type": "string",
22372295
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations"
22382296
},

api/swagger.json

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,55 @@
997997
}
998998
},
999999
"/v1/budgets/{budgetId}/{month}/allocations": {
1000+
"post": {
1001+
"description": "Sets allocations for a month for all envelopes that do not have an allocation yet",
1002+
"tags": [
1003+
"Budgets"
1004+
],
1005+
"summary": "Set allocations for a month",
1006+
"parameters": [
1007+
{
1008+
"type": "string",
1009+
"description": "The month in YYYY-MM format",
1010+
"name": "month",
1011+
"in": "path",
1012+
"required": true
1013+
},
1014+
{
1015+
"type": "string",
1016+
"description": "Budget ID formatted as string",
1017+
"name": "budgetId",
1018+
"in": "path",
1019+
"required": true
1020+
},
1021+
{
1022+
"description": "Budget",
1023+
"name": "mode",
1024+
"in": "body",
1025+
"required": true,
1026+
"schema": {
1027+
"$ref": "#/definitions/controllers.BudgetAllocationMode"
1028+
}
1029+
}
1030+
],
1031+
"responses": {
1032+
"204": {
1033+
"description": "No Content"
1034+
},
1035+
"400": {
1036+
"description": "Bad Request",
1037+
"schema": {
1038+
"$ref": "#/definitions/httperrors.HTTPError"
1039+
}
1040+
},
1041+
"500": {
1042+
"description": "Internal Server Error",
1043+
"schema": {
1044+
"$ref": "#/definitions/httperrors.HTTPError"
1045+
}
1046+
}
1047+
}
1048+
},
10001049
"delete": {
10011050
"description": "Deletes all allocation for the specified month",
10021051
"tags": [
@@ -2199,6 +2248,15 @@
21992248
}
22002249
}
22012250
},
2251+
"controllers.BudgetAllocationMode": {
2252+
"type": "object",
2253+
"properties": {
2254+
"mode": {
2255+
"type": "string",
2256+
"example": "ALLOCATE_LAST_MONTH_SPEND"
2257+
}
2258+
}
2259+
},
22022260
"controllers.BudgetLinks": {
22032261
"type": "object",
22042262
"properties": {
@@ -2215,12 +2273,12 @@
22152273
"example": "https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"
22162274
},
22172275
"month": {
2218-
"description": "This 'YYYY-MM' for clients to use replace with the actual year and month.",
2276+
"description": "This 'YYYY-MM' for clients to replace with the actual year and month.",
22192277
"type": "string",
22202278
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM"
22212279
},
22222280
"monthAllocations": {
2223-
"description": "This uses 'YYYY-MM' for clients to use replace with the actual year and month.",
2281+
"description": "This uses 'YYYY-MM' for clients to replace with the actual year and month.",
22242282
"type": "string",
22252283
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations"
22262284
},

api/swagger.yaml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ definitions:
142142
example: "2022-04-17T20:14:01.048145Z"
143143
type: string
144144
type: object
145+
controllers.BudgetAllocationMode:
146+
properties:
147+
mode:
148+
example: ALLOCATE_LAST_MONTH_SPEND
149+
type: string
150+
type: object
145151
controllers.BudgetLinks:
146152
properties:
147153
accounts:
@@ -154,13 +160,13 @@ definitions:
154160
example: https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf
155161
type: string
156162
month:
157-
description: This 'YYYY-MM' for clients to use replace with the actual year
158-
and month.
163+
description: This 'YYYY-MM' for clients to replace with the actual year and
164+
month.
159165
example: https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM
160166
type: string
161167
monthAllocations:
162-
description: This uses 'YYYY-MM' for clients to use replace with the actual
163-
year and month.
168+
description: This uses 'YYYY-MM' for clients to replace with the actual year
169+
and month.
164170
example: https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations
165171
type: string
166172
self:
@@ -1308,6 +1314,40 @@ paths:
13081314
summary: Allowed HTTP verbs
13091315
tags:
13101316
- Budgets
1317+
post:
1318+
description: Sets allocations for a month for all envelopes that do not have
1319+
an allocation yet
1320+
parameters:
1321+
- description: The month in YYYY-MM format
1322+
in: path
1323+
name: month
1324+
required: true
1325+
type: string
1326+
- description: Budget ID formatted as string
1327+
in: path
1328+
name: budgetId
1329+
required: true
1330+
type: string
1331+
- description: Budget
1332+
in: body
1333+
name: mode
1334+
required: true
1335+
schema:
1336+
$ref: '#/definitions/controllers.BudgetAllocationMode'
1337+
responses:
1338+
"204":
1339+
description: No Content
1340+
"400":
1341+
description: Bad Request
1342+
schema:
1343+
$ref: '#/definitions/httperrors.HTTPError'
1344+
"500":
1345+
description: Internal Server Error
1346+
schema:
1347+
$ref: '#/definitions/httperrors.HTTPError'
1348+
summary: Set allocations for a month
1349+
tags:
1350+
- Budgets
13111351
/v1/categories:
13121352
get:
13131353
description: Returns a list of categories

0 commit comments

Comments
 (0)