feat(buchhaltung): budget types, erstattungen, recurring tab move, overview dividers, order completion guard
This commit is contained in:
@@ -52,9 +52,13 @@ export default function BuchhaltungKontoDetail() {
|
||||
if (isError || !data) return <DashboardLayout><Alert severity="error">Konto nicht gefunden.</Alert></DashboardLayout>;
|
||||
|
||||
const { konto, children, transaktionen } = data;
|
||||
const isEinfach = (konto.budget_typ || 'detailliert') === 'einfach';
|
||||
const totalEinnahmen = transaktionen
|
||||
.filter(t => t.typ === 'einnahme' && t.status === 'gebucht')
|
||||
.reduce((sum, t) => sum + Number(t.betrag), 0);
|
||||
const totalAusgaben = transaktionen
|
||||
.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht')
|
||||
.reduce((sum, t) => sum + Number(t.betrag), 0);
|
||||
|
||||
return (
|
||||
<DashboardLayout>
|
||||
@@ -69,29 +73,47 @@ export default function BuchhaltungKontoDetail() {
|
||||
</Box>
|
||||
|
||||
<Grid container spacing={2} sx={{ mb: 3 }}>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="GWG" budget={konto.budget_gwg} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'gwg').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="Anlagen" budget={konto.budget_anlagen} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'anlagen').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="Instandhaltung" budget={konto.budget_instandhaltung} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'instandhaltung').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="subtitle2" color="text.secondary">Einnahmen</Typography>
|
||||
<Typography variant="h6" color="success.main">{fmtEur(totalEinnahmen)}</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Grid>
|
||||
{isEinfach ? (
|
||||
<>
|
||||
<Grid item xs={12} sm={6} md={4}>
|
||||
<BudgetCard label="Budget Gesamt" budget={konto.budget_gesamt || 0} spent={totalAusgaben} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={4}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="subtitle2" color="text.secondary">Einnahmen</Typography>
|
||||
<Typography variant="h6" color="success.main">{fmtEur(totalEinnahmen)}</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Grid>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="GWG" budget={konto.budget_gwg} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'gwg').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="Anlagen" budget={konto.budget_anlagen} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'anlagen').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<BudgetCard label="Instandhaltung" budget={konto.budget_instandhaltung} spent={
|
||||
transaktionen.filter(t => t.typ === 'ausgabe' && t.status === 'gebucht' && t.ausgaben_typ === 'instandhaltung').reduce((s, t) => s + Number(t.betrag), 0)
|
||||
} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6} md={3}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="subtitle2" color="text.secondary">Einnahmen</Typography>
|
||||
<Typography variant="h6" color="success.main">{fmtEur(totalEinnahmen)}</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
|
||||
{children.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user