Agrarmonitor #2

Merged
bjoernpoettker merged 21 commits from Agrarmonitor into main 2026-05-25 11:02:59 +00:00

21 Commits

Author SHA1 Message Date
bjoernpoettker 8c5a81ed27 feat: implement ProcessVerarbeiteteDocuments (Upload-Check)
Build and Push Multi-Platform Images / build-and-push (push) Successful in 37s
Ported ProcessVerarbeiteteDocuments() from C# ProcessUploads.cs:
- Checks docs tagged "hochgeladen" → eingangsrechnungVorhanden()
- On match: livesearch, update title/type/created/correspondent/tags,
  set custom fields (externeBelegnummer, AgrarmonitorLink), addNote
- Tag "hochgeladen" → "fertig" swap; owner via Client.AgrarmonitorBetriebId
- 401/403 guard: clearClient() + break (same pattern as runPolling)
- Cron: AGRARMONITOR_UPLOAD_CHECK_CRON (default: 0 * * * * *)
- New settings: agrarmonitor_tag_hochgeladen, agrarmonitor_link_field
- Endpoint: POST /api/agrarmonitor/process-uploads
- Frontend: polling-config extended with tagHochgeladen + linkField select,
  new card "Dokumenten-Verarbeitung" with run button + result display

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 12:11:44 +02:00
bjoernpoettker a726f863f0 feat: set loginStrategy to 'redirect' in AgrarmonitorService
Build and Push Multi-Platform Images / build-and-push (push) Successful in 42s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 11:41:22 +02:00
bjoernpoettker 1133023c48 chore: update agrarmonitor-connector to commit cd89a30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 11:38:45 +02:00
bjoernpoettker 74cd2477f1 fix: two polling bugs — correspondent 400 and Agrarmonitor 403
Build and Push Multi-Platform Images / build-and-push (push) Successful in 30s
- 400 on Korrespondenten-Sync: getCorrespondentByName was called with
  searchName "(12345)" but checked exact match against full displayName
  "Firma (12345)". Always returned null → duplicate addCorrespondent on
  every run → Paperless 400. Fix: search by displayName directly.

- 403 on Livesearch: cached Agrarmonitor session expired. Fix: detect
  401/403 from connector, call clearClient() to invalidate cache, break
  out of the polling loop so next cron run re-authenticates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 16:25:47 +02:00
bjoernpoettker 1d11d8a3bd docs: add Agrarmonitor polling design plans
Build and Push Multi-Platform Images / build-and-push (push) Successful in 57s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:09:53 +02:00
bjoernpoettker e5271fc035 chore: add AGRARMONITOR_POLLING_CRON to docker-compose.yml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:05:20 +02:00
bjoernpoettker 6e1f995fe5 feat: extend SettingsPage with Agrarmonitor polling UI
Benutzer & Betriebe tab:
- Add Betriebe table with inline-editable AgrarmonitorBetriebId column

Agrarmonitor tab:
- Add Polling-Konfiguration card (tag-IDs, auto-loaded, save button)
- Add Polling ausführen card (run button, result display with error list)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:04:17 +02:00
bjoernpoettker 5ca202a59e feat: extend frontend API client for Agrarmonitor polling
- Add SettingClient interface and getClients/updateClient methods
- Add AgrarmonitorPollingConfig/Result interfaces
- Add getPollingConfig, updatePollingConfig, runPolling to agrarmonitorApi

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:02:02 +02:00
bjoernpoettker bed797db51 chore: add AGRARMONITOR_POLLING_CRON to .env.example
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:59:38 +02:00
bjoernpoettker 31d51dc19d feat: add GET/PUT clients endpoints to SettingsController
GET  /api/settings/clients       — list all Betriebe ordered by name
PUT  /api/settings/clients/:id   — update AgrarmonitorBetriebId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:59:26 +02:00
bjoernpoettker f3e3df3724 feat: add polling endpoints to AgrarmonitorController
GET  /api/agrarmonitor/polling-config
PUT  /api/agrarmonitor/polling-config
POST /api/agrarmonitor/run-polling

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:58:31 +02:00
bjoernpoettker f3df38610c refactor: replace AgrarmonitorWebService with connector methods
- Delete agrarmonitor-web.service.ts (HTML-scraping no longer needed)
- Rewrite AgrarmonitorPollingService to call connector directly
  (eingangsrechnungenLivesearch, setEingangsdatum, setLieferscheinNummer)
- Fix quality issues: concurrency guard, customer-sync try/catch,
  tag dedup via Set, parseInt NaN guard, page_size overflow warning
- Update AgrarmonitorModule to import TypeORM/PaperlessModule
- Remove node-html-parser dependency
- Update agrarmonitor-connector to latest Gitea commit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:56:23 +02:00
bjoernpoettker dd0fcfc2e5 feat: add AgrarmonitorPollingService with cron and runPolling 2026-05-23 14:45:47 +02:00
bjoernpoettker 79874bf54f fix: harden AgrarmonitorWebService error handling and date parsing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:41:01 +02:00
bjoernpoettker 433b3be7fa feat: add AgrarmonitorWebService with livesearch and date setters 2026-05-23 14:37:52 +02:00
bjoernpoettker f4131ebcf0 feat: add AgrarmonitorBetriebId to Client entity 2026-05-23 14:36:23 +02:00
bjoernpoettker 0d4302dc7e chore: add node-html-parser for Agrarmonitor HTML scraping 2026-05-23 14:35:47 +02:00
bjoernpoettker 9f39578471 fix: disable auto-retry and improve error messages in Agrarmonitor
Build and Push Multi-Platform Images / build-and-push (push) Successful in 43s
- Set autoRetry: false and timeoutMs: 10000 in AgrarmonitorService
- Show specific error message on timeout or backend error in frontend

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 22:10:36 +02:00
bjoernpoettker 6f6a4d83e5 Merge branch 'main' into Agrarmonitor
Build and Push Multi-Platform Images / build-and-push (push) Successful in 49s
2026-05-21 21:42:15 +02:00
bjoernpoettker 6e20dec723 Merge remote-tracking branch 'origin/main' into Agrarmonitor
Build and Push Multi-Platform Images / build-and-push (push) Failing after 23s
2026-05-21 21:38:55 +02:00
bjoernpoettker 1f5dcf4a17 feat: add Agrarmonitor integration module
- New backend module (agrarmonitor) with status check and device registration
- Frontend settings tab with connection status display and registration form
- Environment variables for base URLs, credentials, cookie path and encryption key
- Docker Compose env passthrough for agrarmonitor config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 21:30:46 +02:00