Same product - trying to configure different purchase prices per each lot and different warehouse entry number

Greetings.
I am trying to configure and play with dolibarr on an obscure, huge computing system from the 1970s - to test and evaluate its security.

I am trying to configure the following problem:
For example let’s say I do business with apples, cucumbers, tomatoes, all sort of vegetables, so I defined two products in my warehouse:
Apples, onions, tomatoes:

  • 4 Kg of each - purchased three days ago, price 0.5 euros/Kg (0.53, 0.52), sell price is 0.6 euros/Kg (0.61, 0.59), the bill (“facture”) serial number which confirms the payment - is 122, the Receiving Entry number assigned when these three products transport (4 Kg each) arrived in the warehouse is “631”;
  • 12 Kg of each product purchased two days ago, purchase price 0.53 euros/Kg (0.51, 0.48), sell price is 0.61 euros/Kg (0.59, 0.62), facture serial number 131, Receiving Entry number assigned when they were admitted in the warehouse - 633;
  • 3 Kg, purchased today, 0.48 euros/Kg (and some other prices for the rest), sell price 0.59 eur/kg (and two other prices), facture serial number 136, warehouse entry number assigned was 635;

Cucumbers, coconuts, cat food, bird seed, apricots and some milk: same scenario, receiving entry numbers were 632, 634, 637 and 641: the number gets bigger when the warehouse arrival date is closer to the present.

My question is: how may I implement this?

  • I have been trying to manually increase stock for the same product, but the system is unable to keep the purchase price for each entry. The purchase price stays the same as defined when the product was entered;

  • I have been trying to define attributes in stocks, products and product lots, but I can not track them by any attribute where I can input the ‘warehouse receive entry number’;

To minimize loss (apples and cucumbers have a limited time before they are no longer suitable to eat), first I have to sell the apples and cucumbers with the lower receiving entry numbers. Also, this receiving entry is used to track what other products came on the same bill (facture);

Do I always have to input a new product (Apple) with the same parameters (many: purchase price, sell price 1, sell price 2, dimensions, weight, color, special note for storage conditions) each time, and only the “warehouse receiving entry number” and “purchase price” differ?
Example: Apple-631, Apple-633, Apple-635, Cat_food-641
Or is there any other procedure I am unable to identify?

Please advise.

Thank you.