added validations and fixed invoice saving