Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

When a reimbursement report with Wise transfer fees is unapproved, the fee expense must be deleted since it's no longer applicable.

Changes

  • Model: Extended mark_draft transition to allow reimbursement_approved → draft with callback to delete Wise fee expenses
  • Constant: Added WISE_TRANSFER_FEE_MEMO to ensure consistency between fee creation and deletion
  • Tests: Added specs covering fee deletion across state transitions while preserving regular expenses

Implementation

event :mark_draft do
  transitions from: [..., :reimbursement_approved], to: :draft
  after do
    expenses.where(type: Reimbursement::Expense::Fee.name, memo: WISE_TRANSFER_FEE_MEMO).destroy_all
  end
end

The callback specifically targets expenses by both type and memo to avoid deleting unrelated fees.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Wise Reimbursement] Delete Wise fee expense when report is unapproved</issue_title>
<issue_description>When a report moves from Approved -> Draft, we need to delete the Wise fee expense</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Delete Wise fee expense on report unapproval Delete Wise fee expense when report transitions to draft Nov 4, 2025
Copilot AI requested a review from YodaLightsabr November 4, 2025 01:13
Copilot finished work on behalf of YodaLightsabr November 4, 2025 01:13
@YodaLightsabr YodaLightsabr marked this pull request as ready for review November 4, 2025 04:19
@YodaLightsabr YodaLightsabr requested review from a team as code owners November 4, 2025 04:19
@YodaLightsabr YodaLightsabr added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit c892bc1 Nov 20, 2025
14 checks passed
@YodaLightsabr YodaLightsabr deleted the copilot/delete-wise-fee-expense branch November 20, 2025 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Wise Reimbursement] Delete Wise fee expense when report is unapproved

3 participants