mirror of
https://github.com/johndoe6345789/workforce-pay-bill-p.git
synced 2026-04-24 13:24:57 +00:00
Generated by Spark: Fix all reported errors.
This commit is contained in:
@@ -64,7 +64,7 @@ export function DashboardView({ metrics }: DashboardViewProps) {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-semibold font-mono">
|
||||
£{metrics.monthlyRevenue.toLocaleString()}
|
||||
£{(metrics.monthlyRevenue || 0).toLocaleString()}
|
||||
</div>
|
||||
<div className="flex items-center gap-1 mt-2 text-sm text-success">
|
||||
<ArrowUp size={16} weight="bold" />
|
||||
@@ -80,7 +80,7 @@ export function DashboardView({ metrics }: DashboardViewProps) {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-semibold font-mono">
|
||||
£{metrics.monthlyPayroll.toLocaleString()}
|
||||
£{(metrics.monthlyPayroll || 0).toLocaleString()}
|
||||
</div>
|
||||
<div className="flex items-center gap-1 mt-2 text-sm text-muted-foreground">
|
||||
<ArrowUp size={16} weight="bold" />
|
||||
@@ -96,7 +96,7 @@ export function DashboardView({ metrics }: DashboardViewProps) {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-3xl font-semibold font-mono">
|
||||
{metrics.grossMargin.toFixed(1)}%
|
||||
{(metrics.grossMargin || 0).toFixed(1)}%
|
||||
</div>
|
||||
<div className="flex items-center gap-1 mt-2 text-sm text-success">
|
||||
<ArrowUp size={16} weight="bold" />
|
||||
|
||||
@@ -53,7 +53,7 @@ export function PayrollView({ payrollRuns, timesheets, onPayrollComplete }: Payr
|
||||
)
|
||||
|
||||
const totalPendingValue = useMemo(() =>
|
||||
pendingTimesheets.reduce((sum, ts) => sum + ts.amount, 0),
|
||||
pendingTimesheets.reduce((sum, ts) => sum + (ts.amount || 0), 0),
|
||||
[pendingTimesheets]
|
||||
)
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ export function useAppData() {
|
||||
pendingApprovals: timesheets.filter(t => t.status === 'pending').length,
|
||||
overdueInvoices: invoices.filter(i => i.status === 'overdue').length,
|
||||
complianceAlerts: complianceDocs.filter(d => d.status === 'expiring' || d.status === 'expired').length,
|
||||
monthlyRevenue: invoices.reduce((sum, inv) => sum + inv.amount, 0),
|
||||
monthlyPayroll: payrollRuns.reduce((sum, pr) => sum + pr.totalAmount, 0),
|
||||
monthlyRevenue: invoices.reduce((sum, inv) => sum + (inv.amount || 0), 0),
|
||||
monthlyPayroll: payrollRuns.reduce((sum, pr) => sum + (pr.totalAmount || (pr as any).totalGross || 0), 0),
|
||||
grossMargin: 0,
|
||||
activeWorkers: workers.filter(w => w.status === 'active').length,
|
||||
pendingExpenses: expenses.filter(e => e.status === 'pending').length
|
||||
|
||||
@@ -45,14 +45,14 @@ export function useInvoicing() {
|
||||
? timesheets.map(ts => ({
|
||||
id: `LINE-${ts.id}`,
|
||||
description: `${ts.workerName} - Week ending ${new Date(ts.weekEnding).toLocaleDateString()}`,
|
||||
quantity: ts.hours,
|
||||
quantity: ts.hours || 0,
|
||||
rate: ts.rate || 0,
|
||||
amount: ts.amount,
|
||||
amount: ts.amount || 0,
|
||||
timesheetId: ts.id
|
||||
}))
|
||||
: []
|
||||
|
||||
const subtotal = timesheets.reduce((sum, ts) => sum + ts.amount, 0)
|
||||
const subtotal = timesheets.reduce((sum, ts) => sum + (ts.amount || 0), 0)
|
||||
const tax = applyTax ? subtotal * taxRate : 0
|
||||
const total = Number((subtotal + tax).toFixed(roundingPrecision))
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ export function useMarginAnalysis() {
|
||||
})
|
||||
: []
|
||||
|
||||
const revenue = periodInvoices.reduce((sum, inv) => sum + inv.amount, 0)
|
||||
const payrollCosts = periodTimesheets.reduce((sum, ts) => sum + ts.amount, 0)
|
||||
const expenseCosts = periodExpenses.reduce((sum, exp) => sum + exp.amount, 0)
|
||||
const revenue = periodInvoices.reduce((sum, inv) => sum + (inv.amount || 0), 0)
|
||||
const payrollCosts = periodTimesheets.reduce((sum, ts) => sum + (ts.amount || 0), 0)
|
||||
const expenseCosts = periodExpenses.reduce((sum, exp) => sum + (exp.amount || 0), 0)
|
||||
const totalCosts = payrollCosts + expenseCosts
|
||||
|
||||
const grossMargin = revenue - totalCosts
|
||||
@@ -147,7 +147,7 @@ export function useMarginAnalysis() {
|
||||
filteredInvoices.forEach(inv => {
|
||||
const existing = clientData.get(inv.clientName) || { revenue: 0, costs: 0, invoiceCount: 0 }
|
||||
clientData.set(inv.clientName, {
|
||||
revenue: existing.revenue + inv.amount,
|
||||
revenue: existing.revenue + (inv.amount || 0),
|
||||
costs: existing.costs,
|
||||
invoiceCount: existing.invoiceCount + 1
|
||||
})
|
||||
@@ -157,7 +157,7 @@ export function useMarginAnalysis() {
|
||||
const existing = clientData.get(ts.clientName) || { revenue: 0, costs: 0, invoiceCount: 0 }
|
||||
clientData.set(ts.clientName, {
|
||||
...existing,
|
||||
costs: existing.costs + ts.amount
|
||||
costs: existing.costs + (ts.amount || 0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -190,8 +190,8 @@ export function useMarginAnalysis() {
|
||||
const existing = workerData.get(ts.workerId) || { name: ts.workerName, hours: 0, revenue: 0 }
|
||||
workerData.set(ts.workerId, {
|
||||
name: existing.name,
|
||||
hours: existing.hours + ts.hours,
|
||||
revenue: existing.revenue + ts.amount
|
||||
hours: existing.hours + (ts.hours || 0),
|
||||
revenue: existing.revenue + (ts.amount || 0)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ export function usePayrollCalculations(config: Partial<PayrollConfig> = {}) {
|
||||
if (!acc[ts.workerId]) {
|
||||
acc[ts.workerId] = { grossPay: 0, workerName: ts.workerName }
|
||||
}
|
||||
acc[ts.workerId].grossPay += ts.amount
|
||||
acc[ts.workerId].grossPay += (ts.amount || 0)
|
||||
return acc
|
||||
}, {} as Record<string, { grossPay: number; workerName: string }>)
|
||||
|
||||
@@ -224,7 +224,7 @@ export function usePayrollCalculations(config: Partial<PayrollConfig> = {}) {
|
||||
return tsDate >= startDate && tsDate <= endDate
|
||||
})
|
||||
|
||||
const eligibleHours = workerTimesheets.reduce((sum, ts) => sum + ts.hours, 0)
|
||||
const eligibleHours = workerTimesheets.reduce((sum, ts) => sum + (ts.hours || 0), 0)
|
||||
const accruedHoliday = eligibleHours * holidayAccrualRate
|
||||
|
||||
const avgRate = workerTimesheets.length > 0
|
||||
|
||||
@@ -17,11 +17,23 @@ export function useSampleData() {
|
||||
if (hasInitialized) return
|
||||
|
||||
const initializeData = async () => {
|
||||
setTimesheets(appData.timesheets)
|
||||
const transformedTimesheets = appData.timesheets.map((ts: any) => ({
|
||||
...ts,
|
||||
hours: ts.totalHours || ts.hours || 0,
|
||||
amount: ts.total || ts.amount || 0
|
||||
}))
|
||||
|
||||
const transformedPayrollRuns = appData.payrollRuns.map((pr: any) => ({
|
||||
...pr,
|
||||
totalAmount: pr.totalGross || pr.totalAmount || 0,
|
||||
workersCount: pr.workerCount || pr.workersCount || 0
|
||||
}))
|
||||
|
||||
setTimesheets(transformedTimesheets)
|
||||
setInvoices(appData.invoices)
|
||||
setExpenses(appData.expenses)
|
||||
setComplianceDocs(appData.complianceDocs)
|
||||
setPayrollRuns(appData.payrollRuns)
|
||||
setPayrollRuns(transformedPayrollRuns)
|
||||
setWorkers(appData.workers)
|
||||
setRateCards(appData.rateCards)
|
||||
setClients(appData.clients)
|
||||
|
||||
Reference in New Issue
Block a user