feat(api): add public business info route and TotalVATCollected to daily summary
Expose GET /business-info public endpoint for non-admin users. Add TotalVATCollected field to DailySummary and compute it in the aggregate query. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -50,6 +50,7 @@ type ServiceBookingCount struct {
|
||||
type DailySummary struct {
|
||||
TotalPaymentsToday float64 `json:"total_payments_today"`
|
||||
TotalTipsToday float64 `json:"total_tips_today"`
|
||||
TotalVATCollected float64 `json:"total_vat_collected,omitempty"`
|
||||
AmountDueToday float64 `json:"amount_due_today"`
|
||||
TotalDurationSpent int `json:"total_duration_spent"`
|
||||
CustomersServed int `json:"customers_served"`
|
||||
@@ -240,6 +241,7 @@ func computeAggregateSummary(r *http.Request, rangeStart, rangeEnd time.Time) *D
|
||||
SELECT
|
||||
COALESCE(SUM(p.amount) FILTER (WHERE p.status = 'completed' AND p.payment_type != 'tip'), 0) AS total_payments,
|
||||
COALESCE(SUM(p.amount) FILTER (WHERE p.status = 'completed' AND p.payment_type = 'tip'), 0) AS total_tips,
|
||||
COALESCE(SUM(p.vat_amount) FILTER (WHERE p.status = 'completed' AND p.payment_type != 'tip'), 0) AS total_vat,
|
||||
COALESCE(SUM(sub.amount_due) FILTER (WHERE sub.amount_due > 0), 0) AS amount_due,
|
||||
COALESCE(SUM(sub.duration_minutes), 0) AS total_duration,
|
||||
COUNT(DISTINCT b.id) FILTER (WHERE b.status NOT IN ('client_cancelled','we_cancelled','no_show','deposit_lapsed')) AS total_bookings,
|
||||
@@ -292,6 +294,7 @@ func computeAggregateSummary(r *http.Request, rangeStart, rangeEnd time.Time) *D
|
||||
_ = db.Conn.QueryRow(r.Context(), query, rangeStart, rangeEnd).Scan(
|
||||
&summary.TotalPaymentsToday,
|
||||
&summary.TotalTipsToday,
|
||||
&summary.TotalVATCollected,
|
||||
&summary.AmountDueToday,
|
||||
&summary.TotalDurationSpent,
|
||||
&summary.TotalBookings,
|
||||
|
||||
@@ -207,6 +207,9 @@ func main() {
|
||||
// Public contact info
|
||||
r.Get("/contact", user.GetContactInfoHandler)
|
||||
|
||||
// Public business info (limited, safe for non-admin users)
|
||||
r.Get("/business-info", admin.GetPublicBusinessInfo)
|
||||
|
||||
// Portfolio
|
||||
r.Route("/portfolio", func(r chi.Router) {
|
||||
r.Get("/images", portfolio.ListImages)
|
||||
|
||||
Reference in New Issue
Block a user