How COGS is calculated

I have an expected COGS as a “Periodic Inventory”, calculated as following: (Open Stock Value - Closing Stock Value) + Purchases

In my case we are using “Perpetual Inventory”, so by the end of the month I should expect that the Periodic Inventory will match the Perpetual Inventory.

My question: Is there is a way to verify the COGS in “Perpetual Inventory”? How to trigger recalculating the COGS?