This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Enum.zip( | |
| [:first_field_2, :second_field_2, :third_field_2], | |
| [:first_field, :second_field, :third_field] | |
| ) | |
| |> Enum.each(fn {key, value} -> rename(table("raw_nmi_product_detail"), key, to: value) end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [first_field_2: :first_field, second_field_2: :second_field, third_field_2: :third_field] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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 | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case Decimal.round(Decimal.sub(total_merch_rev, total_group_costs), 2) == | |
| Decimal.round(net_revenue_shared, 2) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule FinanceWeb.ErrorHelpers do | |
| @moduledoc """ | |
| Conveniences for translating and building error messages. | |
| """ | |
| use Phoenix.HTML | |
| @doc """ | |
| Generates tag for inlined form input errors. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Enum.map(error.opts, fn {key, value} -> | |
| {String.to_existing_atom(key), value} | |
| end) |