Hello Nicolas!
Thanks for clarifying. Before Philip's answer I wasn't shure where to look (I'm not exactly a programmer) but I'm starting to understand the problem.
Of course, the dates were not really "random", but we have not been able to see a pattern until Philip pointed out the php-customizations. We are a small company and do most of the work ourselves, but we had help with the set-up and don't know about all the details.
Indeed, some of the "invoices" have been printed before payment and have subsequently been showing the "correct" date for our purposes. I checked and in those cases where customers payed later (e.g. via bank transaction) the dates have been wrong on the re-prints, like you pointed out.
To put matters in simple words: For our needs, the "invoice" needs to show the date of the creation of the order, regardless of any payments, changes in the order status or anything else and should therefore always correspond with the "order created" date.
1) We receive an order
2) We print the delivery note and invoice twice - one for the customer (shipment), one for the books
3) When payment arrives, we send the shipment from our outbox.
Paypal arrives instantly and auto-changes the order status to 'payed', cash payments and bank transactions have to be set manually. In these cases the date of the invoice should also be the order_created date. Does our primitive work-around do the trick?
Thanks guys!