Skip to content

Commit 0a18497

Browse files
authored
feat: add import preview for YNAB import format (#677)
1 parent 7bd96a5 commit 0a18497

23 files changed

+867
-114
lines changed

api/docs.go

Lines changed: 105 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.json

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,74 @@
18641864
}
18651865
}
18661866
},
1867+
"/v1/import/ynab-import-preview": {
1868+
"post": {
1869+
"description": "Returns a preview of transactions to be imported after parsing a YNAB Import format csv file",
1870+
"consumes": [
1871+
"multipart/form-data"
1872+
],
1873+
"produces": [
1874+
"application/json"
1875+
],
1876+
"tags": [
1877+
"Import"
1878+
],
1879+
"summary": "Transaction Import Preview",
1880+
"parameters": [
1881+
{
1882+
"type": "file",
1883+
"description": "File to import",
1884+
"name": "file",
1885+
"in": "formData",
1886+
"required": true
1887+
},
1888+
{
1889+
"type": "string",
1890+
"description": "ID of the account to import transactions for",
1891+
"name": "accountId",
1892+
"in": "query"
1893+
}
1894+
],
1895+
"responses": {
1896+
"200": {
1897+
"description": "OK",
1898+
"schema": {
1899+
"$ref": "#/definitions/controllers.ImportPreviewList"
1900+
}
1901+
},
1902+
"400": {
1903+
"description": "Bad Request",
1904+
"schema": {
1905+
"$ref": "#/definitions/httperrors.HTTPError"
1906+
}
1907+
},
1908+
"500": {
1909+
"description": "Internal Server Error",
1910+
"schema": {
1911+
"$ref": "#/definitions/httperrors.HTTPError"
1912+
}
1913+
}
1914+
}
1915+
},
1916+
"options": {
1917+
"description": "Returns an empty response with the HTTP Header \"allow\" set to the allowed HTTP verbs",
1918+
"tags": [
1919+
"Import"
1920+
],
1921+
"summary": "Allowed HTTP verbs",
1922+
"responses": {
1923+
"204": {
1924+
"description": "No Content"
1925+
},
1926+
"500": {
1927+
"description": "Internal Server Error",
1928+
"schema": {
1929+
"$ref": "#/definitions/httperrors.HTTPError"
1930+
}
1931+
}
1932+
}
1933+
}
1934+
},
18671935
"/v1/import/ynab4": {
18681936
"post": {
18691937
"description": "Imports budgets from YNAB 4",
@@ -1876,7 +1944,7 @@
18761944
"tags": [
18771945
"Import"
18781946
],
1879-
"summary": "Import",
1947+
"summary": "Import YNAB 4 budget",
18801948
"parameters": [
18811949
{
18821950
"type": "file",
@@ -3064,6 +3132,17 @@
30643132
}
30653133
}
30663134
},
3135+
"controllers.ImportPreviewList": {
3136+
"type": "object",
3137+
"properties": {
3138+
"data": {
3139+
"type": "array",
3140+
"items": {
3141+
"$ref": "#/definitions/importer.TransactionPreview"
3142+
}
3143+
}
3144+
}
3145+
},
30673146
"controllers.MonthConfigListResponse": {
30683147
"type": "object",
30693148
"properties": {
@@ -3119,6 +3198,31 @@
31193198
}
31203199
}
31213200
},
3201+
"importer.TransactionPreview": {
3202+
"type": "object",
3203+
"properties": {
3204+
"destinationAccountName": {
3205+
"description": "Name of the destination account if the ID is not known",
3206+
"type": "string",
3207+
"example": "Deutsche Bahn"
3208+
},
3209+
"duplicateTransactionIds": {
3210+
"description": "IDs of transactions that this transaction duplicates",
3211+
"type": "array",
3212+
"items": {
3213+
"type": "string"
3214+
}
3215+
},
3216+
"model": {
3217+
"$ref": "#/definitions/models.Transaction"
3218+
},
3219+
"sourceAccountName": {
3220+
"description": "Name of the source account if the ID is not known",
3221+
"type": "string",
3222+
"example": "Employer"
3223+
}
3224+
}
3225+
},
31223226
"models.AccountCreate": {
31233227
"type": "object",
31243228
"properties": {

api/swagger.yaml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ definitions:
205205
data:
206206
$ref: '#/definitions/models.Envelope'
207207
type: object
208+
controllers.ImportPreviewList:
209+
properties:
210+
data:
211+
items:
212+
$ref: '#/definitions/importer.TransactionPreview'
213+
type: array
214+
type: object
208215
controllers.MonthConfigListResponse:
209216
properties:
210217
data:
@@ -240,6 +247,24 @@ definitions:
240247
example: An ID specified in the query string was not a valid uint64
241248
type: string
242249
type: object
250+
importer.TransactionPreview:
251+
properties:
252+
destinationAccountName:
253+
description: Name of the destination account if the ID is not known
254+
example: Deutsche Bahn
255+
type: string
256+
duplicateTransactionIds:
257+
description: IDs of transactions that this transaction duplicates
258+
items:
259+
type: string
260+
type: array
261+
model:
262+
$ref: '#/definitions/models.Transaction'
263+
sourceAccountName:
264+
description: Name of the source account if the ID is not known
265+
example: Employer
266+
type: string
267+
type: object
243268
models.AccountCreate:
244269
properties:
245270
budgetId:
@@ -2251,6 +2276,53 @@ paths:
22512276
summary: Import
22522277
tags:
22532278
- Import
2279+
/v1/import/ynab-import-preview:
2280+
options:
2281+
description: Returns an empty response with the HTTP Header "allow" set to the
2282+
allowed HTTP verbs
2283+
responses:
2284+
"204":
2285+
description: No Content
2286+
"500":
2287+
description: Internal Server Error
2288+
schema:
2289+
$ref: '#/definitions/httperrors.HTTPError'
2290+
summary: Allowed HTTP verbs
2291+
tags:
2292+
- Import
2293+
post:
2294+
consumes:
2295+
- multipart/form-data
2296+
description: Returns a preview of transactions to be imported after parsing
2297+
a YNAB Import format csv file
2298+
parameters:
2299+
- description: File to import
2300+
in: formData
2301+
name: file
2302+
required: true
2303+
type: file
2304+
- description: ID of the account to import transactions for
2305+
in: query
2306+
name: accountId
2307+
type: string
2308+
produces:
2309+
- application/json
2310+
responses:
2311+
"200":
2312+
description: OK
2313+
schema:
2314+
$ref: '#/definitions/controllers.ImportPreviewList'
2315+
"400":
2316+
description: Bad Request
2317+
schema:
2318+
$ref: '#/definitions/httperrors.HTTPError'
2319+
"500":
2320+
description: Internal Server Error
2321+
schema:
2322+
$ref: '#/definitions/httperrors.HTTPError'
2323+
summary: Transaction Import Preview
2324+
tags:
2325+
- Import
22542326
/v1/import/ynab4:
22552327
options:
22562328
description: Returns an empty response with the HTTP Header "allow" set to the
@@ -2294,7 +2366,7 @@ paths:
22942366
description: Internal Server Error
22952367
schema:
22962368
$ref: '#/definitions/httperrors.HTTPError'
2297-
summary: Import
2369+
summary: Import YNAB 4 budget
22982370
tags:
22992371
- Import
23002372
/v1/month-configs:

0 commit comments

Comments
 (0)