Skip to content

Instantly share code, notes, and snippets.

@noelworden
Last active June 16, 2020 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelworden/e6d430271e4c2324e0699d32c2781334 to your computer and use it in GitHub Desktop.
Save noelworden/e6d430271e4c2324e0699d32c2781334 to your computer and use it in GitHub Desktop.
@zero_with_decimal round(cast(0), 2)
rev_minus_cost = round(sub(total_merch_rev, total_group_costs), 2)
net_rev = round(net_revenue_shared, 2)
net_rev_valid =
Enum.any?([
rev_minus_cost == @zero_with_decimal && net_rev == @zero_with_decimal,
rev_minus_cost == net_rev
])
if net_rev_valid do
changeset
else
add_error(
changeset,
:net_revenue_shared,
"must be total_merch_rev minus total_group costs"
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment