While automatically selecting batch numbers for outgoing items, the code is checking for current date to get non-expired batch numbers. This holds good only if the outgoig items are recorded for current date.
For eg, I have 2 batches for items as below -
Batch 1 - expiring on 25-Feb
Batch 2 - expiring on 31-Mar
Today’ date - 01-Mar.
If I submit a sales invoice with today’s date, Batch 2 should be selected. And I edit the posting date and submit a sales invoice for a past date such as 20-Feb, then the Batch 1 should be selected.
But since the CURDATE() is hardcoded in the function get_batches() - the batches that were active at the time of posting_date of the sales invoice will not get selected. I think this is a big issue.
The same applies for other outgoing transactions such as delivery note and stock entry.
Proposal: The posting date of the parent transaction should be considered while selecting the batches.