From 80b9877686d1fd053e3f17ea64735ad15470f9ea Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Mon, 22 Jun 2026 17:06:12 +0100 Subject: [PATCH] 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 --- backend/handlers/today/today.go | 3 +++ backend/main.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/backend/handlers/today/today.go b/backend/handlers/today/today.go index de94f99..e3b4aca 100644 --- a/backend/handlers/today/today.go +++ b/backend/handlers/today/today.go @@ -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, diff --git a/backend/main.go b/backend/main.go index eaae95f..b31f937 100644 --- a/backend/main.go +++ b/backend/main.go @@ -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)