Tracking real stock of expired items

any retail business needs to add expiry date while adding purchase recipiant

and tracking expiry item stock which gone or stay

the normal way is by using batch

but there is no autobatch creation when add expiry date only
and we cant add batch expiry date directly from purchase recipant

hoping to add child table inside child table
or autocreation of batch by adding only expiry dates
in purchase

i just need to add expiry date in purchase recipeant
so i can track the real expiry stock by batch wise stock

any help

the only Solution I found is by adding batch and expiry in pop up screen which is time consuming

any one can help to add batch expiry only in purchase recipiant item child table
and appear in batch wise stock report

any help here

I think you need to customize the “Purchase Receipt Item” doctype where you can add “Expiry Date”.

Then you can create a Server Script for “After Submit” event of the Purchase Receipt.

Script:

for item in doc.items:
    docBatch = frappe.get_doc("Batch", item.batch_id
    docBatch.expiry_date = item.expiry_date
    docBatch.save()

unfortunately. not work. its add shelf life. as expiry date
I add expiry date field in doc
but after submit
the system use shelf life as expiry end