diff --git a/src/app/mod.rs b/src/app/mod.rs index ec46205c..53cddd70 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -875,10 +875,10 @@ impl App { return Ok(()); } payout.cancel_payout(profile.id); + self.payouts.update(&mut tx, payout).await?; self.ledger - .payout_cancelled(tx, LedgerTransactionId::new(), payout.id) + .payout_cancelled(tx, LedgerTransactionId::new(), id) .await?; - self.payouts.update(payout).await?; Ok(()) } diff --git a/src/payout/repo.rs b/src/payout/repo.rs index 6b910750..eb17d2dc 100644 --- a/src/payout/repo.rs +++ b/src/payout/repo.rs @@ -322,19 +322,20 @@ impl Payouts { Ok(Payout::try_from(entity_events)?) } - pub async fn update(&self, payout: Payout) -> Result<(), PayoutError> { + pub async fn update( + &self, + tx: &mut Transaction<'_, Postgres>, + payout: Payout, + ) -> Result<(), PayoutError> { if !payout.events.is_dirty() { return Ok(()); } - - let mut tx = self.pool.begin().await?; EntityEvents::::persist( "bria_payout_events", - &mut tx, + tx, payout.events.new_serialized_events(payout.id), ) .await?; - tx.commit().await?; Ok(()) } }