A general finite-field scheme for the calculation of frequency-dependent electronic–vibrational hyperpolarizabilities