"use client"; import { useState } from "react"; import { AlertTriangle, MapPin, MapPinned } from "lucide-react"; import { SiteIncomeView } from "@/components/SiteIncomeView"; import { SitesView } from "@/components/SitesView"; import type { SiteIncomeRow } from "@/lib/site-income"; import type { SiteSummary } from "@/lib/sites"; import { ZAR2 } from "@/lib/utils"; export function SitesOverview({ postedRows, billedRows, year, invoiceCount, monthIndex }: { postedRows: SiteIncomeRow[]; billedRows: SiteSummary[]; year: number; invoiceCount: number; monthIndex: number; }) { const [view, setView] = useState<"posted" | "billed">("posted"); const totalIncl = billedRows.reduce((sum, row) => sum + row.revenueIncl, 0); const totalExcl = billedRows.reduce((sum, row) => sum + row.revenueExcl, 0); const totalVat = billedRows.reduce((sum, row) => sum + row.vat, 0); const outstanding = billedRows.reduce((sum, row) => sum + row.unbookedCount, 0); const unpinned = billedRows.filter((row) => !row.pinned).length; return ( <>
Income attributed to the historical site on each invoice. External income and unallocated workbook income remain included.
} /> ) : ( <>What each site was billed per month from {invoiceCount} imported internal invoice{invoiceCount === 1 ? "" : "s"}.
Billing includes unbooked lines. External billing is outside this view.
{unpinned} of {billedRows.length} billed sites have no coordinates yet. Open a site to pin it.
{outstanding} line{outstanding === 1 ? "" : "s"} across these sites still have no machine or booked site. Open an invoice and assign one. Their billed amounts are included above.
No internal site billing recorded for {year}.
Sites appear here as internal invoices are imported.