Align object to walls

Hi everyone,
I have a room with more vertical walls. I want to snap and align my objects to one of these walls.
I make a raycast start from the back of object, when it hits the wall I get the impact point, the normal and the
object bounds. I multiply the normal by the bounds and add this to the impact point.
This looks to work well for 90° snapped wall, but not for walls with yaw of 45° (for example).
Can anyone suggest me which the correct formula is?
Thank you very much.