changing view for group_order_invoices
testing ui of goi restructuring
This commit is contained in:
parent
de6643722a
commit
90c5450525
52 changed files with 783 additions and 57 deletions
|
|
@ -3,6 +3,7 @@
|
|||
# Normal ordering actions of members of order groups is handled by the OrderingController.
|
||||
class OrdersController < ApplicationController
|
||||
include Concerns::SendOrderPdf
|
||||
include SepaHelper
|
||||
|
||||
before_action :authenticate_pickups_or_orders
|
||||
before_action :authenticate_orders,
|
||||
|
|
@ -159,6 +160,69 @@ class OrdersController < ApplicationController
|
|||
render layout: false
|
||||
end
|
||||
|
||||
def collective_direct_debit
|
||||
if foodsoft_sepa_ready?
|
||||
case params[:mode]
|
||||
when 'all'
|
||||
group_orders = GroupOrder.where(order_id: params[:id])
|
||||
when 'selected'
|
||||
group_orders = GroupOrder.where(id: params[:group_order_ids])
|
||||
else
|
||||
redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: '')
|
||||
end
|
||||
|
||||
@order = Order.find(params[:id])
|
||||
ordergroups = group_orders.map(&:ordergroup)
|
||||
|
||||
export_allowed = !ordergroups.map(&:sepa_possible?).include?(false) && !group_orders.map { |go| go.group_order_invoice.present? }.include?(false)
|
||||
group_order_ids = group_orders.map { |go| go.id if go.group_order_invoice.present? }
|
||||
|
||||
sepa_possible_ordergroup_names = ordergroups.map { |ordergroup| ordergroup.name unless ordergroup.sepa_possible? }.compact_blank
|
||||
|
||||
if export_allowed && group_orders.present?
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded)
|
||||
collective_debit = OrderCollectiveDirectDebitXml.new(group_orders)
|
||||
send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
|
||||
rescue StandardError => e
|
||||
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
|
||||
redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', '))
|
||||
end
|
||||
format.xml do
|
||||
group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded)
|
||||
collective_debit = OrderCollectiveDirectDebitXml.new(group_orders)
|
||||
send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
|
||||
rescue SEPA::Error => e
|
||||
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
|
||||
render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) }
|
||||
end
|
||||
format.js
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', '))
|
||||
end
|
||||
format.xml do
|
||||
render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) }
|
||||
end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to finance_order_index_path, alert: "Wichtige SEPA Konfiguration in Administration >> Einstellungen >> Finanzen nicht gesetzt!"
|
||||
end
|
||||
format.xml do
|
||||
redirect_to finance_order_index_path, alert: "Wichtige SEPA Konfiguration in Administration >> Einstellungen >> Finanzen nicht gesetzt!"
|
||||
end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def update_order_amounts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue