Topic: delivery has been invoiced, but there is no invoice

Today I was creating a direct sales invoice.  I got an error 1406 or something about data too long, so I chased that down and updated the column field in the sales_orders table from tinytext to mediumtext.  when I processed the invoice, it actually came up to the sales order screen saying that the sales order had been processed.  So from there I decided to make a delivery, and got the same error which I fixed by changing the memo_ column in the comments table from tinytext to mediumtext.  After that I was able to process the dispatch, but when I went from there to generate the invoice I got the following error in the red bar:

Undefined index: debtor_no in file: /var/www/fa.computerisms.ca/sales/includes/sales_db.inc at line 282

along with the message

This delivery has all items invoiced. There is nothing to modify.

If I go to print the invoice it doesn't exist, if I go to customer payments, the invoice is not listed to be paid; there is no place I can find the invoice exists, but items have been removed from inventory.  Additionally, if I go to print the delivery, all I get is the comments, none of the items are listed. 

This particular invoice had about a dozen line items, but I sent out about a dozen of them prior that had one or two line items with no problems.

Does anyone have any idea how I can fix this without undoing the whole day's work by restoring from backup?

Re: delivery has been invoiced, but there is no invoice

I voided the delivery note, that restored inventory.  I could/can not void or cancel the sales order, canceling the order says it cancels undelivered parts, but the whole order is still listed.  But redid the invoice as a direct invoice and it worked this time.  crisis averted.