adapt financial transaction type for online payment provider

This commit is contained in:
Philipp Rothmann 2023-10-02 23:00:24 +02:00
parent c59eefd219
commit 2ef17ceca4
10 changed files with 66 additions and 25 deletions

View file

@ -50,11 +50,7 @@ class Finance::FinancialTransactionsController < ApplicationController
def create
@financial_transaction = FinancialTransaction.new(params[:financial_transaction])
@financial_transaction.user = current_user
if @financial_transaction.ordergroup
@financial_transaction.add_transaction!
else
@financial_transaction.save!
end
@financial_transaction.save!
redirect_to finance_group_transactions_path(@ordergroup),
notice: I18n.t('finance.financial_transactions.controller.create.notice')
rescue ActiveRecord::RecordInvalid => e

View file

@ -14,7 +14,7 @@ class Finance::OrdergroupsController < Finance::BaseController
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
@total_balances = FinancialTransactionClass.sorted.each_with_object({}) do |c, tmp|
tmp[c.id] = c.financial_transactions.reduce(0) { |sum, t| sum + t.amount }
tmp[c.id] = c.financial_transactions.reduce(0) { |sum, t| sum + (t.amount || 0) }
end
end
end