Check the current member first. If it's leaf member, apply your formual, otherwise, aggregate. Try the formula below:
IIF(NOT ISLEAF([Document type].CurrentMember), ROLLUPCHIILDREN([Document type].CurrentMember, "+"), IIf([Document type].CurrentMember.Name = "Devolution", 0, ([Measures].[Invoiced]-[Measures].[Mfg Cost])/[Measures].[Invoiced]))