Purely curiosity, but surely that can't be how it works? It kind of makes sense at face value, but seems like a monster loophole[1], too -- I'd be curious if anyone could point me towards more reading on the topic.
1 - Bob wants tax deductions. Bob decides to sell pencils for $50k each. Bob discounts them to $0 for non-profits. Can Bob deduct $50k per pencil, for each sold to a non-profit?? Maybe Bob can only deduct his cost, or something?