Previous ammonia advice by the Department for Agriculture, Environment and Rural Affairs (DAERA) failed to comply with environmental laws, a watchdog report has found.