Skip to content

Split expenses: deleting an expense should write a reversal, not remove its ledger rows #1382

Description

@ulsklyc

Deleting an expense in split expenses removes its ledger rows (server/routes/split-expenses.js around lines 311 and 886: DELETE FROM expense_ledger_entries WHERE source_type ... AND source_id = ?). The schema already allows source_type = 'expense_reversal' (server/db.js, expense_ledger_entries), but nothing ever writes it.

Since #1378, a recorded payment is reversed with a counter-entry (settlement_reversal) instead of being removed, so the history keeps what happened. An expense is the other half of the same ledger and still follows the old rule: once deleted, the balance changes and nothing shows why.

Proposal: deleting an expense writes expense_reversal rows (the exact negative of its expense rows, same source_id) and keeps the expense visible in the activity as deleted, the same shape as the payment reversal. Editing an expense would then be reversal plus new booking, or stay as it is; that needs deciding before the build.

This belongs to the same question as #1381 (what deleting means for shared data) and should be decided together with it, not built on its own.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions