commit e47e845d7dc5589fb03118524e03c1a95109bbbf
parent 9067505ee3dd44de76a292d4c3ab77221a689be2
Author: srfsh <dev@srf.sh>
Date: Tue, 6 Dec 2022 11:15:14 +0300
Zenflows.EconomicResource.{Query,Type}: add some NOT filters
Requested by Ennio.
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/zenflows/vf/economic_resource/query.ex b/src/zenflows/vf/economic_resource/query.ex
@@ -41,10 +41,14 @@ defp all_f(q, {:primary_accountable, v}),
do: where(q, [x], x.primary_accountable_id in ^v)
defp all_f(q, {:or_primary_accountable, v}),
do: or_where(q, [x], x.primary_accountable_id in ^v)
+defp all_f(q, {:not_primary_accountable, v}),
+ do: where(q, [x], x.primary_accountable_id not in ^v)
defp all_f(q, {:custodian, v}),
do: where(q, [x], x.custodian_id in ^v)
defp all_f(q, {:or_custodian, v}),
do: or_where(q, [x], x.custodian_id in ^v)
+defp all_f(q, {:not_custodian, v}),
+ do: where(q, [x], x.custodian_id not in ^v)
defp all_f(q, {:conforms_to, v}),
do: where(q, [x], x.conforms_to_id in ^v)
defp all_f(q, {:or_conforms_to, v}),
@@ -70,8 +74,10 @@ defp all_validate(params) do
or_classified_as: {:array, :string},
primary_accountable: {:array, ID},
or_primary_accountable: {:array, ID},
+ not_primary_accountable: {:array, ID},
custodian: {:array, ID},
or_custodian: {:array, ID},
+ not_custodian: {:array, ID},
conforms_to: {:array, ID},
or_conforms_to: {:array, ID},
gt_onhand_quantity_has_numerical_value: :decimal,
@@ -83,8 +89,8 @@ defp all_validate(params) do
}}
|> Changeset.cast(params, ~w[
classified_as or_classified_as
- primary_accountable or_primary_accountable
- custodian or_custodian
+ primary_accountable or_primary_accountable not_primary_accountable
+ custodian or_custodian not_custodian
conforms_to or_conforms_to
gt_onhand_quantity_has_numerical_value
or_gt_onhand_quantity_has_numerical_value
@@ -95,9 +101,11 @@ defp all_validate(params) do
|> Validate.exist_nand([:classified_as, :or_classified_as])
|> Validate.class(:primary_accountable)
|> Validate.class(:or_primary_accountable)
+ |> Validate.class(:not_primary_accountable)
|> Validate.exist_nand([:primary_accountable, :or_primary_accountable])
|> Validate.class(:custodian)
|> Validate.class(:or_custodian)
+ |> Validate.class(:not_custodian)
|> Validate.exist_nand([:custodian, :or_custodian])
|> Validate.class(:conforms_to)
|> Validate.class(:or_conforms_to)
diff --git a/src/zenflows/vf/economic_resource/type.ex b/src/zenflows/vf/economic_resource/type.ex
@@ -251,8 +251,10 @@ input_object :economic_resource_filter_params do
field :or_conforms_to, list_of(non_null(:id))
field :primary_accountable, list_of(non_null(:id))
field :or_primary_accountable, list_of(non_null(:id))
+ field :not_primary_accountable, list_of(non_null(:id))
field :custodian, list_of(non_null(:id))
field :or_custodian, list_of(non_null(:id))
+ field :not_custodian, list_of(non_null(:id))
field :gt_onhand_quantity_has_numerical_value, :decimal
field :or_gt_onhand_quantity_has_numerical_value, :decimal
field :name, :string