@startuml
'https://plantuml.com/sequence-diagram

autonumber

actor User
participant "TransactionList" as TL
participant "UserInterface" as UI
participant ":AccountManager" as AM
participant ":Account" as AC
participant "EmptyArgumentException" as EAE
participant "InvalidIndexException" as IIE
User -> TL: removeTransaction [delete index]

alt input.trim().length() < DELETE_BEGIN_INDEX
    TL -> EAE: throw EmptyArgumentException
end
    TL -> TL: id = parseInt(data)
    alt id >= LOWER_BOUND and id < size
    TL -> AM: getAccountByAccountNumber(accountNumber)
        activate AM
        AM --> TL: :Account
        deactivate AM

        TL -> TL: get(id)
        TL -> TL: remove(id)

        TL -> AC: setBalance(newBalance)
        TL -> UI: <printDeleteMessage(itemRemoved, newBalance)>
        activate UI
        UI --> TL: Display delete confirmation message
        deactivate UI
        TL --> User: Confirmation message
    else
        TL -> IIE: throw InvalidIndexException
    end

@enduml
