Discarding a visit
The user needs the option to discard a started visit and return the app to the state just before starting theat visit. That said we need to remove all the transactional data created and revert any changes to visit and tradersite.
Even though the above statement is true, due to difficaulties related to reverting the trader site photo we do not revert any changes to tradersite photo.
Discard

sequenceDiagram
actor User
participant ui as Mobile UI
participant db as Mobile DB
participant transactions as Transactions Tables
participant visit as Visit Tables
autonumber
User->>ui: Discarding a started visit
activate User
ui->>db: Fetch current open visit login and tradersite
alt currentVisitLogin is undefined
db->>ui: Failure message
else
activate db
db->>transactions: Deleting visit login data
activate transactions
Note over db,transactions: Deleting transaction master/details<br/>Deleting pricecollection documents/details<br/>Deleting unsynced trader site assets
transactions->>db: Success
deactivate transactions
db->>visit: Revert visit changes
activate visit
Note over db,visit: Revert trader site coordinates using visit bo lat/long<br/>Deleting visit login record and revert visit back to synced
visit->>db: Success
deactivate visit
db->>ui: Success message
deactivate db
end
ui->>User: Ok
deactivate User
