Documentation ¶
Index ¶
- Variables
- func AccessData[T Month | Accounts](jsonData []byte) *T
- func AccessDataFiles[T Month | Accounts](fileLocation string) *T
- func DefaultBudget() int
- func FormatCurrency(n float64) string
- func GetURL(apiToken, url string) ([]byte, error)
- func WithMonth(t string) option
- func WithToken(t string) option
- type Account
- type AccountData
- type Accounts
- type Assets
- type Balance
- type Budget
- type Liabilities
- type Month
- type MonthData
- type NetWorth
- type Summary
Constants ¶
This section is empty.
Variables ¶
var AccountMap = make(map[string]Account)
AccountMap allows an Account to be queried by name.
Functions ¶
func AccessData ¶
AccessData reads the JSON data and unmarshals it into the provided struct.
func AccessDataFiles ¶
AccessDataFiles reads the JSON data from the specified file and unmarshals it into the provided struct.
func DefaultBudget ¶
func DefaultBudget() int
DefaultBudget creates a new Budget with the default options and prints a summary for the Month.
func FormatCurrency ¶ added in v0.2.0
FormatCurrency adds a comma to a float64 value and prepends a dollar sign.
Types ¶
type AccountData ¶
type AccountData struct { Data struct { Accounts []struct { Id string `json:"id"` Name string `json:"name"` Type string `json:"type"` OnBudget bool `json:"on_budget"` Closed bool `json:"closed"` Note *string `json:"note"` Balance int `json:"balance"` ClearedBalance int `json:"cleared_balance"` UnclearedBalance int `json:"uncleared_balance"` TransferPayeeId string `json:"transfer_payee_id"` DirectImportLinked bool `json:"direct_import_linked"` DirectImportInError bool `json:"direct_import_in_error"` LastReconciledAt *time.Time `json:"last_reconciled_at"` DebtOriginalBalance *int `json:"debt_original_balance"` DebtInterestRates struct { Field1 int `json:"2021-10-01,omitempty"` Field2 int `json:"2022-06-01,omitempty"` Field3 int `json:"2022-11-01,omitempty"` Field4 int `json:"2023-09-01,omitempty"` } `json:"debt_interest_rates"` DebtMinimumPayments struct { Field1 int `json:"2021-10-01,omitempty"` Field2 int `json:"2022-06-01,omitempty"` Field3 int `json:"2022-11-01,omitempty"` Field4 int `json:"2023-09-01,omitempty"` } `json:"debt_minimum_payments"` DebtEscrowAmounts struct { Field1 int `json:"2022-08-01,omitempty"` Field2 int `json:"2021-10-01,omitempty"` Field3 int `json:"2022-11-01,omitempty"` Field4 int `json:"2023-09-01,omitempty"` } `json:"debt_escrow_amounts"` Deleted bool `json:"deleted"` } `json:"accounts"` ServerKnowledge int `json:"server_knowledge"` } `json:"data"` }
AccountData https://api.ynab.com/v1/#/Accounts/getAccounts
type Accounts ¶
type Accounts []Account
Accounts is a collection of Account structs.
func (*Accounts) Report ¶
func (a *Accounts) Report()
Report prints the account balance for each account.
func (*Accounts) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON data retrieved from YNAB's API into the Accounts struct.
type Balance ¶
type Balance float64
Balance represents the balance of an account. The String method formats the account balance with a dollar sign and comma(s).
func NewRat ¶
NewRat converts an `int` into an `int64` and is fed into `big.NewRat` to avoid floating point errors.
type Budget ¶
Budget contains the API token and month for the budget.
func (*Budget) GetAccounts ¶
GetAccounts retrieves account data from the YNAB API.
type Liabilities ¶ added in v0.2.0
type Liabilities struct { AutoLoans Balance CreditCards Balance StudentLoans Balance Mortgages Balance LinesOfCredit Balance PersonalLoans Balance MedicalDebt Balance Other Balance }
Liabilities contains balances for Accounts that have an outstanding balance
func (Liabilities) Total ¶ added in v0.2.0
func (l Liabilities) Total() Balance
Total calculates the balance across all Liabilities.
type Month ¶
type Month struct { Date string ReadyToAssign Balance Assigned Balance Underfunded Balance Income Balance Expenses Balance }
Month contains the overall financial picture for a specific month.
func (Month) Report ¶
func (m Month) Report()
Report prints the current state of finances for a Month.
func (*Month) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON data retrieved from YNAB's API into the Month struct.
type MonthData ¶
type MonthData struct { Data struct { Month struct { Month string `json:"month"` Note string `json:"note"` Income int `json:"income"` Budgeted int `json:"budgeted"` Activity int `json:"activity"` ToBeBudgeted int `json:"to_be_budgeted"` AgeOfMoney int `json:"age_of_money"` Deleted bool `json:"deleted"` Categories []struct { Id string `json:"id"` CategoryGroupId string `json:"category_group_id"` CategoryGroupName string `json:"category_group_name"` Name string `json:"name"` Hidden bool `json:"hidden"` OriginalCategoryGroupId interface{} `json:"original_category_group_id"` Note *string `json:"note"` Budgeted int `json:"budgeted"` Activity int `json:"activity"` Balance int `json:"balance"` GoalType *string `json:"goal_type"` GoalDay *int `json:"goal_day"` GoalCadence *int `json:"goal_cadence"` GoalCadenceFrequency *int `json:"goal_cadence_frequency"` GoalCreationMonth *string `json:"goal_creation_month"` GoalTarget int `json:"goal_target"` GoalTargetMonth *string `json:"goal_target_month"` GoalPercentageComplete *int `json:"goal_percentage_complete"` GoalMonthsToBudget *int `json:"goal_months_to_budget"` GoalUnderFunded *int `json:"goal_under_funded"` GoalOverallFunded *int `json:"goal_overall_funded"` GoalOverallLeft *int `json:"goal_overall_left"` Deleted bool `json:"deleted"` } `json:"categories"` } `json:"month"` } `json:"data"` }
type NetWorth ¶
type NetWorth struct { Assets Assets Liabilities Liabilities }
NetWorth contains the combined balances Assets and Liabilities.