As for San Diego, they can afford to make this deal, as they still have Chase Headley, who they reacquired from the Yankees, Freddy Galvis at SS who they picked up from the Phillies, and Carlos Asauje at 2B, along with utility player Jose Pirela, who can play all over the diamond.
They also have Cory Spangenberg, along with prospects Luis Urias, Allen Cordoba(who is ticketed for AA or AAA this year now that his rule 5 status is done), Javier Guerra and Fernando Tatis Jr. in the system. They could afford to make this deal.. plus they wanted to get his salary off the books long term (Headley is a free agent after 2018, and will go off San Diego's book after this coming season).