///|
fn customs_score_declared(
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 customs_score_duty(
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 customs_score_insurance(
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 customs_score_commodity(
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 customs_score_country(
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 customs_score_document(
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 customs_score_inspection(
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 customs_score_threshold(
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 customs_score_clearance(
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 customs_check_declared(
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 customs_check_duty(
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 customs_check_insurance(
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 customs_check_commodity(
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 customs_check_country(
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 customs_check_document(
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 customs_check_inspection(
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 customs_check_threshold(
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 customs_check_clearance(
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 customs_estimate_declared(
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 customs_estimate_duty(
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 customs_estimate_insurance(
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 customs_estimate_commodity(
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 customs_estimate_country(
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 customs_estimate_document(
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 customs_estimate_inspection(
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 customs_estimate_threshold(
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 customs_estimate_clearance(
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 customs_measure_declared(
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 customs_measure_duty(
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 customs_measure_insurance(
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 customs_measure_commodity(
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 customs_measure_country(
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 customs_measure_document(
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 customs_measure_inspection(
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 customs_measure_threshold(
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 customs_measure_clearance(
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 customs_bound_declared(
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 customs_bound_duty(
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 customs_bound_insurance(
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 customs_bound_commodity(
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 customs_bound_country(
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 customs_bound_document(
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 customs_bound_inspection(
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 customs_bound_threshold(
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 customs_bound_clearance(
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 customs_classify_declared(
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 customs_classify_duty(
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 customs_classify_insurance(
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 customs_classify_commodity(
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 customs_classify_country(
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 customs_classify_document(
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 customs_classify_inspection(
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 customs_classify_threshold(
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 customs_classify_clearance(
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 customs_project_declared(
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 customs_project_duty(
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 customs_project_insurance(
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 customs_project_commodity(
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 customs_project_country(
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 customs_project_document(
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 customs_project_inspection(
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 customs_project_threshold(
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 customs_project_clearance(
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 customs_reserve_declared(
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 customs_reserve_duty(
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 customs_reserve_insurance(
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 customs_reserve_commodity(
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 customs_reserve_country(
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 customs_reserve_document(
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 customs_reserve_inspection(
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 customs_reserve_threshold(
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 customs_reserve_clearance(
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 customs_reconcile_declared(
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 customs_reconcile_duty(
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 customs_reconcile_insurance(
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 customs_reconcile_commodity(
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 customs_reconcile_country(
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 customs_reconcile_document(
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 customs_reconcile_inspection(
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 customs_reconcile_threshold(
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 customs_reconcile_clearance(
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 customs_rank_declared(
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 customs_rank_duty(
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 customs_rank_insurance(
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 customs_rank_commodity(
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 customs_rank_country(
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 customs_rank_document(
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 customs_rank_inspection(
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 customs_rank_threshold(
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 customs_rank_clearance(
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 customs_policy_score(
parcel : ParcelDim,
rule : BillingRule,
value : Money,
) -> Int {
let mut score = 0
score += customs_score_declared(parcel, rule, value)
score += customs_score_duty(parcel, rule, value)
score += customs_score_insurance(parcel, rule, value)
score += customs_score_commodity(parcel, rule, value)
score += customs_score_country(parcel, rule, value)
score += customs_score_document(parcel, rule, value)
score += customs_score_inspection(parcel, rule, value)
score += customs_score_threshold(parcel, rule, value)
score += customs_score_clearance(parcel, rule, value)
score += customs_check_declared(parcel, rule, value)
score += customs_check_duty(parcel, rule, value)
score += customs_check_insurance(parcel, rule, value)
score += customs_check_commodity(parcel, rule, value)
score += customs_check_country(parcel, rule, value)
score += customs_check_document(parcel, rule, value)
score += customs_check_inspection(parcel, rule, value)
score += customs_check_threshold(parcel, rule, value)
score += customs_check_clearance(parcel, rule, value)
score += customs_estimate_declared(parcel, rule, value)
score += customs_estimate_duty(parcel, rule, value)
score += customs_estimate_insurance(parcel, rule, value)
score += customs_estimate_commodity(parcel, rule, value)
score += customs_estimate_country(parcel, rule, value)
score += customs_estimate_document(parcel, rule, value)
score += customs_estimate_inspection(parcel, rule, value)
score += customs_estimate_threshold(parcel, rule, value)
score += customs_estimate_clearance(parcel, rule, value)
score += customs_measure_declared(parcel, rule, value)
score += customs_measure_duty(parcel, rule, value)
score += customs_measure_insurance(parcel, rule, value)
score += customs_measure_commodity(parcel, rule, value)
score += customs_measure_country(parcel, rule, value)
score += customs_measure_document(parcel, rule, value)
score += customs_measure_inspection(parcel, rule, value)
score += customs_measure_threshold(parcel, rule, value)
score += customs_measure_clearance(parcel, rule, value)
score += customs_bound_declared(parcel, rule, value)
score += customs_bound_duty(parcel, rule, value)
score += customs_bound_insurance(parcel, rule, value)
score += customs_bound_commodity(parcel, rule, value)
score += customs_bound_country(parcel, rule, value)
score += customs_bound_document(parcel, rule, value)
score += customs_bound_inspection(parcel, rule, value)
score += customs_bound_threshold(parcel, rule, value)
score += customs_bound_clearance(parcel, rule, value)
score += customs_classify_declared(parcel, rule, value)
score += customs_classify_duty(parcel, rule, value)
score += customs_classify_insurance(parcel, rule, value)
score += customs_classify_commodity(parcel, rule, value)
score += customs_classify_country(parcel, rule, value)
score += customs_classify_document(parcel, rule, value)
score += customs_classify_inspection(parcel, rule, value)
score += customs_classify_threshold(parcel, rule, value)
score += customs_classify_clearance(parcel, rule, value)
score += customs_project_declared(parcel, rule, value)
score += customs_project_duty(parcel, rule, value)
score += customs_project_insurance(parcel, rule, value)
score += customs_project_commodity(parcel, rule, value)
score += customs_project_country(parcel, rule, value)
score += customs_project_document(parcel, rule, value)
score += customs_project_inspection(parcel, rule, value)
score += customs_project_threshold(parcel, rule, value)
score += customs_project_clearance(parcel, rule, value)
score += customs_reserve_declared(parcel, rule, value)
score += customs_reserve_duty(parcel, rule, value)
score += customs_reserve_insurance(parcel, rule, value)
score += customs_reserve_commodity(parcel, rule, value)
score += customs_reserve_country(parcel, rule, value)
score += customs_reserve_document(parcel, rule, value)
score += customs_reserve_inspection(parcel, rule, value)
score += customs_reserve_threshold(parcel, rule, value)
score += customs_reserve_clearance(parcel, rule, value)
score += customs_reconcile_declared(parcel, rule, value)
score += customs_reconcile_duty(parcel, rule, value)
score += customs_reconcile_insurance(parcel, rule, value)
score += customs_reconcile_commodity(parcel, rule, value)
score += customs_reconcile_country(parcel, rule, value)
score += customs_reconcile_document(parcel, rule, value)
score += customs_reconcile_inspection(parcel, rule, value)
score += customs_reconcile_threshold(parcel, rule, value)
score += customs_reconcile_clearance(parcel, rule, value)
score += customs_rank_declared(parcel, rule, value)
score += customs_rank_duty(parcel, rule, value)
score += customs_rank_insurance(parcel, rule, value)
score += customs_rank_commodity(parcel, rule, value)
score += customs_rank_country(parcel, rule, value)
score += customs_rank_document(parcel, rule, value)
score += customs_rank_inspection(parcel, rule, value)
score += customs_rank_threshold(parcel, rule, value)
score += customs_rank_clearance(parcel, rule, value)
score
}