From 76be8fdf1a22ebbe8666afbe8d74f5f0909af6ee Mon Sep 17 00:00:00 2001 From: viehlieb Date: Tue, 29 Mar 2022 13:17:36 +0200 Subject: [PATCH] wip on entering individual date for invoices --- .../group_order_invoices_controller.rb | 25 ++++++++++++++++++- .../group_order_invoices/_links.html.haml | 6 +++++ config/routes.rb | 9 +++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app/controllers/group_order_invoices_controller.rb b/app/controllers/group_order_invoices_controller.rb index 82c411da..b444462a 100644 --- a/app/controllers/group_order_invoices_controller.rb +++ b/app/controllers/group_order_invoices_controller.rb @@ -26,9 +26,32 @@ class GroupOrderInvoicesController < ApplicationController end end + def create_multiple + invoice_date = params[:group_order_invoice][:invoice_date] + order_id = params[:group_order_invoice][:order_id] + puts " + " + "______________" + " + " + "______________" + " + " + "______________" + " + " + "#{invoice_date}" + " + " + "______________"+ " + " + "______________"+ " + " + "______________" + raise "#{invoice_date}" + gos = GroupOrder.find_by(order_id: params[:order_id]) + for go in gos + GroupOrderInvoice.find_or_create_by!(group_order_id: go.id) + respond_to do |format| + format.js + end + 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) + end + def create go = GroupOrder.find(params[:group_order]) - @order = go.order GroupOrderInvoice.find_or_create_by!(group_order_id: go.id) respond_to do |format| format.js diff --git a/app/views/group_order_invoices/_links.html.haml b/app/views/group_order_invoices/_links.html.haml index 78922d76..4c69e766 100644 --- a/app/views/group_order_invoices/_links.html.haml +++ b/app/views/group_order_invoices/_links.html.haml @@ -1,3 +1,9 @@ +.row + = form_for :group_order_invoice, url: url_for('group_order_invoice#create_multiple') do |f| + = f.date_field :invoice_date, {} + = f.hidden_field :order_id, value: order.id + = f.submit 'Alle Rechnungen mit Datum erzeugen', class: 'btn btn small' + - order.group_orders.includes([:group_order_invoice, :ordergroup]).each do |go| .row .column.small-3 diff --git a/config/routes.rb b/config/routes.rb index 3b0b3ebf..03fa73cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -139,11 +139,15 @@ Rails.application.routes.draw do end end end + + + post 'finance/group_order_invoice', to: 'group_order_invoices#create_multiple' resources :group_order_invoices + resources :article_categories - + ########### Finance - + namespace :finance do root to: 'base#index' @@ -172,6 +176,7 @@ Rails.application.routes.draw do get :unpaid, on: :collection end + resources :links, controller: 'financial_links', only: [:create, :show] do collection do get :incomplete