better readable IBAN (#824)

display IBANs in groups of 4 digits with whitespaces in between
This commit is contained in:
twothreenine 2021-02-20 12:16:21 +01:00 committed by GitHub
parent 00f1dddd3d
commit 401c8f50a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 6 deletions

View File

@ -25,6 +25,11 @@ module ApplicationHelper
content_tag :span, number_to_currency(amount), class: class_name content_tag :span, number_to_currency(amount), class: class_name
end end
# Splits an IBAN into groups of 4 digits displayed with margins in between
def format_iban(iban)
iban.scan(/..?.?.?/).map{ |item| content_tag(:span, item, style: "margin-right: 0.5em;") }.join.html_safe
end
# Creates ajax-controlled-links for pagination # Creates ajax-controlled-links for pagination
def pagination_links_remote(collection, options = {}) def pagination_links_remote(collection, options = {})
per_page = options[:per_page] || @per_page per_page = options[:per_page] || @per_page

View File

@ -9,7 +9,7 @@
- @bank_accounts.each do |bank_account| - @bank_accounts.each do |bank_account|
%tr %tr
%td= bank_account.name %td= bank_account.name
%td= bank_account.iban %td= format_iban bank_account.iban
%td= truncate bank_account.description, length: 50 %td= truncate bank_account.description, length: 50
%td %td
= link_to t('ui.edit'), edit_admin_bank_account_path(bank_account), remote: true, class: 'btn btn-mini' = link_to t('ui.edit'), edit_admin_bank_account_path(bank_account), remote: true, class: 'btn btn-mini'

View File

@ -11,6 +11,6 @@
- for account in @bank_accounts - for account in @bank_accounts
%tr %tr
%td= link_to account.name, finance_bank_account_transactions_path(account) %td= link_to account.name, finance_bank_account_transactions_path(account)
%td= account.iban %td= format_iban account.iban
%td= truncate account.description, length: 50 %td= truncate account.description, length: 50
%td.numeric{style: 'width:5em'}= format_currency account.balance %td.numeric{style: 'width:5em'}= format_currency account.balance

View File

@ -10,7 +10,7 @@
- if @bank_transaction.iban? - if @bank_transaction.iban?
%p %p
%b= heading_helper(BankTransaction, :iban) + ':' %b= heading_helper(BankTransaction, :iban) + ':'
= @bank_transaction.iban = format_iban @bank_transaction.iban
- if user = @bank_transaction.user - if user = @bank_transaction.user
= t('.belongs_to_user') = t('.belongs_to_user')
= user.display = user.display

View File

@ -23,7 +23,7 @@
%p %p
- if supplier.iban.present? - if supplier.iban.present?
%b= heading_helper(Supplier, :iban) + ':' %b= heading_helper(Supplier, :iban) + ':'
= supplier.iban = format_iban supplier.iban
%br/ %br/
%b= t('.invoices_text') + ':' %b= t('.invoices_text') + ':'
= invoices_text.join(', ') = invoices_text.join(', ')

View File

@ -73,4 +73,4 @@
= t('.text1') = t('.text1')
%b.reference= '?' %b.reference= '?'
= t('.text2') = t('.text2')
%b= ba.iban %b= format_iban ba.iban

View File

@ -34,7 +34,7 @@
%dd= @supplier.supplier_category.try(:name) %dd= @supplier.supplier_category.try(:name)
- if FoodsoftConfig[:use_iban] - if FoodsoftConfig[:use_iban]
%dt= heading_helper(Supplier, :iban) + ':' %dt= heading_helper(Supplier, :iban) + ':'
%dd= @supplier.iban %dd= format_iban @supplier.iban
%dt= heading_helper(Supplier, :delivery_days) + ':' %dt= heading_helper(Supplier, :delivery_days) + ':'
%dd= @supplier.delivery_days %dd= @supplier.delivery_days
%dt= heading_helper(Supplier, :order_howto) + ':' %dt= heading_helper(Supplier, :order_howto) + ':'