fix: return 409 on duplicate kontonummer, show server error in snackbar, block save when sub-account suffix is empty

This commit is contained in:
Matthias Hochmeister
2026-03-30 11:03:53 +02:00
parent 2e736f7995
commit b7015ace84
3 changed files with 9 additions and 5 deletions

View File

@@ -268,7 +268,7 @@ function KontoDialog({
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Abbrechen</Button>
<Button variant="contained" onClick={() => onSave(form)}>Speichern</Button>
<Button variant="contained" onClick={() => onSave(form)} disabled={!form.bezeichnung || !form.kontonummer || (!!parentPrefix && kontonummerSuffix === '')}>Speichern</Button>
</DialogActions>
</Dialog>
);
@@ -992,7 +992,7 @@ function KontenTab({ haushaltsjahre, selectedJahrId, onJahrChange }: {
const createKontoMut = useMutation({
mutationFn: buchhaltungApi.createKonto,
onSuccess: () => { qc.invalidateQueries({ queryKey: ['buchhaltung-konten'] }); qc.invalidateQueries({ queryKey: ['kontenTree'] }); setKontoDialog({ open: false }); showSuccess('Konto erstellt'); },
onError: () => showError('Konto konnte nicht erstellt werden'),
onError: (err: any) => showError(err?.response?.data?.message || 'Konto konnte nicht erstellt werden'),
});
const updateKontoMut = useMutation({
mutationFn: ({ id, data }: { id: number; data: Partial<KontoFormData> }) => buchhaltungApi.updateKonto(id, data),