Perfect fluid spacetimes with harmonic generalized curvature tensor