The article presents the optimization of supply chain management in a foundry using computer simulation with the FlexSim program. The authors analyze collaboration with external entities in the production process, focusing on the settlement of raw materials, transportation services, and storage costs. Special attention is given to the production plans of subcontractors integrated into the operational production schedule. Utilizing the 3D FlexSim environment, they showcase a simulation model optimized for minimizing the costs of production, transportation, and storage of alloying elements essential for iron casting production. The case study illustrates the effective use of computer simulation in refining supply chain management within the context of the foundry production process.