controllers

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: AGPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryDBConnect added in v1.0.3

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
	Links AccountLinks `json:"links"`
}
type AccountLinks struct {
	Self         string `json:"self" example:"https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"`
	Transactions string `json:"transactions" example:"https://example.com/api/v1/transactions?account=af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"`
}

type AccountListResponse

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

type AccountQueryFilter added in v0.26.0

type AccountQueryFilter struct {
	Name     string `form:"name"`
	Note     string `form:"note"`
	BudgetID string `form:"budget"`
	OnBudget bool   `form:"onBudget"`
	External bool   `form:"external"`
}

func (AccountQueryFilter) ToCreate added in v0.26.0

type AccountResponse

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

type Allocation

type Allocation struct {
	models.Allocation
	Links AllocationLinks `json:"links"`
}
type AllocationLinks struct {
	Self string `json:"self" example:"https://example.com/api/v1/allocations/902cd93c-3724-4e46-8540-d014131282fc"`
}

type AllocationListResponse

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

type AllocationMode added in v0.41.0

type AllocationMode string

swagger:enum AllocationMode

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

type AllocationQueryFilter added in v0.36.0

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

func (AllocationQueryFilter) ToCreate added in v0.36.0

type AllocationResponse

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

type Budget

type Budget struct {
	models.Budget
	Links BudgetLinks `json:"links"`
}

type BudgetAllocationMode added in v0.41.0

type BudgetAllocationMode struct {
	Mode AllocationMode `json:"mode" example:"ALLOCATE_LAST_MONTH_SPEND"`
}
type BudgetLinks struct {
	Self             string `json:"self" example:"https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
	Accounts         string `json:"accounts" example:"https://example.com/api/v1/accounts?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
	Categories       string `json:"categories" example:"https://example.com/api/v1/categories?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
	Envelopes        string `json:"envelopes" example:"https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
	Transactions     string `json:"transactions" example:"https://example.com/api/v1/transactions?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
	Month            string `json:"month" example:"https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM"`                        // This uses 'YYYY-MM' for clients to replace with the actual year and month.
	GroupedMonth     string `json:"groupedMonth" example:"https://example.com/api/v1/months?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf&month=YYYY-MM"`     // This uses 'YYYY-MM' for clients to replace with the actual year and month.
	MonthAllocations string `json:"monthAllocations" example:"https://example.com/api/v1/months?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf&month=YYYY-MM"` // This uses 'YYYY-MM' for clients to replace with the actual year and month.
}

type BudgetListResponse

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

type BudgetMonthResponse

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

type BudgetQueryFilter added in v0.24.0

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

type BudgetResponse

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

type Category

type Category struct {
	models.Category
	Links     CategoryLinks `json:"links"`
	Envelopes []Envelope    `json:"envelopes"`
}
type CategoryLinks struct {
	Self      string `json:"self" example:"https://example.com/api/v1/categories/3b1ea324-d438-4419-882a-2fc91d71772f"`
	Envelopes string `json:"envelopes" example:"https://example.com/api/v1/envelopes?category=3b1ea324-d438-4419-882a-2fc91d71772f"`
}

type CategoryListResponse

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

type CategoryQueryFilter added in v0.36.0

type CategoryQueryFilter struct {
	Name     string `form:"name"`
	BudgetID string `form:"budget"`
	Note     string `form:"note"`
}

func (CategoryQueryFilter) ToCreate added in v0.36.0

type CategoryResponse

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

type Controller added in v1.1.0

type Controller struct {
	DB *gorm.DB
}

func (Controller) CreateAccount added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.9.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

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

func (Controller) DeleteAllocation added in v1.1.0

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

@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 added in v1.7.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.9.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 "Filter by on/off-budget" @Param external query bool false "Filter internal/external"

func (Controller) GetAllocation added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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"

func (Controller) GetCategories added in v1.1.0

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

@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"

func (Controller) GetCategory added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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"

func (Controller) GetMonth added in v1.1.0

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

@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 added in v1.9.0

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

@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 added in v1.9.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 time.Time false "Filter by date" @Param amount query decimal.Decimal false "Filter by amount" @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 "Filter by reconcilication state"

func (Controller) Import added in v1.6.0

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

@Summary Import @Description Imports data from other sources. Resources with the same name are ignored. Accepts CSV files in the following formats: YNAB Import (use [YNAP](https://ynap.leolabs.org/) to convert your bank statement), YNAB 4 Register export, and YNAB 4 Budget export. @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 for a YNAB 4 import. Ignored for all other imports" @Router /v1/import [post]

func (Controller) OptionsAccountDetail added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.6.0

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

@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 [options]

func (Controller) OptionsMonth added in v1.1.0

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

@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 added in v1.9.0

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

@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 added in v1.9.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

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

func (Controller) RegisterAllocationRoutes added in v1.1.0

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

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

func (Controller) RegisterBudgetRoutes added in v1.1.0

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

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

func (Controller) RegisterCategoryRoutes added in v1.1.0

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

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

func (Controller) RegisterEnvelopeRoutes added in v1.1.0

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

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

func (Controller) RegisterImportRoutes added in v1.6.0

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

RegisterImportRoutes registers the routes for imports.

func (Controller) RegisterMonthConfigRoutes added in v1.9.0

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

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

func (Controller) RegisterMonthRoutes added in v1.1.0

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

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

func (Controller) RegisterTransactionRoutes added in v1.1.0

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

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

func (Controller) SetAllocations added in v1.7.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.1.0

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

@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 added in v1.9.0

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

@Summary Create MonthConfig @Description Creates a new 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 added in v1.1.0

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

@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 Envelope

type Envelope struct {
	models.Envelope
	Links EnvelopeLinks `json:"links"`
}
type EnvelopeLinks struct {
	Self         string `json:"self" example:"https://example.com/api/v1/envelopes/45b6b5b9-f746-4ae9-b77b-7688b91f8166"`
	Allocations  string `json:"allocations" example:"https://example.com/api/v1/allocations?envelope=45b6b5b9-f746-4ae9-b77b-7688b91f8166"`
	Month        string `json:"month" example:"https://example.com/api/v1/envelopes/45b6b5b9-f746-4ae9-b77b-7688b91f8166/YYYY-MM"` // This will always end in 'YYYY-MM' for clients to use replace with actual numbers.
	Transactions string `json:"transactions" example:"https://example.com/api/v1/transactions?envelope=45b6b5b9-f746-4ae9-b77b-7688b91f8166"`
}

type EnvelopeListResponse

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

type EnvelopeMonthResponse

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

type EnvelopeQueryFilter added in v0.36.0

type EnvelopeQueryFilter struct {
	Name       string `form:"name"`
	CategoryID string `form:"category"`
	Note       string `form:"note"`
}

func (EnvelopeQueryFilter) ToCreate added in v0.36.0

type EnvelopeResponse

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

type ImportQuery added in v1.6.0

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

type MonthConfig added in v1.9.0

type MonthConfig struct {
	models.MonthConfig
	Links MonthConfigLinks `json:"links"`
}

type MonthConfigFilter added in v1.9.0

type MonthConfigFilter struct {
	EnvelopeID uuid.UUID
	Month      time.Time
}
type MonthConfigLinks struct {
	Self     string `json:"self" example:"https://example.com/api/v1/month-configs/61027ebb-ab75-4a49-9e23-a104ddd9ba6b/2017-10"`
	Envelope string `json:"envelope" example:"https://example.com/api/v1/envelopes/61027ebb-ab75-4a49-9e23-a104ddd9ba6b"`
}

type MonthConfigListResponse added in v1.9.0

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

type MonthConfigQueryFilter added in v1.9.0

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

func (MonthConfigQueryFilter) Parse added in v1.9.0

type MonthConfigResponse added in v1.9.0

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

type MonthResponse added in v1.1.0

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

type QueryMonth added in v1.9.0

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

type Transaction

type Transaction struct {
	models.Transaction
	Links TransactionLinks `json:"links"`
}
type TransactionLinks struct {
	Self string `json:"self" example:"https://example.com/api/v1/transactions/d430d7c3-d14c-4712-9336-ee56965a6673"`
}

type TransactionListResponse

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

type TransactionQueryFilter added in v0.36.0

type TransactionQueryFilter struct {
	Date                 time.Time       `form:"date"`
	Amount               decimal.Decimal `form:"amount"`
	Note                 string          `form:"note"`
	BudgetID             string          `form:"budget"`
	SourceAccountID      string          `form:"source"`
	DestinationAccountID string          `form:"destination"`
	EnvelopeID           string          `form:"envelope"`
	Reconciled           bool            `form:"reconciled"`
	AccountID            string          `form:"account" createField:"false"`
}

func (TransactionQueryFilter) ToCreate added in v0.36.0

type TransactionResponse

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

type URIMonth

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

Month is used to parse requests for data about a specific month.

Jump to

Keyboard shortcuts

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