Add method to close all invoices with an invoice direct
When the charge_members_manually option is active there is no need for an explicit balancing step. This new function allows to close_direct all orders which have an assigned invoice, which is usually indication enough to find orders which can be closed finally.
This commit is contained in:
parent
226d2dda74
commit
ecb4a8a4ba
6 changed files with 31 additions and 5 deletions
|
@ -85,4 +85,17 @@ class Finance::BalancingController < Finance::BaseController
|
||||||
redirect_to finance_order_index_url, alert: t('finance.balancing.close_direct.alert', message: error.message)
|
redirect_to finance_order_index_url, alert: t('finance.balancing.close_direct.alert', message: error.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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('finance.balancing.close_all_direct_with_invoice.notice', count: count)
|
||||||
|
rescue => error
|
||||||
|
redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: error.message)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Order < ApplicationRecord
|
||||||
scope :stockit, -> { where(supplier_id: 0).order('ends DESC') }
|
scope :stockit, -> { where(supplier_id: 0).order('ends DESC') }
|
||||||
scope :recent, -> { order('starts DESC').limit(10) }
|
scope :recent, -> { order('starts DESC').limit(10) }
|
||||||
scope :stock_group_order, -> { group_orders.where(ordergroup_id: nil).first }
|
scope :stock_group_order, -> { group_orders.where(ordergroup_id: nil).first }
|
||||||
|
scope :with_invoice, -> { where.not(invoice: nil) }
|
||||||
|
|
||||||
# Allow separate inputs for date and time
|
# Allow separate inputs for date and time
|
||||||
# with workaround for https://github.com/einzige/date_time_attribute/issues/14
|
# with workaround for https://github.com/einzige/date_time_attribute/issues/14
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
- title t('.title')
|
- title t('.title')
|
||||||
|
|
||||||
|
- content_for :actionbar do
|
||||||
|
- if FoodsoftConfig[:charge_members_manually]
|
||||||
|
= link_to t('.close_all_direct_with_invoice'), close_all_direct_with_invoice_finance_order_index_path, method: :post, class: 'btn'
|
||||||
|
|
||||||
#ordersTable= render 'orders'
|
#ordersTable= render 'orders'
|
|
@ -712,6 +712,8 @@ de:
|
||||||
close:
|
close:
|
||||||
alert: 'Ein Fehler ist beim Abrechnen aufgetreten: %{message}'
|
alert: 'Ein Fehler ist beim Abrechnen aufgetreten: %{message}'
|
||||||
notice: Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert.
|
notice: Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert.
|
||||||
|
close_all_direct_with_invoice:
|
||||||
|
notice: Es wurden %{count} Bestellung abgerechnet.
|
||||||
close_direct:
|
close_direct:
|
||||||
alert: 'Bestellung kann nicht abgerechnet werden: %{message}'
|
alert: 'Bestellung kann nicht abgerechnet werden: %{message}'
|
||||||
notice: Bestellung wurde abgerechnet.
|
notice: Bestellung wurde abgerechnet.
|
||||||
|
@ -733,6 +735,7 @@ de:
|
||||||
total_fc: Summe (FC-Preis)
|
total_fc: Summe (FC-Preis)
|
||||||
units: Einheiten
|
units: Einheiten
|
||||||
index:
|
index:
|
||||||
|
close_all_direct_with_invoice: Alle mit Rechnung abrechnen
|
||||||
title: Beendete Bestellungen
|
title: Beendete Bestellungen
|
||||||
invoice:
|
invoice:
|
||||||
edit: Rechnung bearbeiten
|
edit: Rechnung bearbeiten
|
||||||
|
|
|
@ -737,6 +737,8 @@ en:
|
||||||
close:
|
close:
|
||||||
alert: 'An error occured while accounting: %{message}'
|
alert: 'An error occured while accounting: %{message}'
|
||||||
notice: Order was settled succesfully, the balance of the account was updated.
|
notice: Order was settled succesfully, the balance of the account was updated.
|
||||||
|
close_all_direct_with_invoice:
|
||||||
|
notice: '%{count} orders have been settled.'
|
||||||
close_direct:
|
close_direct:
|
||||||
alert: 'Order can not be settled: %{message}'
|
alert: 'Order can not be settled: %{message}'
|
||||||
notice: Order was settled.
|
notice: Order was settled.
|
||||||
|
@ -758,6 +760,7 @@ en:
|
||||||
total_fc: Sum (FC-price)
|
total_fc: Sum (FC-price)
|
||||||
units: Units
|
units: Units
|
||||||
index:
|
index:
|
||||||
|
close_all_direct_with_invoice: Close all with invoice
|
||||||
title: Closed orders
|
title: Closed orders
|
||||||
invoice:
|
invoice:
|
||||||
edit: Edit invoice
|
edit: Edit invoice
|
||||||
|
|
|
@ -161,6 +161,8 @@ Foodsoft::Application.routes.draw do
|
||||||
get :new_on_order_article_create
|
get :new_on_order_article_create
|
||||||
get :new_on_order_article_update
|
get :new_on_order_article_update
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post :close_all_direct_with_invoice, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :invoices do
|
resources :invoices do
|
||||||
|
|
Loading…
Reference in a new issue