There are many thing to achieve your requirement, some are below.
1. No to enter Qty. to Invoice field value
2. Put the error if someone does for point no. 1
3. Put an error on Point No. 1
4. Disable the Invoice menu option by going to Codeunit 91
5. Put your logic on OnBeforePosting, in codeunit 90
Thanks.