Add FinacialTransaction create_collection for ordergroup custom fields

Custom fields of an ordergroup can set financial_transaction_source to
true, to act as an source for a new collection of FinacialTransaction.

A typical usecase would be a variable membership fee, which will be stored
in a custom field on the ordergroup. When a new membership period begins
a collection with all membership fees can be created with one click.
This commit is contained in:
Patrick Gansterer 2019-11-11 12:18:00 +01:00
parent d73c206e29
commit a3defc5463
4 changed files with 32 additions and 6 deletions

View file

@ -58,6 +58,14 @@ class Finance::FinancialTransactionsController < ApplicationController
end
def new_collection
@ordergroups = {}
Ordergroup.undeleted.order(:name).map do |ordergroup|
obj = { name: ordergroup.name }
Ordergroup.custom_fields.each do |field|
obj[field[:name]] = ordergroup.settings.custom_fields[field[:name]]
end
@ordergroups[ordergroup.id] = obj
end
end
def create_collection