Auto Document Number based on Dropdown Input

Auto Document Number based on Dropdown Input

Hi Guys, 

I am a newbie and I am trying to automate document numbering based on user input from a dropdown or lookup input. For now, I used a long dropdown list and was following some youtube videos to create this code. 
The code seems to work, but it keeps running and doesn't stop.
It is a single form with two fields, the type of journey and the document code, based on the journey made, it will create a corresponding code. Now there can be many journey types and I was each to have a unique code that accumulates. 

Below is the code: 

LastJourney = Cargo_Manifest[Journey == input.Journey] sort by Added_Time DESC;
if(input.Journey == "BI-TIL")
{
input.Journey = "BI-TIL";
}
else if(input.Journey == "BI-NGY")
{
input.Journey = "BI-NGY";
}
else if(input.Journey == "BI-BCV")
{
input.Journey = "BI-BCV";
}
else if(input.Journey == "BI-VND")
{
input.Journey = "BI-VND";
}
else if(input.Journey == "BI-ELS")
{
input.Journey = "BI-ELS";
}
else
{
input.Journey = "BI-TCZ";
}
if(LastJourney.count(Manifest_Code) > 0)
{
getlstnmb = LastJourney.Manifest_Code.getsuffix("-");
getnumber = getlstnmb.getsuffix("-");
newNumber = getnumber.toNumber() + 1;
input.Manifest_Code = input.Journey + "-" + newNumber;
}
else
{
input.Manifest_Code = input.Journey + "-" + 1;
}

Thanks a lot for any help and sorry for any bother. 
thanks 
Richard