Chuyển tới nội dung chính

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 − beginDay when 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:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 3No

Expected output:

FactorValue
DistanceHCM → Hanoi
Duration3 days (Jun 1, 2, 3)
AccommodationYes (spans more than one calendar day)

TC-02 — Single multi-day leg, with hotel​

Input:

LegRouteDatesHotel
AHCM → Da NangJun 5 – Jun 7Yes

Expected output:

FactorValue
DistanceHCM → Da Nang
Duration3 days (Jun 5, 6, 7)
AccommodationYes (hotel + multi-day)

TC-03 — Single same-day leg, no hotel​

Input:

LegRouteDatesHotel
AHCM → Vung TauJun 10 – Jun 10No

Expected output:

FactorValue
DistanceHCM → Vung Tau
Duration1 day (Jun 10)
AccommodationNo (single day, no hotel)

TC-04 — Single same-day leg, with hotel​

Input:

LegRouteDatesHotel
AHCM → Vung TauJun 10 – Jun 10Yes

Expected output:

FactorValue
DistanceHCM → Vung Tau
Duration1 day (Jun 10)
AccommodationYes (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:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 3No
BHanoi → Da NangJun 3 – Jun 5No

Handoff: A ends Jun 3, B begins Jun 3 → one connected chain.

Expected output (connected chain):

FactorValueWorking
Distance(HCM → Hanoi) + (Hanoi → Da Nang)Sum of consecutive hops
Duration5 daysA: 3 − 1 = 2 (hands Jun 3 to B) + B: 3 (Jun 3,4,5)
AccommodationYesChain spans Jun 1 → Jun 5 (multi-day)

TC-06 — Two legs handing off, hotel on one leg​

Input:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 3No
BHanoi → Da NangJun 3 – Jun 5Yes

Expected output (connected chain):

FactorValueWorking
Distance(HCM → Hanoi) + (Hanoi → Da Nang)Sum of consecutive hops
Duration5 daysA: 2 + B: 3
AccommodationYesHotel 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:

LegRouteDatesHotel
AHCM → Vung TauJun 5 – Jun 5No
BVung Tau → Da NangJun 5 – Jun 5Yes

Expected output (connected chain):

FactorValueWorking
Distance(HCM → Vung Tau) + (Vung Tau → Da Nang)Sum of consecutive hops
Duration1 dayA: 0 → 1 (guarded) + B: 1 − 1 = 0
AccommodationChain = Yes (B has hotel), but leg A is evaluated as NoSee 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:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 1No
BHanoi → Da NangJun 1 – Jun 1No
CDa Nang → Can ThoJun 1 – Jun 1No

Expected output (connected chain):

FactorValueWorking
DistanceSum of the three consecutive hops
Duration1 dayA: 1 + B: 0 + C: 0
AccommodationNoSingle 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:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 3No
BHanoi → Da NangJun 4 – Jun 6Yes

Expected output (two independent legs):

LegDistanceDurationAccommodation
AHCM → Hanoi3 daysYes (multi-day span, no hotel)
BHanoi → Da Nang3 daysYes (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:

LegRouteDatesHotel
AHCM → HanoiJun 1 – Jun 3No
BHCM → HanoiJun 10 – Jun 12Yes

Expected output (two independent legs):

LegDistanceDurationAccommodation
AHCM → Hanoi3 daysYes (multi-day span, no hotel)
BHCM → Hanoi3 daysYes (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:

TravellerLegRouteDatesHotel
AliceAHCM → HanoiJun 1 – Jun 3No
BobBDa Nang → HanoiJun 1 – Jun 3Yes

Expected output:

TravellerDistanceDurationAccommodation
AliceHCM → Hanoi3 daysYes (multi-day)
BobDa Nang → Hanoi3 daysYes (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:

TravellerLegRouteDatesHotel
AliceAHCM → HanoiJun 1 – Jun 4No
BobBHCM → Da NangJun 1 – Jun 3No

Expected output:

TravellerDistanceDurationAccommodation
AliceHCM → Hanoi4 daysYes (multi-day)
BobHCM → Da Nang3 daysYes (multi-day)

Same departure city, but different destinations → different distances → potentially different policy tiers. Calculated separately.


TC-14 — Two travellers, different dates entirely​

Input:

TravellerLegRouteDatesHotel
AliceAHCM → HanoiJun 1 – Jun 3No
BobBHCM → HanoiJun 10 – Jun 12No

Expected output:

TravellerDistanceDurationAccommodation
AliceHCM → Hanoi3 daysYes (multi-day)
BobHCM → Hanoi3 daysYes (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:

TravellerLegRouteDatesHotel
AliceAHCM → HanoiJun 1 – Jun 3No
AliceBHanoi → Da NangJun 3 – Jun 5No
BobCHCM → HanoiJun 1 – Jun 5Yes

Alice: A ends Jun 3, B begins Jun 3 → connected chain. Bob: single leg.

Expected output:

TravellerChain/LegDistanceDurationAccommodation
AliceA + B (chain)(HCM → Hanoi) + (Hanoi → Da Nang)5 daysYes (multi-day)
BobC (standalone)HCM → Hanoi5 daysYes (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​

TCTravellersLegsLinked?DurationAccommodation
TC-0111Standalone3 daysYes (multi-day)
TC-0211Standalone3 daysYes (hotel)
TC-0311Standalone1 dayNo
TC-0411Standalone1 dayYes (hotel)
TC-0512Chain (handoff)5 daysYes (multi-day)
TC-0612Chain (handoff)5 daysYes (hotel + multi-day)
TC-0712Chain (same day)1 dayChain Yes / leg A No ⚠️
TC-0813Chain (same day)1 dayNo
TC-0912Independent (adjacent)3 / 3 daysYes / Yes
TC-1012Independent3 / 3 daysYes / Yes
TC-1221 eachIndependent3 / 3 daysYes / Yes
TC-1321 eachIndependent4 / 3 daysYes / Yes
TC-1421 eachIndependent3 / 3 daysYes / Yes
TC-1522 / 1Chain / Standalone5 / 5 daysYes / Yes
TC-1610N/AN/AN/A