I am creating sales order, so i need to select in sales line item from the LotNo which will expire first[ie. which LotNo 'expiration date is near']. It should be automatic. How can i proceed this; whether i should try with codeunit or should create a button in sales order page.
eg. ItemNo LotNo Expiration-Date Quantity
100 lot1 7/2/2021 10
100 lot2 7/1/2021 20
So, if i am selecting in sales line, itemno:100, with quantity:15; then it should take automatic from lotno: lot2, which will expire first.
[if i need 25, then first it should take 20 quantity from lot2 and 5 quantity from lot1]
please guide me to proceed.
Thanks in advance,