Cycle Management & Member Integration closes #279 #294
1 changed files with 15 additions and 4 deletions
|
|
@ -62,10 +62,10 @@ defmodule Mv.MembershipFees.Changes.ValidateSameInterval do
|
||||||
add_interval_mismatch_error(changeset, current_interval, new_interval)
|
add_interval_mismatch_error(changeset, current_interval, new_interval)
|
||||||
end
|
end
|
||||||
|
|
||||||
{:error, _reason} ->
|
{:error, reason} ->
|
||||||
# If we can't load the types, allow the change (fail open)
|
# Fail closed: If we can't load the types, reject the change
|
||||||
# The database constraint will catch invalid foreign keys
|
# This prevents inconsistent data states
|
||||||
changeset
|
add_type_validation_error(changeset, reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -114,6 +114,17 @@ defmodule Mv.MembershipFees.Changes.ValidateSameInterval do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Add validation error when types cannot be loaded
|
||||||
|
defp add_type_validation_error(changeset, reason) do
|
||||||
|
message = "Could not validate membership fee type intervals: type not found"
|
||||||
|
|
||||||
|
Ash.Changeset.add_error(
|
||||||
|
changeset,
|
||||||
|
field: :membership_fee_type_id,
|
||||||
|
message: message
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# Format interval atom to human-readable string
|
# Format interval atom to human-readable string
|
||||||
defp format_interval(:monthly), do: "monthly"
|
defp format_interval(:monthly), do: "monthly"
|
||||||
defp format_interval(:quarterly), do: "quarterly"
|
defp format_interval(:quarterly), do: "quarterly"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue