From 9f169b9835aa0342140f13edbf84e51dc859ab9e Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 4 Mar 2026 19:37:19 +0100 Subject: [PATCH] Vereinfacht: sync country with finance contact API --- docs/vereinfacht-api.md | 2 +- lib/mv/vereinfacht/changes/sync_contact.ex | 5 +++-- lib/mv/vereinfacht/client.ex | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/vereinfacht-api.md b/docs/vereinfacht-api.md index e0480f4..e50274f 100644 --- a/docs/vereinfacht-api.md +++ b/docs/vereinfacht-api.md @@ -25,7 +25,7 @@ When creating an external finance contact, the API only requires: - **Attributes:** `contactType` (e.g. `"person"`), `isExternal: true` - **Relationship:** `club` (club ID from config) -Additional attributes (firstName, lastName, email, address, zipCode, city) are optional and are sent when present on the member so the contact is filled in. The app does **not** enforce extra required member fields for Vereinfacht; only Settings-based required fields and email apply. +Additional attributes (firstName, lastName, email, address, zipCode, city, country) are optional and are sent when present on the member so the contact is filled in. The app does **not** enforce extra required member fields for Vereinfacht; only Settings-based required fields and email apply. - **Client:** `Mv.Vereinfacht.Client.create_contact/1` builds the JSON:API body from the member; `Mv.Constants.vereinfacht_required_member_fields/0` is an empty list. diff --git a/lib/mv/vereinfacht/changes/sync_contact.ex b/lib/mv/vereinfacht/changes/sync_contact.ex index f3679d4..014557b 100644 --- a/lib/mv/vereinfacht/changes/sync_contact.ex +++ b/lib/mv/vereinfacht/changes/sync_contact.ex @@ -9,7 +9,7 @@ defmodule Mv.Vereinfacht.Changes.SyncContact do (Mv.Config.vereinfacht_configured?/0). Only runs when relevant data changed: on create always; on update only when - first_name, last_name, email, street, house_number, postal_code, or city changed, + first_name, last_name, email, street, house_number, postal_code, city, or country changed, or when the member has no vereinfacht_contact_id yet (to avoid unnecessary API calls). """ use Ash.Resource.Change @@ -26,7 +26,8 @@ defmodule Mv.Vereinfacht.Changes.SyncContact do :street, :house_number, :postal_code, - :city + :city, + :country ] @impl true diff --git a/lib/mv/vereinfacht/client.ex b/lib/mv/vereinfacht/client.ex index f41e962..3ed70b8 100644 --- a/lib/mv/vereinfacht/client.ex +++ b/lib/mv/vereinfacht/client.ex @@ -345,6 +345,7 @@ defmodule Mv.Vereinfacht.Client do |> put_attr("address", address) |> put_attr("zipCode", member |> Map.get(:postal_code)) |> put_attr("city", member |> Map.get(:city)) + |> put_attr("country", member |> Map.get(:country)) |> Map.put("contactType", "person") |> Map.put("isExternal", true) |> Enum.reject(fn {_k, v} -> is_nil(v) end)