@redv: you're right about the cost being misleading when there are multiple jobs. Hopefully this will address that concern. I didn't include other base expenses in the number, though, since the idea here (faithful to the
wiki article) is to figure out whether your *total manufacturing resources* are turning a profit.
I understand what you are trying to show with the algorithm you have, I just think we're trying to answer slightly different questions. You're showing whether the *allocated* resources are turning a profit, and I'm showing whether the player's *investment* in manufacturing resources is turning a profit.
Here's a comparison between the two options. The first screenshot shows a base that is manufacturing items for use -- that is, it's not selling them for profit (not that this particular item would be profitable anyway, but that's not the point. it's just here to clarify the "all bases" line). The next two screenshots compare redv's output and my proposed output for 0 allocated engineers, and the next two compare the output for the maximum number of engineers.
You can see that when all resources are allocated, the calculated value is the same for the two algorithms, but they differ more significantly as more workshop space is left empty.
I think both options are confusing for different reasons. redv's option shows profit that may not actually result in funds at the end of the month. My proposed option will give you the accurate funds change for the base due to manufacturing, but has to combine the calculations for all jobs at the base for the numbers to be consistent (that's why it's "this base" and not just "this job").