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:
@@ -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