fix change prefix

- make this reset mat id first before apply a format
This commit is contained in:
Pakin 2025-10-15 17:27:15 +07:00
parent f9be519e03
commit 4670c5f89a

View file

@ -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::<i64>()
.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::<i64>().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::<i64>()
.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::<i64>().unwrap().into());
}