feat: NAS storage for invoices/offers, code cleanup, date/time fixes

- NAS storage for created invoices (PDF via puppeteer), received invoices,
  and offers with auto-save on create/edit
- Deterministic file paths derived from DB fields (no file_path column needed)
- Separate NAS mount points: NAS_FINANCIALS_PATH, NAS_OFFERS_PATH
- Invoice language field (cs/en) stored per invoice, replaces lang modal
- Invoices list filtered by month/year matching KPI card selection
- Centralized date helpers (src/utils/date.ts) replacing all .toISOString()
  calls that returned UTC instead of local time
- Attendance project switching uses exact time (not rounded)
- Comment cleanup: removed ~100 unnecessary/Czech comments
- Removed as-any casts in orders and attendance
- Prisma migrations: add invoice language, drop received_invoices BLOB columns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-03-26 10:36:39 +01:00
parent 0317ba3168
commit baceb88347
60 changed files with 2475 additions and 563 deletions

View File

@@ -7,7 +7,10 @@ export const CreateBankAccountSchema = z.object({
iban: z.string().nullish(),
bic: z.string().nullish(),
currency: z.string().optional().default("CZK"),
is_default: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(false),
is_default: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(false),
position: z
.union([z.number(), z.string()])
.transform((v) => Number(v))
@@ -22,7 +25,9 @@ export const UpdateBankAccountSchema = z.object({
iban: z.string().nullish(),
bic: z.string().nullish(),
currency: z.string().optional(),
is_default: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
is_default: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
position: z
.union([z.number(), z.string()])
.transform((v) => Number(v))

View File

@@ -16,7 +16,9 @@ export const UpdateCompanySettingsSchema = z.object({
.union([z.number(), z.string()])
.transform((v) => Number(v))
.optional(),
require_2fa: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
require_2fa: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
custom_fields: z.array(z.any()).optional(),
supplier_field_order: z.array(z.any()).optional(),
});

View File

@@ -41,7 +41,10 @@ export const CreateInvoiceSchema = z.object({
.transform((v) => Number(v))
.optional()
.default(21.0),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
payment_method: z.string().nullish(),
constant_symbol: z.string().nullish(),
bank_name: z.string().nullish(),
@@ -53,6 +56,7 @@ export const CreateInvoiceSchema = z.object({
tax_date: z.string().nullish(),
issued_by: z.string().nullish(),
billing_text: z.string().nullish(),
language: z.string().optional().default("cs"),
notes: z.string().nullish(),
internal_notes: z.string().nullish(),
items: z.array(InvoiceItemSchema).optional(),
@@ -61,6 +65,7 @@ export const CreateInvoiceSchema = z.object({
export const UpdateInvoiceSchema = z.object({
status: z.string().optional(),
currency: z.string().optional(),
language: z.string().optional(),
payment_method: z.string().nullish(),
constant_symbol: z.string().nullish(),
bank_name: z.string().nullish(),
@@ -73,7 +78,9 @@ export const UpdateInvoiceSchema = z.object({
.union([z.number(), z.string()])
.transform((v) => Number(v))
.optional(),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
issue_date: z.union([z.string(), z.null()]).optional(),
due_date: z.union([z.string(), z.null()]).optional(),
tax_date: z.union([z.string(), z.null()]).optional(),

View File

@@ -14,7 +14,10 @@ const QuotationItemSchema = z.object({
.transform((v) => Number(v) || 0)
.optional()
.default(0),
is_included_in_total: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
is_included_in_total: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
position: z
.union([z.number(), z.string()])
.transform((v) => Number(v))
@@ -46,7 +49,10 @@ export const CreateQuotationSchema = z.object({
.transform((v) => Number(v))
.optional()
.default(21.0),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
exchange_rate: z
.union([z.number(), z.string()])
.transform((v) => Number(v))
@@ -73,7 +79,9 @@ export const UpdateQuotationSchema = z.object({
.union([z.number(), z.string()])
.transform((v) => Number(v))
.optional(),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
exchange_rate: z
.union([z.number(), z.string()])
.transform((v) => Number(v))

View File

@@ -14,7 +14,10 @@ const OrderItemSchema = z.object({
.transform((v) => Number(v) || 0)
.optional()
.default(0),
is_included_in_total: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
is_included_in_total: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
position: z
.union([z.number(), z.string()])
.transform((v) => Number(v))
@@ -55,7 +58,10 @@ export const CreateOrderSchema = z.object({
.transform((v) => Number(v))
.optional()
.default(21.0),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
exchange_rate: z
.union([z.number(), z.string()])
.transform((v) => Number(v))
@@ -82,7 +88,9 @@ export const UpdateOrderSchema = z.object({
.union([z.number(), z.string()])
.transform((v) => Number(v))
.optional(),
apply_vat: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
apply_vat: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
items: z.array(OrderItemSchema).optional(),
sections: z.array(OrderSectionSchema).optional(),
});

View File

@@ -11,7 +11,10 @@ export const CreateTripSchema = z.object({
end_km: z.union([z.number(), z.string()]).transform((v) => Number(v)),
route_from: z.string(),
route_to: z.string(),
is_business: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(false),
is_business: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(false),
notes: z.string().nullish(),
});
@@ -27,7 +30,9 @@ export const UpdateTripSchema = z.object({
.optional(),
route_from: z.string().optional(),
route_to: z.string().optional(),
is_business: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
is_business: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
notes: z.string().nullish(),
});

View File

@@ -7,7 +7,10 @@ export const CreateUserSchema = z.object({
first_name: z.string().min(1, "Jméno je povinné"),
last_name: z.string().min(1, "Příjmení je povinné"),
role_id: z.union([z.number(), z.string()]).transform((v) => Number(v)),
is_active: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
is_active: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
});
export const UpdateUserSchema = z.object({
@@ -17,7 +20,9 @@ export const UpdateUserSchema = z.object({
first_name: z.string().optional(),
last_name: z.string().optional(),
role_id: z.union([z.number(), z.string(), z.null()]).optional(),
is_active: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
is_active: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
});
export type CreateUserInput = z.infer<typeof CreateUserSchema>;

View File

@@ -15,7 +15,10 @@ export const CreateVehicleSchema = z.object({
.transform((v) => Number(v))
.optional()
.default(0),
is_active: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional().default(true),
is_active: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional()
.default(true),
});
export const UpdateVehicleSchema = z.object({
@@ -31,7 +34,9 @@ export const UpdateVehicleSchema = z.object({
.union([z.number(), z.string()])
.transform((v) => Number(v))
.optional(),
is_active: z.preprocess(v => v === true || v === 1 || v === "1", z.boolean()).optional(),
is_active: z
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
.optional(),
});
export type CreateVehicleInput = z.infer<typeof CreateVehicleSchema>;