fix in inventories   if (inventory != null && inventory.StocktakeQuantity.HasValue) // inventory.StocktakeQuantity.HasValue it is not auto generated