Ibrahim and al-Hasan say that fasting in a state of janabah counts in a voluntary fast, but in an obligatory fast he must make up that fast.