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:
40
src/utils/date.ts
Normal file
40
src/utils/date.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Centralized date/time helpers.
|
||||
*
|
||||
* Prisma stores DateTime as UTC in MySQL DATETIME columns.
|
||||
* The Date.toJSON override in config/env.ts serializes using local getters,
|
||||
* so the frontend always receives local time. These helpers ensure
|
||||
* consistent local-time formatting whenever we need a string outside
|
||||
* of JSON serialization (e.g., building lookup keys, shift_date strings).
|
||||
*/
|
||||
|
||||
/** YYYY-MM-DD in local time */
|
||||
export function localDateStr(d: Date): string {
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
return `${y}-${m}-${day}`;
|
||||
}
|
||||
|
||||
/** YYYY-MM in local time */
|
||||
export function localMonthStr(d: Date): string {
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** HH:MM in local time */
|
||||
export function localTimeStr(d: Date): string {
|
||||
return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** DD.MM.YYYY in local time (Czech date format) */
|
||||
export function localDateCzStr(d: Date): string {
|
||||
return `${String(d.getDate()).padStart(2, "0")}.${String(d.getMonth() + 1).padStart(2, "0")}.${d.getFullYear()}`;
|
||||
}
|
||||
|
||||
/** DD.MM.YYYY HH:MM:SS in local time (Czech datetime format) */
|
||||
export function localDateTimeCzStr(d: Date): string {
|
||||
const h = String(d.getHours()).padStart(2, "0");
|
||||
const min = String(d.getMinutes()).padStart(2, "0");
|
||||
const s = String(d.getSeconds()).padStart(2, "0");
|
||||
return `${localDateCzStr(d)} ${h}:${min}:${s}`;
|
||||
}
|
||||
Reference in New Issue
Block a user