Created
June 14, 2019 17:55
-
-
Save mgiacomini/420c6d0fa022cf3286761b4fb17f3899 to your computer and use it in GitHub Desktop.
pipefy mappings
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
| @statuses %{ | |
| "1.0 Cobrança Jurídica" => %{ | |
| "Leilão" => {:foreclosure_auction, "auction_in_progress"}, | |
| "Tentativa de Negociação" => {:notification, "attempt_to_negotiate"}, | |
| "Não Notificar (Casos de exceção)" => {:notification, "not_notify"} | |
| }, | |
| "1.1 Notificação" => %{ | |
| "Emissão" => {:notification, "notification_in_progress"}, | |
| "Envio e Custas" => {:notification, "notification_in_progress"}, | |
| "Análise do Cartório" => {:notification, "notification_in_progress"}, | |
| "Guia ITBI" => {:notification, "notified"}, | |
| "Negociação com Guia ITBI" => {:notification, "notified"}, | |
| "Liminar" => {:notification, "injunction"}, | |
| "Acordo" => {:notification, "deal"} | |
| }, | |
| "1.2 Consolidação" => %{ | |
| "Emissão" => {:consolidation, "foreclosure_in_progress"}, | |
| "Envio e Custas" => {:consolidation, "foreclosure_in_progress"}, | |
| "Análise do Cartório" => {:consolidation, "foreclosure_in_progress"}, | |
| "Consolidação" => {:consolidation, "foreclosure_in_progress"}, | |
| "Tributos" => {:consolidation, "foreclosure_in_progress"}, | |
| "Liminar" => {:consolidation, "injunction"}, | |
| "Acordo" => {:consolidation, "deal"} | |
| }, | |
| "1.3 Leilão" => %{ | |
| "Liminar" => {:foreclosure_auction, "injunction"} | |
| } | |
| } | |
| @doc """ | |
| Cast the status from some card. | |
| ## Examples | |
| iex> cast_status(%{phase: "Leilão"}, %{"pipe" => %{"name" => "1.0 Cobrança Jurídica"}}) | |
| %{status: {:foreclosure_auction, "auction_in_progress"}} | |
| """ | |
| # credo:disable-for-lines:20 | |
| def cast_status(%{phase: phase} = acc, card) do | |
| pipe = card["pipe"]["name"] | |
| status = | |
| cond do | |
| "1.1 Notificação" == pipe and "Intimação" == phase and customer_was_summoned?(card) -> | |
| {:notification, "notified"} | |
| "1.1 Notificação" == pipe and "Intimação" == phase and not customer_was_summoned?(card) -> | |
| {:notification, "notification_in_progress"} | |
| true -> | |
| case @statuses[pipe][phase] do | |
| nil -> {:notification, "not_started"} | |
| {schema, status} -> {schema, status} | |
| end | |
| end | |
| Map.put(acc, :status, status) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment