Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. @statuses %{
  2. "1.0 Cobrança Jurídica" => %{
  3. "Leilão" => {:foreclosure_auction, "auction_in_progress"},
  4. "Tentativa de Negociação" => {:notification, "attempt_to_negotiate"},
  5. "Não Notificar (Casos de exceção)" => {:notification, "not_notify"}
  6. },
  7. "1.1 Notificação" => %{
  8. "Emissão" => {:notification, "notification_in_progress"},
  9. "Envio e Custas" => {:notification, "notification_in_progress"},
  10. "Análise do Cartório" => {:notification, "notification_in_progress"},
  11. "Guia ITBI" => {:notification, "notified"},
  12. "Negociação com Guia ITBI" => {:notification, "notified"},
  13. "Liminar" => {:notification, "injunction"},
  14. "Acordo" => {:notification, "deal"}
  15. },
  16. "1.2 Consolidação" => %{
  17. "Emissão" => {:consolidation, "foreclosure_in_progress"},
  18. "Envio e Custas" => {:consolidation, "foreclosure_in_progress"},
  19. "Análise do Cartório" => {:consolidation, "foreclosure_in_progress"},
  20. "Consolidação" => {:consolidation, "foreclosure_in_progress"},
  21. "Tributos" => {:consolidation, "foreclosure_in_progress"},
  22. "Liminar" => {:consolidation, "injunction"},
  23. "Acordo" => {:consolidation, "deal"}
  24. },
  25. "1.3 Leilão" => %{
  26. "Liminar" => {:foreclosure_auction, "injunction"}
  27. }
  28. }
  29.  
  30. @doc """
  31. Cast the status from some card.
  32. ## Examples
  33. iex> cast_status(%{phase: "Leilão"}, %{"pipe" => %{"name" => "1.0 Cobrança Jurídica"}})
  34. %{status: {:foreclosure_auction, "auction_in_progress"}}
  35. """
  36. # credo:disable-for-lines:20
  37. def cast_status(%{phase: phase} = acc, card) do
  38. pipe = card["pipe"]["name"]
  39.  
  40. status =
  41. cond do
  42. "1.1 Notificação" == pipe and "Intimação" == phase and customer_was_summoned?(card) ->
  43. {:notification, "notified"}
  44.  
  45. "1.1 Notificação" == pipe and "Intimação" == phase and not customer_was_summoned?(card) ->
  46. {:notification, "notification_in_progress"}
  47.  
  48. true ->
  49. case @statuses[pipe][phase] do
  50. nil -> {:notification, "not_started"}
  51. {schema, status} -> {schema, status}
  52. end
  53. end
  54.  
  55. Map.put(acc, :status, status)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement