A generalization of the half-electron method for calculations for complex compounds