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)
|
||||
end
|
||||
|
||||
{:error, _reason} ->
|
||||
# If we can't load the types, allow the change (fail open)
|
||||
# The database constraint will catch invalid foreign keys
|
||||
changeset
|
||||
{:error, reason} ->
|
||||
# Fail closed: If we can't load the types, reject the change
|
||||
# This prevents inconsistent data states
|
||||
add_type_validation_error(changeset, reason)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -114,6 +114,17 @@ defmodule Mv.MembershipFees.Changes.ValidateSameInterval do
|
|||
)
|
||||
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
|
||||
defp format_interval(:monthly), do: "monthly"
|
||||
defp format_interval(:quarterly), do: "quarterly"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue