feat: full invoice editing before payment, NAS cleanup on date change

- Invoice edit mode now uses the same form as create mode (all fields editable)
- Bank account pre-selected by matching IBAN/account number
- Invoice number read-only in edit mode
- Paid invoices remain read-only
- NAS: old PDF deleted when invoice date changes to different month
- Buttons: Zobrazit fakturu, Uložit, Smazat + status transitions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-04-02 15:47:46 +02:00
parent 90e797b8fa
commit 3106aaf314
3 changed files with 868 additions and 1084 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1008,6 +1008,7 @@ ${indentCSS}
? new Date(invoice.issue_date)
: new Date();
const saveMode = query.save === "1";
nasFinancialsManager.cleanIssuedInvoice(invoice.invoice_number!);
const pdfPromise = htmlToPdf(html)
.then((pdfBuffer) => {
nasFinancialsManager.saveIssuedInvoicePdf(

View File

@@ -30,6 +30,28 @@ class NasFinancialsManager {
// ── Created (issued) invoices ────────────────────────────────────
/** Remove any existing PDF for this invoice number across all year/month folders */
cleanIssuedInvoice(invoiceNumber: string): void {
if (!this.basePath) return;
const safeName = this.sanitizeFilename(invoiceNumber) + ".pdf";
const issuedDir = path.join(this.basePath, DIR_ISSUED);
try {
if (!fs.existsSync(issuedDir)) return;
for (const yearDir of fs.readdirSync(issuedDir)) {
const yearPath = path.join(issuedDir, yearDir);
if (!fs.statSync(yearPath).isDirectory()) continue;
for (const monthDir of fs.readdirSync(yearPath)) {
const filePath = path.join(yearPath, monthDir, safeName);
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
}
}
} catch {
// best effort
}
}
saveIssuedInvoicePdf(
invoiceNumber: string,
year: number,