fix: offer name in client detail, retainer forecast, LTV with offers, offers-sold chart

- Client detail offers: show offer macro name ("Mantenimento") instead of tier letter
- Forecast: retainers project the monthly fee across every month from start_date
  (no longer capped by duration_months); una_tantum unchanged
- Clients list LTV: per project max(accepted_total, sum of assigned offers) so a
  retainer with unset quote still counts
- Dashboard: new "Offerte vendute" chart (count by offer + tier)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 14:14:13 +02:00
parent ae355c33a6
commit 9abe1fe4bb
5 changed files with 153 additions and 22 deletions
+1 -1
View File
@@ -142,7 +142,7 @@ export default async function ClientDetailPage({
<div key={offer.offer_id} className="flex items-center justify-between px-4 py-3">
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-2">
<p className="text-sm font-medium text-[#1a1a1a]">{offer.public_name}</p>
<p className="text-sm font-medium text-[#1a1a1a]">{offer.macro_name}</p>
{categoryLabel && (
<span className="inline-flex items-center rounded-full bg-[#1A463C]/10 px-2 py-0.5 text-[11px] font-semibold text-[#1A463C]">
{categoryLabel}
+20 -9
View File
@@ -8,9 +8,10 @@ import {
getTimeByClient,
getTotalTrackedHours,
} from "@/lib/analytics-queries";
import { getRevenueForecast12Months } from "@/lib/forecast-queries";
import { getRevenueForecast12Months, getOffersSoldBreakdown } from "@/lib/forecast-queries";
import { YearSelector, MonthlyChart } from "@/components/admin/YearSelector";
import { ForecastChart } from "@/components/admin/ForecastChart";
import { OffersSoldChart } from "@/components/admin/OffersSoldChart";
export const revalidate = 0;
@@ -77,14 +78,16 @@ export default async function AdminDashboard({
const { kpi } = await getDashboardStats();
const [data, monthly, availableYears, timeByClient, totalHours, forecast] = await Promise.all([
getAnalyticsByYear(year),
getMonthlyCollected(year),
getAvailableYears(),
getTimeByClient(year),
getTotalTrackedHours(year),
getRevenueForecast12Months(),
]);
const [data, monthly, availableYears, timeByClient, totalHours, forecast, offersSold] =
await Promise.all([
getAnalyticsByYear(year),
getMonthlyCollected(year),
getAvailableYears(),
getTimeByClient(year),
getTotalTrackedHours(year),
getRevenueForecast12Months(),
getOffersSoldBreakdown(),
]);
const collectedPct =
data.contracted > 0 ? Math.round((data.collected / data.contracted) * 100) : 0;
@@ -137,6 +140,14 @@ export default async function AdminDashboard({
</p>
</div>
{/* Offerte vendute */}
<div className="space-y-4">
<h3 className="text-sm font-bold text-[#71717a] uppercase tracking-wider">
Offerte vendute
</h3>
<OffersSoldChart data={offersSold} />
</div>
{/* Sezione economica */}
<div className="space-y-4">
<h3 className="text-sm font-bold text-[#71717a] uppercase tracking-wider">Fatturato</h3>