diff --git a/src-tauri/src/capture.rs b/src-tauri/src/capture.rs index 48c34cc..e1583a3 100644 --- a/src-tauri/src/capture.rs +++ b/src-tauri/src/capture.rs @@ -323,6 +323,7 @@ fn spool_folder_loop( label: spool_dir.display().to_string(), bytes: 0, barcodes: vec![], + pallet_print: None, captured_at: chrono::Utc::now().to_rfc3339(), forwarded: false, error: Some(format!("spool read failed: {error}")), diff --git a/src-tauri/src/pallet.rs b/src-tauri/src/pallet.rs index b4417b2..d119182 100644 --- a/src-tauri/src/pallet.rs +++ b/src-tauri/src/pallet.rs @@ -74,11 +74,14 @@ pub fn parse_pallet_snapshot(raw_text: &str, pallet_id: &str) -> PalletSnapshot } if snapshot.variety.is_none() { - snapshot.variety = capture( - &flat, - r"(?i)\bAvocados?\s*-\s*([A-Z][A-Z -]{1,20}?)(?=\s+(?:ORIGIN|Pallet|Grower|Pick|Pack|Time|Total)\b|$)", - 1, - ); + if let Ok(regex) = Regex::new(r"(?i)^\s*Avocados?\s*-\s*([A-Z][A-Z -]{1,20})\s*$") { + snapshot.variety = raw_text.lines().find_map(|line| { + regex + .captures(line) + .and_then(|captures| captures.get(1)) + .and_then(|value| clean(value.as_str())) + }); + } } if let Ok(regex) = Regex::new( diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs index ddfa29f..5269acc 100644 --- a/src-tauri/src/state.rs +++ b/src-tauri/src/state.rs @@ -199,7 +199,7 @@ impl SharedState { id: uuid::Uuid::new_v4().to_string(), raw_value, format, - duplicate: !matches!(comparison.status, PalletPrintStatus::NewPallet), + duplicate: comparison.status != PalletPrintStatus::NewPallet, captured_at: chrono::Utc::now().to_rfc3339(), source: "print".into(), source_metadata: json!({