Allow deletion of financial transactions

This commit is contained in:
Patrick Gansterer 2019-11-01 19:30:23 +01:00
parent 260ef90f6b
commit ff76fa60c0
14 changed files with 79 additions and 8 deletions

View file

@ -1,4 +1,5 @@
- with_ordergroup = local_assigns[:with_ordergroup]
- with_hidden = local_assigns[:with_hidden]
- with_csv = local_assigns[:with_csv]
.pull-right
- if with_csv
@ -22,9 +23,11 @@
- FinancialTransactionClass.sorted.each do |c|
%th
= sort_link_helper c.display, "amount"
- if with_hidden
%th
%tbody
- @financial_transactions.each do |t|
%tr
%tr{class: "#{'deleted_row' if t.hidden?}"}
%td
- if t.financial_link
= link_to format_time(t.created_on), finance_link_path(t.financial_link)
@ -40,3 +43,10 @@
%td.numeric{style: 'width:5em'}
- if t.financial_transaction_type.financial_transaction_class == c
= format_currency t.amount
- if with_hidden
%td.actions{style: 'width:1em'}
- unless t.hidden?
= link_to finance_ordergroup_transaction_path(t.ordergroup, t), method: :delete,
data: {confirm: t('.confirm_revert', name: t.note)}, title: t('.revert_title'),
class: 'btn btn-danger btn-mini' do
= glyph :remove

View file

@ -19,3 +19,8 @@
= f.text_field :amount_gteq, class: 'input-mini'
%span.add-on -
= f.text_field :amount_lteq, class: 'input-mini search-query'
 
%label{for: 'show_hidden'}
= check_box_tag 'show_hidden', 1, params[:show_hidden]
= t '.show_hidden'

View file

@ -22,4 +22,4 @@
= render 'transactions_search', url: finance_ordergroup_transactions_path(@ordergroup)
#transactions= render 'transactions', with_csv: true
#transactions= render 'transactions', with_csv: true, with_hidden: true

View file

@ -1 +1 @@
$('#transactions').html('<%= escape_javascript(render("transactions", with_csv: true)) %>');
$('#transactions').html('<%= escape_javascript(render("transactions", with_csv: true, with_hidden: true)) %>');

View file

@ -73,7 +73,7 @@
- FinancialTransactionClass.sorted.each do |fc|
%th
= fc.display
- for ft in current_user.ordergroup.financial_transactions.includes(:financial_transaction_type, :user).limit(5).order('created_on DESC')
- for ft in current_user.ordergroup.financial_transactions.visible.includes(:financial_transaction_type, :user).limit(5).order(created_on: :desc)
%tr
%td= format_time(ft.created_on)
%td= h(show_user(ft.user))