Documentation ¶
Index ¶
- Variables
- func S3Upload(path string, file *bytes.Buffer) error
- type AnnualBudget
- type AnnualBudgetItem
- type AnnualBudgetItems
- type AnnualBudgets
- type AssetLiability
- type AssetsLiabilities
- type Budget
- type BudgetCategories
- type BudgetCategory
- type BudgetItem
- type BudgetItemExpense
- type BudgetItemExpenses
- type BudgetItems
- type Budgets
- type MonthlyStatistic
- type NetWorth
- type NetWorthItem
- type NetWorthItemGraph
- type NetWorthItems
- type NetWorths
- type PushNotification
- type Session
- type Sessions
- type User
- func (u *User) AvatarUrl() string
- func (u *User) EncryptPassword(password []byte)
- func (u *User) MarshalJSON() ([]byte, error)
- func (u *User) NullableFirstName() *string
- func (u *User) NullableLastName() *string
- func (u *User) SaveAvatar(file multipart.File) error
- func (u *User) SendPushNotification(title, body string) error
- func (u User) String() string
- func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) VerifyPassword(password string) bool
- type Users
Constants ¶
This section is empty.
Variables ¶
var CategorySortOrder = map[string]int{
"Charity": 0,
"Saving": 1,
"Housing": 2,
"Utilities": 3,
"Food": 4,
"Clothing": 5,
"Transportation": 6,
"Medical/Health": 7,
"Insurance": 8,
"Personal": 9,
"Recreation": 10,
"Debts": 11,
}
var DB *pop.Connection
DB is a connection to your database to be used throughout your application.
Functions ¶
Types ¶
type AnnualBudget ¶
type AnnualBudget struct { ID int `json:"id" db:"id"` UserID int `json:"userId" db:"user_id"` Year int `json:"year" db:"year"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` AnnualBudgetItems []AnnualBudgetItem `json:"annualBudgetItems" db:"-"` }
func (*AnnualBudget) FindOrCreate ¶
func (ab *AnnualBudget) FindOrCreate()
type AnnualBudgetItem ¶
type AnnualBudgetItem struct { ID int `json:"id" db:"id"` AnnualBudgetID int `json:"annualBudgetId" db:"annual_budget_id"` Name string `json:"name" db:"name"` Amount json.Number `json:"amount" db:"amount"` DueDate string `json:"dueDate" db:"due_date"` Interval int `json:"interval" db:"payment_intervals"` Paid bool `json:"paid" db:"paid"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
func (*AnnualBudgetItem) MarshalJSON ¶
func (a *AnnualBudgetItem) MarshalJSON() ([]byte, error)
func (*AnnualBudgetItem) Update ¶
func (item *AnnualBudgetItem) Update(params *AnnualBudgetItem) error
type AnnualBudgetItems ¶
type AnnualBudgetItems []AnnualBudgetItem
type AnnualBudgets ¶
type AnnualBudgets []AnnualBudget
type AssetLiability ¶
type AssetLiability struct { ID int `json:"id" db:"id"` UserID int `json:"userId" db:"user_id"` Name string `json:"name" db:"name"` IsAsset bool `json:"isAsset" db:"is_asset"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
AssetLiability is a db model
func (*AssetLiability) DestroyAllNetWorthItems ¶
func (al *AssetLiability) DestroyAllNetWorthItems(tx *pop.Connection, logger buffalo.Logger) error
DestroyAllNetWorthItems deletes all child records
func (AssetLiability) TableName ¶
func (al AssetLiability) TableName() string
TableName overrides the table name used by Pop.
type AssetsLiabilities ¶
type AssetsLiabilities []AssetLiability
AssetsLiabilities is a slice of AssetLiability
func (*AssetsLiabilities) Partition ¶
func (als *AssetsLiabilities) Partition() (AssetsLiabilities, AssetsLiabilities)
Partition Takes a slice of assets and liabilities and partition them based on type
func (AssetsLiabilities) TableName ¶
func (als AssetsLiabilities) TableName() string
TableName overrides the table name used by Pop.
type Budget ¶
type Budget struct { ID int `json:"id" db:"id"` UserID int `json:"-" db:"user_id"` Month int `json:"month" db:"month"` Year int `json:"year" db:"year"` Income json.Number `json:"income" db:"monthly_income"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` BudgetCategories []BudgetCategory `json:"" db:"-"` }
func (*Budget) CreateDefaultCategories ¶
func (*Budget) FindOrCreate ¶
func (*Budget) MonthlyView ¶
func (b *Budget) MonthlyView() (BudgetCategories, BudgetItems, BudgetItemExpenses)
type BudgetCategories ¶
type BudgetCategories []BudgetCategory
func (BudgetCategories) Len ¶
func (s BudgetCategories) Len() int
func (BudgetCategories) Less ¶
func (s BudgetCategories) Less(i, j int) bool
func (BudgetCategories) Swap ¶
func (s BudgetCategories) Swap(i, j int)
type BudgetCategory ¶
type BudgetCategory struct { ID int `json:"id" db:"id"` BudgetId int `json:"budgetId" db:"budget_id"` Name string `json:"name" db:"name"` Percentage string `json:"percentage" db:"percentage"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` BudgetItems []BudgetItem `json:"" db:"-"` }
func (*BudgetCategory) ImportPreviousItems ¶
func (budgetCategory *BudgetCategory) ImportPreviousItems() (string, BudgetItems)
type BudgetItem ¶
type BudgetItem struct { ID int `json:"id" db:"id"` BudgetCategoryId int `json:"budgetCategoryId" db:"budget_category_id"` Name string `json:"name" db:"name"` Amount json.Number `json:"amount" db:"amount_budgeted"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` BudgetItemExpenses []BudgetItemExpense `json:"" db:"-"` }
func (*BudgetItem) DestroyAllExpenses ¶
func (budgetItem *BudgetItem) DestroyAllExpenses(tx *pop.Connection, logger buffalo.Logger) error
func (*BudgetItem) DestroyAllExpensesSilently ¶
func (budgetItem *BudgetItem) DestroyAllExpensesSilently(tx *pop.Connection) error
func (*BudgetItem) Update ¶
func (budgetItem *BudgetItem) Update(params *BudgetItem) error
type BudgetItemExpense ¶
type BudgetItemExpense struct { ID int `json:"id" db:"id"` BudgetItemId int `json:"budgetItemId" db:"budget_item_id"` Name string `json:"name" db:"name"` Amount json.Number `json:"amount" db:"amount"` Date time.Time `json:"date" db:"date"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
func (*BudgetItemExpense) MarshalJSON ¶
func (e *BudgetItemExpense) MarshalJSON() ([]byte, error)
func (*BudgetItemExpense) UnmarshalJSON ¶
func (e *BudgetItemExpense) UnmarshalJSON(data []byte) error
func (*BudgetItemExpense) Update ¶
func (e *BudgetItemExpense) Update(params *BudgetItemExpense) error
type BudgetItemExpenses ¶
type BudgetItemExpenses []BudgetItemExpense
type BudgetItems ¶
type BudgetItems []BudgetItem
type MonthlyStatistic ¶
type MonthlyStatistic struct { ID string `json:"id" db:"id"` UserID int `json:"-" db:"user_id"` Month int `json:"month" db:"month"` Year int `json:"year" db:"year"` Name string `json:"name" db:"name"` AmountSpent string `json:"amountSpent" db:"amount_spent"` TotalSpent string `json:"totalSpent" db:"total_spent"` PercentSpent string `json:"percentSpent" db:"percent_spent"` }
MonthlyStatistic is a db model
func FindMonthlyStatistics ¶
func FindMonthlyStatistics(month, year, userID int) ([]MonthlyStatistic, error)
FindMonthlyStatistics loads stats for a calendar month
type NetWorth ¶
type NetWorth struct { ID int `json:"id" db:"id"` UserID int `json:"userId" db:"user_id"` Year int `json:"year" db:"year"` Month int `json:"month" db:"month"` Items NetWorthItems `json:"items" fk_id:"net_worth_id" has_many:"net_worth_items"` NetWorthItems NetWorthItems `json:"-" db:"-"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
NetWorth db model
func (*NetWorth) ImportPreviousItems ¶
func (nw *NetWorth) ImportPreviousItems() (string, NetWorthItems)
type NetWorthItem ¶
type NetWorthItem struct { ID int `json:"id" db:"id"` NetWorthID int `json:"netWorthId" db:"net_worth_id"` AssetLiabilityID int `json:"assetId" db:"asset_liability_id"` Asset AssetLiability `json:"-" db:"-"` Amount json.Number `json:"amount" db:"amount"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
NetWorthItem is a db model
type NetWorthItemGraph ¶
type NetWorthItemGraph struct { ID int `json:"id" db:"id"` NetWorthID int `json:"netWorthId" db:"net_worth_id"` AssetLiabilityID int `json:"assetLiabilityId" db:"asset_liability_id"` Amount json.Number `json:"amount" db:"amount"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
func FindNetWorthItemsByYear ¶
func FindNetWorthItemsByYear(year, userID int) []NetWorthItemGraph
FindNetWorthItemsByYear returns formatted data structure for API
type NetWorths ¶
type NetWorths []NetWorth
NetWorths db model
func (*NetWorths) FindOrCreateYearTemplates ¶
FindOrCreateYearTemplates finds or creates 12 months of net worths
type PushNotification ¶
type Session ¶
type Session struct { AuthenticationKey uuid.UUID `json:"authenticationKey" db:"authentication_key"` AuthenticationToken string `json:"authenticationToken" db:"authentication_token"` IpAddress string `json:"ipAddress" db:"ip"` UserID int `json:"userId" db:"user_id"` UserAgent string `json:"userAgent" db:"user_agent"` DeviceName nulls.String `json:"deviceName" db:"device_name"` PushNotificationToken nulls.String `json:"-" db:"push_notification_token"` ExpiredAt nulls.Time `json:"expiredAt" db:"expired_at"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` }
func (*Session) PrimaryKeyType ¶
func (*Session) UpdatePushNotificationToken ¶
UpdatePushNotificationToken updates the PN token if it is valid
type User ¶
type User struct { ID int `json:"-" db:"id"` Email string `json:"email" db:"email"` FirstName nulls.String `json:"firstName" db:"first_name"` LastName nulls.String `json:"lastName" db:"last_name"` Admin bool `json:"admin" db:"admin"` PasswordResetToken nulls.String `json:"-" db:"password_reset_token"` PasswordResetSentAt nulls.Time `json:"-" db:"password_reset_sent_at"` AvatarFileName nulls.String `json:"-" db:"avatar_file_name"` AvatarContentType nulls.String `json:"-" db:"avatar_content_type"` AvatarFileSize nulls.Int64 `json:"-" db:"avatar_file_size"` AvatarUpdatedAt nulls.Time `json:"-" db:"avatar_updated_at"` EncryptedPassword string `json:"-" db:"encrypted_password"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` CurrentSession *Session `json:"-" db:"-"` }
func (*User) EncryptPassword ¶
func (*User) MarshalJSON ¶
func (*User) NullableFirstName ¶
NullableFirstName returns JSON nulls if empty
func (*User) NullableLastName ¶
NullableLastName returns JSON nulls if empty
func (*User) SendPushNotification ¶
func (*User) Validate ¶
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
func (*User) ValidateCreate ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*User) ValidateUpdate ¶
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.