I am trying to show that for any integer $a$, $$e(a/q) = \sum_{d|q, d|a} \dfrac{1}{ϕ(q/d)} \sum_{χ \ (mod \ q/d)} χ(a/d) τ(χ).$$ First I considered the case $(a,q)=1$ and the mentioned equality holds. But for $(a,q)>1$, I tried anything that I knew from the analytic number theory course but I failed. Any useful hint would be appreciated.
The Gauss sum $τ(χ)$ of $χ$ is defined to be $τ(χ) = \sum_{a=1}^q χ(a) e(a/q)$.
Because I have worked on this exercise a lot and checked many theorems I knew, even a little but useful hint might be helpful, thanks!