diff --git a/src/recipe_functions/common.rs b/src/recipe_functions/common.rs index 55891d0..b58fe73 100644 --- a/src/recipe_functions/common.rs +++ b/src/recipe_functions/common.rs @@ -151,7 +151,22 @@ pub fn change_prefix_by_country( for ele in x.clone().recipes { let mut eled = ele.clone(); if check_allowed_change_mat_prefix(eled.clone().materialPathId) { - let new_f = format!("{}{}", mat_prefix, eled.clone().materialPathId); + let curr_id = eled.clone().materialPathId.as_i64().unwrap_or(0); + + let new_f = if curr_id > 99999 { + // is from inter + + // TODO: reset first + let back_to_default_id = curr_id.to_string()[2..] + .parse::() + .expect("not a number"); + + format!("{}{}", mat_prefix, back_to_default_id) + } else { + // is from thai + format!("{}{}", mat_prefix, eled.clone().materialPathId) + }; + eled.materialPathId = Value::Number(new_f.parse::().unwrap().into()); } new_recipes_format.push(eled); @@ -170,8 +185,21 @@ pub fn change_prefix_by_country( for ele in sl.recipes { let mut eled = ele.clone(); if check_allowed_change_mat_prefix(eled.clone().materialPathId) { - let new_f = - format!("{}{}", mat_prefix, eled.clone().materialPathId); + let curr_id = eled.clone().materialPathId.as_i64().unwrap_or(0); + + let new_f = if curr_id > 99999 { + // is from inter + + // TODO: reset first + let back_to_default_id = curr_id.to_string()[2..] + .parse::() + .expect("not a number"); + + format!("{}{}", mat_prefix, back_to_default_id) + } else { + // is from thai + format!("{}{}", mat_prefix, eled.clone().materialPathId) + }; eled.materialPathId = Value::Number(new_f.parse::().unwrap().into()); }