This file contains 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 Finance.SourceFiles.Data.Screen do | |
import Ecto.Changeset | |
def validate_decimal(changeset, fields) do | |
%{errors: errors} = changeset | |
fields_not_decimal = | |
for field <- fields, | |
not_decimal?(changeset, field), | |
do: field |
This file contains 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
rename( | |
table("raw_example_product_detail"), | |
:first_field_2, | |
to: :first_field | |
) | |
rename( | |
table("raw_example_product_detail"), | |
:second_field_2, | |
to: :second_field |
This file contains 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 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 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 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 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 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 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 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 |
OlderNewer