Improve reference calculator

fix rounding error, add currency symbol, better(?) translation for headline
This commit is contained in:
twothreenine 2021-02-22 11:40:36 +01:00 committed by GitHub
parent 401c8f50a8
commit 226c11737f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -12,7 +12,7 @@
$('input[data-has-name-short]').each(function() {
var bank_account = $(this).attr('data-bank-account') || default_bank_account;
var name = $(this).attr('name');
var value = Math.ceil(parseFloat($(this).val()) * 100) / 100;
var value = Math.round(parseFloat($(this).val()) * 100) / 100;
if (value > 0) {
var item = items[bank_account];
if (!item) {
@ -32,7 +32,7 @@
console.dir(item);
if (item) {
ele.show();
ele.find('.amount').text(item.amount);
ele.find('.amount').text(item.amount.toFixed(2));
ele.find('.reference').text((#{raw BankTransactionReference.js_code_for_user(@current_user)})(item.values));
} else {
ele.hide();
@ -55,13 +55,16 @@
%table#ordergroups
%thead
%tr
%th= heading_helper FinancialTransactionType, :name
%th= t('.transaction_types_headline')
%th= heading_helper FinancialTransaction, :amount
%tbody
- for t in @types
%tr
%td= "#{t.name} (#{t.name_short}):"
%td= text_field_tag t.name_short, nil, class: 'input-small',
%td
.input-prepend
%span.add-on= t 'number.currency.format.unit'
= text_field_tag t.name_short, nil, class: 'input-small',
'data-has-name-short' => true, 'data-bank-account' => t.bank_account.try(:id),
step: 0.01, type: :number
%p#placeholder
@ -70,6 +73,7 @@
%p{'data-text' => ba.id}
= t('.text0')
%b.amount= '?'
%b= t 'number.currency.format.unit'
= t('.text1')
%b.reference= '?'
= t('.text2')

View file

@ -1144,6 +1144,7 @@ de:
since: "(Mitglied seit %{when})"
title: "%{user}"
reference_calculator:
transaction_types_headline: Zweck
placeholder: Bitte fülle zuerst die einzelnen Felder mit den gewünschten Beträgen für die Überweisung aus, um die Zahlungsreferenz für diese Transaktion anzuzeigen.
text0: Bitte überweise
text1: mit der Zahlungsreferenz

View file

@ -1148,6 +1148,7 @@ en:
since: "(member for %{when})"
title: "%{user}"
reference_calculator:
transaction_types_headline: Purpose
placeholder: Please enter the amounts you want to tranfser in every field first, to see the reference you should use for that transaction.
text0: Please transfer
text1: with the reference