fix
This commit is contained in:
parent
e3128d7214
commit
9468629302
2 changed files with 26 additions and 18 deletions
36
src/flow.rs
36
src/flow.rs
|
@ -164,27 +164,27 @@ impl Flow {
|
||||||
|
|
||||||
for prod in produced {
|
for prod in produced {
|
||||||
let t = Item::get(&prod.item)
|
let t = Item::get(&prod.item)
|
||||||
.await
|
.await
|
||||||
.ok_or_else(item_does_not_exist_error)?
|
.ok_or_else(item_does_not_exist_error)?
|
||||||
.variant(&prod.variant)
|
.variant(&prod.variant)
|
||||||
.ok_or_else(variant_does_not_exist_error)?;
|
.ok_or_else(variant_does_not_exist_error)?;
|
||||||
|
|
||||||
t_create.push((t, prod));
|
t_create.push((t, prod));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item, info) in t_create {
|
for (item, info) in t_create {
|
||||||
let t = item
|
let t = item
|
||||||
.supply(
|
.supply(
|
||||||
Price::zero(),
|
Price::zero(),
|
||||||
Some(&format!("flow::{}::{}", self.kind.id(), self._id)),
|
Some(&format!("flow::{}::{}", self.kind.id(), self._id)),
|
||||||
info.location.as_ref().map(|x| x.as_str()),
|
info.location.as_ref().map(|x| x.as_str()),
|
||||||
info.note.as_ref().map(|x| x.as_str()),
|
info.note.as_ref().map(|x| x.as_str()),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
ret.entry(item.item_variant_id().clone())
|
ret.entry(item.item_variant_id().clone())
|
||||||
.or_insert(Vec::new())
|
.or_insert(Vec::new())
|
||||||
.push(t._id.clone());
|
.push(t._id.clone());
|
||||||
produced_ref.push(t.reference());
|
produced_ref.push(t.reference());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.change()
|
self.change()
|
||||||
|
|
|
@ -156,6 +156,10 @@ pub async fn end_flow_route(id: &str, form: Json<EndFlow>) -> FallibleApiRespons
|
||||||
.await
|
.await
|
||||||
.ok_or_else(|| api_error("Flow not found"))?;
|
.ok_or_else(|| api_error("Flow not found"))?;
|
||||||
|
|
||||||
|
if flow.done.is_some() {
|
||||||
|
return Err(api_error("Flow already ended"));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(produced) = &form.produced {
|
if let Some(produced) = &form.produced {
|
||||||
let prod = flow.end_with_produce(produced).await?;
|
let prod = flow.end_with_produce(produced).await?;
|
||||||
Ok(json!({"produced": prod}))
|
Ok(json!({"produced": prod}))
|
||||||
|
@ -175,6 +179,10 @@ pub async fn continue_flow_route(
|
||||||
.await
|
.await
|
||||||
.ok_or_else(|| api_error("Flow not found"))?;
|
.ok_or_else(|| api_error("Flow not found"))?;
|
||||||
|
|
||||||
|
if this_flow.done.is_some() {
|
||||||
|
return Err(api_error("Flow already ended"));
|
||||||
|
}
|
||||||
|
|
||||||
// create next flow
|
// create next flow
|
||||||
let next_kind = flows
|
let next_kind = flows
|
||||||
.get(this_flow.kind.id())
|
.get(this_flow.kind.id())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue