Seeds: robust default fee type lookup; no fee type overwrite on re-run
Bootstrap: filter default fee type by name and interval (yearly). Dev: do not send membership_fee_type_id in member upsert; set only via update when nil so re-runs do not overwrite existing assignments.
This commit is contained in:
parent
a98d921848
commit
ea350ab315
2 changed files with 5 additions and 7 deletions
|
|
@ -250,6 +250,8 @@ Enum.with_index(member_configs)
|
|||
fee_type_id = if fee_type_index, do: Enum.at(all_fee_types, fee_type_index).id, else: nil
|
||||
cycle_status = Enum.at(cycle_statuses, index)
|
||||
|
||||
# Do not include membership_fee_type_id in upsert so re-runs do not overwrite
|
||||
# existing assignments; set via update below only when member has none
|
||||
base_attrs = %{
|
||||
first_name: config.first_name,
|
||||
last_name: config.last_name,
|
||||
|
|
@ -262,13 +264,8 @@ Enum.with_index(member_configs)
|
|||
country: Enum.at(countries_list, index)
|
||||
}
|
||||
|
||||
member_attrs =
|
||||
if fee_type_id,
|
||||
do: Map.put(base_attrs, :membership_fee_type_id, fee_type_id),
|
||||
else: base_attrs
|
||||
|
||||
member =
|
||||
Membership.create_member!(member_attrs,
|
||||
Membership.create_member!(base_attrs,
|
||||
upsert?: true,
|
||||
upsert_identity: :unique_email,
|
||||
actor: admin_user_with_role
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue