Under the periodic method you do not track a running inventory balance. You let the inventory account sit untouched all period. When the period closes, you count stock on hand, value that count, and record the results in a single adjusting entry pair.
The method rests on one equation: what you started with, plus what you bought, equals what you had available. Subtract what you still have and the rest is what you sold. The OpenStax teaching module states the logic plainly: the units that remain under FIFO are those that were purchased last, given the earliest acquisitions are treated as sold first (OpenStax, Principles of Financial Accounting, 10.2).
In the worked example the firm carries a product line called The Spy Who Loves You. During the period 585 units were available for sale. The firm sold 300 of them. Working FIFO from the front of the purchase list, 300 units come off the oldest layers, and the units still sitting on the shelf are the newest ones. That leaves the firm with 210 units purchased at $33 and 75 units purchased at $27 each, for a total FIFO periodic ending inventory value of $8,955.
Total goods available for sale during the period came to $16,155. Subtracting the $8,955 ending inventory leaves $7,200 in cost of goods sold for the period (OpenStax, Principles of Financial Accounting, 10.2).
Those are the two amounts. Everything else in the close flows from them.
The arithmetic also tells you why the two amounts are inseparable. The same ending inventory figure that raises the balance sheet account to the counted value is the figure you subtract from goods available to produce the expense. Move one and the other moves with it. That is why the periodic close is taught as a pair rather than as two independent postings.
One more piece of the equation lives in the pre-adjustment balance. The worked example opened the period with a merchandise inventory balance of $3,150 before adjustment (OpenStax, Principles of Financial Accounting, 10.2). That opening figure is the starting point you carry forward when you write the entry, and the difference between it and the counted ending balance is the amount you actually post to the inventory account.