feat(projekt-matching): auto-tag created opportunities, add German docs (S68)

Every opportunity created by the workflow now carries the CTag
"Auto: Durch Suchagent-Treffer erstellt" (id 6a83292a186dce7b2), set via
cTagsIds directly in the create POST. The tag id is resolved at runtime
by name (EspoClient.ensure_ctag, same pattern as team_id; self-healing
after a CRM rebuild); the read-back verification now also checks the tag.
No backfill: existing opportunities and the saved "Via cowork-api
erstellt" list filter are untouched.

Live-verified end to end: synthetic trigger mail, opportunity
6a832b8f29cc86bdf created with cTagsNames containing the tag (test
artifact removed afterwards). 65/65 pytest.

Also adds the complete German technical documentation of the workflow
(docs/projekt-matching-dokumentation.md, sections 1-13 + S68 appendix).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tlg
2026-08-17 18:09:06 +02:00
parent 58b64c6d5f
commit 86bd7f6a07
5 changed files with 436 additions and 2 deletions

View File

@@ -74,6 +74,12 @@ class EspoClient:
json={"firstName": first, "lastName": last,
"accountId": account_id})["id"]
def ensure_ctag(self, name):
hits = self.search("CTag", "equals", "name", name)
if hits:
return hits[0]["id"]
return self._req("POST", "CTag", json={"name": name})["id"]
def unique_opportunity_name(self, name):
existing = {h["name"] for h in self.search(
"Opportunity", "startsWith", "name", name, max_size=100)}