Kontrolle: AB ohne Projekt im Rechnungsdialog für Anzahlung und Schluss wählbar
Der Server (rechnungsbau.js, baueAbRechnung) nimmt Anzahlung und Schlussrechnung ohne Projekt an. Unter 'Ohne Projekt' lädt der Dialog die ABs des Kunden ohne Projekt und ihre Rechnungen; frei bleibt die Vorgabe. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79f230ea2c
commit
4b184f744f
4 files changed
+88
-12
No files matched your search
@@ -122,11 +122,15 @@ function RechnungFormular({ onClose, onCreated, projektId, auftraegeAktiv, onSho
|
||||
const aktiv = konten.data ? Boolean(konten.data.auftraegeAktiv) : Boolean(auftraegeAktiv)
|
||||
|
||||
const detail = useProjektkontoDetail(projekt || '')
|
||||
const auftraege = detail.data?.auftraege || []
|
||||
const rechnungen = detail.data?.rechnungen || []
|
||||
// „Ohne Projekt“: gültige ABs ohne Projekt (der Server nimmt Anzahlung und Schlussrechnung dazu ohne Projekt an)
|
||||
const ohne = useOhneProjektAbs(kunde?.$id, projekt === '' && aktiv)
|
||||
const quelleDaten = projekt === '' ? ohne.data : detail.data
|
||||
const auftraege = quelleDaten?.auftraege || []
|
||||
const rechnungen = quelleDaten?.rechnungen || []
|
||||
const datenNeuLaden = projekt === '' ? ohne.reload : detail.reload
|
||||
|
||||
let optionen = []
|
||||
if (projekt === '') optionen = artOptionen({ projektId: '', auftraege: [], rechnungen: [], auftraegeAktiv: aktiv })
|
||||
if (projekt === '') optionen = artOptionen({ projektId: '', auftraege, rechnungen, auftraegeAktiv: aktiv })
|
||||
else if (projekt && detail.data) optionen = artOptionen({ projektId: projekt, auftraege, rechnungen, auftraegeAktiv: aktiv })
|
||||
|
||||
const stripeOk = detail.data?.stripeOk
|
||||
@@ -187,8 +191,8 @@ function RechnungFormular({ onClose, onCreated, projektId, auftraegeAktiv, onSho
|
||||
if (art === 'aufwand' && vorschauZeitraum !== null) dispatch({ type: 'zeitraum-vorschlag', text: vorschauZeitraum })
|
||||
}, [art, vorschauZeitraum])
|
||||
|
||||
const detailReloadRef = useRef(detail.reload)
|
||||
detailReloadRef.current = detail.reload
|
||||
const detailReloadRef = useRef(datenNeuLaden)
|
||||
detailReloadRef.current = datenNeuLaden
|
||||
useEffect(() => {
|
||||
// 409 der Vorschau: ein Arbeitsblatt ist inzwischen abgerechnet, das Projektkonto neu laden (einmal je Fehlerobjekt)
|
||||
if (vorschau?.status === 'fehler' && vorschau.httpStatus === 409 && neuGeladenRef.current !== vorschau) {
|
||||
@@ -205,7 +209,7 @@ function RechnungFormular({ onClose, onCreated, projektId, auftraegeAktiv, onSho
|
||||
if (aliveRef.current) setBusy(null)
|
||||
if (r.status === 'fehler') {
|
||||
if (aliveRef.current) setError(r.message)
|
||||
if (r.httpStatus === 409) detail.reload()
|
||||
if (r.httpStatus === 409) datenNeuLaden()
|
||||
} else if (r.status === 'festgeschrieben') {
|
||||
if (onCreated) onCreated(null, { senden: true, notice: r.notice, tone: 'warn', finalizedFilter: r.finalizedFilter })
|
||||
onClose()
|
||||
@@ -519,6 +523,20 @@ function RechnungFormular({ onClose, onCreated, projektId, auftraegeAktiv, onSho
|
||||
</>
|
||||
)}
|
||||
|
||||
{kunde && projekt === '' && ohne.loading && (
|
||||
<p className="msg muted" role="status">
|
||||
Aufträge werden geladen …
|
||||
</p>
|
||||
)}
|
||||
{kunde && projekt === '' && ohne.error && (
|
||||
<p className="msg warn" role="alert">
|
||||
Die Aufträge ohne Projekt konnten nicht geladen werden: {ohne.error}{' '}
|
||||
<button type="button" className="link" onClick={ohne.reload}>
|
||||
Erneut versuchen
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{kunde && projektBereit && projekt !== '' && (
|
||||
<>
|
||||
{detail.loading && !detail.data && (
|
||||
|
||||
Reference in new issue
Block a user