Compare commits

...

2 Commits

Author SHA1 Message Date
BOHA
44d389201c 1.5.0 2026-04-02 15:47:46 +02:00
BOHA
3106aaf314 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>
2026-04-02 15:47:46 +02:00
5 changed files with 871 additions and 1087 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "app-ts", "name": "app-ts",
"version": "1.4.9", "version": "1.5.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "app-ts", "name": "app-ts",
"version": "1.4.9", "version": "1.5.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@dnd-kit/core": "^6.3.1", "@dnd-kit/core": "^6.3.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "app-ts", "name": "app-ts",
"version": "1.4.9", "version": "1.5.0",
"description": "", "description": "",
"main": "dist/server.js", "main": "dist/server.js",
"scripts": { "scripts": {

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -30,6 +30,28 @@ class NasFinancialsManager {
// ── Created (issued) invoices ──────────────────────────────────── // ── 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( saveIssuedInvoicePdf(
invoiceNumber: string, invoiceNumber: string,
year: number, year: number,