You need to use either mNpdt52 or mNpdt12 depending on the npc type. See current version of ensureCustomData for an example.

Additionally, the code for this should be moved to a new MWWorld::Class::getMaxGold function, implemented for MWClass::Creature and MWClass::Npc.