I have a global coordinate system that I need to transform to a local coordinate system. The new and old coordinate systems are shown below.

Using transformation rules, I came with with the coordinates in the new system. To get the coordinate system in the right position, it has to translated in the x and y directions, rotated about the x and z axis, and scaled. These formulas are shown below.

These formulas are not working, and I'm not sure why? As test points I tried out these,
Old System (0,-1.11270165)
New System (5.88729835,-10)
If anyone can enlighten me it would be greatly appreciated. Thanks.