1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Transaction transfers, payments, and matching (#883)

* Add transfer model and clean up family snapshot fixtures

* Ignore transfers in income and expense snapshots

* Add transfer validations

* Implement basic transfer matching UI

* Fix merge conflicts

* Add missing translations

* Tweak selection states for transfer types

* Add missing i18n translation
This commit is contained in:
Zach Gollwitzer 2024-06-19 06:52:08 -04:00 committed by GitHub
parent b462bc8f8c
commit ca39b26070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 991 additions and 427 deletions

View file

@ -9,9 +9,9 @@ class TransactionsController < ApplicationController
@pagy, @transactions = pagy(result, items: 50)
@totals = {
count: result.count,
income: result.inflows.sum(&:amount_money).abs,
expense: result.outflows.sum(&:amount_money).abs
count: result.select { |t| t.currency == Current.family.currency }.count,
income: result.income_total(Current.family.currency).abs,
expense: result.expense_total(Current.family.currency)
}
end
@ -54,7 +54,7 @@ class TransactionsController < ApplicationController
def bulk_delete
destroyed = Current.family.transactions.destroy_by(id: bulk_delete_params[:transaction_ids])
redirect_to transactions_url, notice: t(".success", count: destroyed.count)
redirect_back_or_to transactions_url, notice: t(".success", count: destroyed.count)
end
def bulk_edit
@ -63,13 +63,31 @@ class TransactionsController < ApplicationController
def bulk_update
transactions = Current.family.transactions.where(id: bulk_update_params[:transaction_ids])
if transactions.update_all(bulk_update_params.except(:transaction_ids).to_h.compact_blank!)
redirect_to transactions_url, notice: t(".success", count: transactions.count)
redirect_back_or_to transactions_url, notice: t(".success", count: transactions.count)
else
flash.now[:error] = t(".failure")
render :index, status: :unprocessable_entity
end
end
def mark_transfers
Current.family
.transactions
.where(id: bulk_update_params[:transaction_ids])
.mark_transfers!
redirect_back_or_to transactions_url, notice: t(".success")
end
def unmark_transfers
Current.family
.transactions
.where(id: bulk_update_params[:transaction_ids])
.update_all marked_as_transfer: false
redirect_back_or_to transactions_url, notice: t(".success")
end
private
def set_transaction