feat: Vorschlaege buchen und Telefon-Dateien nur ablegen
Zwei Luecken geschlossen: Mail-Vorschlaege standen als "pending" im Eingang, aber es gab keinen Knopf zum Buchen – der Weg war hinten offen. Jetzt je Eintrag "Buchen" und ein "Alle buchen". Unklare bleiben liegen: Bei ihnen fehlt etwas oder die Erkennung war unsicher, die soll man ansehen statt im Stapel durchzuwinken. Der Auszug vom Telefon bucht nicht mehr sofort, sondern wird nur abgelegt. Am Telefon prueft man keine 500 Zeilen; die Datei wartet in der Import-Ansicht und laeuft dort durch die normale Vorschau mit Saldo-Abgleich, Zeilenfilter und Duplikatpruefung. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,6 +172,10 @@ export const api = {
|
||||
discardInboxItem: (id) => request(`/inbox/${id}`, { method: "DELETE" }),
|
||||
setInboxCategory: (id, categoryId) =>
|
||||
request(`/inbox/${id}/category/${categoryId}`, { method: "POST" }),
|
||||
bookInboxItem: (id) => request(`/inbox/${id}/book`, { method: "POST" }),
|
||||
bookAllInbox: () => request("/inbox/book-all", { method: "POST" }),
|
||||
listUploads: () => request("/imports/uploads"),
|
||||
deleteUpload: (id) => request(`/imports/uploads/${id}`, { method: "DELETE" }),
|
||||
|
||||
// Postfächer für den Mail-Abruf
|
||||
listMailSources: () => request("/mail/sources"),
|
||||
|
||||
+14
-2
@@ -368,7 +368,13 @@
|
||||
"removeAllUndone": "Rückgängig gemachte entfernen",
|
||||
"removeAllUndoneConfirm": "{{n}} rückgängig gemachte Einträge aus dem Verlauf entfernen? Die Buchungen sind bereits weg, es verschwindet nur der Eintrag.",
|
||||
"dupInbox": "schon erfasst",
|
||||
"dupInboxHint": "Diese Zahlung hast du unterwegs per Kurzbefehl erfasst – Betrag gleich, Datum in der Nähe. Sie ist bereits gebucht und wird deshalb übersprungen. Falls das doch zwei verschiedene Zahlungen sind, kannst du die Zeile von Hand anhaken."
|
||||
"dupInboxHint": "Diese Zahlung hast du unterwegs per Kurzbefehl erfasst – Betrag gleich, Datum in der Nähe. Sie ist bereits gebucht und wird deshalb übersprungen. Falls das doch zwei verschiedene Zahlungen sind, kannst du die Zeile von Hand anhaken.",
|
||||
"fromPhone": "Vom Telefon empfangen",
|
||||
"fromPhoneHint": "Diese Dateien hast du per Kurzbefehl geschickt. Gebucht ist noch nichts – übernimm eine, dann läuft sie durch die normale Vorschau mit Saldo-Abgleich.",
|
||||
"usePhoneFile": "Übernehmen",
|
||||
"phoneFileLoaded": "„{{name}}“ geladen – jetzt Format prüfen und Vorschau erzeugen.",
|
||||
"discardPhoneFile": "Datei verwerfen",
|
||||
"discardPhoneFileConfirm": "„{{name}}“ verwerfen? Die Datei wird gelöscht, gebucht war ohnehin nichts."
|
||||
},
|
||||
"password": {
|
||||
"show": "Passwort anzeigen",
|
||||
@@ -499,7 +505,13 @@
|
||||
"noText": "ohne Text",
|
||||
"viaShortcut": "per Kurzbefehl",
|
||||
"discard": "Verwerfen",
|
||||
"discardConfirm": "Diese Erfassung verwerfen? Die Buchung wird gelöscht. Der Eintrag bleibt als verworfen vermerkt, damit der Kontoauszug die Zahlung später trotzdem erkennt."
|
||||
"discardConfirm": "Diese Erfassung verwerfen? Die Buchung wird gelöscht. Der Eintrag bleibt als verworfen vermerkt, damit der Kontoauszug die Zahlung später trotzdem erkennt.",
|
||||
"book": "Buchen",
|
||||
"bookAll": "Alle buchen",
|
||||
"bookedN": "{{n}} gebucht.",
|
||||
"booked": "gebucht",
|
||||
"unclear": "unklar – bitte ansehen",
|
||||
"viaMail": "aus einer E-Mail"
|
||||
},
|
||||
"mailbox": {
|
||||
"title": "Postfach für Zahlungs-Mails",
|
||||
|
||||
+14
-2
@@ -368,7 +368,13 @@
|
||||
"removeAllUndone": "Remove undone entries",
|
||||
"removeAllUndoneConfirm": "Remove {{n}} undone entries from the history? The bookings are already gone; only the entry disappears.",
|
||||
"dupInbox": "already captured",
|
||||
"dupInboxHint": "You recorded this payment on the go via shortcut – same amount, nearby date. It is already booked, so it is skipped. If these really are two separate payments, tick the row by hand."
|
||||
"dupInboxHint": "You recorded this payment on the go via shortcut – same amount, nearby date. It is already booked, so it is skipped. If these really are two separate payments, tick the row by hand.",
|
||||
"fromPhone": "Received from your phone",
|
||||
"fromPhoneHint": "You sent these via shortcut. Nothing is booked yet – take one over and it runs through the normal preview with balance check.",
|
||||
"usePhoneFile": "Take over",
|
||||
"phoneFileLoaded": "“{{name}}” loaded – check the format and build the preview.",
|
||||
"discardPhoneFile": "Discard file",
|
||||
"discardPhoneFileConfirm": "Discard “{{name}}”? The file is deleted; nothing was booked anyway."
|
||||
},
|
||||
"password": {
|
||||
"show": "Show password",
|
||||
@@ -499,7 +505,13 @@
|
||||
"noText": "no text",
|
||||
"viaShortcut": "via shortcut",
|
||||
"discard": "Discard",
|
||||
"discardConfirm": "Discard this capture? The booking is deleted. The entry stays marked as discarded so the statement still recognises the payment later."
|
||||
"discardConfirm": "Discard this capture? The booking is deleted. The entry stays marked as discarded so the statement still recognises the payment later.",
|
||||
"book": "Book",
|
||||
"bookAll": "Book all",
|
||||
"bookedN": "{{n}} booked.",
|
||||
"booked": "booked",
|
||||
"unclear": "unclear – please review",
|
||||
"viaMail": "from an email"
|
||||
},
|
||||
"mailbox": {
|
||||
"title": "Mailbox for payment emails",
|
||||
|
||||
@@ -54,6 +54,25 @@ export default function Eingang() {
|
||||
}
|
||||
}
|
||||
|
||||
async function buchen(item) {
|
||||
try {
|
||||
await api.bookInboxItem(item.id);
|
||||
laden();
|
||||
} catch (e) {
|
||||
toast(e.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function alleBuchen() {
|
||||
try {
|
||||
const r = await api.bookAllInbox();
|
||||
toast(t("inbox.bookedN", { n: r.gebucht }));
|
||||
laden();
|
||||
} catch (e) {
|
||||
toast(e.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function verwerfen(item) {
|
||||
if (!(await confirm({
|
||||
title: t("inbox.discard"),
|
||||
@@ -76,6 +95,11 @@ export default function Eingang() {
|
||||
<div className="page-head">
|
||||
<h1>{t("inbox.title")}</h1>
|
||||
<p className="muted">{t("inbox.intro")}</p>
|
||||
{rows.some((r) => r.status === "pending" && r.account_id) && (
|
||||
<button className="btn primary" onClick={alleBuchen}>
|
||||
<Icon name="check" size={15} /> {t("inbox.bookAll")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
@@ -94,6 +118,9 @@ export default function Eingang() {
|
||||
<div className="named-sub">
|
||||
{formatDate(item.date)} · {konto?.name || "—"}
|
||||
{item.source === "shortcut" && ` · ${t("inbox.viaShortcut")}`}
|
||||
{item.source === "mail" && ` · ${t("inbox.viaMail")}`}
|
||||
{item.status === "unclear" && ` · ${t("inbox.unclear")}`}
|
||||
{item.status === "booked" && ` · ${t("inbox.booked")}`}
|
||||
</div>
|
||||
</div>
|
||||
<Money cents={Math.abs(item.amount_cents)} currency={item.currency}
|
||||
@@ -103,6 +130,11 @@ export default function Eingang() {
|
||||
value={item.category_id}
|
||||
onChange={(id) => zuordnen(item, id)}
|
||||
/>
|
||||
{item.status !== "booked" && item.account_id && (
|
||||
<button className="btn sm primary" onClick={() => buchen(item)}>
|
||||
<Icon name="check" size={14} /> {t("inbox.book")}
|
||||
</button>
|
||||
)}
|
||||
<button className="btn sm ghost" title={t("inbox.discard")}
|
||||
onClick={() => verwerfen(item)}>
|
||||
<Icon name="trash" size={15} />
|
||||
|
||||
@@ -58,6 +58,8 @@ export default function Import() {
|
||||
const [file, setFile] = useState(null);
|
||||
const [config, setConfig] = useState(defaultConfig());
|
||||
const [raw, setRaw] = useState(null);
|
||||
// Dateien, die per Kurzbefehl vom Telefon hereinkamen.
|
||||
const [uploads, setUploads] = useState([]);
|
||||
const [quelle, setQuelle] = useState(""); // "preset:i" | "tpl:id" | ""
|
||||
const [rows, setRows] = useState(null);
|
||||
const [recon, setRecon] = useState(null);
|
||||
@@ -69,6 +71,7 @@ export default function Import() {
|
||||
const accountById = useMemo(() => Object.fromEntries(accounts.map((a) => [a.id, a])), [accounts]);
|
||||
|
||||
async function loadStamm() {
|
||||
api.listUploads().then(setUploads).catch(() => {});
|
||||
try {
|
||||
const [a, g, tp, pr, b] = await Promise.all([
|
||||
api.listAccounts(), api.listCategories(), api.importTemplates(), api.importPresets(), api.importBatches(),
|
||||
@@ -243,6 +246,33 @@ export default function Import() {
|
||||
} catch (e) { toast(e.message, "error"); }
|
||||
}
|
||||
|
||||
// Die abgelieferte Datei so behandeln, als haette man sie hier ausgewaehlt –
|
||||
// damit gilt der ganze normale Weg samt Vorschau und Saldo-Abgleich.
|
||||
async function uploadUebernehmen(u) {
|
||||
try {
|
||||
const antwort = await fetch(`/api/imports/uploads/${u.id}/content`, { credentials: "include" });
|
||||
if (!antwort.ok) throw new Error(await antwort.text());
|
||||
const blob = await antwort.blob();
|
||||
setAccountId(String(u.account_id));
|
||||
setFile(new File([blob], u.filename, { type: "text/csv" }));
|
||||
setRaw(null);
|
||||
setRows(null);
|
||||
setMode("csv");
|
||||
toast(t("import.phoneFileLoaded", { name: u.filename }));
|
||||
} catch (e) {
|
||||
toast(e.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadVerwerfen(u) {
|
||||
if (!(await confirm({
|
||||
title: t("import.discardPhoneFile"),
|
||||
message: t("import.discardPhoneFileConfirm", { name: u.filename }),
|
||||
danger: true, confirmLabel: t("common.delete"),
|
||||
}))) return;
|
||||
try { await api.deleteUpload(u.id); loadStamm(); } catch (e) { toast(e.message, "error"); }
|
||||
}
|
||||
|
||||
async function undo(b) {
|
||||
if (!(await confirm({ title: t("import.undo"), message: t("import.undoConfirm", { file: b.filename }), danger: true, confirmLabel: t("import.undo") }))) return;
|
||||
try { await api.undoImportBatch(b.id); loadStamm(); } catch (e) { toast(e.message, "error"); }
|
||||
@@ -711,6 +741,33 @@ export default function Import() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{uploads.length > 0 && (
|
||||
<div className="card">
|
||||
<div className="card-head">
|
||||
<Icon name="smartphone" size={18} />
|
||||
<h2>{t("import.fromPhone")}</h2>
|
||||
</div>
|
||||
<p className="muted small">{t("import.fromPhoneHint")}</p>
|
||||
{uploads.map((u) => (
|
||||
<div className="mail-source" key={u.id}>
|
||||
<div><strong>{u.filename}</strong></div>
|
||||
<div className="muted small">
|
||||
{accountById[u.account_id]?.name || "—"} · {Math.round(u.size_bytes / 1024)} KB
|
||||
{u.created_at ? ` · ${formatDate(u.created_at.slice(0, 10))}` : ""}
|
||||
</div>
|
||||
<div className="mail-actions">
|
||||
<button className="btn sm primary" onClick={() => uploadUebernehmen(u)}>
|
||||
<Icon name="download" size={14} /> {t("import.usePhoneFile")}
|
||||
</button>
|
||||
<button className="btn sm danger" onClick={() => uploadVerwerfen(u)}>
|
||||
<Icon name="trash" size={14} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Verlauf */}
|
||||
{batches.length > 0 && (
|
||||
<div className="card">
|
||||
|
||||
Reference in New Issue
Block a user