NOTE 3—ACQUISITIONS AND DIVESTITURES
Sale of CGD Services
On April 18, 2018, we entered into a stock purchase agreement with Nova Global Supply & Services, LLC (Purchaser), an entity affiliated with GC Valiant, LP, under which we agreed to sell our CGD Services business to the Purchaser. We concluded that the sale of the CGD Services business met all of the required conditions for discontinued operations presentation in the second quarter of fiscal 2018. Consequently, in the second quarter of fiscal 2018, we recognized a $6.9 million loss within discontinued operations, which was calculated as the excess of the carrying value of the net assets of CGD Services less the estimated sales price in the stock purchase agreement less estimated selling costs.
The sale closed on May 31, 2018. In accordance with the terms of the stock purchase agreement, the Purchaser agreed to pay us $135.0 million in cash upon the closing of the transaction, adjusted for the estimated working capital of CGD Services at the date of the sale compared to a working capital target. In the third quarter of fiscal 2018, we received $133.8 million in connection with the sale and we recorded a receivable from the Purchaser for the estimated amount due related to the working capital settlement. The balance of this receivable was $3.7 million at September 30, 2018. During fiscal 2019, we worked with the Purchaser and revised certain estimates related to the working capital settlement. In connection with the revision of these estimates, we reduced the receivable from the Purchaser by $1.4 million and recognized a corresponding loss on the sale of CGD Services in fiscal 2019. Certain remaining working capital settlement estimates, primarily related to the fair value of accounts receivable, have not yet been settled with the Purchaser.
In addition to the amounts described above, we are eligible to receive an additional cash payment of $3.0 million based on the achievement of pre-determined earn-out conditions related to the award of certain government contracts. No amount has been recorded as a receivable related to the potential achievement of earn-out conditions based upon our assessment of the probability of achievement of the required conditions.
The operations and cash flows of CGD Services are reflected in our Consolidated Statements of Operations and Consolidated Statements of Cash Flows as discontinued operations through May 31, 2018, the date of the sale. The following table presents the composition of net income from discontinued operations, net of taxes (in thousands):
Table:
 |  | Years Ended September 30, | 
 | 2019 | 2018 | 2017
Net sales | $  — | $  262,228 | $  378,152
Costs and expenses: |  |  | 
Cost of sales | — | 235,279 | 342,819
Selling, general and administrative expenses | — | 11,365 | 17,487
Amortization of purchased intangibles | — | 1,373 | 2,752
Restructuring costs | — | 7 | 208
Other income | — | (15) | (46)
Earnings from discontinued operations before income taxes | — | 14,219 | 14,932
Net loss on sale | 1,423 | 6,131 | —
Income tax provision | — | 3,845 | 401
Net income (loss) from discontinued operations | $  (1,423) | $  4,243 | $  14,531


Question: How was the loss within discontinued operations in 2018 calculated?
Answer: the excess of the carrying value of the net assets of CGD Services less the estimated sales price in the stock purchase agreement less estimated selling costs