Compare commits

6 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
BOHA
90e797b8fa 1.4.9 2026-04-02 15:25:35 +02:00
BOHA
1f7362c8af fix: invoice PDF — tighter layout, more room for items
- Page margins reduced, content width 186mm
- Header/grid padding tightened
- Table headers 8.5pt normal case, cells 4px padding
- Footer flows naturally across pages (no forced page break)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:25:35 +02:00
BOHA
fe44a2b12d 1.4.8 2026-04-02 12:55:24 +02:00
BOHA
8a9239311d feat: invoice PDF — larger fonts, order number and date in dates column
- Base font 9pt→10pt, all sub-elements scaled proportionally
- Order number and date shown in dates column when invoice linked to order
- Uses customer_order_number with fallback to internal order_number

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:55:24 +02:00
5 changed files with 907 additions and 1122 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "app-ts", "name": "app-ts",
"version": "1.4.7", "version": "1.5.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "app-ts", "name": "app-ts",
"version": "1.4.7", "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.7", "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

@@ -284,6 +284,7 @@ export default async function invoicesPdfRoutes(
> | null; > | null;
let orderNumber = ""; let orderNumber = "";
let orderDate = "";
if (invoice.order_id) { if (invoice.order_id) {
const orderRow = await prisma.orders.findUnique({ const orderRow = await prisma.orders.findUnique({
where: { id: invoice.order_id }, where: { id: invoice.order_id },
@@ -299,6 +300,9 @@ export default async function invoicesPdfRoutes(
orderRow.customer_order_number || orderRow.order_number || "", orderRow.customer_order_number || orderRow.order_number || "",
), ),
); );
if (orderRow.created_at) {
orderDate = formatDate(orderRow.created_at);
}
} }
} }
@@ -491,14 +495,14 @@ export default async function invoicesPdfRoutes(
<style> <style>
@page { @page {
size: A4; size: A4;
margin: 12mm 15mm 15mm 15mm; margin: 8mm 12mm 10mm 12mm;
} }
* { margin: 0; padding: 0; box-sizing: border-box; } * { margin: 0; padding: 0; box-sizing: border-box; }
html, body { html, body {
font-family: "Segoe UI", Tahoma, Arial, sans-serif; font-family: "Segoe UI", Tahoma, Arial, sans-serif;
font-size: 9pt; font-size: 10pt;
color: #1a1a1a; color: #1a1a1a;
width: 180mm; width: 186mm;
} }
.invoice-page { .invoice-page {
@@ -509,8 +513,6 @@ export default async function invoicesPdfRoutes(
.invoice-content { flex: 1 1 auto; } .invoice-content { flex: 1 1 auto; }
.invoice-footer { .invoice-footer {
flex-shrink: 0; flex-shrink: 0;
page-break-inside: avoid;
break-inside: avoid;
} }
.accent { color: #de3a3a; } .accent { color: #de3a3a; }
@@ -520,8 +522,8 @@ export default async function invoicesPdfRoutes(
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 3mm; margin-bottom: 1mm;
padding-bottom: 3mm; padding-bottom: 1mm;
border-bottom: 2pt solid #de3a3a; border-bottom: 2pt solid #de3a3a;
} }
.invoice-header .left { .invoice-header .left {
@@ -553,10 +555,10 @@ export default async function invoicesPdfRoutes(
border: 0.5pt solid #d0d0d0; border: 0.5pt solid #d0d0d0;
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
margin-bottom: 3mm; margin-bottom: 1mm;
} }
.header-grid td { .header-grid td {
padding: 3mm 4mm; padding: 2mm 3mm;
border: 0.5pt solid #d0d0d0; border: 0.5pt solid #d0d0d0;
vertical-align: top; vertical-align: top;
width: 50%; width: 50%;
@@ -568,7 +570,7 @@ export default async function invoicesPdfRoutes(
background: #f5f5f5; background: #f5f5f5;
} }
.address-label { .address-label {
font-size: 7pt; font-size: 8pt;
font-weight: 700; font-weight: 700;
color: #de3a3a; color: #de3a3a;
text-transform: uppercase; text-transform: uppercase;
@@ -583,7 +585,7 @@ export default async function invoicesPdfRoutes(
margin-bottom: 1mm; margin-bottom: 1mm;
} }
.address-line { .address-line {
font-size: 8pt; font-size: 9pt;
color: #444; color: #444;
line-height: 1.5; line-height: 1.5;
} }
@@ -593,7 +595,7 @@ export default async function invoicesPdfRoutes(
.info-row { .info-row {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
font-size: 8pt; font-size: 9pt;
padding: 1mm 0; padding: 1mm 0;
border-bottom: 0.5pt solid #f0f0f0; border-bottom: 0.5pt solid #f0f0f0;
} }
@@ -614,7 +616,7 @@ export default async function invoicesPdfRoutes(
/* VS/KS blok */ /* VS/KS blok */
.vs-block { .vs-block {
font-size: 8pt; font-size: 9pt;
line-height: 1.4; line-height: 1.4;
padding-top: 2mm; padding-top: 2mm;
} }
@@ -623,7 +625,7 @@ export default async function invoicesPdfRoutes(
.billing-label { .billing-label {
font-weight: 700; font-weight: 700;
color: #1a1a1a; color: #1a1a1a;
font-size: 9pt; font-size: 10pt;
padding: 2mm 0 1mm 0; padding: 2mm 0 1mm 0;
border-bottom: 1.5pt solid #de3a3a; border-bottom: 1.5pt solid #de3a3a;
margin-bottom: 0; margin-bottom: 0;
@@ -635,24 +637,22 @@ export default async function invoicesPdfRoutes(
width: 100%; width: 100%;
table-layout: fixed; table-layout: fixed;
border-collapse: collapse; border-collapse: collapse;
font-size: 8pt; font-size: 9pt;
margin-bottom: 2mm; margin-bottom: 2mm;
} }
table.items thead th { table.items thead th {
font-size: 8pt; font-size: 8.5pt;
font-weight: 600; font-weight: 600;
color: #646464; color: #646464;
padding: 6px 8px; padding: 4px 4px;
text-align: left; text-align: left;
letter-spacing: 0.02em;
text-transform: uppercase;
border-bottom: 0.5pt solid #d0d0d0; border-bottom: 0.5pt solid #d0d0d0;
white-space: nowrap; white-space: nowrap;
} }
table.items thead th.center { text-align: center; } table.items thead th.center { text-align: center; }
table.items thead th.right { text-align: right; } table.items thead th.right { text-align: right; }
table.items tbody td { table.items tbody td {
padding: 5px 8px; padding: 4px 4px;
border-bottom: 0.5pt solid #e0e0e0; border-bottom: 0.5pt solid #e0e0e0;
vertical-align: middle; vertical-align: middle;
color: #1a1a1a; color: #1a1a1a;
@@ -663,10 +663,10 @@ export default async function invoicesPdfRoutes(
table.items tbody td.row-num { table.items tbody td.row-num {
text-align: center; text-align: center;
color: #969696; color: #969696;
font-size: 8pt; font-size: 9pt;
} }
table.items tbody td.desc { table.items tbody td.desc {
font-size: 8pt; font-size: 9pt;
font-weight: 600; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
} }
@@ -688,7 +688,7 @@ export default async function invoicesPdfRoutes(
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: baseline; align-items: baseline;
font-size: 8.5pt; font-size: 9.5pt;
color: #1a1a1a; color: #1a1a1a;
margin-bottom: 2mm; margin-bottom: 2mm;
} }
@@ -700,7 +700,7 @@ export default async function invoicesPdfRoutes(
align-items: baseline; align-items: baseline;
} }
.totals .grand .label { .totals .grand .label {
font-size: 9.5pt; font-size: 10.5pt;
font-weight: 400; font-weight: 400;
color: #1a1a1a; color: #1a1a1a;
align-self: center; align-self: center;
@@ -714,14 +714,14 @@ export default async function invoicesPdfRoutes(
} }
.totals .currency-note { .totals .currency-note {
text-align: right; text-align: right;
font-size: 7.5pt; font-size: 8pt;
color: #1a1a1a; color: #1a1a1a;
margin-top: 2mm; margin-top: 2mm;
} }
/* Vystavil */ /* Vystavil */
.issued-by { .issued-by {
font-size: 8pt; font-size: 9pt;
margin: 2mm 0; margin: 2mm 0;
line-height: 1.4; line-height: 1.4;
} }
@@ -729,7 +729,7 @@ export default async function invoicesPdfRoutes(
/* Upozorneni */ /* Upozorneni */
.notice { .notice {
font-size: 7pt; font-size: 8pt;
color: #1a1a1a; color: #1a1a1a;
margin: 2mm 0; margin: 2mm 0;
line-height: 1.3; line-height: 1.3;
@@ -751,11 +751,11 @@ export default async function invoicesPdfRoutes(
.recap-section table { .recap-section table {
border-collapse: collapse; border-collapse: collapse;
font-size: 8pt; font-size: 9pt;
flex: 1; flex: 1;
} }
.recap-section table th { .recap-section table th {
font-size: 7.5pt; font-size: 8pt;
font-weight: 600; font-weight: 600;
color: #555; color: #555;
padding: 3px 6px; padding: 3px 6px;
@@ -769,7 +769,7 @@ export default async function invoicesPdfRoutes(
} }
.recap-section table td.center { text-align: center; } .recap-section table td.center { text-align: center; }
.recap-section table td.cnb-rate { .recap-section table td.cnb-rate {
font-size: 7pt; font-size: 8pt;
color: #888; color: #888;
text-align: right; text-align: right;
border-bottom: none; border-bottom: none;
@@ -781,7 +781,7 @@ export default async function invoicesPdfRoutes(
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-top: 4mm; margin-top: 4mm;
font-size: 8pt; font-size: 9pt;
border-top: 0.5pt solid #aaa; border-top: 0.5pt solid #aaa;
padding-top: 2mm; padding-top: 2mm;
min-height: 15mm; min-height: 15mm;
@@ -794,13 +794,13 @@ export default async function invoicesPdfRoutes(
/* Poznamky */ /* Poznamky */
.invoice-notes { .invoice-notes {
margin-top: 4mm; margin-top: 4mm;
font-size: 9pt; font-size: 10pt;
line-height: 1.5; line-height: 1.5;
color: #1a1a1a; color: #1a1a1a;
} }
.invoice-notes-label { .invoice-notes-label {
font-weight: 600; font-weight: 600;
font-size: 8pt; font-size: 9pt;
text-transform: uppercase; text-transform: uppercase;
color: #555; color: #555;
margin-bottom: 1mm; margin-bottom: 1mm;
@@ -889,8 +889,7 @@ ${indentCSS}
<div class="info-row"><span class="lbl">${escapeHtml(t.account_no)}</span> <span class="val">${escapeHtml(invoice.bank_account)}</span></div> <div class="info-row"><span class="lbl">${escapeHtml(t.account_no)}</span> <span class="val">${escapeHtml(invoice.bank_account)}</span></div>
<div class="vs-block"> <div class="vs-block">
${escapeHtml(t.var_symbol)} <strong>${invoiceNumber}</strong> ${escapeHtml(t.var_symbol)} <strong>${invoiceNumber}</strong>
&nbsp;&nbsp;&nbsp; ${escapeHtml(t.const_symbol)} <strong>${escapeHtml(invoice.constant_symbol)}</strong><br> &nbsp;&nbsp;&nbsp; ${escapeHtml(t.const_symbol)} <strong>${escapeHtml(invoice.constant_symbol)}</strong>
${orderNumber ? `${escapeHtml(t.order_no)} ${orderNumber}` : ""}
</div> </div>
</td> </td>
<td> <td>
@@ -898,6 +897,8 @@ ${indentCSS}
<div class="info-row"><span class="lbl">${escapeHtml(t.due_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.due_date))}</span></div> <div class="info-row"><span class="lbl">${escapeHtml(t.due_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.due_date))}</span></div>
<div class="info-row"><span class="lbl">${escapeHtml(t.tax_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.tax_date))}</span></div> <div class="info-row"><span class="lbl">${escapeHtml(t.tax_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.tax_date))}</span></div>
<div class="info-row"><span class="lbl">${escapeHtml(t.payment_method)}</span> <span class="val">${escapeHtml(invoice.payment_method)}</span></div> <div class="info-row"><span class="lbl">${escapeHtml(t.payment_method)}</span> <span class="val">${escapeHtml(invoice.payment_method)}</span></div>
${orderNumber ? `<div class="info-row"><span class="lbl">${lang === "cs" ? "Objednávka č.:" : "Order no.:"}</span> <span class="val">${orderNumber}</span></div>` : ""}
${orderDate ? `<div class="info-row"><span class="lbl">${lang === "cs" ? "Objednávka ze dne:" : "Order date:"}</span> <span class="val">${escapeHtml(orderDate)}</span></div>` : ""}
</td> </td>
</tr> </tr>
</table> </table>
@@ -1007,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,