Automatic lots calculation