Class: Finance::BalancingController
- Inherits:
-
BaseController
- Object
- BaseController
- Finance::BalancingController
- Defined in:
- app/controllers/finance/balancing_controller.rb
Instance Method Summary collapse
-
#close ⇒ Object
Balances the Order, Update of the Ordergroup.account_balances.
- #close_all_direct_with_invoice ⇒ Object
-
#close_direct ⇒ Object
Close the order directly, without automaticly updating ordergroups account balances.
-
#confirm ⇒ Object
before the order will booked, a view lists all Ordergroups and its order_prices.
- #edit_note ⇒ Object
- #edit_transport ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#new_on_order_article_create ⇒ Object
See publish/subscribe design pattern in /doc.
-
#new_on_order_article_update ⇒ Object
See publish/subscribe design pattern in /doc.
- #update_note ⇒ Object
- #update_summary ⇒ Object
- #update_transport ⇒ Object
Instance Method Details
#close ⇒ Object
Balances the Order, Update of the Ordergroup.account_balances
80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/finance/balancing_controller.rb', line 80 def close @order = Order.find(params[:id]) @type = FinancialTransactionType.find_by_id(params.permit(:type)[:type]) @link = FinancialLink.new if params[:create_financial_link] @order.close!(@current_user, @type, @link, create_foodcoop_transaction: params[:create_foodcoop_transaction]) redirect_to finance_order_index_url, notice: t('.notice') rescue StandardError => e redirect_to new_finance_order_url(order_id: @order.id), alert: t('.alert', message: e.) end |
#close_all_direct_with_invoice ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/finance/balancing_controller.rb', line 99 def close_all_direct_with_invoice count = 0 Order.transaction do Order.finished_not_closed.with_invoice.each do |order| order.close_direct! current_user count += 1 end end redirect_to finance_order_index_url, notice: t('.notice', count: count) rescue StandardError => e redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: e.) end |
#close_direct ⇒ Object
Close the order directly, without automaticly updating ordergroups account balances
91 92 93 94 95 96 97 |
# File 'app/controllers/finance/balancing_controller.rb', line 91 def close_direct @order = Order.find(params[:id]) @order.close_direct!(@current_user) redirect_to finance_order_index_url, notice: t('.notice') rescue StandardError => e redirect_to finance_order_index_url, alert: t('.alert', message: e.) end |
#confirm ⇒ Object
before the order will booked, a view lists all Ordergroups and its order_prices
75 76 77 |
# File 'app/controllers/finance/balancing_controller.rb', line 75 def confirm @order = Order.find(params[:id]) end |
#edit_note ⇒ Object
47 48 49 50 |
# File 'app/controllers/finance/balancing_controller.rb', line 47 def edit_note @order = Order.find(params[:id]) render layout: false end |
#edit_transport ⇒ Object
61 62 63 64 |
# File 'app/controllers/finance/balancing_controller.rb', line 61 def edit_transport @order = Order.find(params[:id]) render layout: false end |
#index ⇒ Object
2 3 4 |
# File 'app/controllers/finance/balancing_controller.rb', line 2 def index @orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC') end |
#new ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/finance/balancing_controller.rb', line 6 def new @order = Order.find(params[:order_id]) flash.now.alert = t('.alert') if @order.closed? @comments = @order.comments @articles = @order.order_articles.ordered_or_member.includes(:article, :article_price, group_order_articles: { group_order: :ordergroup }) sort_param = params['sort'] || 'name' @articles = case sort_param when 'name' @articles.order('articles.name ASC') when 'name_reverse' @articles.order('articles.name DESC') when 'order_number' @articles.order('articles.order_number ASC') when 'order_number_reverse' @articles.order('articles.order_number DESC') else @articles end render layout: false if request.xhr? end |
#new_on_order_article_create ⇒ Object
See publish/subscribe design pattern in /doc.
31 32 33 34 35 |
# File 'app/controllers/finance/balancing_controller.rb', line 31 def new_on_order_article_create # See publish/subscribe design pattern in /doc. @order_article = OrderArticle.find(params[:order_article_id]) render layout: false end |
#new_on_order_article_update ⇒ Object
See publish/subscribe design pattern in /doc.
37 38 39 40 41 |
# File 'app/controllers/finance/balancing_controller.rb', line 37 def new_on_order_article_update # See publish/subscribe design pattern in /doc. @order_article = OrderArticle.find(params[:order_article_id]) render layout: false end |
#update_note ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/controllers/finance/balancing_controller.rb', line 52 def update_note @order = Order.find(params[:id]) if @order.update(params[:order]) render layout: false else render action: :edit_note, layout: false end end |
#update_summary ⇒ Object
43 44 45 |
# File 'app/controllers/finance/balancing_controller.rb', line 43 def update_summary @order = Order.find(params[:id]) end |
#update_transport ⇒ Object
66 67 68 69 70 71 72 |
# File 'app/controllers/finance/balancing_controller.rb', line 66 def update_transport @order = Order.find(params[:id]) @order.update!(params[:order]) redirect_to new_finance_order_path(order_id: @order.id) rescue StandardError => e redirect_to new_finance_order_path(order_id: @order.id), alert: t('errors.general_msg', msg: e.) end |