fix: invoice edit/list improvements

- Due date uses days selector in edit mode (same as create)
- Overdue invoices fully editable (same as issued)
- Overdue status reversed to issued when due date moved to future
- Invoice list: edit icon for issued/overdue, eye for paid
- Invoice list: PDF opens blob from NAS (removed lang modal)
- NAS cleanup: properly scans directories when cleaning old PDFs
- Fixed syntax error from leftover else block

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-04-02 20:01:43 +02:00
parent 44d389201c
commit e9f07a4a39
4 changed files with 91 additions and 133 deletions

View File

@@ -70,6 +70,11 @@ export async function markOverdueInvoices() {
where: { status: "issued", due_date: { lt: new Date() } },
data: { status: "overdue" },
});
// Reverse: if due_date was changed to future, set back to issued
await prisma.invoices.updateMany({
where: { status: "overdue", due_date: { gte: new Date() } },
data: { status: "issued" },
});
} catch (err) {
console.error("markOverdueInvoices failed:", err);
}
@@ -350,8 +355,8 @@ export async function updateInvoice(id: number, body: Record<string, any>) {
const data: Record<string, unknown> = { modified_at: new Date() };
// Only allow full editing in 'issued' state
const isDraft = currentStatus === "issued";
// Allow full editing in 'issued' and 'overdue' states
const isDraft = currentStatus === "issued" || currentStatus === "overdue";
if (isDraft) {
const strFields = [
"currency",