Citadels Tax Collector timing
The alchemist description found in the rules, page 18, strongly suggest that first the tax collector taxes the alchemist, then the alchemist gets money back from his construction. Then, if the alchemist has no money after building something, the tax collector gets nothing. See also a similar question on BGG.

Applying the same rationale, the diplomat swapping ability will be effective in the end of the turn, after he pays the tax collector. Note that the diplomat's collection of coins from red districts may happen before or after building something (if the player wants it, of course), as stated in the rulebook, page 12. The end of turn happens after that.