3 Commits

Author SHA1 Message Date
Konrad du Plessis
3da039b74e Revert "feat(webhooks): outbound payslip webhook → Make.com / Zapier / n8n"
This reverts commit a52d841c00ad642942dd6de7bf54373ad9ea62d6.
2026-04-24 13:03:12 +02:00
Konrad du Plessis
a52d841c00 feat(webhooks): outbound payslip webhook → Make.com / Zapier / n8n
First integration: when a PayrollRecord is created, the app POSTs a
JSON summary to WEBHOOK_PAYSLIP_URL (env var) if set. Unset = feature
OFF; no network call, no behaviour change. Typical destination: a
Make.com / Zapier / n8n Catch-Hook URL that fans the event out to
Google Sheets / Airtable / Slack / etc. — no more Python required.

This is the highest-leverage starter integration per the research plan
at ~/.claude/plans/prancy-painting-brook.md (Section B). One webhook
sender unlocks 5000+ downstream destinations via visual workflow UIs,
and the pattern (post_save signal + env-var gate + try/except) becomes
the template for future event types.

Implementation:
  - core/signals.py (new) — post_save receiver on PayrollRecord;
    fires only on created=True; short-circuits when env var empty;
    swallows all network errors with a WARNING log so payslip save
    is never blocked
  - core/apps.py — ready() imports signals for dispatcher registration
  - config/settings.py — reads WEBHOOK_PAYSLIP_URL env var (default "")
  - requirements.txt — adds requests>=2.32.0 (de facto Python HTTP lib,
    no prior outbound-HTTP code in the codebase)
  - CLAUDE.md — documents the env var + the non-fatal failure contract
    + points at PayslipWebhookTests for the behavioural spec

Payload shape: event, payslip_id, worker_id, worker_name, amount_paid
(as string for Decimal safety), payslip_date (ISO), work_log_count,
adjustment_count, admin_url. No unbounded text fields; no secrets.

Tests (4 new, PayslipWebhookTests):
  - fires when configured with right payload
  - no-op when env var unset
  - swallows ConnectionError without breaking PayrollRecord.save()
  - does NOT refire on subsequent .save() of an existing record
Full suite: 73/73.

Risks + rollback: trivial. Revert the commit, no data impact. Make.com
handles its own retries; if the webhook is down we just miss events
until it comes back.

Out of scope for v1 (deferred): other event types (adjustment.created,
loan.issued), HMAC signing, in-app retry queue, inbound webhooks, AI
integrations, public read-only API. All are on the roadmap in the plan
doc; each follows the same signal-based pattern and is cheap to add.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 12:39:01 +02:00
Flatlogic Bot
d3fb8046d5 Initial version 2026-02-22 12:14:54 +00:00