Skip to content

Commit

Permalink
feat: let database generate reversal dates
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 16, 2024
1 parent 036aa86 commit 1d0e9bc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/storage/ledger/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ func (s *Store) updateTxWithRetrieve(ctx context.Context, id int, query *bun.Upd

func (s *Store) RevertTransaction(ctx context.Context, id int) (tx *ledger.Transaction, modified bool, err error) {
_, err = tracing.TraceWithLatency(ctx, "RevertTransaction", func(ctx context.Context) (*ledger.Transaction, error) {
now := time.Now()
tx, modified, err = s.updateTxWithRetrieve(
ctx,
id,
Expand All @@ -431,8 +430,8 @@ func (s *Store) RevertTransaction(ctx context.Context, id int) (tx *ledger.Trans
Where("id = ?", id).
Where("reverted_at is null").
Where("ledger = ?", s.ledger.Name).
Set("reverted_at = ?", now).
Set("updated_at = ?", now).
Set("reverted_at = (now() at time zone 'utc')").
Set("updated_at = (now() at time zone 'utc')").
Returning("*"),
)
return nil, err
Expand Down

0 comments on commit 1d0e9bc

Please sign in to comment.