Unless the contract language says the 40k is nonrefundable with no exceptions, this is a consignment arrangement. As to how to record the 40k, it depends on whether the 40k is an advance or an advance on the security of consigned goods. In either case, you wouldn't record it as a sale since it's a consignment of goods. If the 40k is a straight advance then you would record that as Dr. to cash and Cr. advance on consigned goods. Then you would clear it when the related sales are recorded. If it's an advance on security of consigned goods, then you would clear the account in proportion to goods sold. So, if 63% of goods are sold by the consignee, then repay 63% of the advance.
If the 40k is nonrefundable, then that amount would be considered a final sale regardless of anticipated additional revenues from the consignee. In keeping with the matching principle of accounting, COGS to be recognized would be proportional to the amount of estimated total final sales revenue to be received. So, if total estimated final sales revenue is $50k, then the nonrefundable $40k is 80% ($40k / $50K) of estimated total final sales revenue. Thus, 80% of COGS should be recognized. The difference between COGS and $40k would be the gross margin. Of course it wouldn't be net margin since that would take into account the selling & admin expenses along with other expenses not related to cogs.