Hi community!
I've found my self hitting a brick wall and hopefully some one out there can help....
I am trying to automate the calculation of debtor days. I have extracted the data which contains the posting narrative (invoice number), date and amount. Unfortunately the settlement is not always in the correct order and there are occasions where invoices are part settled. Here is an extract of the data:

I guess the first part is to match the Invoice number comment against the settlement of the same number, then work out the number of days?!
I'd be very grateful if anyone could point me in the right direction.
Thanks
Jonathan