Numeric tools do not all accept the same kind of evidence. I extracted differences among time, distance, replacement intervals and agreement modes into independent synthetic functions, publishing the complete implementation and tests.

The standard-library Python module connects to no roads, fuel-price feed, vehicle, ledger or payment service. The selector reads four saved local example results; it does not run Python or a server in the browser.

Four functions use different comparison bases

compare reads declared distance, fuel cost, other costs and driving, waiting, handling and rest time for two plans. reserve adds exact replacement-cost fractions and a monthly distance-based portion. measured_fuel requires caller confirmation of a common interval and separates total from non-driving fuel. waiting_quote combines observed time with a declared agreement to calculate a proposal.

Number bounds describe a small experiment rather than an industry standard or company operating limit. Before changing labels or adding inputs, establish which basis must remain valid. This is an inspectable calculation contract, not a complete transport management system or a substitute for reviewing actual source records.

Separate exact arithmetic from observed truth

Fraction preserves internal ratios. Small maintenance allocations are summed before target-distance multiplication and final rounding. Hourly comparisons use exact ratios while rounded values serve display. Inputs accept integers and bounded decimal strings, rejecting booleans and binary floating-point values to avoid ambiguous interpretation.

None of that certifies measurement accuracy. A trusted caller must confirm the fill basis, costs and agreement rates. A true confirmation flag remains an input, not an authenticated observation from a tank or receipt. Arithmetic consistency and evidence provenance require separate responsibilities, especially when precise-looking output might otherwise encourage unwarranted confidence.

Preserve unknown schedules and distinct agreements

Arrival and cutoff must appear together or remain absent together. Missing either plan’s schedule leaves the buffer comparison unknown. Civil dates are validated without guessing tomorrow; tests cover midnight and nonexistent days. This is one declared civil-calendar basis, not timezone conversion or traffic prediction. Known zero minutes and unknown remain different outcomes.

Proportional and started-unit waiting agreements are explicit alternatives. Inactive rate fields are rejected, tax is excluded and proposal_only remains true. The calculation neither determines entitlement or payment nor recommends replacement intervals or vehicle safety. Code retains these limits so a numeric result does not imply operational authority or a completed business outcome.

Explore the implementation

Complete independent synthetic implementation

"""Synthetic unit/basis calculations, not market rates or legal/vehicle advice."""
from fractions import Fraction
from decimal import Decimal,InvalidOperation
from datetime import datetime
import re

def number(value,minimum=0,maximum=10**9,places=2):
    if type(value) not in (str,int):raise ValueError('explicit numeric text or integer required')
    text=str(value)
    if len(text)>32 or not re.fullmatch(r'(?:0|[1-9][0-9]*)(?:\.[0-9]{1,'+str(places)+r'})?' if places else r'(?:0|[1-9][0-9]*)',text):raise ValueError('number format')
    try:result=Fraction(Decimal(text))
    except InvalidOperation:raise ValueError('number') from None
    if not minimum<=result<=maximum:raise ValueError('number range')
    return result

def whole(value,minimum=0,maximum=10**9):return int(number(value,minimum,maximum,0))
def rounded(value):
    sign=-1 if value<0 else 1;value=abs(value)
    return sign*((2*value.numerator+value.denominator)//(2*value.denominator))
def ratio(value):return {'numerator':value.numerator,'denominator':value.denominator}
def exact_keys(data,keys):
    if not isinstance(data,dict) or set(data)!=set(keys):raise ValueError('known fields required')
def label(value):
    if not isinstance(value,str) or not re.fullmatch(r'[A-Za-z0-9_-]{1,32}',value):raise ValueError('synthetic label')
    return value
def civil(value):
    if not isinstance(value,str) or not re.fullmatch(r'[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}',value):raise ValueError('civil date time')
    parsed=datetime.strptime(value,'%Y-%m-%dT%H:%M')
    if not 2000<=parsed.year<=2100:raise ValueError('year')
    return parsed

def plan(data):
    exact_keys(data,('revenue','loaded_km','empty_km','fuel_economy','fuel_price','toll','fee','other_cost','fixed_allocation','drive_minutes','wait_minutes','handling_minutes','rest_minutes','arrival','deadline'))
    distance=number(data['loaded_km'],0,100000)+number(data['empty_km'],0,100000)
    if distance<=0:raise ValueError('positive total distance')
    economy=number(data['fuel_economy'],Fraction(1,100),100)
    fuel=rounded(distance*whole(data['fuel_price'],1)/economy)
    costs=fuel+sum(whole(data[k]) for k in ('toll','fee','other_cost','fixed_allocation'))
    revenue=whole(data['revenue']);minutes=sum(whole(data[k],0,10080) for k in ('drive_minutes','wait_minutes','handling_minutes','rest_minutes'))
    if not 1<=minutes<=10080:raise ValueError('positive bounded total minutes')
    arrival,deadline=data['arrival'],data['deadline'];buffer=None
    if arrival is not None or deadline is not None:
        if arrival is None or deadline is None:raise ValueError('paired civil schedule')
        buffer=int((civil(deadline)-civil(arrival)).total_seconds()/60)
    residual=revenue-costs
    return {'revenue':revenue,'fuel_cost':fuel,'total_cost':costs,'residual':residual,'minutes':minutes,'hourly_residual':rounded(Fraction(residual*60,minutes)),'hourly_exact':ratio(Fraction(residual*60,minutes)),'schedule_buffer_minutes':buffer,'basis':'declared_inputs_only'}

def compare(a,b):
    a,b=plan(a),plan(b);ar,br=(Fraction(x['hourly_exact']['numerator'],x['hourly_exact']['denominator']) for x in (a,b))
    return {'a':a,'b':b,'residual_difference':a['residual']-b['residual'],'hourly_winner':'tie' if ar==br else ('a' if ar>br else 'b'),'schedule_buffer_difference':None if a['schedule_buffer_minutes'] is None or b['schedule_buffer_minutes'] is None else a['schedule_buffer_minutes']-b['schedule_buffer_minutes']}

def reserve(items,monthly_budget=None,monthly_distance=None,target_distance=1,basis='paid'):
    if not isinstance(items,list) or len(items)>12 or basis not in ('paid','supply'):raise ValueError('reserve contract')
    total=Fraction(0);seen=set()
    for item in items:
        exact_keys(item,('id','replacement_cost','interval_km'));key=label(item['id'])
        if key in seen:raise ValueError('duplicate reserve item')
        seen.add(key);total+=Fraction(whole(item['replacement_cost'],1),whole(item['interval_km'],1,10**7))
    if (monthly_budget is None)!=(monthly_distance is None):raise ValueError('paired monthly basis')
    periodic=total
    if monthly_budget is not None:total+=Fraction(whole(monthly_budget),whole(monthly_distance,1,10**7))
    if total<=0:raise ValueError('nonzero reserve basis')
    target=whole(target_distance,1,10**7)
    return {'periodic_exact':ratio(periodic),'total_per_km_exact':ratio(total),'target_reserve':rounded(total*target),'target_distance':target,'cost_basis':basis,'recommendation':False}

def measured_fuel(data):
    exact_keys(data,('start_km','end_km','liters','gross_cost','confirmed_deductions','non_driving_liters','same_fill_basis'))
    if data['same_fill_basis'] is not True:raise ValueError('measurement basis unconfirmed')
    distance=number(data['end_km'])-number(data['start_km']);liters=number(data['liters'],Fraction(1,100),100000);idle=number(data['non_driving_liters'],0,100000)
    gross=whole(data['gross_cost'],1);deductions=whole(data['confirmed_deductions'])
    if distance<=0 or idle>=liters or deductions>gross:raise ValueError('inconsistent measurement')
    return {'distance_exact':ratio(distance),'total_economy_exact':ratio(distance/liters),'adjusted_driving_economy_exact':ratio(distance/(liters-idle)) if idle else None,'net_cost':gross-deductions,'net_per_km':rounded(Fraction(gross-deductions)/distance),'basis_confirmed_by_caller':True,'vehicle_diagnosis':False}

def waiting_quote(data):
    keys=('start','end','excluded_minutes','free_minutes','mode','hourly_rate','unit_minutes','unit_rate','works','expenses');exact_keys(data,keys)
    elapsed=int((civil(data['end'])-civil(data['start'])).total_seconds()/60)
    excluded=whole(data['excluded_minutes'],0,10080);free=whole(data['free_minutes'],0,10080)
    if not 1<=elapsed<=10080 or excluded>elapsed:raise ValueError('time interval')
    billable=max(0,elapsed-excluded-free)
    if data['mode']=='proportional':
        if data['unit_minutes'] is not None or data['unit_rate'] is not None:raise ValueError('inactive rate fields')
        waiting=rounded(Fraction(billable*whole(data['hourly_rate']),60));units=None
    elif data['mode']=='started_unit':
        if data['hourly_rate'] is not None:raise ValueError('inactive rate fields')
        unit=whole(data['unit_minutes'],1,1440);units=(billable+unit-1)//unit;waiting=units*whole(data['unit_rate'])
    else:raise ValueError('declared agreement mode')
    extra=0
    for key in ('works','expenses'):
        rows=data[key]
        if not isinstance(rows,list) or len(rows)>5:raise ValueError('row bound')
        seen=set()
        for row in rows:
            exact_keys(row,('id','quantity','unit_price'));identity=label(row['id'])
            if identity in seen:raise ValueError('duplicate quote row')
            seen.add(identity);extra+=whole(row['quantity'],1,10000)*whole(row['unit_price'])
    return {'elapsed_minutes':elapsed,'observed_minutes':elapsed-excluded,'billable_minutes':billable,'billed_units':units,'waiting_amount':waiting,'extras':extra,'proposed_amount':waiting+extra,'proposal_only':True,'includes_tax':False,'entitlement_decided':False}

def synthetic_plan(**changes):
    return {**dict(revenue=1000,loaded_km=100,empty_km=0,fuel_economy=10,fuel_price=10,toll=0,fee=0,other_cost=0,fixed_allocation=0,drive_minutes=120,wait_minutes=0,handling_minutes=0,rest_minutes=0,arrival=None,deadline=None),**changes}
def synthetic_waiting(**changes):
    return {**dict(start='2026-10-21T09:00',end='2026-10-21T11:30',excluded_minutes=20,free_minutes=60,mode='proportional',hourly_rate=36,unit_minutes=None,unit_rate=None,works=[],expenses=[]),**changes}

Inspect actual local boundary checks

Twenty-four tests passed in the source folder and again after extracting the ZIP. Cases cover reversed revenue and hourly rankings, empty distance, waiting and rest, missing schedules, midnight, fraction aggregation, paired budgets, interval confirmation, deductions, agreement modes and extra rows. Input preservation is also checked. The selector contains fixed results from actual runs, not a visitor’s records.

No client application or customer browser was executed. There is no comparison with current market rates or actual vehicle measurements. Integrating a real screen still requires checks of wording, units, error placement and result presentation. A function rejecting an input is different evidence from a person understanding that rejection in a rendered interface.

Reads saved execution evidence; it does not run Python or a server in the browser.

Keep integration responsibilities after download

The ZIP includes full implementation, tests, runner, saved records and guidance. It is independent synthetic code with permission to modify and reuse. There are no dispatch sheets, original receipts, company contacts, accounts, persistent storage or transmission. Connecting new operational data remains separate from downloading the example.

Start adoption by agreeing on measurement intervals and cost boundaries, then inspect whether result names overstate them. The source tool and this narrower example are not identical: the fuel function accepts declared non-driving liters only, and the agreement function excludes tax. I share small reusable contracts with actual evidence rather than imply that every operational feature was transferred.

Download implementation, tests and examples
Independent synthetic code; modification and reuse permitted