← Back to Hub|🗺 QA Flowchart — State Machine DesignDeliverable 02
Start / End / Success
Process Step
Decision / Validation Gate
Error / Failure State
Mitigation / Recovery Action
▶ STARTS0 — INITIAL STATE
LAYER 1 — UI / AUTHENTICATION
🔐 Finance Executive AuthenticationValidate Session & Role Permissions
Is User
Authenticated & Authorised?
YES
📋 Load Brand DropdownFetch available brands from DB
NO
⛔ Redirect to LoginS8 — ERROR
Brand
Selected?
YES → S1
📦 Load Outlets for Selected BrandS2 — OUTLETS LOADED
NO
⚠ "Please select a Brand"Inline Error — No API call
Outlets
Loaded Successfully?
YES
✏️ Finance Executive Enters Top-Up Per OutletS3 — TOP-UP ENTERED
NO
⚠ "Failed to load outlets"S8 — Offer retry button
LAYER 2 — BUSINESS LOGIC & VALIDATION
🔒 Finance Executive Clicks Submit
→ Submit button DISABLED immediately (prevent double-click TC26)
All Fields
Pass Validation?
YES
NO
⚠ Highlight invalid fields
Re-enable Submit buttonS8 | TC05–TC12
⚙ VALIDATION RULES CHECKED:
Empty fields | Negative values | Text/special chars | Zero total | Decimal precision | Overflow | Injection attempts
Total
Amount > 0 ?
YES → S4
NO
⚠ "Total must be > 0"
Re-enable SubmitTC07
🔑 Generate Unique Transaction IDS4 — VALIDATED | Idempotency Key Assigned
🗺 Validate Outlet → Company MappingConfirm mapping before any write | TC29, TC30
LAYER 3 — QUICKBOOKS API INTEGRATION
📡 Call QuickBooks API
→ Send: Transaction ID, Brand, Total, Client Info, Item Lines per Company
QuickBooks
API Available?
YES
NO / TIMEOUT
🔁 Retry Logic
Attempt 1 → Wait 2s
Attempt 2 → Wait 5s
Attempt 3 → Wait 10sTC13, TC14
❌ IF ALL 3 RETRIES FAIL:
Abort entire flow → No email sent → No SMS credit applied → Admin alert triggered → User shown error with Transaction ID
Duplicate
Transaction ID Exists?
YES — DUPLICATE
↩ Return existing Quotation ID
Do NOT create new invoiceTC16 — Idempotency
NO — UNIQUE
Quotation
Created Successfully?
YES → S5
NO
⛔ Abort Flow
Log error + Transaction ID
Do NOT credit SMSS8 | TC15
LAYER 4 — EMAIL SERVICE (NON-BLOCKING)
📧 Trigger Email to Client
→ Fetch client email from QuickBooks record → Build email with quotation details
Email
Sent Successfully?
YES → S6
NO
⚠ Log failure
Add to retry queue
Notify Finance Executive
→ CONTINUE to Credit StepTC18, TC19 — NON-BLOCKING
LAYER 5 — DATABASE / SMS CREDIT WRITE
🗄 Open Atomic DB TransactionBEGIN TRANSACTION — All writes or none
💳 Write SMS Credits Per CompanyS7 — Company A: +X | Company B: +Y | Company N: +Z
🔒 CONCURRENCY PROTECTION (TC27):
Row-level locking (SELECT FOR UPDATE) on company credit records prevents race conditions during simultaneous multi-user submission.
All Credit
Writes Succeeded?
YES → S7
NO
🔄 ROLLBACK TRIGGERED
Reverse ALL credit writes
Restore pre-transaction state
Log: Status = ROLLED_BACK + Tx ID
TC21 | TC22 | TC23 | TC25
✅ COMMIT Transaction
→ Write audit log entry with Tx ID, user, amounts, timestamp, status=SUCCESS
🔓 Re-enable Submit ButtonAllow new submission — TC26 protection lifted
✅ SUCCESSS9 — Display Transaction ID + Summary to Finance Executive
⏹ ENDTRANSACTION COMPLETE
STATE TRANSITION QUICK REFERENCE
State Name Valid Next Error Next Key Test Cases
S0 Initial S1 S8 TC04
S1 Brand Selected S2 S8 TC04
S2 Outlets Loaded S3 S8 TC30
S3 Top-Up Entered S4 S8 TC05–TC12
S4 Validated + Tx ID S5 S8 TC06, TC07, TC09
S5 Quotation Created S6 S8 TC13–TC17
S6 Email Sent S7 S8* (non-blocking) TC18, TC19, TC20
S7 SMS Credited S9 S8 + ROLLBACK TC21–TC25
S8 Error State Terminal (re-enable form) All error TCs
S9 Success Terminal TC01, TC02, TC03
GoSMS QA Test Plan — Flowchart & State Reference | MikeTango / QuickBooks Integration | Sourav — Mulah Technologies, Malaysia