2019-11-11 12:09:18 +01:00
|
|
|
- title t('.title')
|
|
|
|
|
|
|
|
- content_for :javascript do
|
|
|
|
:javascript
|
|
|
|
$(function() {
|
|
|
|
var default_bank_account = $('p[data-text]').attr('data-text');
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
var items = {};
|
|
|
|
var hide_placeholder = false;
|
|
|
|
|
|
|
|
$('input[data-has-name-short]').each(function() {
|
|
|
|
var bank_account = $(this).attr('data-bank-account') || default_bank_account;
|
|
|
|
var name = $(this).attr('name');
|
2021-02-22 11:40:36 +01:00
|
|
|
var value = Math.round(parseFloat($(this).val()) * 100) / 100;
|
2019-11-11 12:09:18 +01:00
|
|
|
if (value > 0) {
|
|
|
|
var item = items[bank_account];
|
|
|
|
if (!item) {
|
|
|
|
items[bank_account] = item = { amount: 0, values: {} };
|
|
|
|
}
|
|
|
|
|
|
|
|
item.amount += value;
|
|
|
|
item.values[name] = value;
|
|
|
|
hide_placeholder = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('p[data-text]').each(function() {
|
|
|
|
var ele = $(this);
|
|
|
|
var bank_account = ele.attr('data-text');
|
|
|
|
var item = items[bank_account];
|
|
|
|
console.dir(item);
|
|
|
|
if (item) {
|
|
|
|
ele.show();
|
2021-02-22 11:40:36 +01:00
|
|
|
ele.find('.amount').text(item.amount.toFixed(2));
|
2020-08-12 02:44:19 +02:00
|
|
|
ele.find('.reference').text((#{raw BankTransactionReference.js_code_for_user(@current_user)})(item.values));
|
2019-11-11 12:09:18 +01:00
|
|
|
} else {
|
|
|
|
ele.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (hide_placeholder) {
|
|
|
|
$('#placeholder').hide();
|
|
|
|
} else {
|
|
|
|
$('#placeholder').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('input', 'input[data-has-name-short]', update);
|
|
|
|
update();
|
|
|
|
});
|
|
|
|
|
|
|
|
= form_tag finance_create_transaction_collection_path do
|
|
|
|
%p
|
|
|
|
%table#ordergroups
|
|
|
|
%thead
|
|
|
|
%tr
|
2021-02-22 11:40:36 +01:00
|
|
|
%th= t('.transaction_types_headline')
|
2019-11-11 12:09:18 +01:00
|
|
|
%th= heading_helper FinancialTransaction, :amount
|
|
|
|
%tbody
|
|
|
|
- for t in @types
|
|
|
|
%tr
|
|
|
|
%td= "#{t.name} (#{t.name_short}):"
|
2021-02-22 11:40:36 +01:00
|
|
|
%td
|
|
|
|
.input-prepend
|
|
|
|
%span.add-on= t 'number.currency.format.unit'
|
|
|
|
= text_field_tag t.name_short, nil, class: 'input-small',
|
2019-11-11 12:09:18 +01:00
|
|
|
'data-has-name-short' => true, 'data-bank-account' => t.bank_account.try(:id),
|
|
|
|
step: 0.01, type: :number
|
|
|
|
%p#placeholder
|
|
|
|
= t('.placeholder')
|
|
|
|
- for ba in @bank_accounts
|
|
|
|
%p{'data-text' => ba.id}
|
|
|
|
= t('.text0')
|
|
|
|
%b.amount= '?'
|
2021-02-22 11:40:36 +01:00
|
|
|
%b= t 'number.currency.format.unit'
|
2019-11-11 12:09:18 +01:00
|
|
|
= t('.text1')
|
|
|
|
%b.reference= '?'
|
|
|
|
= t('.text2')
|
2021-02-20 12:16:21 +01:00
|
|
|
%b= format_iban ba.iban
|