diff --git a/src/routes/(app)/companies/[companyId]/+page.svelte b/src/routes/(app)/companies/[companyId]/+page.svelte index 627abcf..3502b88 100644 --- a/src/routes/(app)/companies/[companyId]/+page.svelte +++ b/src/routes/(app)/companies/[companyId]/+page.svelte @@ -9,12 +9,15 @@ const spent = $derived(data.projects.reduce((s, p) => s + parseFloat(p.spent), 0)); const total = $derived(parseFloat(data.company.totalBudget)); const income = $derived(parseFloat(data.totalIncome ?? '0')); - const remaining = $derived(total - spent); - const remainingPct = $derived(total > 0 ? (remaining / total) * 100 : 0); + // Total already reflects approved expenses (they post negative txns to the ledger), + // so available cash IS the total. Spent stays informational. + const available = $derived(total); + const unallocated = $derived(total - allocated); + const allocatedPct = $derived(total > 0 ? (allocated / total) * 100 : 0); const net = $derived(income - spent); const netPositive = $derived(net >= 0); - const tone = $derived(remaining < 0 ? 'red' : remainingPct < 20 ? 'amber' : 'green'); + const tone = $derived(available < 0 ? 'red' : available < Math.abs(allocated) * 0.2 ? 'amber' : 'green'); const toneRing: Record = { green: 'border-green-300 dark:border-green-700', @@ -85,36 +88,20 @@ - +

- Remaining Budget + Available Cash

- {formatCurrency(remaining, currency)} + {formatCurrency(available, currency)}

-
-
-

- {remainingPct.toFixed(1)}% of total + Sum of account balances (base currency)

-
-

- Total Budget -

-

- {formatCurrency(total, currency)} -

-

From account balances

-
-

Allocated @@ -122,8 +109,23 @@

{formatCurrency(allocated, currency)}

+
+
+

- {total > 0 ? ((allocated / total) * 100).toFixed(1) : '0'}% of total + {allocatedPct.toFixed(1)}% of available +

+
+ +
+

+ Unallocated +

+

+ {formatCurrency(unallocated, currency)} +

+

+ Cash not assigned to a project