We are creating a custom autonumber in the custom invoice object. For this, we used the Before insert event in the apex trigger. So the user will generate bulk invoices based on the term for all the college students on monthly basis.
The issue is when two or three administrative SF users generate the invoices at the same time the logic creates duplicate autonumbers numbers for the invoices.
Based on the requirement, we have defined some logic to identify the last number, current month, current year and College name and then, concatenated these values to create a custom invoice autonumber.