How are Expected Costs calculated in Sage X3?

Hello!

We are finding that it's become near impossible for us to Close and Cost our work orders prior to our shipments. We run on average costs. To ensure our actuals are close to the expected, does anyone have a breakdown on how Expected Costs are calculated? I understand the BoM and Routings are used but how exactly does Sage build the cost? What formula is used where we could try and simulate the cost in excel to better understand and build our costs...

Any insight/help is appreciated! Thanks!! 

Jenny C. in NJ