fix(buchhaltung): respect budget_typ in konten manage table and pod detail subaccounts view
This commit is contained in:
@@ -487,8 +487,8 @@ function buildTree(flat: KontoTreeNode[]): KontoTreeNode[] {
|
||||
function KontoRow({ konto, depth = 0, onNavigate }: { konto: KontoTreeNode; depth?: number; onNavigate: (id: number) => void }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const isEinfach = (konto.budget_typ || 'detailliert') === 'einfach';
|
||||
const totalBudget = isEinfach ? Number(konto.budget_gesamt || 0) : konto.budget_gwg + konto.budget_anlagen + konto.budget_instandhaltung;
|
||||
const totalSpent = konto.spent_gwg + konto.spent_anlagen + konto.spent_instandhaltung;
|
||||
const totalBudget = isEinfach ? Number(konto.budget_gesamt || 0) : Number(konto.budget_gwg || 0) + Number(konto.budget_anlagen || 0) + Number(konto.budget_instandhaltung || 0);
|
||||
const totalSpent = Number(konto.spent_gwg || 0) + Number(konto.spent_anlagen || 0) + Number(konto.spent_instandhaltung || 0);
|
||||
const utilization = totalBudget > 0 ? (totalSpent / totalBudget) * 100 : 0;
|
||||
|
||||
return (
|
||||
@@ -534,7 +534,10 @@ function KontoManageRow({ konto, depth = 0, onNavigate }: {
|
||||
onNavigate: (id: number) => void;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const totalBudget = Number(konto.budget_gwg) + Number(konto.budget_anlagen) + Number(konto.budget_instandhaltung);
|
||||
const isEinfach = (konto.budget_typ || 'detailliert') === 'einfach';
|
||||
const totalBudget = isEinfach
|
||||
? Number(konto.budget_gesamt || 0)
|
||||
: Number(konto.budget_gwg) + Number(konto.budget_anlagen) + Number(konto.budget_instandhaltung);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -542,9 +545,9 @@ function KontoManageRow({ konto, depth = 0, onNavigate }: {
|
||||
<TableCell sx={{ pl: 2 + depth * 3 }}>
|
||||
<Typography variant="body2">{konto.kontonummer} — {konto.bezeichnung}</Typography>
|
||||
</TableCell>
|
||||
<TableCell align="right">{fmtEur(konto.budget_gwg)}</TableCell>
|
||||
<TableCell align="right">{fmtEur(konto.budget_anlagen)}</TableCell>
|
||||
<TableCell align="right">{fmtEur(konto.budget_instandhaltung)}</TableCell>
|
||||
<TableCell align="right">{isEinfach ? '—' : fmtEur(konto.budget_gwg)}</TableCell>
|
||||
<TableCell align="right">{isEinfach ? '—' : fmtEur(konto.budget_anlagen)}</TableCell>
|
||||
<TableCell align="right">{isEinfach ? '—' : fmtEur(konto.budget_instandhaltung)}</TableCell>
|
||||
<TableCell align="right"><strong>{fmtEur(totalBudget)}</strong></TableCell>
|
||||
<TableCell sx={{ width: 40, px: 0.5 }}>
|
||||
{konto.children.length > 0 && (
|
||||
|
||||
@@ -124,14 +124,19 @@ export default function BuchhaltungKontoDetail() {
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Konto</TableCell>
|
||||
<TableCell align="right">Budget GWG</TableCell>
|
||||
<TableCell align="right">Budget Anlagen</TableCell>
|
||||
<TableCell align="right">Budget Instandh.</TableCell>
|
||||
{!isEinfach && <TableCell align="right">Budget GWG</TableCell>}
|
||||
{!isEinfach && <TableCell align="right">Budget Anlagen</TableCell>}
|
||||
{!isEinfach && <TableCell align="right">Budget Instandh.</TableCell>}
|
||||
<TableCell align="right">Budget Gesamt</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{children.map(child => (
|
||||
{children.map(child => {
|
||||
const childIsEinfach = (child.budget_typ || 'detailliert') === 'einfach';
|
||||
const childTotal = childIsEinfach
|
||||
? Number(child.budget_gesamt || 0)
|
||||
: Number(child.budget_gwg) + Number(child.budget_anlagen) + Number(child.budget_instandhaltung);
|
||||
return (
|
||||
<TableRow
|
||||
key={child.id}
|
||||
hover
|
||||
@@ -139,14 +144,13 @@ export default function BuchhaltungKontoDetail() {
|
||||
onClick={() => navigate(`/buchhaltung/konto/${child.id}`)}
|
||||
>
|
||||
<TableCell>{child.kontonummer} — {child.bezeichnung}</TableCell>
|
||||
<TableCell align="right">{fmtEur(Number(child.budget_gwg))}</TableCell>
|
||||
<TableCell align="right">{fmtEur(Number(child.budget_anlagen))}</TableCell>
|
||||
<TableCell align="right">{fmtEur(Number(child.budget_instandhaltung))}</TableCell>
|
||||
<TableCell align="right">
|
||||
{fmtEur(Number(child.budget_gwg) + Number(child.budget_anlagen) + Number(child.budget_instandhaltung))}
|
||||
</TableCell>
|
||||
{!isEinfach && <TableCell align="right">{childIsEinfach ? '—' : fmtEur(Number(child.budget_gwg))}</TableCell>}
|
||||
{!isEinfach && <TableCell align="right">{childIsEinfach ? '—' : fmtEur(Number(child.budget_anlagen))}</TableCell>}
|
||||
{!isEinfach && <TableCell align="right">{childIsEinfach ? '—' : fmtEur(Number(child.budget_instandhaltung))}</TableCell>}
|
||||
<TableCell align="right">{fmtEur(childTotal)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
Reference in New Issue
Block a user