Calculate average lead time for product supplier
On purchase product, user can define a lead time (or on the party) but it can be useful to verify that this lead time is close to what actually happen.
So the proposal is to calculate the average lead time based on the effective date of incoming stock moves and the purchase date for the last year.
For the stock move not yet done, if the planned date is in the future we use this one (as it will be calculated as the theoretical lead time) but if the planned date is in the past, we use the current date to already acknowledge the lateness.
I do not think we should weigh the average by the quantity as the configured lead time is neither.
The 1 year duration is only a default value for calculation that could be customized per product, supplier etc.
issue