-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Location: backend/src/dashboard/providers/admin-analytics.provider.ts
Description
The first set of admin analytics covers financial performance — total revenue ever, revenue this month, revenue last month, a 6-month revenue trend, and invoice summary counts. All revenue figures come from Payment records with status = SUCCESS. The 6-month trend groups payments by calendar month using DATE_TRUNC.
This is the first method on the AdminAnalyticsProvider class. Subsequent issues (#72 and #73) add more methods to the same class — contributors should coordinate to avoid merge conflicts on this file.
Acceptance Criteria
- An
AdminAnalyticsProviderclass is created atbackend/src/dashboard/providers/admin-analytics.provider.tswith@InjectRepositorydecorators forPaymentandInvoice - A
getRevenueStats(from?: string, to?: string)method is implemented that returns:total— sum ofamountKoboacross allSUCCESSpayments (filtered by date range if provided)thisMonth— sum ofamountKoboforSUCCESSpayments wherepaidAtis in the current calendar monthlastMonth— sum ofamountKoboforSUCCESSpayments wherepaidAtis in the previous calendar monthtrend— array of{ month: string, totalKobo: number, totalNaira: number }for the last 6 calendar months, computed viaDATE_TRUNC('month', "paidAt")grouped query, ordered oldest to newest
- A
getInvoiceStats(from?: string, to?: string)method is implemented that returns:total— total count of all invoicespaid— count of invoices withstatus = PAIDpending— count of invoices withstatus = PENDINGtotalAmountKobo— sum ofamountKoboacross all invoicestotalAmountNaira—totalAmountKobo / 100
- Both methods accept optional
fromandtodate strings and apply them as filters on the relevant timestamp column when provided -
npx tsc --noEmitpasses with no errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers