fixed invoice migration
refactored before hooks in models