revenue vs. cogs per GAAP

Say you have a company that sells two products X and Y, where X is used by Y (e.g. plastic bullets for a BB gun).
The company selling X and Y have a contract with their customer that
says the more of X they buy, the bigger the discount they will get when purchasing Y, but there is nothing in the agreement as to just how much X they are required to purchase, so we can't know the final selling price of Y until the contract expires (contracts are generally for 120 days) and we know how much of X was purchased (so we know how much discount to apply to Y).
The customer was shipped Y at the beginning of the contract even though the purchase price wasn't yet known, and then they were shipped units of X periodically throughout the period of the contract. At the expiration of the contract, the final price of Y is calculated an an invoice mailed to the customer.
The question is, when can the selling company recognize the sale price of Y in their COGS. Do they get the COGS deduction:
1) When they ship Y (they use FOB shipping so title passes when it is shipped) 2) When the contract concludes and the final price of Y can be determined 3) When the invoice is put in the mail, or recv'd by the customer. 4) Some other moment in time ?
The price of Y can't be included in revenue until the final price is known, per SAB 104, and the matching principle would tend to suggest the COGS can't be deducted until the price of Y is recorded as revenue, so I'm leaning towards (2), but I can't find anywhere, if it exists at all, when GAAP says a sale actually occurs. Or are SAB considered part of GAAP?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a site by and for consumers of financial services and advice. We are not affiliated with any of the banks, financial services or software manufacturers discussed here. All logos and trade names are the property of their respective owners.

Tax and financial advice you come across on this site is freely given by your peers and professionals on their own time and out of the kindness of their hearts. We can guarantee neither accuracy of such advice nor its applicability for your situation. Simply put, you are fully responsible for the results of using information from this site in real life situations.