Documentation
¶
Overview ¶
Package dashboard provides the handler and related logic for rendering the dashboard page of the Moolah web UI.
templ: version: v0.3.1001
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BalancePartial ¶ added in v1.22.0
func BalancePartial(ctx context.Context, summary NetWorthSummary) templ.Component
Types ¶
type DashboardHandler ¶
type DashboardHandler struct {
// contains filtered or unexported fields
}
DashboardHandler is the HTTP handler for the dashboard page. It retrieves necessary data from services, computes summaries, and renders the dashboard template.
func NewDashboardHandler ¶
func NewDashboardHandler(accountService domain.AccountService, txService domain.TransactionService, categoryService domain.CategoryService) *DashboardHandler
NewDashboardHandler creates a new instance of DashboardHandler with the provided services.
func (*DashboardHandler) PartialBalance ¶ added in v1.22.0
func (h *DashboardHandler) PartialBalance(w http.ResponseWriter, r *http.Request)
PartialBalance handles requests for the net worth balance fragment. It is used for real-time updates via WebSocket OOB swaps or HTMX polling/triggers.
func (*DashboardHandler) Render ¶
func (h *DashboardHandler) Render(w http.ResponseWriter, r *http.Request)
Render handles HTTP requests to the dashboard page. It checks for tenant and user context, retrieves accounts and transactions, computes the net worth summary and cash flow data, and renders the dashboard template. If any errors occur during data retrieval or rendering, it logs the error and returns an appropriate HTTP response.
type DashboardProps ¶ added in v1.22.0
type DashboardProps struct {
DefaultCurrency string
AccountNames map[string]string
CategoryNames map[string]string
CashFlow []MonthlyFlow
RecentTxs []domain.Transaction
NetWorth NetWorthSummary
}
DashboardProps carries all data the template needs.
type MonthlyFlow ¶ added in v1.22.0
type MonthlyFlow struct {
Month time.Time // first day of month
IncomeCents int64
ExpenseCents int64
}
MonthlyFlow represents income and expense totals for a single calendar month.
func AggregateCashFlow ¶ added in v1.22.0
func AggregateCashFlow(txs []domain.Transaction, months int) []MonthlyFlow
AggregateCashFlow groups transactions by calendar month for the last N months.
type NetWorthSummary ¶ added in v1.22.0
type NetWorthSummary struct {
Currency string
TotalAssetsCents int64
TotalLiabilitiesCents int64
NetWorthCents int64
}
NetWorthSummary is the computed financial snapshot shown in the summary card.
func ComputeNetWorth ¶ added in v1.22.0
func ComputeNetWorth(accounts []domain.Account) NetWorthSummary
ComputeNetWorth derives the net-worth summary from a list of accounts.