Files
online-backend/internal/dashboard/dto.go
GuwandykA 28509eb4ca
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
Add backups, currencies and dashboard APIs, and scope access by guard_name.
Web users may only CRUD their own records, operators stay in assigned branches, and admin/manager/superadmin keep full access.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 18:14:47 +05:00

79 lines
2.2 KiB
Go

package dashboard
import "time"
// StatMetricDTO is a single KPI card: a running total plus the percent
// change of new records this calendar month-to-date versus the same
// elapsed window last month. ChangePercent is nil when last month's
// window has zero records, since a percent change against zero is
// undefined.
type StatMetricDTO struct {
Count int64 `json:"count"`
ChangePercent *float64 `json:"changePercent"`
}
type StatsDTO struct {
LoanOrders StatMetricDTO `json:"loanOrders"`
ActiveCards StatMetricDTO `json:"activeCards"`
ActiveCustomers StatMetricDTO `json:"activeCustomers"`
OnlinePayments StatMetricDTO `json:"onlinePayments"`
}
type TrendPointDTO struct {
Month int `json:"month"`
Loans int64 `json:"loans"`
Cards int64 `json:"cards"`
}
type TrendDTO struct {
Year int `json:"year"`
Points []TrendPointDTO `json:"points"`
}
// LoanStatusShareDTO buckets loan_orders.status into one of five
// normalized states so the UI can render a stable donut chart regardless
// of the raw status text stored on the row.
type LoanStatusShareDTO struct {
Status string `json:"status"`
Count int64 `json:"count"`
Percent float64 `json:"percent"`
}
const (
LoanStatusSatisfied = "satisfied"
LoanStatusPending = "pending"
LoanStatusProcessing = "processing"
LoanStatusCancelled = "cancelled"
LoanStatusRegistered = "registered"
)
type WeeklyPointDTO struct {
Date string `json:"date"`
Weekday int `json:"weekday"`
Loans int64 `json:"loans"`
Cards int64 `json:"cards"`
}
type RecentActivityDTO struct {
Id int64 `json:"id"`
UniqueId *string `json:"uniqueId"`
CustomerName string `json:"customerName"`
Amount *string `json:"amount"`
Status *string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
}
type OverviewDTO struct {
Stats StatsDTO `json:"stats"`
Trend TrendDTO `json:"trend"`
LoanStatus []LoanStatusShareDTO `json:"loanStatus"`
WeeklyOrders []WeeklyPointDTO `json:"weeklyOrders"`
RecentActivity []RecentActivityDTO `json:"recentActivity"`
}
type OverviewFilter struct {
BranchIds []int64
Year int
RecentLimit int
}