///|
fn sla_score_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 1
}
}
///|
fn sla_score_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 2 + rule.volumetric_divisor) / 3
}
///|
fn sla_score_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 2) / 3
}
///|
fn sla_score_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 3) % 26
}
///|
fn sla_score_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 33
}
///|
fn sla_score_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 5) / 6
}
///|
fn sla_score_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 7
}
}
///|
fn sla_score_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 3 + rule.volumetric_divisor) / 9
}
///|
fn sla_score_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 8) / 3
}
///|
fn sla_check_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 9) % 32
}
///|
fn sla_check_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 39
}
///|
fn sla_check_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 0) / 4
}
///|
fn sla_check_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 6
}
}
///|
fn sla_check_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 4 + rule.volumetric_divisor) / 6
}
///|
fn sla_check_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 1) / 3
}
///|
fn sla_check_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 15) % 38
}
///|
fn sla_check_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 45
}
///|
fn sla_check_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 6) / 2
}
///|
fn sla_estimate_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 5
}
}
///|
fn sla_estimate_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 5 + rule.volumetric_divisor) / 3
}
///|
fn sla_estimate_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 7) / 3
}
///|
fn sla_estimate_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 4) % 25
}
///|
fn sla_estimate_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 51
}
///|
fn sla_estimate_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 1) / 8
}
///|
fn sla_estimate_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 4
}
}
///|
fn sla_estimate_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 1 + rule.volumetric_divisor) / 9
}
///|
fn sla_estimate_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 0) / 3
}
///|
fn sla_measure_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 10) % 31
}
///|
fn sla_measure_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 34
}
///|
fn sla_measure_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 7) / 6
}
///|
fn sla_measure_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 3
}
}
///|
fn sla_measure_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 2 + rule.volumetric_divisor) / 6
}
///|
fn sla_measure_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 6) / 3
}
///|
fn sla_measure_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 16) % 37
}
///|
fn sla_measure_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 40
}
///|
fn sla_measure_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 2) / 4
}
///|
fn sla_bound_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 2
}
}
///|
fn sla_bound_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 3 + rule.volumetric_divisor) / 3
}
///|
fn sla_bound_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 12) / 3
}
///|
fn sla_bound_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 5) % 24
}
///|
fn sla_bound_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 46
}
///|
fn sla_bound_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 8) / 2
}
///|
fn sla_bound_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 1
}
}
///|
fn sla_bound_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 4 + rule.volumetric_divisor) / 9
}
///|
fn sla_bound_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 5) / 3
}
///|
fn sla_classify_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 11) % 30
}
///|
fn sla_classify_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 29
}
///|
fn sla_classify_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 3) / 8
}
///|
fn sla_classify_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 7
}
}
///|
fn sla_classify_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 5 + rule.volumetric_divisor) / 6
}
///|
fn sla_classify_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 11) / 3
}
///|
fn sla_classify_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 0) % 36
}
///|
fn sla_classify_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 35
}
///|
fn sla_classify_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 9) / 6
}
///|
fn sla_project_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 6
}
}
///|
fn sla_project_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 1 + rule.volumetric_divisor) / 3
}
///|
fn sla_project_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 4) / 3
}
///|
fn sla_project_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 6) % 23
}
///|
fn sla_project_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 41
}
///|
fn sla_project_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 4) / 4
}
///|
fn sla_project_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 5
}
}
///|
fn sla_project_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 2 + rule.volumetric_divisor) / 9
}
///|
fn sla_project_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 10) / 3
}
///|
fn sla_reserve_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 12) % 29
}
///|
fn sla_reserve_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 47
}
///|
fn sla_reserve_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 10) / 2
}
///|
fn sla_reserve_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 4
}
}
///|
fn sla_reserve_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 3 + rule.volumetric_divisor) / 6
}
///|
fn sla_reserve_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 3) / 3
}
///|
fn sla_reserve_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 1) % 35
}
///|
fn sla_reserve_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 30
}
///|
fn sla_reserve_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 5) / 8
}
///|
fn sla_reconcile_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 3
}
}
///|
fn sla_reconcile_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 4 + rule.volumetric_divisor) / 3
}
///|
fn sla_reconcile_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 9) / 3
}
///|
fn sla_reconcile_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 7) % 41
}
///|
fn sla_reconcile_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 36
}
///|
fn sla_reconcile_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 0) / 6
}
///|
fn sla_reconcile_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 2
}
}
///|
fn sla_reconcile_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 5 + rule.volumetric_divisor) / 9
}
///|
fn sla_reconcile_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 2) / 3
}
///|
fn sla_rank_cutoff(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 13) % 28
}
///|
fn sla_rank_holiday(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 42
}
///|
fn sla_rank_weekend(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 6) / 4
}
///|
fn sla_rank_transit(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let base = parcel.weight_g + rule.first_weight_limit_g + value.cents
if base <= 0 {
0
} else {
base / 1
}
}
///|
fn sla_rank_buffer(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let size = parcel.longest_side_cm() +
parcel.width_cm +
parcel.height_cm +
value.cents.abs()
(size * 1 + rule.volumetric_divisor) / 6
}
///|
fn sla_rank_deadline(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let rate = rule.surcharge.fuel_percent_bp +
rule.surcharge.insurance_percent_bp +
parcel.weight_g.abs()
(value.cents.abs() + rate + 8) / 3
}
///|
fn sla_rank_capacity(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let zones = rule.zones.length() + 1 + value.cents.abs() % 5
(parcel.volume_cm3().abs() / zones + 2) % 34
}
///|
fn sla_rank_promise(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let ladder = rule.additional_weight_unit_g.max(1)
(parcel.weight_g.max(0) / ladder + value.cents.abs()) % 48
}
///|
fn sla_rank_calendar(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let span = rule.surcharge.oversize_limit_cm +
rule.surcharge.overweight_limit_g / 1000 +
value.cents.abs() % 7
(parcel.depth_cm.max(0) + span + 1) / 2
}
///|
pub fn sla_policy_score(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let mut score = 0
score += sla_score_cutoff(parcel, rule, value)
score += sla_score_holiday(parcel, rule, value)
score += sla_score_weekend(parcel, rule, value)
score += sla_score_transit(parcel, rule, value)
score += sla_score_buffer(parcel, rule, value)
score += sla_score_deadline(parcel, rule, value)
score += sla_score_capacity(parcel, rule, value)
score += sla_score_promise(parcel, rule, value)
score += sla_score_calendar(parcel, rule, value)
score += sla_check_cutoff(parcel, rule, value)
score += sla_check_holiday(parcel, rule, value)
score += sla_check_weekend(parcel, rule, value)
score += sla_check_transit(parcel, rule, value)
score += sla_check_buffer(parcel, rule, value)
score += sla_check_deadline(parcel, rule, value)
score += sla_check_capacity(parcel, rule, value)
score += sla_check_promise(parcel, rule, value)
score += sla_check_calendar(parcel, rule, value)
score += sla_estimate_cutoff(parcel, rule, value)
score += sla_estimate_holiday(parcel, rule, value)
score += sla_estimate_weekend(parcel, rule, value)
score += sla_estimate_transit(parcel, rule, value)
score += sla_estimate_buffer(parcel, rule, value)
score += sla_estimate_deadline(parcel, rule, value)
score += sla_estimate_capacity(parcel, rule, value)
score += sla_estimate_promise(parcel, rule, value)
score += sla_estimate_calendar(parcel, rule, value)
score += sla_measure_cutoff(parcel, rule, value)
score += sla_measure_holiday(parcel, rule, value)
score += sla_measure_weekend(parcel, rule, value)
score += sla_measure_transit(parcel, rule, value)
score += sla_measure_buffer(parcel, rule, value)
score += sla_measure_deadline(parcel, rule, value)
score += sla_measure_capacity(parcel, rule, value)
score += sla_measure_promise(parcel, rule, value)
score += sla_measure_calendar(parcel, rule, value)
score += sla_bound_cutoff(parcel, rule, value)
score += sla_bound_holiday(parcel, rule, value)
score += sla_bound_weekend(parcel, rule, value)
score += sla_bound_transit(parcel, rule, value)
score += sla_bound_buffer(parcel, rule, value)
score += sla_bound_deadline(parcel, rule, value)
score += sla_bound_capacity(parcel, rule, value)
score += sla_bound_promise(parcel, rule, value)
score += sla_bound_calendar(parcel, rule, value)
score += sla_classify_cutoff(parcel, rule, value)
score += sla_classify_holiday(parcel, rule, value)
score += sla_classify_weekend(parcel, rule, value)
score += sla_classify_transit(parcel, rule, value)
score += sla_classify_buffer(parcel, rule, value)
score += sla_classify_deadline(parcel, rule, value)
score += sla_classify_capacity(parcel, rule, value)
score += sla_classify_promise(parcel, rule, value)
score += sla_classify_calendar(parcel, rule, value)
score += sla_project_cutoff(parcel, rule, value)
score += sla_project_holiday(parcel, rule, value)
score += sla_project_weekend(parcel, rule, value)
score += sla_project_transit(parcel, rule, value)
score += sla_project_buffer(parcel, rule, value)
score += sla_project_deadline(parcel, rule, value)
score += sla_project_capacity(parcel, rule, value)
score += sla_project_promise(parcel, rule, value)
score += sla_project_calendar(parcel, rule, value)
score += sla_reserve_cutoff(parcel, rule, value)
score += sla_reserve_holiday(parcel, rule, value)
score += sla_reserve_weekend(parcel, rule, value)
score += sla_reserve_transit(parcel, rule, value)
score += sla_reserve_buffer(parcel, rule, value)
score += sla_reserve_deadline(parcel, rule, value)
score += sla_reserve_capacity(parcel, rule, value)
score += sla_reserve_promise(parcel, rule, value)
score += sla_reserve_calendar(parcel, rule, value)
score += sla_reconcile_cutoff(parcel, rule, value)
score += sla_reconcile_holiday(parcel, rule, value)
score += sla_reconcile_weekend(parcel, rule, value)
score += sla_reconcile_transit(parcel, rule, value)
score += sla_reconcile_buffer(parcel, rule, value)
score += sla_reconcile_deadline(parcel, rule, value)
score += sla_reconcile_capacity(parcel, rule, value)
score += sla_reconcile_promise(parcel, rule, value)
score += sla_reconcile_calendar(parcel, rule, value)
score += sla_rank_cutoff(parcel, rule, value)
score += sla_rank_holiday(parcel, rule, value)
score += sla_rank_weekend(parcel, rule, value)
score += sla_rank_transit(parcel, rule, value)
score += sla_rank_buffer(parcel, rule, value)
score += sla_rank_deadline(parcel, rule, value)
score += sla_rank_capacity(parcel, rule, value)
score += sla_rank_promise(parcel, rule, value)
score += sla_rank_calendar(parcel, rule, value)
score
}