VCB — Expense Calculation Test Cases
Test cases for verifying the computed values: Distance, Duration, and Accommodation.
The policy tier is selected from Distance + Accommodation only. Duration does not affect tier selection — it is applied afterward as a multiplier on the per-unit rate.
Model reminder: A traveller's legs are sequential and do not overlap in date range. Two legs are linked into a connected chain only when one leg ends on the same calendar day the next leg begins (same-day handoff). Legs that are merely adjacent (end the day before the next begins) are not linked.
Accommodation rule: a leg / chain is treated as having accommodation if a leg has a hotel booking or the chain spans more than one calendar day. Only a single-calendar-day leg with no hotel is
No.
Duration rule: within a chain a handoff day is counted once — each leg contributes
endDay − beginDaywhen it hands off to the next leg, and the final leg contributes its full inclusive day count.
Group 1 — Single Leg (Standalone)
A standalone leg has no same-day handoff with another leg and is evaluated directly.
TC-01 — Single multi-day leg, no hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 3 | No |
Expected output:
| Factor | Value |
|---|---|
| Distance | HCM → Hanoi |
| Duration | 3 days (Jun 1, 2, 3) |
| Accommodation | Yes (spans more than one calendar day) |
TC-02 — Single multi-day leg, with hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Da Nang | Jun 5 – Jun 7 | Yes |
Expected output:
| Factor | Value |
|---|---|
| Distance | HCM → Da Nang |
| Duration | 3 days (Jun 5, 6, 7) |
| Accommodation | Yes (hotel + multi-day) |
TC-03 — Single same-day leg, no hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Vung Tau | Jun 10 – Jun 10 | No |
Expected output:
| Factor | Value |
|---|---|
| Distance | HCM → Vung Tau |
| Duration | 1 day (Jun 10) |
| Accommodation | No (single day, no hotel) |
TC-04 — Single same-day leg, with hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Vung Tau | Jun 10 – Jun 10 | Yes |
Expected output:
| Factor | Value |
|---|---|
| Distance | HCM → Vung Tau |
| Duration | 1 day (Jun 10) |
| Accommodation | Yes (hotel) |
Group 2 — Connected Chains (Same-Day Handoff)
Consecutive legs where one leg ends on the same calendar day the next begins.
TC-05 — Two legs handing off on the shared day, no hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| B | Hanoi → Da Nang | Jun 3 – Jun 5 | No |
Handoff: A ends Jun 3, B begins Jun 3 → one connected chain.
Expected output (connected chain):
| Factor | Value | Working |
|---|---|---|
| Distance | (HCM → Hanoi) + (Hanoi → Da Nang) | Sum of consecutive hops |
| Duration | 5 days | A: 3 − 1 = 2 (hands Jun 3 to B) + B: 3 (Jun 3,4,5) |
| Accommodation | Yes | Chain spans Jun 1 → Jun 5 (multi-day) |
TC-06 — Two legs handing off, hotel on one leg
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| B | Hanoi → Da Nang | Jun 3 – Jun 5 | Yes |
Expected output (connected chain):
| Factor | Value | Working |
|---|---|---|
| Distance | (HCM → Hanoi) + (Hanoi → Da Nang) | Sum of consecutive hops |
| Duration | 5 days | A: 2 + B: 3 |
| Accommodation | Yes | Hotel on B + multi-day chain |
TC-07 — Same-day stacked legs, hotel on later leg (known limitation)
Both legs occur on the same calendar day, with a same-day handoff.
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Vung Tau | Jun 5 – Jun 5 | No |
| B | Vung Tau → Da Nang | Jun 5 – Jun 5 | Yes |
Expected output (connected chain):
| Factor | Value | Working |
|---|---|---|
| Distance | (HCM → Vung Tau) + (Vung Tau → Da Nang) | Sum of consecutive hops |
| Duration | 1 day | A: 0 → 1 (guarded) + B: 1 − 1 = 0 |
| Accommodation | Chain = Yes (B has hotel), but leg A is evaluated as No | See limitation below |
Known limitation: Accommodation is evaluated per leg. The chain is single-calendar-day, so the multi-day rule does not apply, and the hotel on leg B is not propagated to leg A. Leg A therefore selects its tier with
accommodation = No. Because leg A also carries the only non-zero duration (1 day; B contributes 0), the chain is effectively billed at leg A's no-accommodation tier. If the hotel should drive the whole chain's accommodation, this is a code gap to fix.
TC-08 — Multiple same-day legs, no hotel
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 1 | No |
| B | Hanoi → Da Nang | Jun 1 – Jun 1 | No |
| C | Da Nang → Can Tho | Jun 1 – Jun 1 | No |
Expected output (connected chain):
| Factor | Value | Working |
|---|---|---|
| Distance | Sum of the three consecutive hops | |
| Duration | 1 day | A: 1 + B: 0 + C: 0 |
| Accommodation | No | Single calendar day, no hotel |
Group 3 — Independent Legs (No Same-Day Handoff)
Legs that do not share a handoff day are evaluated separately.
TC-09 — Adjacent legs (end the day before the next begins)
A ends Jun 3; B begins Jun 4 — no shared day → not linked.
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| B | Hanoi → Da Nang | Jun 4 – Jun 6 | Yes |
Expected output (two independent legs):
| Leg | Distance | Duration | Accommodation |
|---|---|---|---|
| A | HCM → Hanoi | 3 days | Yes (multi-day span, no hotel) |
| B | Hanoi → Da Nang | 3 days | Yes (hotel) |
No linking occurs. Each leg is evaluated separately.
TC-10 — Same route, different dates, no handoff
Same route, non-adjacent dates → not linked. Each leg is evaluated independently.
Input:
| Leg | Route | Dates | Hotel |
|---|---|---|---|
| A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| B | HCM → Hanoi | Jun 10 – Jun 12 | Yes |
Expected output (two independent legs):
| Leg | Distance | Duration | Accommodation |
|---|---|---|---|
| A | HCM → Hanoi | 3 days | Yes (multi-day span, no hotel) |
| B | HCM → Hanoi | 3 days | Yes (hotel) |
Group 4 — Multiple Travellers on the Same Trip
Travellers on the same trip are calculated completely independently. They may have different departure cities, different destinations, different dates, and different hotels. None of these differences affect each other's calculation.
TC-12 — Two travellers, different origins, same destination, same dates
Input:
| Traveller | Leg | Route | Dates | Hotel |
|---|---|---|---|---|
| Alice | A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| Bob | B | Da Nang → Hanoi | Jun 1 – Jun 3 | Yes |
Expected output:
| Traveller | Distance | Duration | Accommodation |
|---|---|---|---|
| Alice | HCM → Hanoi | 3 days | Yes (multi-day) |
| Bob | Da Nang → Hanoi | 3 days | Yes (hotel + multi-day) |
Alice and Bob travel to the same destination on the same dates but are evaluated independently. Bob's hotel has no effect on Alice's accommodation factor, and the different distances mean they may land on different policy tiers.
TC-13 — Two travellers, same origin, different destinations
Input:
| Traveller | Leg | Route | Dates | Hotel |
|---|---|---|---|---|
| Alice | A | HCM → Hanoi | Jun 1 – Jun 4 | No |
| Bob | B | HCM → Da Nang | Jun 1 – Jun 3 | No |
Expected output:
| Traveller | Distance | Duration | Accommodation |
|---|---|---|---|
| Alice | HCM → Hanoi | 4 days | Yes (multi-day) |
| Bob | HCM → Da Nang | 3 days | Yes (multi-day) |
Same departure city, but different destinations → different distances → potentially different policy tiers. Calculated separately.
TC-14 — Two travellers, different dates entirely
Input:
| Traveller | Leg | Route | Dates | Hotel |
|---|---|---|---|---|
| Alice | A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| Bob | B | HCM → Hanoi | Jun 10 – Jun 12 | No |
Expected output:
| Traveller | Distance | Duration | Accommodation |
|---|---|---|---|
| Alice | HCM → Hanoi | 3 days | Yes (multi-day) |
| Bob | HCM → Hanoi | 3 days | Yes (multi-day) |
Same route but different travel dates. Each is evaluated on their own leg independently.
TC-15 — Two travellers, one has a connected chain, the other has a standalone leg
Input:
| Traveller | Leg | Route | Dates | Hotel |
|---|---|---|---|---|
| Alice | A | HCM → Hanoi | Jun 1 – Jun 3 | No |
| Alice | B | Hanoi → Da Nang | Jun 3 – Jun 5 | No |
| Bob | C | HCM → Hanoi | Jun 1 – Jun 5 | Yes |
Alice: A ends Jun 3, B begins Jun 3 → connected chain. Bob: single leg.
Expected output:
| Traveller | Chain/Leg | Distance | Duration | Accommodation |
|---|---|---|---|---|
| Alice | A + B (chain) | (HCM → Hanoi) + (Hanoi → Da Nang) | 5 days | Yes (multi-day) |
| Bob | C (standalone) | HCM → Hanoi | 5 days | Yes (hotel + multi-day) |
Alice's chain and Bob's standalone leg are evaluated entirely separately. Alice's distance includes both hops; Bob's is the direct HCM → Hanoi distance.
Group 5 — Edge Cases
TC-16 — Single traveller, no legs
Input: No legs assigned.
Expected output: No calculation performed. No expense applied.
Summary Table
| TC | Travellers | Legs | Linked? | Duration | Accommodation |
|---|---|---|---|---|---|
| TC-01 | 1 | 1 | Standalone | 3 days | Yes (multi-day) |
| TC-02 | 1 | 1 | Standalone | 3 days | Yes (hotel) |
| TC-03 | 1 | 1 | Standalone | 1 day | No |
| TC-04 | 1 | 1 | Standalone | 1 day | Yes (hotel) |
| TC-05 | 1 | 2 | Chain (handoff) | 5 days | Yes (multi-day) |
| TC-06 | 1 | 2 | Chain (handoff) | 5 days | Yes (hotel + multi-day) |
| TC-07 | 1 | 2 | Chain (same day) | 1 day | Chain Yes / leg A No ⚠️ |
| TC-08 | 1 | 3 | Chain (same day) | 1 day | No |
| TC-09 | 1 | 2 | Independent (adjacent) | 3 / 3 days | Yes / Yes |
| TC-10 | 1 | 2 | Independent | 3 / 3 days | Yes / Yes |
| TC-12 | 2 | 1 each | Independent | 3 / 3 days | Yes / Yes |
| TC-13 | 2 | 1 each | Independent | 4 / 3 days | Yes / Yes |
| TC-14 | 2 | 1 each | Independent | 3 / 3 days | Yes / Yes |
| TC-15 | 2 | 2 / 1 | Chain / Standalone | 5 / 5 days | Yes / Yes |
| TC-16 | 1 | 0 | N/A | N/A | N/A |