I'm trying to prove that the following statements are equivalent for a commutative ring $R$
A: $_RR=_RN \oplus_RM$ for some submodules $_RN$, $_RM\subseteq_RR$
B: There exists an element $e=e^2\in R$ such that $N=Re$ and $M=R(1-e)$
I have no idea how to show $A \implies B$, but $B\implies A$ seems easy: every $r \in R$ can be written as $re+r(1-e)$ and for $r\in N\cap M$ $r=ae=b(1-e)$ for some $a,b\in R$, so $re=ae^2=b(1-e)e=b(e-e^2)=0$. Now if $R$ is a domain, $e=0$ and $M=R$ or $r=0$ and $N\cap M=\emptyset$. But what if it's not a domain?