To add to this, I tackled this problem with three different approaches in the linked sheet. The first is a tool that compares options to get to the next level for any given weapon. The second is a series of tables that lays out recommended upgrade paths for any given rarity. The third is an advanced tool that combines aspects of the previous two: it allows you to create your own complete upgrade path for a given weapon. Together these represent the most comprehensive toolset I've come across to get weapon enhancement advice, tweak the advice based on resources available to your account, and calculate total resource usage over the entire level range that includes the cost of rolling Gem Gatcha.
I suppose I should dedicate an additional section of my guide to listing the most important tools in my toolbox and explaining how to use them.