moonbit-freight-calculator

    A MoonBit freight billing rule engine for parcel logistics.

    freight
    billing
    logistics
    tariff
    calculator
    Download zip
    Version
    0.2.0
    License
    MIT
    Last updated
    2 months ago
    Downloads
    39

    No dependencies

    #moonbit-freight-calculator

    Typed, deterministic freight-rating primitives for MoonBit applications. The library turns parcel dimensions, weight, route, tariff bands, and surcharges into an auditable quote made of exact integer-cent charge lines.

    #Core capabilities

    • Actual-versus-dimensional weight using configurable divisors.
    • First-weight and incremental-weight ladder pricing.
    • Zone multipliers, remote-area fees, overweight and oversize surcharges.
    • Fuel and declared-value insurance charges with minimum-charge protection.
    • Exact Money arithmetic, configurable rounding, discount stacks, and tax basis calculation.
    • Route selection, service metadata, manifest totals, and weight outlier analysis.
    • Tariff candidate composition with applicability predicates and decision traces.
    • Settlement invoices, payment allocation, balance states, and manifest reconciliation.
    • Business-calendar SLA deadlines, customs duty summaries, bulk-job state transitions, and auditable policy analyzers.
    • Built-in domestic, regional, international, and returns weight-band catalogs.
    • CLI demo and a deterministic benchmark with a checksum.

    #Quick start

    moon check --target all moon test --target all moon run cmd/main

    ///|
    test {
    let rule = standard_rule()
    let parcel = parcel_dim(width_cm=42, height_cm=30, depth_cm=24, weight_g=2600)
    let result = quote(rule, parcel, "regional", Money::yuan(300))
    inspect(result.summary(), content="billable=5040g total=CNY 61.03 lines=5")
    }

    #CLI

    The example CLI quotes the checked-in sample manifest:

    moon run cmd/main

    It prints one manifest total followed by an auditable summary for each parcel. The library itself is pure and can be embedded without the CLI package.

    #Architecture

    types.mbt public domain types money*.mbt exact money and rounding operations parcel*.mbt dimensional weight and parcel profiling rules.mbt / audit*.mbt tariff construction and validation engine.mbt quote and manifest calculation discounts.mbt / taxes.mbt adjustments and tax basis routing.mbt origin/destination lane resolution catalog*.mbt operational weight-band tables manifest_analytics.mbt manifest-level operational metrics tariff_composition.mbt candidate selection and decision traces settlement_*.mbt invoice, payment, and reconciliation workflows sla_calendar.mbt business-day and service-window deadlines customs_engine.mbt duty, insurance, and declared-value totals bulk_pipeline.mbt deterministic bulk-job transitions *_policy.mbt auditable operational policy analyzers cmd/main runnable example benchmarks deterministic performance smoke benchmark

    Public concrete types live in the root package. Files are organizational units; package boundaries are defined by moon.pkg.

    #Production source inventory

    The repository contains 31,727 non-test MoonBit source lines. Of these, 15,660 lines are non-catalog production logic and 16,067 lines are typed, compiled rate-catalog data. The catalog lines are reported separately because they are operational data tables rather than algorithmic implementation; both sets are compiled and exercised by the package. Counts exclude tests, build artifacts, and generated output.

    #Benchmark

    Run the real quote engine over the checked-in manifest 1,000 times:

    moon run benchmarks

    The reproducible checksum is items=3000 total=CNY 269930.00. On the validation host (Windows, MoonBit 0.1.20260807, wasm-gc target), three command runs were 588.49 ms, 151.44 ms, and 154.74 ms; the median was 154.74 ms for 3,000 quote operations, or approximately 19,387 operations per second. Wall-clock results are host-dependent; see docs/benchmarks.md.

    #Testing and CI

    Local validation:

    moon fmt --check moon check --deny-warn --target all moon info moon test --deny-warn --target all moon test --deny-warn --target native --enable-coverage moon coverage report -f summary

    GitHub Actions runs the same quality gates on Ubuntu, macOS, and Windows. It installs the current stable MoonBit toolchain, checks all backends, verifies formatting and generated interfaces, runs tests with coverage, and executes the native test target.

    #License

    MIT. See LICENSE.

    AuditEvent

    pub struct AuditEvent {
    sequence : Int
    code : String
    detail : String
    amount : Money
    } derive(Eq, ToJson,
    Debug
    )

    BalanceState

    pub(all) enum BalanceState {
    Unpaid
    PartiallyPaid
    Paid
    Overpaid
    } derive(Eq, ToJson,
    Debug
    )

    BalanceState::is_terminal

    fn BalanceState::is_terminal(self : BalanceState) -> Bool

    BillingRule

    pub struct BillingRule {
    volumetric_divisor : Int
    first_weight_limit_g : Int
    first_weight_rate : Money
    additional_weight_unit_g : Int
    additional_weight_rate : Money
    min_charge : Money
    zones : Array[ZoneRate]
    surcharge : SurchargePolicy
    } derive(Eq, ToJson,
    Debug
    )

    BillingRule::zone_rate

    fn BillingRule::zone_rate(self : BillingRule, zone : String) -> ZoneRate

    BulkJob

    pub struct BulkJob {
    id : String
    state : JobState
    item_count : Int
    completed : Int
    failed : Int
    attempts : Int
    } derive(Eq, ToJson,
    Debug
    )

    BulkJob::is_terminal

    fn BulkJob::is_terminal(self : BulkJob) -> Bool

    BulkJob::progress_bp

    fn BulkJob::progress_bp(self : BulkJob) -> Int

    BulkJob::remaining

    fn BulkJob::remaining(self : BulkJob) -> Int

    BusinessCalendar

    pub struct BusinessCalendar {
    weekend_days : Array[Int]
    holidays : Array[Int]
    cutoff_hour : Int
    } derive(Eq, ToJson,
    Debug
    )

    BusinessCalendar::holiday_count

    fn BusinessCalendar::holiday_count(self : BusinessCalendar) -> Int

    BusinessCalendar::is_valid

    fn BusinessCalendar::is_valid(self : BusinessCalendar) -> Bool

    BusinessCalendar::weekend_count

    fn BusinessCalendar::weekend_count(self : BusinessCalendar) -> Int

    BusinessCalendar::working_days_between

    fn BusinessCalendar::working_days_between(self : BusinessCalendar, start_day : Int, end_day : Int) -> Int

    ChargeLine

    pub enum ChargeLine {
    Base(weight_g~ : Int, Money)
    Additional(units~ : Int, Money)
    Zone(zone~ : String, multiplier_bp~ : Int, Money)
    Remote(zone~ : String, Money)
    Overweight(limit_g~ : Int, Money)
    Oversize(limit_cm~ : Int, Money)
    Fuel(percent_bp~ : Int, Money)
    Insurance(percent_bp~ : Int, declared_value~ : Money, Money)
    Minimum(Money)
    } derive(Eq, ToJson,
    Debug
    )

    ConfigDiagnostic

    pub struct ConfigDiagnostic {
    code : String
    severity : DiagnosticSeverity
    field : String
    message : String
    } derive(Eq, ToJson,
    Debug
    )

    ConfigDiagnostic::is_blocking

    fn ConfigDiagnostic::is_blocking(self : ConfigDiagnostic) -> Bool

    ConfigDiagnostic::summary

    fn ConfigDiagnostic::summary(self : ConfigDiagnostic) -> String

    CustomsLine

    pub struct CustomsLine {
    code : String
    declared_value : Money
    duty_bp : Int
    insurance_bp : Int
    } derive(Eq, ToJson,
    Debug
    )

    CustomsLine::is_valid

    fn CustomsLine::is_valid(self : CustomsLine) -> Bool

    CustomsSummary

    pub struct CustomsSummary {
    declared_value : Money
    duty : Money
    insurance : Money
    total : Money
    } derive(Eq, ToJson,
    Debug
    )

    CustomsSummary::effective_duty_bp

    fn CustomsSummary::effective_duty_bp(self : CustomsSummary) -> Int

    CustomsSummary::is_empty

    fn CustomsSummary::is_empty(self : CustomsSummary) -> Bool

    DecisionTrace

    pub struct DecisionTrace {
    selected : String
    considered : Int
    rejected : Array[String]
    reasons : Array[String]
    } derive(Eq, ToJson,
    Debug
    )

    DecisionTrace::explanation

    fn DecisionTrace::explanation(self : DecisionTrace) -> String

    DecisionTrace::has_selection

    fn DecisionTrace::has_selection(self : DecisionTrace) -> Bool

    DecisionTrace::rejection_count

    fn DecisionTrace::rejection_count(self : DecisionTrace) -> Int

    DiagnosticSeverity

    pub enum DiagnosticSeverity {
    Info
    Warning
    Error
    } derive(Eq, ToJson,
    Debug
    )

    DiscountResult

    pub struct DiscountResult {
    original : Money
    discount : Money
    payable : Money
    applied : Array[String]
    } derive(Eq, ToJson,
    Debug
    )

    DiscountResult::effective_rate_bp

    fn DiscountResult::effective_rate_bp(self : DiscountResult) -> Int

    DiscountRule

    pub struct DiscountRule {
    code : String
    percent_bp : Int
    cap : Money
    } derive(Eq, ToJson,
    Debug
    )

    DiscountRule::valid

    fn DiscountRule::valid(self : DiscountRule) -> Bool

    Invoice

    pub struct Invoice {
    id : String
    lines : Array[SettlementLine]
    tax : Money
    paid : Money
    } derive(Eq, ToJson,
    Debug
    )

    Invoice::is_closed

    fn Invoice::is_closed(self : Invoice) -> Bool

    Invoice::line_count

    fn Invoice::line_count(self : Invoice) -> Int

    Invoice::taxable_subtotal

    fn Invoice::taxable_subtotal(self : Invoice) -> Money

    JobState

    pub(all) enum JobState {
    Queued
    Running
    Succeeded
    Failed
    Retrying
    } derive(Eq, ToJson,
    Debug
    )

    Lane

    pub struct Lane {
    origin : String
    destination : String
    zone : String
    transit_days : Int
    } derive(Eq, ToJson,
    Debug
    )

    Lane::is_valid

    fn Lane::is_valid(self : Lane) -> Bool

    Lane::key

    fn Lane::key(self : Lane) -> String

    ManifestItem

    pub struct ManifestItem {
    tracking_no : String
    zone : String
    parcel : ParcelDim
    declared_value : Money
    } derive(Eq, ToJson,
    Debug
    )

    ManifestQuote

    pub struct ManifestQuote {
    items : Array[Quote]
    total : Money
    } derive(Eq, ToJson,
    Debug
    )

    ManifestQuote::summary

    fn ManifestQuote::summary(self : ManifestQuote) -> String

    ManifestSummary

    pub struct ManifestSummary {
    count : Int
    total_weight_g : Int
    average_weight_g : Int
    max_weight_g : Int
    min_weight_g : Int
    outlier_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    ManifestSummary::average_kg

    fn ManifestSummary::average_kg(self : ManifestSummary) -> Int

    ManifestSummary::is_empty

    fn ManifestSummary::is_empty(self : ManifestSummary) -> Bool

    ManifestSummary::weight_range

    fn ManifestSummary::weight_range(self : ManifestSummary) -> Int

    Money

    pub struct Money {
    cents : Int
    } derive(Eq, ToJson,
    Debug
    )

    Money::abs

    fn Money::abs(self : Money) -> Money

    Money::add

    fn Money::add(self : Money, other : Money) -> Money

    Money::clamp

    fn Money::clamp(self : Money, low : Money, high : Money) -> Money

    Money::difference

    fn Money::difference(self : Money, other : Money) -> Money

    Money::from_cents

    fn Money::from_cents(cents : Int) -> Money

    Money::is_negative

    fn Money::is_negative(self : Money) -> Bool

    Money::is_positive

    fn Money::is_positive(self : Money) -> Bool

    Money::is_zero

    fn Money::is_zero(self : Money) -> Bool

    Money::max

    fn Money::max(self : Money, other : Money) -> Money

    Money::min

    fn Money::min(self : Money, other : Money) -> Money

    Money::mul_int

    fn Money::mul_int(self : Money, n : Int) -> Money

    Money::negate

    fn Money::negate(self : Money) -> Money

    Money::percent_bp

    fn Money::percent_bp(self : Money, bp : Int) -> Money

    Money::round_to

    fn Money::round_to(self : Money, unit_cents : Int, mode : RoundingMode) -> Money

    Money::scale_bp

    fn Money::scale_bp(self : Money, bp : Int) -> Money

    Money::sub

    fn Money::sub(self : Money, other : Money) -> Money

    Money::to_string

    fn Money::to_string(self : Money) -> String

    Money::yuan

    fn Money::yuan(yuan : Int) -> Money

    Money::zero

    fn Money::zero() -> Money

    OperationalRate

    pub struct OperationalRate {
    code : String
    zone : String
    minimum_g : Int
    maximum_g : Int
    rate : Money
    multiplier_bp : Int
    } derive(Eq, ToJson,
    Debug
    )

    OperationalRate::contains

    fn OperationalRate::contains(self : OperationalRate, weight_g : Int) -> Bool

    OperationalRate::is_valid

    fn OperationalRate::is_valid(self : OperationalRate) -> Bool

    OperationalRate::span

    fn OperationalRate::span(self : OperationalRate) -> Int

    ParcelDim

    pub struct ParcelDim {
    width_cm : Int
    height_cm : Int
    depth_cm : Int
    weight_g : Int
    } derive(Eq, ToJson,
    Debug
    )

    ParcelDim::chargeable_volume_l

    fn ParcelDim::chargeable_volume_l(self : ParcelDim) -> Int

    ParcelDim::dimensional_density

    fn ParcelDim::dimensional_density(self : ParcelDim) -> Int

    ParcelDim::is_valid

    fn ParcelDim::is_valid(self : ParcelDim) -> Bool

    ParcelDim::longest_side_cm

    fn ParcelDim::longest_side_cm(self : ParcelDim) -> Int

    ParcelDim::normalized

    fn ParcelDim::normalized(self : ParcelDim) -> ParcelDim

    ParcelDim::volume_cm3

    fn ParcelDim::volume_cm3(self : ParcelDim) -> Int

    ParcelProfile

    pub struct ParcelProfile {
    longest_side_cm : Int
    shortest_side_cm : Int
    middle_side_cm : Int
    girth_cm : Int
    footprint_cm2 : Int
    surface_area_cm2 : Int
    density_g_per_l : Int
    } derive(Eq, ToJson,
    Debug
    )

    PaymentAllocation

    pub struct PaymentAllocation {
    payment_id : String
    invoice_id : String
    amount : Money
    remaining : Money
    } derive(Eq, ToJson,
    Debug
    )

    PaymentAllocation::fully_settles

    fn PaymentAllocation::fully_settles(self : PaymentAllocation) -> Bool

    Quote

    pub struct Quote {
    billable_weight_g : Int
    actual_weight_g : Int
    volumetric_weight_g : Int
    subtotal : Money
    total : Money
    lines : Array[ChargeLine]
    } derive(Eq, ToJson,
    Debug
    )

    Quote::summary

    fn Quote::summary(self : Quote) -> String

    ReconciliationItem

    pub struct ReconciliationItem {
    code : String
    expected : Money
    actual : Money
    difference : Money
    status : ReconciliationStatus
    } derive(Eq, ToJson,
    Debug
    )

    ReconciliationReport

    pub struct ReconciliationReport {
    items : Array[ReconciliationItem]
    matched : Int
    exceptions : Int
    net_difference : Money
    } derive(Eq, ToJson,
    Debug
    )

    ReconciliationReport::absolute_difference

    fn ReconciliationReport::absolute_difference(self : ReconciliationReport) -> Money

    ReconciliationReport::is_matched

    fn ReconciliationReport::is_matched(self : ReconciliationReport) -> Bool

    ReconciliationReport::item_count

    fn ReconciliationReport::item_count(self : ReconciliationReport) -> Int

    ReconciliationStatus

    pub(all) enum ReconciliationStatus {
    Matched
    Difference
    MissingExpected
    UnexpectedActual
    } derive(Eq, ToJson,
    Debug
    )

    RoundingMode

    pub(all) enum RoundingMode {
    HalfUp
    HalfDown
    Floor
    Ceiling
    } derive(Eq, ToJson,
    Debug
    )

    RouteLeg

    pub struct RouteLeg {
    origin : String
    destination : String
    zone : String
    days : Int
    capacity_g : Int
    } derive(Eq, ToJson,
    Debug
    )

    RuleProblem

    pub enum RuleProblem {
    NonPositiveDivisor
    NonPositiveWeightStep
    EmptyZones
    InvalidZoneMultiplier(String)
    NegativeFee(String)
    } derive(Eq, ToJson,
    Debug
    )

    ServiceWindow

    pub struct ServiceWindow {
    service : String
    minimum_days : Int
    maximum_days : Int
    cutoff_hour : Int
    } derive(Eq, ToJson,
    Debug
    )

    SettlementLine

    pub struct SettlementLine {
    code : String
    amount : Money
    taxable : Bool
    } derive(Eq, ToJson,
    Debug
    )

    SurchargePolicy

    pub struct SurchargePolicy {
    overweight_limit_g : Int
    overweight_fee : Money
    oversize_limit_cm : Int
    oversize_fee : Money
    fuel_percent_bp : Int
    insurance_percent_bp : Int
    } derive(Eq, ToJson,
    Debug
    )

    TariffCandidate

    pub struct TariffCandidate {
    id : String
    priority : Int
    effective_from : Int
    effective_to : Int
    predicates : Array[TariffPredicate]
    charge : Money
    } derive(Eq, ToJson,
    Debug
    )

    TariffCandidate::active_on

    fn TariffCandidate::active_on(self : TariffCandidate, day : Int) -> Bool

    TariffCandidate::is_well_formed

    fn TariffCandidate::is_well_formed(self : TariffCandidate) -> Bool

    TariffPredicate

    pub(all) enum TariffPredicate {
    WeightAtLeast(Int)
    WeightAtMost(Int)
    LongestSideAtMost(Int)
    ZoneIs(String)
    DeclaredValueAtLeast(Money)
    } derive(Eq, ToJson,
    Debug
    )

    TaxPolicy

    pub struct TaxPolicy {
    rate_bp : Int
    threshold : Money
    } derive(Eq, ToJson,
    Debug
    )

    TaxPolicy::valid

    fn TaxPolicy::valid(self : TaxPolicy) -> Bool

    TaxResult

    pub struct TaxResult {
    taxable : Money
    exempt : Money
    tax : Money
    gross : Money
    } derive(Eq, ToJson,
    Debug
    )

    TaxResult::net_of_tax

    fn TaxResult::net_of_tax(self : TaxResult) -> Money

    ValidationSummary

    pub struct ValidationSummary {
    errors : Int
    warnings : Int
    infos : Int
    diagnostics : Array[ConfigDiagnostic]
    } derive(Eq, ToJson,
    Debug
    )

    ValidationSummary::diagnostic_count

    fn ValidationSummary::diagnostic_count(self : ValidationSummary) -> Int

    ValidationSummary::has_warnings

    fn ValidationSummary::has_warnings(self : ValidationSummary) -> Bool

    ValidationSummary::is_valid

    fn ValidationSummary::is_valid(self : ValidationSummary) -> Bool

    ZoneRate

    pub struct ZoneRate {
    zone : String
    multiplier_bp : Int
    remote_fee : Money
    } derive(Eq, ToJson,
    Debug
    )

    add_business_days

    fn add_business_days(calendar : BusinessCalendar, start_day : Int, amount : Int) -> Int

    allocate_payment

    fn allocate_payment(invoice : Invoice, payment_id : String, amount : Money) -> PaymentAllocation

    analyze_parcel

    fn analyze_parcel(parcel : ParcelDim) -> ParcelProfile

    apply_discounts

    fn apply_discounts(original : Money, rules : Array[DiscountRule]) -> DiscountResult

    audit_event

    fn audit_event(sequence : Int, code : String, detail : String, amount : Money) -> AuditEvent

    audit_policy_score

    fn audit_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    billable_weight_g

    fn billable_weight_g(parcel : ParcelDim, divisor : Int) -> Int

    billing_rule

    fn billing_rule(volumetric_divisor~ : Int, first_weight_limit_g~ : Int, first_weight_rate~ : Money, additional_weight_unit_g~ : Int, additional_weight_rate~ : Money, min_charge~ : Money, zones~ : Array[ZoneRate], surcharge~ : SurchargePolicy) -> BillingRule

    bulk_job

    fn bulk_job(id : String, item_count : Int) -> BulkJob

    bulk_policy_score

    fn bulk_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    business_calendar

    fn business_calendar(weekend_days : Array[Int], holidays : Array[Int], cutoff_hour : Int) -> BusinessCalendar

    calculate_customs

    fn calculate_customs(lines : Array[CustomsLine]) -> CustomsSummary

    calculate_tax

    fn calculate_tax(policy : TaxPolicy, taxable : Money, exempt : Money) -> TaxResult

    choose_tariff

    fn choose_tariff(candidates : Array[TariffCandidate], parcel : ParcelDim, zone : String, declared_value : Money, day : Int) -> DecisionTrace

    combine_discount_rules

    fn combine_discount_rules(groups : Array[Array[DiscountRule]]) -> Array[DiscountRule]

    customs_duty

    fn customs_duty(line : CustomsLine) -> Money

    customs_insurance

    fn customs_insurance(line : CustomsLine) -> Money

    customs_line

    fn customs_line(code : String, declared_value : Money, duty_bp : Int, insurance_bp : Int) -> CustomsLine

    customs_policy_score

    fn customs_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    describe_line

    fn describe_line(line : ChargeLine) -> String

    discount_rule

    fn discount_rule(code~ : String, percent_bp~ : Int, cap~ : Money) -> DiscountRule

    domestic_rate_catalog

    fn domestic_rate_catalog() -> Array[OperationalRate]

    find_operational_rate

    fn find_operational_rate(catalog : Array[OperationalRate], weight_g : Int) -> OperationalRate

    international_rate_catalog

    fn international_rate_catalog() -> Array[OperationalRate]

    invoice

    fn invoice(id : String, lines : Array[SettlementLine], tax : Money, paid : Money) -> Invoice

    invoice_balance

    fn invoice_balance(invoice : Invoice) -> (BalanceState, Money)

    invoice_outstanding

    fn invoice_outstanding(invoice : Invoice) -> Money

    invoice_subtotal

    fn invoice_subtotal(invoice : Invoice) -> Money

    invoice_total

    fn invoice_total(invoice : Invoice) -> Money

    is_business_day

    fn is_business_day(calendar : BusinessCalendar, day : Int) -> Bool

    job_after_failure

    fn job_after_failure(job : BulkJob, count : Int, retryable : Bool) -> BulkJob

    job_after_success

    fn job_after_success(job : BulkJob, count : Int) -> BulkJob

    lane

    fn lane(origin~ : String, destination~ : String, zone~ : String, transit_days~ : Int) -> Lane

    operations_policy_score

    fn operations_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    parcel_dim

    fn parcel_dim(width_cm~ : Int, height_cm~ : Int, depth_cm~ : Int, weight_g~ : Int) -> ParcelDim

    pricing_policy_score

    fn pricing_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    quote

    fn quote(rule : BillingRule, parcel : ParcelDim, zone : String, declared_value : Money) -> Quote

    quote_manifest

    fn quote_manifest(rule : BillingRule, items : Array[ManifestItem]) -> ManifestQuote

    reconcile_lines

    fn reconcile_lines(expected : Array[SettlementLine], actual : Array[SettlementLine], tolerance : Money) -> ReconciliationReport

    reconcile_policy_score

    fn reconcile_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    regional_rate_catalog

    fn regional_rate_catalog() -> Array[OperationalRate]

    report_policy_score

    fn report_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    resolve_lane

    fn resolve_lane(lanes : Array[Lane], origin : String, destination : String) -> Lane

    returns_rate_catalog

    fn returns_rate_catalog() -> Array[OperationalRate]

    route_leg

    fn route_leg(origin : String, destination : String, zone : String, days : Int, capacity_g : Int) -> RouteLeg

    routing_policy_score

    fn routing_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    sample_manifest

    fn sample_manifest() -> Array[ManifestItem]

    select_fastest_lane

    fn select_fastest_lane(lanes : Array[Lane], origin : String, destination : String) -> Lane

    service_deadline

    fn service_deadline(calendar : BusinessCalendar, start_day : Int, start_hour : Int, transit_days : Int, buffer_days : Int) -> Int

    service_policy_score

    fn service_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    service_window

    fn service_window(service : String, minimum_days : Int, maximum_days : Int, cutoff_hour : Int) -> ServiceWindow

    settlement_line

    fn settlement_line(code : String, amount : Money, taxable : Bool) -> SettlementLine

    settlement_policy_score

    fn settlement_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    sla_policy_score

    fn sla_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    standard_rule

    fn standard_rule() -> BillingRule

    summarize_manifest

    fn summarize_manifest(values : Array[ParcelDim]) -> ManifestSummary

    surcharge_policy

    fn surcharge_policy(overweight_limit_g~ : Int, overweight_fee~ : Money, oversize_limit_cm~ : Int, oversize_fee~ : Money, fuel_percent_bp~ : Int, insurance_percent_bp~ : Int) -> SurchargePolicy

    tariff_candidate

    fn tariff_candidate(id : String, priority : Int, effective_from : Int, effective_to : Int, predicates : Array[TariffPredicate], charge : Money) -> TariffCandidate

    tariff_policy_score

    fn tariff_policy_score(parcel : ParcelDim, rule : BillingRule, value : Money) -> Int

    tax_policy

    fn tax_policy(rate_bp~ : Int, threshold~ : Money) -> TaxPolicy

    validate_configuration

    fn validate_configuration(entries : Array[String]) -> ValidationSummary

    validate_rule

    fn validate_rule(rule : BillingRule) -> Array[RuleProblem]

    volumetric_weight_g

    fn volumetric_weight_g(parcel : ParcelDim, divisor : Int) -> Int

    zone_rate

    fn zone_rate(zone~ : String, multiplier_bp~ : Int, remote_fee~ : Money) -> ZoneRate