diff --git a/module.wasm b/module.wasm index d459b08..f413498 100644 Binary files a/module.wasm and b/module.wasm differ diff --git a/src/lib.rs b/src/lib.rs index 11a1e28..36f3215 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,12 @@ struct InputDuties { #[derive(Debug, Deserialize)] struct InputDuty { - population: u64, + // f64, not u64: JSON inputs arriving via google.protobuf.Struct + // (HubClient.submit jsonInputs) are always floating-point, so a + // u64 field rejects `180000.0`. A population is a count, but f64 + // represents it exactly up to 2^53 and the SKM product is f64 + // anyway. Display still renders whole numbers without a decimal. + population: f64, frequency: f32, tariff_eur_per_hour: f32, time_hours_per_case: f32, @@ -59,7 +64,7 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result { if d.frequency < 0.0 || d.tariff_eur_per_hour < 0.0 || d.time_hours_per_case < 0.0 { return Err(ModuleError::invalid_input("negative P/F/T/h not allowed")); } - let value = d.population as f64 + let value = d.population * d.frequency as f64 * d.tariff_eur_per_hour as f64 * d.time_hours_per_case as f64;