18 Commits

Author SHA1 Message Date
BOHA
cd25cd6ee4 1.4.7 2026-04-02 12:31:51 +02:00
BOHA
967fbba2a4 fix: invoice PDF footer — single line with space for signatures
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:31:51 +02:00
BOHA
41fe65c7fc 1.4.6 2026-04-02 12:01:52 +02:00
BOHA
09d345a312 fix: invoice PDF table — numbers 8pt, description column wider (36%)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:01:51 +02:00
BOHA
1a13d745f1 1.4.5 2026-04-02 11:56:06 +02:00
BOHA
ce184771a6 feat: invoice PDF redesign — professional table-based layout
- Header with red accent border, larger invoice number
- Address blocks in connected table grid with equal heights
- Customer and bank info highlighted with gray background
- Bank info uses same row layout as dates (aligned labels/values)
- Labels nowrap, values right-aligned
- Item font size 8pt, table header border gray
- Removed duplicate separator lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:56:05 +02:00
BOHA
7b6365f6b3 1.4.4 2026-04-02 11:28:13 +02:00
BOHA
44867c79f8 fix: PDF item names bold on Linux — font-weight 500→600
Linux lacks Segoe UI semibold, so weight 500 rendered as regular.
Changed to 600 which maps to bold on both Windows and Linux.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:28:12 +02:00
BOHA
09a9e8c2f0 1.4.3 2026-04-02 11:13:30 +02:00
BOHA
b26a6f40b9 fix: invoice PDF shows unit next to quantity (e.g. 193,50 / ks)
Adjusted column widths to prevent header overlap.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:13:29 +02:00
BOHA
40cb5a4d76 1.4.2 2026-04-02 11:05:42 +02:00
BOHA
ecd97ae5a3 fix: bulk attendance fill creates holiday records instead of skipping
Holidays now get leave_type: "holiday" with 8h so they count in fund calculation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:05:42 +02:00
BOHA
d14e97d7bd 1.4.1 2026-04-02 10:56:26 +02:00
BOHA
ef891f8e01 fix: bulk attendance fill — accept string user_ids, skip holidays
- Schema now accepts both string and number user_ids (frontend sends strings)
- Bulk fill now skips Czech public holidays in addition to weekends

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 10:56:25 +02:00
BOHA
96ba5d034f 1.4.0 2026-03-28 09:03:06 +01:00
BOHA
2402b7cbc8 fix: "Moje žádosti" page shows only current user's requests
Admins were seeing all requests on their own requests page.
Added mine=1 param to force user_id filter regardless of role.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 09:03:05 +01:00
BOHA
79b2fa5570 1.3.9 2026-03-28 08:56:14 +01:00
BOHA
35fa172d36 fix: trips admin shows only users with trips.record permission
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 08:56:14 +01:00
10 changed files with 186 additions and 175 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "app-ts", "name": "app-ts",
"version": "1.3.8", "version": "1.4.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "app-ts", "name": "app-ts",
"version": "1.3.8", "version": "1.4.7",
"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.3.8", "version": "1.4.7",
"description": "", "description": "",
"main": "dist/server.js", "main": "dist/server.js",
"scripts": { "scripts": {

View File

@@ -61,7 +61,7 @@ export default function LeaveRequests() {
const fetchRequests = useCallback(async () => { const fetchRequests = useCallback(async () => {
try { try {
const response = await apiFetch(`${API_BASE}/leave-requests`); const response = await apiFetch(`${API_BASE}/leave-requests?mine=1`);
if (response.status === 401) return; if (response.status === 401) return;
const result = await response.json(); const result = await response.json();
if (result.success) { if (result.success) {

View File

@@ -127,7 +127,7 @@ export default function TripsAdmin() {
try { try {
const [vRes, uRes, csRes] = await Promise.all([ const [vRes, uRes, csRes] = await Promise.all([
apiFetch(`${API_BASE}/vehicles`), apiFetch(`${API_BASE}/vehicles`),
apiFetch(`${API_BASE}/users?limit=1000`), apiFetch(`${API_BASE}/trips/users`),
apiFetch(`${API_BASE}/company-settings`), apiFetch(`${API_BASE}/company-settings`),
]); ]);
const vJson = await vRes.json(); const vJson = await vRes.json();
@@ -136,14 +136,7 @@ export default function TripsAdmin() {
if (vJson.success) setVehicles(vJson.data); if (vJson.success) setVehicles(vJson.data);
if (csJson.success) setCompanyName(csJson.data.company_name || ""); if (csJson.success) setCompanyName(csJson.data.company_name || "");
if (uJson.success) { if (uJson.success) {
setUsers( setUsers(uJson.data);
uJson.data.map(
(u: { id: number; first_name: string; last_name: string }) => ({
id: u.id,
name: `${u.first_name} ${u.last_name}`,
}),
),
);
} }
} catch { } catch {
// silently fail, filters will just be empty // silently fail, filters will just be empty

View File

@@ -427,7 +427,7 @@ export default async function invoicesPdfRoutes(
return `<tr> return `<tr>
<td class="row-num">${i + 1}</td> <td class="row-num">${i + 1}</td>
<td class="desc">${escapeHtml(item.description)}</td> <td class="desc">${escapeHtml(item.description)}</td>
<td class="center">${formatNum(qty, qtyDecimals)}</td> <td class="center">${formatNum(qty, qtyDecimals)}${item.unit ? ` / ${escapeHtml(item.unit)}` : ""}</td>
<td class="right">${formatNum(unitPrice)}</td> <td class="right">${formatNum(unitPrice)}</td>
<td class="right">${formatNum(lineSubtotal)}</td> <td class="right">${formatNum(lineSubtotal)}</td>
<td class="center">${applyVat ? Math.floor(vatRate) : 0}%</td> <td class="center">${applyVat ? Math.floor(vatRate) : 0}%</td>
@@ -515,76 +515,31 @@ export default async function invoicesPdfRoutes(
.accent { color: #de3a3a; } .accent { color: #de3a3a; }
/* Hlavicka */ /* ── Hlavicka ── */
.invoice-header { .invoice-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: flex-start; align-items: center;
margin-bottom: 0; margin-bottom: 3mm;
padding-bottom: 1mm; padding-bottom: 3mm;
border-bottom: 2pt solid #de3a3a;
} }
.invoice-header .left { .invoice-header .left {
display: flex; display: flex;
align-items: flex-start; align-items: center;
gap: 3mm; gap: 3mm;
} }
.logo-header { .logo-header { text-align: left; }
text-align: left;
}
.company-title { .company-title {
font-size: 12pt; font-size: 12pt;
font-weight: 700; font-weight: 700;
margin-top: 2mm;
} }
.invoice-title { .invoice-title {
font-size: 10pt; font-size: 13pt;
font-weight: 700; font-weight: 700;
color: #de3a3a; color: #de3a3a;
text-align: right; text-align: right;
margin-top: 2mm; letter-spacing: 0.03em;
}
/* Adresy - dva sloupce, stejna vyska */
.addresses-row {
display: flex;
gap: 8mm;
align-items: stretch;
margin-bottom: 0;
}
.addresses-row .address-block {
flex: 1;
padding-bottom: 2mm;
border-bottom: 0.5pt solid #e0e0e0;
}
/* Detaily pod adresami */
.details-row {
display: flex;
gap: 8mm;
margin-bottom: 3mm;
}
.details-row .col { flex: 1; }
/* Adresy - styl z nabidek */
.address-block {
margin-bottom: 0;
}
.address-label {
font-size: 8pt;
font-weight: 600;
color: #646464;
line-height: 1.5;
}
.address-name {
font-size: 9pt;
font-weight: 700;
color: #1a1a1a;
line-height: 1.5;
}
.address-line {
font-size: 8.5pt;
color: #1a1a1a;
line-height: 1.5;
} }
.logo { .logo {
@@ -593,46 +548,68 @@ export default async function invoicesPdfRoutes(
object-fit: contain; object-fit: contain;
} }
/* Separator */ /* ── Adresy ── */
.header-separator { .header-grid {
border: none; border: 0.5pt solid #d0d0d0;
border-top: 0.5pt solid #e0e0e0; border-collapse: collapse;
margin: 2mm 0 3mm 0; width: 100%;
margin-bottom: 3mm;
} }
.header-grid td {
/* Banka */ padding: 3mm 4mm;
.bank-box { border: 0.5pt solid #d0d0d0;
font-size: 8pt; vertical-align: top;
line-height: 1.4; width: 50%;
padding-top: 2mm;
} }
.bank-box .lbl { .header-grid td.addr-customer {
font-weight: 600; background: #f5f5f5;
}
.header-grid td.details-bank {
background: #f5f5f5;
}
.address-label {
font-size: 7pt;
font-weight: 700;
color: #de3a3a;
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 1mm;
}
.address-name {
font-size: 10pt;
font-weight: 700;
color: #1a1a1a; color: #1a1a1a;
display: inline-block; line-height: 1.3;
min-width: 16mm; margin-bottom: 1mm;
}
.address-line {
font-size: 8pt;
color: #444;
line-height: 1.5;
} }
/* Datumy */ /* ── Detaily (banka + datumy) — inside header-grid ── */
.dates-box {
font-size: 8pt; .info-row {
line-height: 1.4;
padding-top: 2mm;
}
.dates-row {
display: flex; display: flex;
align-items: center; align-items: baseline;
margin-bottom: 0.5mm; font-size: 8pt;
padding: 1mm 0;
border-bottom: 0.5pt solid #f0f0f0;
} }
.dates-row .lbl { .info-row:last-child { border-bottom: none; }
flex: 1; .info-row .lbl {
color: #1a1a1a; color: #666;
font-weight: 400;
flex-shrink: 0;
white-space: nowrap;
margin-right: 3mm;
} }
.dates-row .val { .info-row .val {
font-weight: 600; font-weight: 600;
min-width: 22mm; color: #1a1a1a;
text-align: center; text-align: right;
padding: 0.5mm 2mm; margin-left: auto;
} }
/* VS/KS blok */ /* VS/KS blok */
@@ -642,32 +619,23 @@ export default async function invoicesPdfRoutes(
padding-top: 2mm; padding-top: 2mm;
} }
/* Konecny prijemce */ /* ── Polozky ── */
.recipient-box {
font-size: 8pt;
margin-top: 2mm;
padding-top: 2mm;
border-top: 0.5pt solid #e0e0e0;
}
.recipient-box .lbl {
font-weight: 600;
font-style: italic;
color: #646464;
}
/* Polozky tabulka - styl z nabidek */
.billing-label { .billing-label {
font-weight: 600; font-weight: 700;
color: #de3a3a; color: #1a1a1a;
font-size: 8.5pt; font-size: 9pt;
padding: 3px 5px; padding: 2mm 0 1mm 0;
border-bottom: 1.5pt solid #de3a3a;
margin-bottom: 0;
text-transform: uppercase;
letter-spacing: 0.03em;
} }
table.items { table.items {
width: 100%; width: 100%;
table-layout: fixed; table-layout: fixed;
border-collapse: collapse; border-collapse: collapse;
font-size: 9pt; font-size: 8pt;
margin-bottom: 2mm; margin-bottom: 2mm;
} }
table.items thead th { table.items thead th {
@@ -678,7 +646,7 @@ export default async function invoicesPdfRoutes(
text-align: left; text-align: left;
letter-spacing: 0.02em; letter-spacing: 0.02em;
text-transform: uppercase; text-transform: uppercase;
border-bottom: 1pt solid #1a1a1a; 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; }
@@ -698,8 +666,8 @@ export default async function invoicesPdfRoutes(
font-size: 8pt; font-size: 8pt;
} }
table.items tbody td.desc { table.items tbody td.desc {
font-size: 9.5pt; font-size: 8pt;
font-weight: 500; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
} }
table.items tbody td.total-cell { font-weight: 700; } table.items tbody td.total-cell { font-weight: 700; }
@@ -811,13 +779,14 @@ export default async function invoicesPdfRoutes(
/* Prevzal / razitko */ /* Prevzal / razitko */
.footer-row { .footer-row {
display: flex; display: flex;
justify-content: space-between;
margin-top: 4mm; margin-top: 4mm;
font-size: 8pt; font-size: 8pt;
}
.footer-row .col {
flex: 1;
border-top: 0.5pt solid #aaa; border-top: 0.5pt solid #aaa;
padding-top: 2mm; padding-top: 2mm;
min-height: 15mm;
}
.footer-row .col {
font-weight: 600; font-weight: 600;
color: #555; color: #555;
} }
@@ -898,59 +867,53 @@ ${indentCSS}
<div class="invoice-title">${escapeHtml(t.heading)} ${invoiceNumber}</div> <div class="invoice-title">${escapeHtml(t.heading)} ${invoiceNumber}</div>
</div> </div>
<hr class="header-separator" /> <!-- Dodavatel / Odberatel + Banka / Datumy -->
<table class="header-grid" cellspacing="0">
<!-- Dodavatel / Odberatel - stejna vyska --> <tr>
<div class="addresses-row"> <td>
<div class="address-block"> <div class="address-label">${escapeHtml(t.supplier)}</div>
<div class="address-label">${escapeHtml(t.supplier)}</div> <div class="address-name">${escapeHtml(supp.name)}</div>
<div class="address-name">${escapeHtml(supp.name)}</div> ${suppLinesHtml}
${suppLinesHtml} </td>
</div> <td class="addr-customer">
<div class="address-block"> <div class="address-label">${escapeHtml(t.customer)}</div>
<div class="address-label">${escapeHtml(t.customer)}</div> <div class="address-name">${escapeHtml(cust.name)}</div>
<div class="address-name">${escapeHtml(cust.name)}</div> ${custLinesHtml}
${custLinesHtml} </td>
</div> </tr>
</div> <tr>
<td class="details-bank">
<!-- Banka + VS / Datumy --> <div class="info-row"><span class="lbl">${escapeHtml(t.bank)}</span> <span class="val">${escapeHtml(invoice.bank_name)}</span></div>
<div class="details-row"> <div class="info-row"><span class="lbl">${escapeHtml(t.swift)}</span> <span class="val">${escapeHtml(invoice.bank_swift)}</span></div>
<div class="col"> <div class="info-row"><span class="lbl">${escapeHtml(t.iban)}</span> <span class="val">${escapeHtml(invoice.bank_iban)}</span></div>
<div class="bank-box"> <div class="info-row"><span class="lbl">${escapeHtml(t.account_no)}</span> <span class="val">${escapeHtml(invoice.bank_account)}</span></div>
<span class="lbl">${escapeHtml(t.bank)}</span> ${escapeHtml(invoice.bank_name)}<br> <div class="vs-block">
<span class="lbl">${escapeHtml(t.swift)}</span> ${escapeHtml(invoice.bank_swift)}<br> ${escapeHtml(t.var_symbol)} <strong>${invoiceNumber}</strong>
<span class="lbl">${escapeHtml(t.iban)}</span> ${escapeHtml(invoice.bank_iban)}<br> &nbsp;&nbsp;&nbsp; ${escapeHtml(t.const_symbol)} <strong>${escapeHtml(invoice.constant_symbol)}</strong><br>
<span class="lbl">${escapeHtml(t.account_no)}</span> ${escapeHtml(invoice.bank_account)} ${orderNumber ? `${escapeHtml(t.order_no)} ${orderNumber}` : ""}
</div> </div>
<div class="vs-block"> </td>
${escapeHtml(t.var_symbol)} <strong>${invoiceNumber}</strong> <td>
&nbsp;&nbsp;&nbsp; ${escapeHtml(t.const_symbol)} <strong>${escapeHtml(invoice.constant_symbol)}</strong><br> <div class="info-row"><span class="lbl">${escapeHtml(t.issue_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.issue_date))}</span></div>
${orderNumber ? `${escapeHtml(t.order_no)} ${orderNumber}` : ""} <div class="info-row"><span class="lbl">${escapeHtml(t.due_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.due_date))}</span></div>
</div> <div class="info-row"><span class="lbl">${escapeHtml(t.tax_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.tax_date))}</span></div>
</div> <div class="info-row"><span class="lbl">${escapeHtml(t.payment_method)}</span> <span class="val">${escapeHtml(invoice.payment_method)}</span></div>
<div class="col"> </td>
<div class="dates-box"> </tr>
<div class="dates-row"><span class="lbl">${escapeHtml(t.issue_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.issue_date))}</span></div> </table>
<div class="dates-row"><span class="lbl">${escapeHtml(t.due_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.due_date))}</span></div>
<div class="dates-row"><span class="lbl">${escapeHtml(t.tax_date)}</span> <span class="val">${escapeHtml(formatDate(invoice.tax_date))}</span></div>
<div class="dates-row"><span class="lbl">${escapeHtml(t.payment_method)}</span> <span class="val">${escapeHtml(invoice.payment_method)}</span></div>
</div>
</div>
</div>
<!-- Polozky --> <!-- Polozky -->
<div class="billing-label">${escapeHtml(invoice.billing_text || t.billing)}</div> <div class="billing-label">${escapeHtml(invoice.billing_text || t.billing)}</div>
<table class="items"> <table class="items">
<thead> <thead>
<tr> <tr>
<th class="center" style="width:5%">${escapeHtml(t.col_no)}</th> <th class="center" style="width:3%">${escapeHtml(t.col_no)}</th>
<th style="width:30%">${escapeHtml(t.col_desc)}</th> <th style="width:36%">${escapeHtml(t.col_desc)}</th>
<th class="center" style="width:9%">${escapeHtml(t.col_qty)}</th> <th class="center" style="width:10%">${escapeHtml(t.col_qty)}</th>
<th class="right" style="width:11%">${escapeHtml(t.col_unit_price)}</th> <th class="right" style="width:10%">${escapeHtml(t.col_unit_price)}</th>
<th class="right" style="width:11%">${escapeHtml(t.col_price)}</th> <th class="right" style="width:10%">${escapeHtml(t.col_price)}</th>
<th class="center" style="width:7%">${escapeHtml(t.col_vat_pct)}</th> <th class="center" style="width:5%">${escapeHtml(t.col_vat_pct)}</th>
<th class="right" style="width:11%">${escapeHtml(t.col_vat)}</th> <th class="right" style="width:10%">${escapeHtml(t.col_vat)}</th>
<th class="right" style="width:16%">${escapeHtml(t.col_total)}</th> <th class="right" style="width:16%">${escapeHtml(t.col_total)}</th>
</tr> </tr>
</thead> </thead>

View File

@@ -29,7 +29,7 @@ export default async function leaveRequestsRoutes(
const isAdmin = authData.permissions.includes("attendance.approve"); const isAdmin = authData.permissions.includes("attendance.approve");
const where: Record<string, unknown> = {}; const where: Record<string, unknown> = {};
if (!isAdmin) where.user_id = authData.userId; if (!isAdmin || query.mine === "1") where.user_id = authData.userId;
else if (query.user_id) where.user_id = Number(query.user_id); else if (query.user_id) where.user_id = Number(query.user_id);
if (query.status) where.status = String(query.status); if (query.status) where.status = String(query.status);

View File

@@ -517,7 +517,7 @@ ${indentCSS}
} }
table.items tbody td.desc { table.items tbody td.desc {
font-size: 10pt; font-size: 10pt;
font-weight: 500; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
} }
table.items tbody td.total-cell { table.items tbody td.total-cell {

View File

@@ -66,6 +66,45 @@ export default async function tripsRoutes(
}); });
}); });
// GET /api/admin/trips/users — users with trips.record permission
fastify.get(
"/users",
{ preHandler: requireAuth },
async (_request, reply) => {
const users = await prisma.users.findMany({
where: {
is_active: true,
roles: {
is: {
OR: [
{ name: "admin" },
{
role_permissions: {
some: { permissions: { name: "trips.record" } },
},
},
],
},
},
},
select: {
id: true,
first_name: true,
last_name: true,
username: true,
},
orderBy: { last_name: "asc" },
});
return success(
reply,
users.map((u) => ({
id: u.id,
name: `${u.first_name} ${u.last_name}`.trim() || u.username,
})),
);
},
);
// GET /api/admin/trips/print — print data for trip report // GET /api/admin/trips/print — print data for trip report
fastify.get( fastify.get(
"/print", "/print",

View File

@@ -39,7 +39,9 @@ export const AttendanceBalancesSchema = z.object({
export const AttendanceBulkSchema = z.object({ export const AttendanceBulkSchema = z.object({
month: z.string().regex(/^\d{4}-\d{2}$/, "Měsíc je povinný (formát YYYY-MM)"), month: z.string().regex(/^\d{4}-\d{2}$/, "Měsíc je povinný (formát YYYY-MM)"),
user_ids: z.array(z.number()).min(1, "Vyberte alespoň jednoho zaměstnance"), user_ids: z
.array(z.union([z.number(), z.string()]).transform((v) => Number(v)))
.min(1, "Vyberte alespoň jednoho zaměstnance"),
arrival_time: z.string().optional().default("08:00"), arrival_time: z.string().optional().default("08:00"),
departure_time: z.string().optional().default("16:30"), departure_time: z.string().optional().default("16:30"),
break_start_time: z.string().optional().default("12:00"), break_start_time: z.string().optional().default("12:00"),

View File

@@ -1,6 +1,6 @@
import { attendance_leave_type, Prisma } from "@prisma/client"; import { attendance_leave_type, Prisma } from "@prisma/client";
import prisma from "../config/database"; import prisma from "../config/database";
import { getBusinessDaysInMonth } from "../utils/czech-holidays"; import { getBusinessDaysInMonth, isHoliday } from "../utils/czech-holidays";
import { localDateStr } from "../utils/date"; import { localDateStr } from "../utils/date";
import { getSystemSettings } from "./system-settings"; import { getSystemSettings } from "./system-settings";
@@ -1094,6 +1094,20 @@ export async function bulkCreateAttendance(data: BulkAttendanceData) {
} }
const shiftDate = new Date(Date.UTC(yr, mo - 1, day, 12, 0, 0)); const shiftDate = new Date(Date.UTC(yr, mo - 1, day, 12, 0, 0));
if (isHoliday(dateStr)) {
await prisma.attendance.create({
data: {
user_id: userId,
shift_date: shiftDate,
leave_type: "holiday",
leave_hours: 8,
},
});
inserted++;
continue;
}
await prisma.attendance.create({ await prisma.attendance.create({
data: { data: {
user_id: userId, user_id: userId,