e7657b987f
This change introduces two new data types to group the financial transactions. Now every transaction has a "type", which itself belongs to a "class". Types should be used add structured information to an transaction, instead of writing it into the notice textfield. E.g. this could be used to have different types depending on the source of money (cash vs. bank transfer). Classes are shown as different columns in the tables and will be uses to group transactions of specific types. They should be used if not the whole amount of ordergroup should be used to order food. E.g. if there is a deposit or membership fee, which is independent of the normal credit. This will allow us to implement additional features based on classes in the future. E.g. the sum of transactions in the "membership fee" class must be positive to allow food orders or show a big warning if it is bellow a certain value.
57 lines
2.1 KiB
Text
57 lines
2.1 KiB
Text
- title t('.title')
|
|
|
|
- content_for :javascript do
|
|
:javascript
|
|
var ordergroup = $($.parseHTML("#{escape_javascript(render('ordergroup'))}"));
|
|
|
|
$(function() {
|
|
$(document).on('touchclick', 'a[data-remove-transaction]', function() {
|
|
$(this).parents('tr').remove();
|
|
return false;
|
|
});
|
|
|
|
$(document).on('touchclick', 'a[data-add-transaction]', function() {
|
|
ordergroup.clone().appendTo('#ordergroups');
|
|
return false;
|
|
});
|
|
|
|
$(document).on('touchclick', 'a[data-add-all-ordergroups]', function() {
|
|
var value = prompt("#{escape_javascript(heading_helper(FinancialTransaction, :amount))}:");
|
|
if (value === null)
|
|
return false;
|
|
$('#ordergroups > tbody > tr').remove();
|
|
var options = ordergroup.find('td > select > option').each(function() {
|
|
var row = ordergroup.clone();
|
|
row.find('td > input').val(value);
|
|
row.find('td > select').val(this.value);
|
|
row.appendTo('#ordergroups');
|
|
});
|
|
return false;
|
|
});
|
|
});
|
|
|
|
- content_for :sidebar do
|
|
.well.well-small= t('.sidebar')
|
|
|
|
= form_tag finance_create_transaction_collection_path do
|
|
- if FinancialTransactionType.has_multiple_types
|
|
%p
|
|
%b= heading_helper FinancialTransaction, :financial_transaction_type
|
|
= select_tag :type, options_for_select(FinancialTransactionType.order(:name).map { |t| [ t.name, t.id ] })
|
|
%p
|
|
%b= heading_helper FinancialTransaction, :note
|
|
= text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required'
|
|
%p
|
|
%table#ordergroups{:style => "width:20em"}
|
|
%thead
|
|
%tr
|
|
%th= heading_helper FinancialTransaction, :ordergroup
|
|
%th= heading_helper FinancialTransaction, :amount
|
|
%tbody
|
|
= render :partial => 'ordergroup', :collection => [1, 2, 3]
|
|
%p
|
|
= link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
|
|
= link_to t('.add_all_ordergroups'), '#', 'data-add-all-ordergroups' => true, class: 'btn'
|
|
.form-actions
|
|
= submit_tag t('.save'), class: 'btn btn-primary'
|
|
= link_to t('ui.or_cancel'), finance_ordergroups_path
|