fix change prefix
- make this reset mat id first before apply a format
This commit is contained in:
parent
f9be519e03
commit
4670c5f89a
1 changed files with 31 additions and 3 deletions
|
|
@ -151,7 +151,22 @@ pub fn change_prefix_by_country(
|
||||||
for ele in x.clone().recipes {
|
for ele in x.clone().recipes {
|
||||||
let mut eled = ele.clone();
|
let mut eled = ele.clone();
|
||||||
if check_allowed_change_mat_prefix(eled.clone().materialPathId) {
|
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());
|
eled.materialPathId = Value::Number(new_f.parse::<i64>().unwrap().into());
|
||||||
}
|
}
|
||||||
new_recipes_format.push(eled);
|
new_recipes_format.push(eled);
|
||||||
|
|
@ -170,8 +185,21 @@ pub fn change_prefix_by_country(
|
||||||
for ele in sl.recipes {
|
for ele in sl.recipes {
|
||||||
let mut eled = ele.clone();
|
let mut eled = ele.clone();
|
||||||
if check_allowed_change_mat_prefix(eled.clone().materialPathId) {
|
if check_allowed_change_mat_prefix(eled.clone().materialPathId) {
|
||||||
let new_f =
|
let curr_id = eled.clone().materialPathId.as_i64().unwrap_or(0);
|
||||||
format!("{}{}", mat_prefix, eled.clone().materialPathId);
|
|
||||||
|
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 =
|
eled.materialPathId =
|
||||||
Value::Number(new_f.parse::<i64>().unwrap().into());
|
Value::Number(new_f.parse::<i64>().unwrap().into());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue