Skip to content

Instantly share code, notes, and snippets.

Noel Worden noelworden

View GitHub Profile
View week_june22_get_message.ex
def get_message(error) do
converted_opts = Enum.map(error.opts, fn {key, value} ->
{String.to_existing_atom(key), value}
end)
translate_error({"#{error.message}", converted_opts})
end
View week_june22_map_to_list.ex
Enum.map(error.opts, fn {key, value} ->
{String.to_existing_atom(key), value}
end)
View week_june22_error_helpers.ex
defmodule FinanceWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
use Phoenix.HTML
@doc """
Generates tag for inlined form input errors.
"""
View week_june8_refactor02.ex
rev_minus_cost = round(sub(total_merch_rev, total_group_costs), 2)
net_rev = round(net_revenue_shared, 2)
if rev_minus_cost == net_rev do
changeset
else
add_error(
changeset,
:net_revenue_shared,
"must be total_merch_rev minus total_group costs"
View week_june8_chunk02.ex
case Decimal.round(Decimal.sub(total_merch_rev, total_group_costs), 2) ==
Decimal.round(net_revenue_shared, 2) do
View week_june8_chuck01.ex
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
View week_june8_refactor01.ex
@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
])
View week_june8_variables.ex
round(sub(total_merch_rev, total_group_costs), 2) == 0.00 && net_revenue_shared == 0 ||
round(sub(total_merch_rev, total_group_costs), 2) == round(net_revenue_shared, 2)
View week_june8_validation.ex
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,
View week_june1_zipped.ex
[first_field_2: :first_field, second_field_2: :second_field, third_field_2: :third_field]
You can’t perform that action at this time.