controllers

package
v2.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryDBConnect

func TryDBConnect(e error) error

TryDBConnect checks the database error to decide if a reconnection attempt makes sense and executes the reconnection. It returns nil for success and an error if reconnecting the database is not possible or not a sensible decision

In cases where the database file might have been deleted, we err on the side of caution and do *not* reconnect the database so that we do not have two states that need to be merged manually by the user afterwards

TODO: Actually implement the reconnection logic. This is not yet done as we currently do not store.

Types

type Account

type Account struct {
	models.Account
	RecentEnvelopes []models.Envelope `json:"recentEnvelopes"`
}

type AccountListResponse

type AccountListResponse struct {
	Data []Account `json:"data"`
}

type AccountQueryFilter

type AccountQueryFilter struct {
	Name     string `form:"name" filterField:"false"` // Fuzzy filter for the account name
	Note     string `form:"note" filterField:"false"` // Fuzzy filter for the note
	BudgetID string `form:"budget"`                   // By budget ID
	OnBudget bool   `form:"onBudget"`                 // Is the account on-budget?
	External bool   `form:"external"`                 // Is the account external?
	Hidden   bool   `form:"hidden"`                   // Is the account hidden?
	Search   string `form:"search" filterField:"false"`
}

func (AccountQueryFilter) ToCreate

type AccountResponse

type AccountResponse struct {
	Data Account `json:"data"`
}

type AllocationListResponse

type AllocationListResponse struct {
	Data []models.Allocation `json:"data"`
}

type AllocationMode

type AllocationMode string

swagger:enum AllocationMode

const (
	AllocateLastMonthBudget AllocationMode = "ALLOCATE_LAST_MONTH_BUDGET"
	AllocateLastMonthSpend  AllocationMode = "ALLOCATE_LAST_MONTH_SPEND"
)

type AllocationQueryFilter

type AllocationQueryFilter struct {
	Month      string          `form:"month"`
	Amount     decimal.Decimal `form:"amount"`
	EnvelopeID string          `form:"envelope"`
}

func (AllocationQueryFilter) Parse

type AllocationResponse

type AllocationResponse struct {
	Data models.Allocation `json:"data"`
}

type BudgetAllocationMode

type BudgetAllocationMode struct {
	Mode AllocationMode `json:"mode" example:"ALLOCATE_LAST_MONTH_SPEND"`
}

type BudgetListResponse

type BudgetListResponse struct {
	Data []models.Budget `json:"data"`
}

type BudgetMonthResponse

type BudgetMonthResponse struct {
	Data models.BudgetMonth `json:"data"`
}

type BudgetQueryFilter

type BudgetQueryFilter struct {
	Name     string `form:"name" filterField:"false"`
	Note     string `form:"note" filterField:"false"`
	Currency string `form:"currency"`
	Search   string `form:"search" filterField:"false"`
}

type BudgetResponse

type BudgetResponse struct {
	Data models.Budget `json:"data"`
}

type Category

type Category struct {
	models.Category
	Envelopes []models.Envelope `json:"envelopes"`
}

type CategoryListResponse

type CategoryListResponse struct {
	Data []Category `json:"data"`
}

type CategoryQueryFilter

type CategoryQueryFilter struct {
	Name     string `form:"name" filterField:"false"`
	BudgetID string `form:"budget"`
	Note     string `form:"note" filterField:"false"`
	Hidden   bool   `form:"hidden"`
	Search   string `form:"search" filterField:"false"`
}

func (CategoryQueryFilter) ToCreate

type CategoryResponse

type CategoryResponse struct {
	Data Category `json:"data"`
}

type Controller

type Controller struct {
	DB *gorm.DB
}

func (Controller) CreateAccount

func (co Controller) CreateAccount(c *gin.Context)

CreateAccount creates a new account

@Summary		Create account
@Description	Creates a new account
@Tags			Accounts
@Produce		json
@Success		201	{object}	AccountResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500		{object}	httperrors.HTTPError
@Param			account	body		models.AccountCreate	true	"Account"
@Router			/v1/accounts [post]

func (Controller) CreateAllocation

func (co Controller) CreateAllocation(c *gin.Context)

CreateAllocation creates a new allocation

@Summary		Create allocations
@Description	Create a new allocation of funds to an envelope for a specific month
@Tags			Allocations
@Produce		json
@Success		201	{object}	AllocationResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			allocation	body		models.AllocationCreate	true	"Allocation"
@Router			/v1/allocations [post]

func (Controller) CreateBudget

func (co Controller) CreateBudget(c *gin.Context)

CreateBudget creates a new budget

@Summary		Create budget
@Description	Creates a new budget
@Tags			Budgets
@Accept			json
@Produce		json
@Success		201		{object}	BudgetResponse
@Failure		400		{object}	httperrors.HTTPError
@Failure		500		{object}	httperrors.HTTPError
@Param			budget	body		models.BudgetCreate	true	"Budget"
@Router			/v1/budgets [post]

func (Controller) CreateCategory

func (co Controller) CreateCategory(c *gin.Context)

CreateCategory creates a new category

@Summary		Create category
@Description	Creates a new category
@Tags			Categories
@Produce		json
@Success		201	{object}	CategoryResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			category	body		models.CategoryCreate	true	"Category"
@Router			/v1/categories [post]

func (Controller) CreateEnvelope

func (co Controller) CreateEnvelope(c *gin.Context)

CreateEnvelope creates a new envelope

@Summary		Create envelope
@Description	Creates a new envelope
@Tags			Envelopes
@Produce		json
@Success		201	{object}	EnvelopeResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			envelope	body		models.EnvelopeCreate	true	"Envelope"
@Router			/v1/envelopes [post]

func (Controller) CreateMonthConfig

func (co Controller) CreateMonthConfig(c *gin.Context)

CreateMonthConfig creates a new month config

@Summary		Create MonthConfig
@Description	Creates a new MonthConfig
@Tags			MonthConfigs
@Produce		json
@Success		201			{object}	MonthConfigResponse
@Failure		400			{object}	httperrors.HTTPError
@Failure		404			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string						true	"ID of the Envelope"
@Param			month		path		string						true	"The month in YYYY-MM format"
@Param			monthConfig	body		models.MonthConfigCreate	true	"MonthConfig"
@Router			/v1/month-configs/{envelopeId}/{month} [post]

func (Controller) CreateTransaction

func (co Controller) CreateTransaction(c *gin.Context)

CreateTransaction creates a new transaction

@Summary		Create transaction
@Description	Creates a new transaction
@Tags			Transactions
@Produce		json
@Success		201	{object}	TransactionResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			transaction	body		models.TransactionCreate	true	"Transaction"
@Router			/v1/transactions [post]

func (Controller) DeleteAccount

func (co Controller) DeleteAccount(c *gin.Context)

DeleteAccount deletes an account

@Summary		Delete account
@Description	Deletes an account
@Tags			Accounts
@Produce		json
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			accountId	path		string	true	"ID formatted as string"
@Router			/v1/accounts/{accountId} [delete]

func (Controller) DeleteAll

func (co Controller) DeleteAll(c *gin.Context)

DeleteAll permanently deletes all resources in the database

@Summary		Delete everything
@Description	Permanently deletes all resources
@Tags			v1
@Success		204
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1 [delete]

func (Controller) DeleteAllocation

func (co Controller) DeleteAllocation(c *gin.Context)

DeleteAllocation deletes an allocation

@Summary		Delete allocation
@Description	Deletes an allocation
@Tags			Allocations
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			allocationId	path		string	true	"ID formatted as string"
@Router			/v1/allocations/{allocationId} [delete]

func (Controller) DeleteAllocations

func (co Controller) DeleteAllocations(c *gin.Context)

DeleteAllocations deletes all allocations for a month

@Summary		Delete allocations for a month
@Description	Deletes all allocation for the specified month
@Tags			Months
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500		{object}	httperrors.HTTPError
@Param			budget	query		string	true	"ID formatted as string"
@Param			month	query		string	true	"The month in YYYY-MM format"
@Router			/v1/months [delete]

func (Controller) DeleteAllocationsMonth

func (co Controller) DeleteAllocationsMonth(c *gin.Context)

DeleteAllocationsMonth deletes all allocations for a specific month

@Summary		Delete allocations for a month
@Description	Deletes all allocation for the specified month. **Use DELETE /month endpoint with month and budgetId query parameters instead.**
@Tags			Budgets
@Success		204
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			month		path		string	true	"The month in YYYY-MM format"
@Param			budgetId	path		string	true	"Budget ID formatted as string"
@Router			/v1/budgets/{budgetId}/{month}/allocations [delete]
@Deprecated		true.

func (Controller) DeleteBudget

func (co Controller) DeleteBudget(c *gin.Context)

Do stuff

@Summary		Delete budget
@Description	Deletes a budget
@Tags			Budgets
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Router			/v1/budgets/{budgetId} [delete]

func (Controller) DeleteCategory

func (co Controller) DeleteCategory(c *gin.Context)

DeleteCategory deletes a specific category

@Summary		Delete category
@Description	Deletes a category
@Tags			Categories
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			categoryId	path		string	true	"ID formatted as string"
@Router			/v1/categories/{categoryId} [delete]

func (Controller) DeleteEnvelope

func (co Controller) DeleteEnvelope(c *gin.Context)

DeleteEnvelope deletes an envelope

@Summary		Delete envelope
@Description	Deletes an envelope
@Tags			Envelopes
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID formatted as string"
@Router			/v1/envelopes/{envelopeId} [delete]

func (Controller) DeleteMonthConfig

func (co Controller) DeleteMonthConfig(c *gin.Context)

DeleteMonthConfig deletes configuration data for a specific envelope and month

@Summary		Delete MonthConfig
@Description	Deletes configuration settings for a specific month
@Tags			MonthConfigs
@Produce		json
@Success		204
@Failure		400			{object}	httperrors.HTTPError
@Failure		404			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID of the Envelope"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/month-configs/{envelopeId}/{month} [delete]

func (Controller) DeleteTransaction

func (co Controller) DeleteTransaction(c *gin.Context)

DeleteTransaction deletes a specific transaction

@Summary		Delete transaction
@Description	Deletes a transaction
@Tags			Transactions
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			transactionId	path		string	true	"ID formatted as string"
@Router			/v1/transactions/{transactionId} [delete]

func (Controller) GetAccount

func (co Controller) GetAccount(c *gin.Context)

GetAccount returns data for a specific account

@Summary		Get account
@Description	Returns a specific account
@Tags			Accounts
@Produce		json
@Success		200	{object}	AccountResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			accountId	path		string	true	"ID formatted as string"
@Router			/v1/accounts/{accountId} [get]

func (Controller) GetAccounts

func (co Controller) GetAccounts(c *gin.Context)

GetAccounts returns a list of all accounts matching the filter parameters

@Summary		List accounts
@Description	Returns a list of accounts
@Tags			Accounts
@Produce		json
@Success		200	{object}	AccountListResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/accounts [get]
@Param			name		query	string	false	"Filter by name"
@Param			note		query	string	false	"Filter by note"
@Param			budget		query	string	false	"Filter by budget ID"
@Param			onBudget	query	bool	false	"Is the account on-budget?"
@Param			external	query	bool	false	"Is the account external?"
@Param			hidden		query	bool	false	"Is the account hidden?"
@Param			search		query	string	false	"Search for this text in name and note"

func (Controller) GetAllocation

func (co Controller) GetAllocation(c *gin.Context)

GetAllocation returns data about a specific allocation

@Summary		Get allocation
@Description	Returns a specific allocation
@Tags			Allocations
@Produce		json
@Success		200	{object}	AllocationResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			allocationId	path		string	true	"ID formatted as string"
@Router			/v1/allocations/{allocationId} [get]

func (Controller) GetAllocations

func (co Controller) GetAllocations(c *gin.Context)

GetAllocations returns a list of allocations matching the search parameters

@Summary		Get allocations
@Description	Returns a list of allocations
@Tags			Allocations
@Produce		json
@Success		200	{object}	AllocationListResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/allocations [get]
@Param			month		query	string	false	"Filter by month"
@Param			amount		query	string	false	"Filter by amount"
@Param			envelope	query	string	false	"Filter by envelope ID"

func (Controller) GetBudget

func (co Controller) GetBudget(c *gin.Context)

GetBudget returns data for a single budget

@Summary		Get budget
@Description	Returns a specific budget
@Tags			Budgets
@Produce		json
@Success		200	{object}	BudgetResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Router			/v1/budgets/{budgetId} [get]

func (Controller) GetBudgetMonth

func (co Controller) GetBudgetMonth(c *gin.Context)

GetBudgetMonth returns data for a month for a specific budget

@Summary		Get Budget month data
@Description	Returns data about a budget for a for a specific month. **Use GET /month endpoint with month and budgetId query parameters instead.**
@Tags			Budgets
@Produce		json
@Success		200	{object}	BudgetMonthResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/budgets/{budgetId}/{month} [get]
@Deprecated		true

func (Controller) GetBudgets

func (co Controller) GetBudgets(c *gin.Context)

GetBudgets returns data for all budgets filtered by the query parameters

@Summary		List budgets
@Description	Returns a list of budgets
@Tags			Budgets
@Produce		json
@Success		200	{object}	BudgetListResponse
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/budgets [get]
@Param			name		query	string	false	"Filter by name"
@Param			note		query	string	false	"Filter by note"
@Param			currency	query	string	false	"Filter by currency"
@Param			search		query	string	false	"Search for this text in name and note"

func (Controller) GetCategories

func (co Controller) GetCategories(c *gin.Context)

GetCategories returns a list of categories filtered by the query parameters

@Summary		Get categories
@Description	Returns a list of categories
@Tags			Categories
@Produce		json
@Success		200	{object}	CategoryListResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/categories [get]
@Param			name	query	string	false	"Filter by name"
@Param			note	query	string	false	"Filter by note"
@Param			budget	query	string	false	"Filter by budget ID"
@Param			hidden	query	bool	false	"Is the category hidden?"
@Param			search	query	string	false	"Search for this text in name and note"

func (Controller) GetCategory

func (co Controller) GetCategory(c *gin.Context)

GetCategory returns data for a specific category

@Summary		Get category
@Description	Returns a specific category
@Tags			Categories
@Produce		json
@Success		200	{object}	CategoryResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			categoryId	path		string	true	"ID formatted as string"
@Router			/v1/categories/{categoryId} [get]

func (Controller) GetEnvelope

func (co Controller) GetEnvelope(c *gin.Context)

GetEnvelope returns data about a specific envelope

@Summary		Get envelope
@Description	Returns a specific envelope
@Tags			Envelopes
@Produce		json
@Success		200	{object}	EnvelopeResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID formatted as string"
@Router			/v1/envelopes/{envelopeId} [get]

func (Controller) GetEnvelopeMonth

func (co Controller) GetEnvelopeMonth(c *gin.Context)

GetEnvelopeMonth returns month data for a specific envelope

@Summary		Get Envelope month data
@Description	Returns data about an envelope for a for a specific month. **Use GET /month endpoint with month and budgetId query parameters instead.**
@Tags			Envelopes
@Produce		json
@Success		200	{object}	EnvelopeMonthResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID formatted as string"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/envelopes/{envelopeId}/{month} [get]
@Deprecated		true

func (Controller) GetEnvelopes

func (co Controller) GetEnvelopes(c *gin.Context)

GetEnvelopes returns a list of envelopes filtered by the query parameters

@Summary		Get envelopes
@Description	Returns a list of envelopes
@Tags			Envelopes
@Produce		json
@Success		200	{object}	EnvelopeListResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/envelopes [get]
@Param			name		query	string	false	"Filter by name"
@Param			note		query	string	false	"Filter by note"
@Param			category	query	string	false	"Filter by category ID"
@Param			hidden		query	bool	false	"Is the envelope hidden?"
@Param			search		query	string	false	"Search for this text in name and note"

func (Controller) GetMonth

func (co Controller) GetMonth(c *gin.Context)

GetMonth returns data for a specific budget and month

@Summary		Get data about a month
@Description	Returns data about a specific month.
@Tags			Months
@Produce		json
@Success		200	{object}	MonthResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500		{object}	httperrors.HTTPError
@Param			budget	query		string	true	"ID formatted as string"
@Param			month	query		string	true	"The month in YYYY-MM format"
@Router			/v1/months [get]

func (Controller) GetMonthConfig

func (co Controller) GetMonthConfig(c *gin.Context)

GetMonthConfig returns config for a specific envelope and month

@Summary		Get MonthConfig
@Description	Returns configuration for a specific month
@Tags			MonthConfigs
@Produce		json
@Success		200			{object}	MonthConfigResponse
@Failure		400			{object}	httperrors.HTTPError
@Failure		404			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID of the Envelope"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/month-configs/{envelopeId}/{month} [get]

func (Controller) GetMonthConfigs

func (co Controller) GetMonthConfigs(c *gin.Context)

GetMonthConfigs returns all month configs filtered by the query parameters

@Summary		List MonthConfigs
@Description	Returns a list of MonthConfigs
@Tags			MonthConfigs
@Produce		json
@Success		200			{object}	MonthConfigListResponse
@Failure		400			{object}	httperrors.HTTPError
@Failure		404			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			envelope	query		string	false	"Filter by name"
@Param			month		query		string	false	"Filter by month"
@Router			/v1/month-configs [get]

func (Controller) GetTransaction

func (co Controller) GetTransaction(c *gin.Context)

GetTransaction returns a specific transaction

@Summary		Get transaction
@Description	Returns a specific transaction
@Tags			Transactions
@Produce		json
@Success		200	{object}	TransactionResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			transactionId	path		string	true	"ID formatted as string"
@Router			/v1/transactions/{transactionId} [get]

func (Controller) GetTransactions

func (co Controller) GetTransactions(c *gin.Context)

GetTransactions returns transactions filtered by the query parameters

@Summary		Get transactions
@Description	Returns a list of transactions
@Tags			Transactions
@Produce		json
@Success		200	{object}	TransactionListResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/transactions [get]
@Param			date					query	string	false	"Date of the transaction. Ignores exact time, matches on the day of the RFC3339 timestamp provided."
@Param			fromDate				query	string	false	"Transactions at and after this date. Ignores exact time, matches on the day of the RFC3339 timestamp provided."
@Param			untilDate				query	string	false	"Transactions before and at this date. Ignores exact time, matches on the day of the RFC3339 timestamp provided."
@Param			amount					query	string	false	"Filter by amount"
@Param			amountLessOrEqual		query	string	false	"Amount less than or equal to this"
@Param			amountMoreOrEqual		query	string	false	"Amount more than or equal to this"
@Param			note					query	string	false	"Filter by note"
@Param			budget					query	string	false	"Filter by budget ID"
@Param			account					query	string	false	"Filter by ID of associated account, regardeless of source or destination"
@Param			source					query	string	false	"Filter by source account ID"
@Param			destination				query	string	false	"Filter by destination account ID"
@Param			envelope				query	string	false	"Filter by envelope ID"
@Param			reconciled				query	bool	false	"DEPRECATED. Filter by reconcilication state"
@Param			reconciledSource		query	bool	false	"Reconcilication state in source account"
@Param			reconciledDestination	query	bool	false	"Reconcilication state in destination account"

func (Controller) Import

func (co Controller) Import(c *gin.Context)

Import imports a YNAB 4 budget

@Summary		Import
@Description	Imports budgets from YNAB 4. **Please use /v1/import/ynab4, which works exactly the same.**
@Tags			Import
@Accept			multipart/form-data
@Produce		json
@Success		204
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			file		formData	file	true	"File to import"
@Param			budgetName	query		string	false	"Name of the Budget to create"
@Router			/v1/import [post]
@Deprecated		true

func (Controller) ImportYnab4

func (co Controller) ImportYnab4(c *gin.Context)

ImportYnab4 imports a YNAB 4 budget

@Summary		Import YNAB 4 budget
@Description	Imports budgets from YNAB 4
@Tags			Import
@Accept			multipart/form-data
@Produce		json
@Success		201			{object}	BudgetResponse
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			file		formData	file	true	"File to import"
@Param			budgetName	query		string	false	"Name of the Budget to create"
@Router			/v1/import/ynab4 [post]

func (Controller) ImportYnabImportPreview added in v2.7.0

func (co Controller) ImportYnabImportPreview(c *gin.Context)

ImportYnabImportPreview parses a YNAB import format CSV and returns a preview of transactions to be imported into Envelope Zero.

@Summary		Transaction Import Preview
@Description	Returns a preview of transactions to be imported after parsing a YNAB Import format csv file
@Tags			Import
@Accept			multipart/form-data
@Produce		json
@Success		200			{object}	ImportPreviewList
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			file		formData	file	true	"File to import"
@Param			accountId	query		string	false	"ID of the account to import transactions for"
@Router			/v1/import/ynab-import-preview [post]

func (Controller) OptionsAccountDetail

func (co Controller) OptionsAccountDetail(c *gin.Context)

OptionsAccountDetail returns the allowed HTTP verbs

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Accounts
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Param			accountId	path	string	true	"ID formatted as string"
@Router			/v1/accounts/{accountId} [options]

func (Controller) OptionsAccountList

func (co Controller) OptionsAccountList(c *gin.Context)

OptionsAccountList returns the allowed HTTP verbs

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Accounts
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Router			/v1/accounts [options]

func (Controller) OptionsAllocationDetail

func (co Controller) OptionsAllocationDetail(c *gin.Context)

OptionsAllocationDetail returns the allowed HTTP verbs

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Allocations
@Success		204
@Param			allocationId	path	string	true	"ID formatted as string"
@Router			/v1/allocations/{allocationId} [options]

func (Controller) OptionsAllocationList

func (co Controller) OptionsAllocationList(c *gin.Context)

OptionsAllocationList returns the allowed HTTP verbs

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Allocations
@Success		204
@Router			/v1/allocations [options]

func (Controller) OptionsBudgetDetail

func (co Controller) OptionsBudgetDetail(c *gin.Context)

OptionsBudgetDetail returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Budgets
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Router			/v1/budgets/{budgetId} [options]

func (Controller) OptionsBudgetList

func (co Controller) OptionsBudgetList(c *gin.Context)

OptionsBudgetList returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Budgets
@Success		204
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/budgets [options]

func (Controller) OptionsBudgetMonth

func (co Controller) OptionsBudgetMonth(c *gin.Context)

OptionsBudgetMonth returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs. **Use OPTIONS /month endpoint with month and budgetId query parameters instead.**
@Tags			Budgets
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/budgets/{budgetId}/{month} [options]
@Deprecated		true

func (Controller) OptionsBudgetMonthAllocations

func (co Controller) OptionsBudgetMonthAllocations(c *gin.Context)

OptionsBudgetMonthAllocations returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs. **Use OPTIONS /month endpoint with month and budgetId query parameters instead.**
@Tags			Budgets
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string	true	"ID formatted as string"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/budgets/{budgetId}/{month}/allocations [options]
@Deprecated		true

func (Controller) OptionsCategoryDetail

func (co Controller) OptionsCategoryDetail(c *gin.Context)

OptionsCategoryDetail returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Categories
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Param			categoryId	path	string	true	"ID formatted as string"
@Router			/v1/categories/{categoryId} [options]

func (Controller) OptionsCategoryList

func (co Controller) OptionsCategoryList(c *gin.Context)

OptionsCategoryList returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Categories
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Router			/v1/categories [options]

func (Controller) OptionsEnvelopeDetail

func (co Controller) OptionsEnvelopeDetail(c *gin.Context)

OptionsEnvelopeDetail returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Envelopes
@Success		204
@Param			envelopeId	path	string	true	"ID formatted as string"
@Router			/v1/envelopes/{envelopeId} [options]

func (Controller) OptionsEnvelopeList

func (co Controller) OptionsEnvelopeList(c *gin.Context)

OptionsEnvelopeList returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Envelopes
@Success		204
@Router			/v1/envelopes [options]

func (Controller) OptionsImport

func (co Controller) OptionsImport(c *gin.Context)

OptionsImport returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs. **Please use /v1/import/ynab4, which works exactly the same.**
@Tags			Import
@Success		204
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/import [options]
@Deprecated		true

func (Controller) OptionsImportYnab4

func (co Controller) OptionsImportYnab4(c *gin.Context)

OptionsImportYnab4 returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Import
@Success		204
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/import/ynab4 [options]

func (Controller) OptionsImportYnabImportPreview added in v2.7.0

func (co Controller) OptionsImportYnabImportPreview(c *gin.Context)

OptionsImportYnab4 returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Import
@Success		204
@Failure		500	{object}	httperrors.HTTPError
@Router			/v1/import/ynab-import-preview [options]

func (Controller) OptionsMonth

func (co Controller) OptionsMonth(c *gin.Context)

OptionsMonth returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs.
@Tags			Months
@Success		204
@Router			/v1/months [options]

func (Controller) OptionsMonthConfigDetail

func (co Controller) OptionsMonthConfigDetail(c *gin.Context)

OptionsMonthConfigDetail returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			MonthConfigs
@Success		204
@Failure		400			{object}	httperrors.HTTPError
@Failure		404			{object}	httperrors.HTTPError
@Param			envelopeId	path		string	true	"ID of the Envelope"
@Param			month		path		string	true	"The month in YYYY-MM format"
@Router			/v1/month-configs/{envelopeId}/{month} [options]

func (Controller) OptionsMonthConfigList

func (co Controller) OptionsMonthConfigList(c *gin.Context)

OptionsMonthConfigList returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs.
@Tags			MonthConfigs
@Success		204
@Router			/v1/month-configs [options]

func (Controller) OptionsTransactionDetail

func (co Controller) OptionsTransactionDetail(c *gin.Context)

OptionsTransactionDetail returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Transactions
@Success		204
@Param			transactionId	path	string	true	"ID formatted as string"
@Router			/v1/transactions/{transactionId} [options]

func (Controller) OptionsTransactionList

func (co Controller) OptionsTransactionList(c *gin.Context)

OptionsTransactionList returns the allowed HTTP methods

@Summary		Allowed HTTP verbs
@Description	Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
@Tags			Transactions
@Success		204
@Router			/v1/transactions [options]

func (Controller) RegisterAccountRoutes

func (co Controller) RegisterAccountRoutes(r *gin.RouterGroup)

RegisterAccountRoutes registers the routes for accounts with the RouterGroup that is passed.

func (Controller) RegisterAllocationRoutes

func (co Controller) RegisterAllocationRoutes(r *gin.RouterGroup)

RegisterAllocationRoutes registers the routes for allocations with the RouterGroup that is passed.

func (Controller) RegisterBudgetRoutes

func (co Controller) RegisterBudgetRoutes(r *gin.RouterGroup)

RegisterBudgetRoutes registers the routes for budgets with the RouterGroup that is passed.

func (Controller) RegisterCategoryRoutes

func (co Controller) RegisterCategoryRoutes(r *gin.RouterGroup)

RegisterCategoryRoutes registers the routes for categories with the RouterGroup that is passed.

func (Controller) RegisterEnvelopeRoutes

func (co Controller) RegisterEnvelopeRoutes(r *gin.RouterGroup)

RegisterEnvelopeRoutes registers the routes for envelopes with the RouterGroup that is passed.

func (Controller) RegisterImportRoutes

func (co Controller) RegisterImportRoutes(r *gin.RouterGroup)

RegisterImportRoutes registers the routes for imports.

func (Controller) RegisterMonthConfigRoutes

func (co Controller) RegisterMonthConfigRoutes(r *gin.RouterGroup)

RegisterMonthConfigRoutes registers the routes for transactions with the RouterGroup that is passed.

func (Controller) RegisterMonthRoutes

func (co Controller) RegisterMonthRoutes(r *gin.RouterGroup)

RegisterMonthRoutes registers the routes for months with the RouterGroup that is passed.

func (Controller) RegisterTransactionRoutes

func (co Controller) RegisterTransactionRoutes(r *gin.RouterGroup)

RegisterTransactionRoutes registers the routes for transactions with the RouterGroup that is passed.

func (Controller) SetAllocations

func (co Controller) SetAllocations(c *gin.Context)

SetAllocations sets all allocations for a month

@Summary		Set allocations for a month
@Description	Sets allocations for a month for all envelopes that do not have an allocation yet
@Tags			Months
@Success		204
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500		{object}	httperrors.HTTPError
@Param			budget	query		string					true	"ID formatted as string"
@Param			month	query		string					true	"The month in YYYY-MM format"
@Param			mode	body		BudgetAllocationMode	true	"Budget"
@Router			/v1/months [post]

func (Controller) SetAllocationsMonth

func (co Controller) SetAllocationsMonth(c *gin.Context)

SetAllocationsMonth sets all allocations for a specific month

@Summary		Set allocations for a month
@Description	Sets allocations for a month for all envelopes that do not have an allocation yet. **Use POST /month endpoint with month and budgetId query parameters instead.**
@Tags			Budgets
@Success		204
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			month		path		string					true	"The month in YYYY-MM format"
@Param			budgetId	path		string					true	"Budget ID formatted as string"
@Param			mode		body		BudgetAllocationMode	true	"Budget"
@Router			/v1/budgets/{budgetId}/{month}/allocations [post]
@Deprecated		true.

func (Controller) UpdateAccount

func (co Controller) UpdateAccount(c *gin.Context)

UpdateAccount updates data for a specific account

@Summary		Update account
@Description	Updates an account. Only values to be updated need to be specified.
@Tags			Accounts
@Produce		json
@Success		200	{object}	AccountResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			accountId	path		string					true	"ID formatted as string"
@Param			account		body		models.AccountCreate	true	"Account"
@Router			/v1/accounts/{accountId} [patch]

func (Controller) UpdateAllocation

func (co Controller) UpdateAllocation(c *gin.Context)

UpdateAllocation updates allocation data

@Summary		Update allocation
@Description	Update an allocation. Only values to be updated need to be specified.
@Tags			Allocations
@Accept			json
@Produce		json
@Success		200	{object}	AllocationResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			allocationId	path		string					true	"ID formatted as string"
@Param			allocation		body		models.AllocationCreate	true	"Allocation"
@Router			/v1/allocations/{allocationId} [patch]

func (Controller) UpdateBudget

func (co Controller) UpdateBudget(c *gin.Context)

UpdateBudget updates data for a budget

@Summary		Update budget
@Description	Update an existing budget. Only values to be updated need to be specified.
@Tags			Budgets
@Accept			json
@Produce		json
@Success		200	{object}	BudgetResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			budgetId	path		string				true	"ID formatted as string"
@Param			budget		body		models.BudgetCreate	true	"Budget"
@Router			/v1/budgets/{budgetId} [patch]

func (Controller) UpdateCategory

func (co Controller) UpdateCategory(c *gin.Context)

UpdateCategory updates data for a specific category

@Summary		Update category
@Description	Update an existing category. Only values to be updated need to be specified.
@Tags			Categories
@Accept			json
@Produce		json
@Success		200	{object}	CategoryResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			categoryId	path		string					true	"ID formatted as string"
@Param			category	body		models.CategoryCreate	true	"Category"
@Router			/v1/categories/{categoryId} [patch]

func (Controller) UpdateEnvelope

func (co Controller) UpdateEnvelope(c *gin.Context)

UpdateEnvelope updates data for an envelope

@Summary		Update envelope
@Description	Updates an existing envelope. Only values to be updated need to be specified.
@Tags			Envelopes
@Accept			json
@Produce		json
@Success		200	{object}	EnvelopeResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string					true	"ID formatted as string"
@Param			envelope	body		models.EnvelopeCreate	true	"Envelope"
@Router			/v1/envelopes/{envelopeId} [patch]

func (Controller) UpdateMonthConfig

func (co Controller) UpdateMonthConfig(c *gin.Context)

UpdateMonthConfig updates configuration data for a specific envelope and month

@Summary		Update MonthConfig
@Description	Changes settings of an existing MonthConfig
@Tags			MonthConfigs
@Produce		json
@Success		201			{object}	MonthConfigResponse
@Failure		400			{object}	httperrors.HTTPError
@Failure		500			{object}	httperrors.HTTPError
@Param			envelopeId	path		string						true	"ID of the Envelope"
@Param			month		path		string						true	"The month in YYYY-MM format"
@Param			monthConfig	body		models.MonthConfigCreate	true	"MonthConfig"
@Router			/v1/month-configs/{envelopeId}/{month} [patch]

func (Controller) UpdateTransaction

func (co Controller) UpdateTransaction(c *gin.Context)

UpdateTransaction updates a specific transaction

@Summary		Update transaction
@Description	Updates an existing transaction. Only values to be updated need to be specified.
@Tags			Transactions
@Accept			json
@Produce		json
@Success		200	{object}	TransactionResponse
@Failure		400	{object}	httperrors.HTTPError
@Failure		404
@Failure		500				{object}	httperrors.HTTPError
@Param			transactionId	path		string						true	"ID formatted as string"
@Param			transaction		body		models.TransactionCreate	true	"Transaction"
@Router			/v1/transactions/{transactionId} [patch]

type EnvelopeListResponse

type EnvelopeListResponse struct {
	Data []models.Envelope `json:"data"`
}

type EnvelopeMonthResponse

type EnvelopeMonthResponse struct {
	Data models.EnvelopeMonth `json:"data"`
}

type EnvelopeQueryFilter

type EnvelopeQueryFilter struct {
	Name       string `form:"name" filterField:"false"`
	CategoryID string `form:"category"`
	Note       string `form:"note" filterField:"false"`
	Hidden     bool   `form:"hidden"`
	Search     string `form:"search" filterField:"false"`
}

func (EnvelopeQueryFilter) ToCreate

type EnvelopeResponse

type EnvelopeResponse struct {
	Data models.Envelope `json:"data"`
}

type ImportPreviewList added in v2.7.0

type ImportPreviewList struct {
	Data []importer.TransactionPreview `json:"data"`
}

type ImportPreviewQuery added in v2.7.0

type ImportPreviewQuery struct {
	AccountID string `form:"accountId" binding:"required"`
}

type ImportQuery

type ImportQuery struct {
	BudgetName string `form:"budgetName" binding:"required"`
}

type MonthConfigFilter

type MonthConfigFilter struct {
	EnvelopeID uuid.UUID
	Month      types.Month
}

type MonthConfigListResponse

type MonthConfigListResponse struct {
	Data []models.MonthConfig `json:"data"`
}

type MonthConfigQueryFilter

type MonthConfigQueryFilter struct {
	EnvelopeID string `form:"envelope"`
	Month      string `form:"month"`
}

func (MonthConfigQueryFilter) Parse

type MonthConfigResponse

type MonthConfigResponse struct {
	Data models.MonthConfig `json:"data"`
}

type MonthResponse

type MonthResponse struct {
	Data models.Month `json:"data"`
}

type QueryMonth

type QueryMonth struct {
	Month time.Time `form:"month" time_format:"2006-01" time_utc:"1" example:"2022-07"`
}

type TransactionListResponse

type TransactionListResponse struct {
	Data []models.Transaction `json:"data"`
}

type TransactionQueryFilter

type TransactionQueryFilter struct {
	Date                  time.Time       `form:"date" filterField:"false"`
	FromDate              time.Time       `form:"fromDate" filterField:"false"`
	UntilDate             time.Time       `form:"untilDate" filterField:"false"`
	Amount                decimal.Decimal `form:"amount"`
	AmountLessOrEqual     decimal.Decimal `form:"amountLessOrEqual" filterField:"false"` // Amount less than or equal to this
	AmountMoreOrEqual     decimal.Decimal `form:"amountMoreOrEqual" filterField:"false"` // Amount more than or equal to this
	Note                  string          `form:"note" filterField:"false"`
	BudgetID              string          `form:"budget"`
	SourceAccountID       string          `form:"source"`
	DestinationAccountID  string          `form:"destination"`
	EnvelopeID            string          `form:"envelope"`
	Reconciled            bool            `form:"reconciled"`            // DEPRECATED. Do not use, this field does not work as intended. See https://github.com/envelope-zero/backend/issues/528. Use reconciledSource and reconciledDestination instead.
	ReconciledSource      bool            `form:"reconciledSource"`      // Is the transaction reconciled in the source account?
	ReconciledDestination bool            `form:"reconciledDestination"` // Is the transaction reconciled in the destination account?
	AccountID             string          `form:"account" filterField:"false"`
}

func (TransactionQueryFilter) ToCreate

type TransactionResponse

type TransactionResponse struct {
	Data models.Transaction `json:"data"`
}

type URIMonth

type URIMonth struct {
	Month time.Time `uri:"month" time_format:"2006-01" time_utc:"1" example:"2013-11"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL