diff --git a/src/main.rs b/src/main.rs index 3de0027..9ca96b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,14 +178,18 @@ async fn update_transaction( notes: s.notes, }) .collect(); - if let Some(split) = splits.last_mut() { + let jrnl_id = if let Some(split) = splits.last_mut() { if form.amount != amount { split.amount = form.amount.to_string(); } if !form.notes.is_empty() { split.notes = Some(form.notes.clone()); } - } + split.transaction_journal_id.clone() + } else { + error!("Somehow, transaction {} has no splits!", id); + return (Status::BadRequest, "Invalid transaction: no splits".into()); + }; let update = TransactionUpdate { transactions: splits, }; @@ -209,7 +213,11 @@ async fn update_transaction( } if let Err(e) = ctx .firefly - .attach_receipt(id, content, file.name().unwrap_or("receipt.jpg")) + .attach_receipt( + &jrnl_id, + content, + file.name().unwrap_or("receipt.jpg"), + ) .await { error!("Failed to attach receipt to transaction: {}", e);