I think your forgot to test already the first select statement:
// Find the first invoice date for each customer
while select minof(InvoiceDate), InvoiceAccount from custInvoiceJour
where custInvoiceJour.InvoiceDate >= twoYear
&& custInvoiceJour.InvoiceDate <= oneYear
exists join custTable
where custTable.AccountNum==custInvoiceJour.InvoiceAccount && (custTable.CustGroup != "SCP" || custTable.CustGroup != "RMS" || custTable.CustGroup != "FAS")
exists join custInvoiceTrans
where custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
&& (custInvoiceTrans.ItemId like '101*' || custInvoiceTrans.ItemId like '201*' || custInvoiceTrans.ItemId like '301*' || custInvoiceTrans.ItemId like '251*')
{
customerFirstInvoiceDate.insert(custInvoiceJour.InvoiceAccount, custInvoiceJour.InvoiceDate);
}
The comment says that it returns the invoice date for each customer, but it doesn't. It returns a single record with the minimum invoice date regardless of the customer; the InvoiceAccount field will always be empty. You apparently meant to use the 'group by' clause with InvoiceAccount, but you didn't and you haven't tested your code at all.
You could easily see the problem if you walked through your code in the debugger.