Skip to content

Instantly share code, notes, and snippets.

@noelworden
Last active June 16, 2020 02:10
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/72f255e315c45b1f847343a4cbb11d42 to your computer and use it in GitHub Desktop.
Save noelworden/72f255e315c45b1f847343a4cbb11d42 to your computer and use it in GitHub Desktop.
case Decimal.round(Decimal.sub(total_merch_rev, total_group_costs), 2) ==
Decimal.round(Decimal.cast(0), 2) do
true ->
case net_revenue_shared == Decimal.cast(0) do
true ->
changeset
false ->
add_error(
changeset,
:net_revenue_shared,
"must be total_merch_rev minus total_group costs"
)
end
false ->
case Decimal.round(Decimal.sub(total_merch_rev, total_group_costs), 2) ==
Decimal.round(net_revenue_shared, 2) do
true ->
changeset
false ->
add_error(
changeset,
:net_revenue_shared,
"must be total_merch_rev minus total_group costs"
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment