mix, the extent to which we factor customer receivables and the negotiation of payment terms with customers and suppliers. These fluctuations can significantly affect our cash flows from operating activities.
During the six months ended April 1, 2023, we generated $276 million of cash primarily from earnings, excluding non-cash items, and used $174 million of cash due primarily to an increase in accounts receivable and a decrease in accounts payable, partially offset by a decrease in inventory. Individual components of operating assets and liabilities fluctuate for a number of reasons, including linearity of purchases and sales, the mix of customer and supplier payment terms within our accounts receivable and accounts payable, and the amount and timing of sales of accounts receivable. The increase in accounts receivable is primarily attributable to an increase in sales and billings to customers for their inventory obligations. The decrease in inventory is primarily due to improved availability of supply-constrained parts which reduced the need for us to carry other inventory while waiting for these supply-constrained parts to become available and the impact of other inventory reduction initiatives such as working more closely with our customers to ensure their demand forecasts properly consider the current supply chain environment to the extent possible. The decrease in accounts payable was primarily attributable to lower inventory receipts and unfavorable supplier payment terms mix.
Net cash used in investing activities was $101 million and $46 million for the six months ended April 1, 2023 and April 2, 2022, respectively. During the six months ended April 1, 2023, we used $101 million of cash for capital expenditures. During the six months ended April 2, 2022, we used $53 million of cash for capital expenditures, purchased $1 million of long-term investments and received proceeds of $8 million primarily from the sale of a certain property.
Net cash provided by (used in) financing activities was $186 million and $(190) million for the six months ended April 1, 2023 and April 2, 2022, respectively. During the six months ended April 1, 2023, we received $216 million from sale of shares of SIPL to RSBVL and used $22 million of cash to repurchase common stock primarily related to employee tax withholding on vested restricted stock units and repaid $9 million of long-term debt. During the six months ended April 2, 2022, we used $182 million of cash to repurchase common stock (including $13 million related to employee tax withholding on vested restricted stock units), repaid an aggregate of $9 million of long-term debt and received $1 million of net proceeds from issuances of common stock pursuant to stock option exercises.
Other Liquidity Matters
On May 17, 2023, as a result of our failure to timely file our Form 10-Q for the quarter ended April 1, 2023, we were in technical default with respect to certain covenants within our Credit Agreement. Because we are filing this Form 10-Q on May 19, 2023, which is within the stated cure period of 15 calendar days, we are no longer in default.
During the six months ended April 1, 2023 and April 2, 2022, we repurchased 3,800 and 4.4 million shares of our common stock for $0.2 million and $169 million, respectively, under stock repurchase programs authorized by the Board of Directors. There were no repurchases during the three months ended April 1, 2023. These programs have no expiration dates and the timing of repurchases will depend upon capital needs to support the growth of our business, market conditions and other factors. Although stock repurchases are intended to increase stockholder value, they also reduce our liquidity. As a result, the timing of future repurchases depends upon our future capital needs, market conditions and other factors. As of April 1, 2023, an aggregate of $164 million remained available under these programs.
We are a party to a Receivable Purchase Agreement (the “RPA”) with certain third-party banking institutions for the sale of trade receivables generated from sales to certain customers, subject to acceptance by, and a funding commitment from, the banks that are party to the RPA. As of April 1, 2023, a maximum of $542 million of sold receivables can be outstanding at any point in time under this program, as amended, as required by our Fifth Amended Credit Agreement (the “Credit Agreement”). Additionally, the amount available under the RPA is uncommitted and, as such, is available at the discretion of our third-party banking institutions. Under the Credit Agreement, the percentage of our total accounts receivable that can be sold and outstanding at any time is 50%. Trade receivables sold pursuant to the RPA are serviced by us.
In addition to the RPA, we participate in trade receivables sales programs that have been implemented by certain of our customers, as in effect from time to time. We do not service trade receivables sold under these other programs.
The sale of receivables under all of these programs is subject to the approval of the banks or customers involved and there can be no assurance that we will be able to sell the maximum amount of receivables permitted by these programs when desired.