diff --git a/app/controllers/group_order_invoices_controller.rb b/app/controllers/group_order_invoices_controller.rb index 8228005e..7ba9b760 100644 --- a/app/controllers/group_order_invoices_controller.rb +++ b/app/controllers/group_order_invoices_controller.rb @@ -37,9 +37,9 @@ class GroupOrderInvoicesController < ApplicationController goi.invoice_number = goi.generate_invoice_number(1) goi.save! end - redirect_back fallback_location: root_path - rescue => error - redirect_back fallback_location: root_path, notice: 'Something went wrong', :alert => I18n.t('errors.general_msg', :msg => error) + respond_to do |format| + format.js + end end def create diff --git a/app/models/group_order_invoice.rb b/app/models/group_order_invoice.rb index a4c1cf1c..21557161 100644 --- a/app/models/group_order_invoice.rb +++ b/app/models/group_order_invoice.rb @@ -7,14 +7,6 @@ class GroupOrderInvoice < ApplicationRecord def generate_invoice_number(count) trailing_number = count.to_s.rjust(4, '0') - puts " - " + "______________" + " - " + "______________" + " - " + "______________" + " - " + "#{self.invoice_date}" + " - " + "______________"+ " - " + "______________"+ " - " + "______________" if GroupOrderInvoice.find_by(invoice_number: self.invoice_date.strftime("%Y%m%d") + trailing_number) generate_invoice_number(count.to_i + 1) else diff --git a/app/views/finance/balancing/index.html.haml b/app/views/finance/balancing/index.html.haml index 1d1fd8b5..0cfeccbd 100644 --- a/app/views/finance/balancing/index.html.haml +++ b/app/views/finance/balancing/index.html.haml @@ -1,5 +1,5 @@ - title t('.title') - +- puts params - 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' diff --git a/app/views/group_order_invoices/_links.html.haml b/app/views/group_order_invoices/_links.html.haml index b79b0f64..34bd6271 100644 --- a/app/views/group_order_invoices/_links.html.haml +++ b/app/views/group_order_invoices/_links.html.haml @@ -5,9 +5,9 @@ - if go.group_order_invoice.present? - show_generate_with_date = false - if show_generate_with_date - = form_for :group_order_invoice, url: url_for('group_order_invoice#create_multiple') do |f| + = form_for :group_order_invoice, url: url_for('group_order_invoice#create_multiple'), remote: true do |f| = f.label :invoice_date, I18n.t('activerecord.attributes.group_order_invoice.links.invoice_date') - = f.date_field :invoice_date, {} + = f.date_field :invoice_date, {value: Date.today, max: Date.today, required: true} = f.hidden_field :order_id, value: order.id = f.submit I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'), class: 'btn btn small' diff --git a/app/views/group_order_invoices/create_multiple.js.erb b/app/views/group_order_invoices/create_multiple.js.erb new file mode 100644 index 00000000..11ebbe45 --- /dev/null +++ b/app/views/group_order_invoices/create_multiple.js.erb @@ -0,0 +1 @@ +$("#generate-invoice<%= @order.id %>").html("<%= escape_javascript(render partial: 'links', locals: {order: @order}) %>");