Cancelled build returns as many resources as possible

When a build/train is cancelled, most of the time I get all resources back. Sometimes I get none. The rules behind when I get none is tedious and not at all “strategic” in a fun way. Just return as many resources as possible. Keep warnings the same but just overflow my storage, but the. I should be at max.