     case fetch_custom(saltedge_account_id, from, to, nil, []) do
       [] -> List.flatten(acc)
       transactions_chunk ->
-        to = substract_days(from, 30)
-        from = substract_days(from, 1)
-        fetch_all(saltedge_account_id, from, to, [transactions_chunk | acc])
+        new_from = Timex.Date.shift(from, months: -1)
+        new_to = Timex.Date.shift(from, days: -1)
+        fetch_all(saltedge_account_id, new_from, new_to, [transactions_chunk | acc])
     end
   end
 

  end

  defp fetch_all(saltedge_account_id) do
    to = current_date()
    from = substract_days(to, 30)

    transactions = fetch_all(saltedge_account_id, from, to, [])


    end
  end

  defp date_to_string(date) do
    {:ok, str_date} = Timex.DateFormat.format(date, "%Y-%m-%d", :strftime)
    str_date
  end

  defp find_last_transaction(saltedge_account_id) do
