Commit graph

66 commits

Author SHA1 Message Date
22d2507d52 fix: CSV reports now include claim currency column, claim totals, and total claim header 2026-07-14 14:33:45 +00:00
f1b029949e feat: PDF — total claim in header, wider merchant column (52mm) 2026-07-14 13:48:31 +00:00
e9460a6a7d fix: UpdateEvent now saves the event name, not just currency/rate 2026-07-14 12:21:40 +00:00
47fb82d109 fix: PDF reports show local+claim columns, totals in claim currency, remove grand total 2026-07-14 12:17:42 +00:00
a7f7dca41d fix: auto-calculate claim conversion when converted_amount is empty using event exchange rate 2026-07-14 11:47:26 +00:00
dfefd0208c fix: allow editing expenses in pre-migration events (empty month_id) 2026-07-14 11:24:24 +00:00
2f2fbf7630 fix: bump upload limit to 11MB, add .gitignore for build artifacts 2026-07-14 10:40:49 +00:00
949d4f277c fix: expense edit form — restore description value, use event's exchange rate 2026-07-14 10:26:28 +00:00
10e6b78940 feat: prepend user name to email report subjects (Claus Lohmar | Monthly Expense Report: ...) 2026-07-14 10:18:18 +00:00
64844baa83 fix: landscape PDF reports, full text, wider columns, include CSV+PDF in monthly ZIP 2026-07-14 10:06:31 +00:00
d65c0cd5fa feat: add month hierarchy, AI categories, and UI polish
- Restructure hierarchy: Month → Event → Expense (new months table, FK)
- Add MonthHandler with CRUD, monthly reports, dropdown create form
- Events now scoped under months with extended ownership chain
- AI extraction: 16 specific expense categories (Airfare, Meals, etc.)
- UI: category dropdown, button-consistent cards, centered mobile shell on desktop
- Dashboard/month views show claim totals per card
- Description field now mandatory, forms simplified
- Months sorted by name chronologically (latest first)
2026-07-14 09:29:26 +00:00
1c9ab4554a chore: always include both CSV and PDF in report ZIP instead of picking one format 2026-07-13 09:10:12 +00:00
517e95adc2 chore: rebrand ReceiptNext to NextExpense
- Rename Go module from github.com/cclohmar/ReceiptNext to NextExpense
- Update all import paths across 7 Go source files
- Update templates (titles, headings, branding)
- Update static files (manifest.json, sw.js, CSS)
- Update config (Makefile, install.sh, .env.example)
- Update README with new name and URLs
- Rename service file receiptnext.service -> nextexpense.service
- Update install paths, service names, log paths in install.sh
2026-06-21 18:39:48 +00:00
ce08681d81 chore: add profile editor — edit name/department via dashboard 2026-06-17 15:15:23 +00:00
24451b4f4f chore: put currency labels in proper CSV/PDF columns, not jammed into number cells 2026-06-17 13:05:18 +00:00
95762cd1ae chore: add base currency to CSV totals row too 2026-06-17 12:58:33 +00:00
b50699fc0e chore: add base currency label to PDF totals row 2026-06-17 12:57:41 +00:00
7c84c0858f chore: add totals row to PDF reports (local + converted currency) 2026-06-17 12:54:16 +00:00
a943c258bb chore: use request Host header for download links, not BASE_URL 2026-06-17 12:41:38 +00:00
5e66e849fc chore: add Close Event button + cleanup download tokens on reopen 2026-06-17 12:38:21 +00:00
5aa5523e8b chore: remove eager token cleanup on regenerate to prevent breaking emailed links 2026-06-17 12:34:22 +00:00
64d7494e33 chore: flat ZIP structure + event-name download filenames (/dl/{token}/{name}.zip) 2026-06-17 12:28:20 +00:00
4bc9fe52ae chore: add onboarding flow — capture user name/department, inject into CSV/PDF reports 2026-06-17 12:23:21 +00:00
8759b31e47 chore: log addToZip errors instead of silently dropping 2026-06-17 12:14:37 +00:00
be3aa7a036 chore: add postbox — generate report package, download or email link 2026-06-17 12:13:34 +00:00
cc56d1ac9f chore: resize receipt images on upload (max 2048px, JPEG 85%) to prevent SMTP attachment size rejections 2026-06-17 11:50:46 +00:00
44309dc189 chore: surface SMTP error message to user on filing failure 2026-06-17 11:45:45 +00:00
290f803996 chore: fix upload error visibility + install.sh update mode ownership bug 2026-06-17 11:27:33 +00:00
422aaa08ab chore: fix invisible filing errors — add HTMX error feedback and loading indicator 2026-06-17 11:08:01 +00:00
90c9df6cce fix: receipt images missing from filed event ZIP + feat: delete individual expenses
- Fix createReceiptZip path traversal guard blocking new ImagePath entries
  (UploadReceipt stores bare filenames, guard required 'storage/' prefix)
- Add DeleteExpense DB function, handler with ownership verification,
  DELETE /expenses/{id} route, and 🗑️ button in both expense templates
- Uses existing htmx.trigger confirm pattern for delete UX
2026-06-14 11:46:43 +00:00
ce2efd9be7 feat: persistent session + logout button + auto-redirect for authenticated users
- Logout button added to dashboard and event page headers
- Landing page checks for valid session cookie → auto-redirects to dashboard
- Session cookie persists 24h — closing and reopening browser keeps login
2026-06-05 11:24:05 +00:00
aa07ff3c50 feat: changing event exchange rate recalculates all expense converted amounts
- New RecalculateExpenses DB function updates all expenses for an event
- Expenses in different currency: converted = ROUND(amount * new_rate, 2)
- Expenses already in base currency: left unchanged
- Called from UpdateEvent handler after saving the new event rate
2026-06-03 08:24:46 +00:00
0d42a35cb8 refactor: remove duplicate edit from event page, add delete to edit form
- Event page now shows read-only metadata only (no edit/delete buttons)
- Edit works from dashboard (Edit button on event cards)
- Delete added to the edit form as a button alongside Save/Cancel
- htmx.trigger #delete div in the edit form fragment
2026-06-03 08:09:31 +00:00
c815e022b5 fix: OTP email subject 'Your ExpenseFlow OTP' → 'Your ReceiptNext OTP' 2026-06-03 08:01:00 +00:00
91534ed8bd fix: renderOTPForm in auth.go now uses cached single-field template
- Was using its own inline template with 6 digit_0..digit_5 fields
- Now calls getTemplate('otp_form') which has the single 6-digit input
- templates.go already had the correct single-field version
2026-06-03 07:57:56 +00:00
bb34528bf5 feat: single OTP field, event metadata on page, delete event
- OTP: 6 separate inputs → single 6-digit field with copy/paste support
- Event page: shows name, currency, exchange rate at top
- Edit toggle: unlock to edit fields, lock to save (via PUT)
- Delete button with confirmation popup
- DeleteEvent handler + DB function + route
- Backward compatible: collectOTP strips non-digits
2026-06-03 07:46:12 +00:00
0748af7c26 fix: EditEvent returns standalone form fragment, not full page
- Edit button now shows inline form with pre-filled values
- Cancel button hides the form again
- Computes sample claim from existing exchange rate
- No full-page rendering issues
2026-06-03 07:41:29 +00:00
5f5f2be75b feat: event editing — change exchange rate and currency
- Added Edit button on open event cards in dashboard
- EditEvent handler returns dashboard.html with pre-filled form
- UpdateEvent handler (PUT /events/{id}) saves new currency + rate
- UpdateEvent in db.go updates base_currency and exchange_rate
- Form auto-switches between create (POST) and edit (PUT) mode
- Reuses the same conversion sample pattern as event creation
2026-06-03 07:33:37 +00:00
4ea3d63b29 feat: OTP inputs auto-advance to next field when digit is typed
- oninput moves focus to next field when digit entered
- onkeydown Backspace moves to previous field when current is empty
- Last field (digit_5) only handles backspace
2026-06-02 00:00:57 +00:00
0b55ac1fac fix: normalize ImagePath for old database entries with storage/ prefix
- Added normalizeImagePath() helper that strips legacy storage/ prefix
- Applied in ViewEventExpenses, SaveExpense, UpdateExpense, EditExpense
- Prevents double storage/storage/ in image URLs for old expenses
2026-06-01 23:30:56 +00:00
8ff1a4175a feat: view receipt image from expense list
- Added 🖼️ button on each expense — opens full-screen lightbox
- Click anywhere on the overlay to close
- Images served via /storage/{filename} (auth-protected)
- Fixed ImagePath to store only filename (was storage/storage/...)
- Both expense_list.html fragment and event_expenses.html page updated
2026-06-01 23:16:35 +00:00
92f070440f refactor: implement best-practice recommendations from code review
MUST FIX:
- M1: Fixed ignored errors in AI providers (json.Marshal, http.NewRequest, json.Unmarshal)
- M2: Template cache — pre-parse all templates once at startup, reuse via getTemplate()
- M3: Fixed silent ParseFloat error fallbacks — now returns HTTP 400 on invalid amounts
- M4: Wrapped readFile errors with context (fmt.Errorf with %w)
- M5: Deleted stale llm.go placeholder file
- M6: Renamed utils.New() to utils.NewUUID() for clarity
- M7: Validate current_event_id cookie UUID format, prevent tampering

SHOULD FIX:
- S4: Added utils.Timestamp() helper to replace repeated time.Now().Format() calls
- S6: Added request ID middleware for concurrent request log tracing
- S7: Increased DB pool from 1 to 4 connections (HTMX concurrency)
- S8: Graceful shutdown via http.Server.Shutdown() on SIGINT/SIGTERM
- S9: Storage served behind auth middleware with path traversal check

COULD FIX:
- C2: renderOTPForm uses cached template (not per-request Must)
- C3: CSP pinned to unpkg.com/htmx.org@1.9.10
- C4: Added ReadHeaderTimeout, ReadTimeout, WriteTimeout, IdleTimeout
- C7: PDF generation auto-adds page breaks when content overflows

ADDITIONAL:
- Pass config to AI provider constructors (newGeminiProvider, newOpenAIProvider)
- Value receivers on geminiProvider/openaiProvider (empty structs)
- Added envOrDefault() helper in ai/receipt.go
- Session cleanup goroutine started in main.go
- Removed duplicate imports and unused html/template from handlers
2026-05-31 02:13:07 +00:00
a7381bde0c fix: final vulnerability sweep — storage auth, security headers, body limits, cookie flags
- Storage route moved behind auth middleware (was publicly accessible)
- Security headers: X-Content-Type-Options, X-Frame-Options, CSP, Referrer-Policy
- Request body size limit: 10 MB on all endpoints via MaxBytesReader
- Session cookie now sets Secure flag when BASE_URL uses HTTPS
- readFile() returns proper errors for dirs & oversized files (was nil,nil)
- Removed dead DEEPSEEK_API_KEY code from main.go
- Added fmt import to ai/receipt.go for error formatting
2026-05-31 02:01:12 +00:00
e831fcf617 fix: resolve 7 critical security findings from code review
CR-1: Path traversal in createReceiptZip — validate image_path is within storage/
CR-2: Missing authz on EditExpense/UpdateExpense — verify event ownership
CR-3: OTP timing side-channel — use crypto/subtle.ConstantTimeCompare
CR-4: Logout doesn't invalidate session — moved to AuthHandler with Sessions.Delete()
CR-5: OTP reuse race condition — mutex lock around validate+delete
CR-6: Live credentials on disk — removed .env from disk entirely
CR-7: No TLS — documented as expected behind-proxy deployment

Additional:
- Removed stale github.com/expenseflow import path from auth.go
- Made EnvironmentFile optional (prefix with -) so .env is not required
- App runs and starts clean without any .env file
2026-05-31 01:50:08 +00:00
9f52198647 fix: remove orphaned fallthrough after ollama removal 2026-05-30 17:40:40 +00:00
3327fd4fac feat: use glm-ocr as default Ollama model (specialized OCR, not a general LLM)
- glm-ocr is a 1.1B parameter model built specifically for OCR
- No reasoning overhead, no thinking field issues
- Faster inference than qwen3.5 on CPU
- Removed old qwen3.5 models (2B + 0.8B) to free ~4GB disk
- Updated install.sh, ollama.go, .env.example defaults
2026-05-30 17:17:06 +00:00
1eca4ae777 fix: qwen3.5 reasoning model outputs to thinking field not content
- ollamaResponse now reads both content and thinking fields
- Falls back to thinking if content is empty
- Install script adds model warm-up prompt to preload into memory
- Warm-up uses OLLAMA_HOST for correct user context
- Makes first real receipt analysis faster
2026-05-30 16:51:43 +00:00
b6c2c3f99d fix: Ollama timeout + image compression + selective sudo in install.sh 2026-05-30 15:41:47 +00:00
c0d3002e22 fix: remove hardcoded credentials from .env.example and source
- .env.example: placeholder values only
- gemini.go: error on missing API key instead of fallback
- main.go: dynamic from address from SMTP_USER
- Security: old credentials removed from active codebase
2026-05-30 15:08:01 +00:00
6de9c27f9c chore: switch from mattn/go-sqlite3 (CGO) to modernc.org/sqlite (pure Go)
- Zero CGO dependencies — builds with CGO_ENABLED=0
- Fully static binaries, no libc required
- Cross-compilation now works without any GCC cross-compilers
- ldd confirms: 'not a dynamic executable'
- Updates go.mod to Go 1.23 (required by modernc.org/sqlite)
2026-05-30 15:02:07 +00:00