Simplifiying balancing view part 2. Lets call it finished.
This commit is contained in:
parent
dc0d1b3e46
commit
af3c07f031
26 changed files with 185 additions and 219 deletions
|
@ -13,7 +13,8 @@ class Finance::BalancingController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:order_id])
|
||||||
|
flash.now.alert = "Achtung, Bestellung wurde schon abgerechnet" if @order.closed?
|
||||||
@comments = @order.comments
|
@comments = @order.comments
|
||||||
|
|
||||||
if params['sort']
|
if params['sort']
|
||||||
|
@ -35,131 +36,20 @@ class Finance::BalancingController < ApplicationController
|
||||||
@articles = @articles.to_a.sort { |a,b| b.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> a.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
|
@articles = @articles.to_a.sort { |a,b| b.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> a.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
|
||||||
end
|
end
|
||||||
|
|
||||||
view = params[:view]
|
render layout: false if request.xhr?
|
||||||
params[:view] = nil
|
|
||||||
|
|
||||||
case view.try(:to_sym)
|
|
||||||
when 'editResults'
|
|
||||||
render :partial => 'edit_results_by_articles' and return
|
|
||||||
when :groups_overview
|
|
||||||
render :partial => 'shared/articles_by_groups', :locals => {:order => @order} and return
|
|
||||||
when 'articlesOverview'
|
|
||||||
render :partial => 'shared/articles_by_articles', :locals => {:order => @order} and return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_group_order_article
|
def edit_note
|
||||||
goa = OrderArticle.find(params[:id]).group_order_articles.build
|
@order = Order.find(params[:id])
|
||||||
render :update do |page|
|
render :layout => false
|
||||||
page["edit_box"].replace_html :partial => "new_group_order_article",
|
|
||||||
:locals => {:group_order_article => goa}
|
|
||||||
page["edit_box"].show
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a new GroupOrderArticle
|
def update_note
|
||||||
# If the the chosen Ordergroup hasn't ordered yet, a GroupOrder will also be created
|
@order = Order.find(params[:id])
|
||||||
#FIXME: Clean up this messy code !
|
if @order.update_attributes(params[:order])
|
||||||
def create_group_order_article
|
render :layout => false
|
||||||
goa = GroupOrderArticle.new(params[:group_order_article])
|
|
||||||
order_article = goa.order_article
|
|
||||||
order = order_article.order
|
|
||||||
|
|
||||||
# creates a new GroupOrder if necessary
|
|
||||||
group_order = GroupOrder.first :conditions => {:order_id => order.id, :ordergroup_id => goa.ordergroup_id}
|
|
||||||
unless group_order
|
|
||||||
goa.create_group_order(:order_id => order.id, :ordergroup_id => goa.ordergroup_id)
|
|
||||||
else
|
else
|
||||||
goa.group_order = group_order
|
render :action => :edit_note, :layout => false
|
||||||
end
|
|
||||||
|
|
||||||
# If there is an GroupOrderArticle already, only update result attribute.
|
|
||||||
if group_order_article = GroupOrderArticle.first(:conditions => {:group_order_id => goa.group_order, :order_article_id => goa.order_article})
|
|
||||||
goa = group_order_article
|
|
||||||
goa.result = params[:group_order_article]["result"]
|
|
||||||
end
|
|
||||||
|
|
||||||
render :update do |page|
|
|
||||||
if goa.save
|
|
||||||
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
|
||||||
order_article.update_results! if order_article.article.is_a?(StockArticle) # Update units_to_order of order_article
|
|
||||||
page["edit_box"].hide
|
|
||||||
page["order_article_#{order_article.id}"].replace_html :partial => 'order_article', :locals => {:order_article => order_article}
|
|
||||||
|
|
||||||
page["group_order_articles_#{order_article.id}"].replace_html :partial => 'group_order_articles',
|
|
||||||
:locals => {:order_article => order_article}
|
|
||||||
page["group_order_article_#{goa.id}"].visual_effect :highlight, :duration => 2
|
|
||||||
|
|
||||||
page["summary"].replace_html :partial => 'summary', :locals => {:order => order}
|
|
||||||
page["order_profit"].visual_effect :highlight, :duration => 2
|
|
||||||
else
|
|
||||||
page["edit_box"].replace_html :partial => "new_group_order_article",
|
|
||||||
:locals => {:group_order_article => goa}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit_group_order_article
|
|
||||||
group_order_article = GroupOrderArticle.find(params[:id])
|
|
||||||
render :partial => 'edit_group_order_article',
|
|
||||||
:locals => {:group_order_article => group_order_article}
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_group_order_article
|
|
||||||
goa = GroupOrderArticle.find(params[:id])
|
|
||||||
|
|
||||||
render :update do |page|
|
|
||||||
if goa.update_attributes(params[:group_order_article])
|
|
||||||
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
|
||||||
goa.order_article.update_results! if goa.order_article.article.is_a?(StockArticle) # Update units_to_order of order_article
|
|
||||||
|
|
||||||
page["edit_box"].hide
|
|
||||||
page["order_article_#{goa.order_article.id}"].replace_html :partial => 'order_article', :locals => {:order_article => goa.order_article}
|
|
||||||
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
|
|
||||||
:locals => {:order_article => goa.order_article}
|
|
||||||
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
|
|
||||||
page["order_profit"].visual_effect :highlight, :duration => 2
|
|
||||||
else
|
|
||||||
page["edit_box"].replace_html :partial => 'edit_group_order_article'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_group_order_article_result
|
|
||||||
goa = GroupOrderArticle.find(params[:id])
|
|
||||||
|
|
||||||
if params[:modifier] == '-'
|
|
||||||
goa.update_attributes({:result => goa.result - 1})
|
|
||||||
elsif params[:modifier] == '+'
|
|
||||||
goa.update_attributes({:result => goa.result + 1})
|
|
||||||
end
|
|
||||||
|
|
||||||
render :update do |page|
|
|
||||||
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
|
||||||
goa.order_article.update_results! if goa.order_article.article.is_a?(StockArticle) # Update units_to_order of order_article
|
|
||||||
|
|
||||||
page["order_article_#{goa.order_article.id}"].replace_html :partial => 'order_article', :locals => {:order_article => goa.order_article}
|
|
||||||
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
|
|
||||||
:locals => {:order_article => goa.order_article}
|
|
||||||
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
|
|
||||||
page["order_profit"].visual_effect :highlight, :duration => 2
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy_group_order_article
|
|
||||||
goa = GroupOrderArticle.find(params[:id])
|
|
||||||
goa.destroy
|
|
||||||
goa.group_order.update_price! # Updates the price attribute of new GroupOrder
|
|
||||||
goa.order_article.update_results! if goa.order_article.article.is_a?(StockArticle) # Update units_to_order of order_article
|
|
||||||
|
|
||||||
render :update do |page|
|
|
||||||
page["edit_box"].hide
|
|
||||||
page["order_article_#{goa.order_article.id}"].replace_html :partial => 'order_article', :locals => {:order_article => goa.order_article}
|
|
||||||
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
|
|
||||||
:locals => {:order_article => goa.order_article}
|
|
||||||
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
|
|
||||||
page["order_profit"].visual_effect :highlight, :duration => 2
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -171,27 +61,20 @@ class Finance::BalancingController < ApplicationController
|
||||||
# Balances the Order, Update of the Ordergroup.account_balances
|
# Balances the Order, Update of the Ordergroup.account_balances
|
||||||
def close
|
def close
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:id])
|
||||||
begin
|
@order.close!(@current_user)
|
||||||
@order.close!(@current_user)
|
redirect_to finance_balancing_url, notice: "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert."
|
||||||
flash[:notice] = "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert."
|
|
||||||
redirect_to :action => "index"
|
rescue => error
|
||||||
rescue => e
|
redirect_to finance_balancing_url, alert: "Ein Fehler ist beim Abrechnen aufgetreten: #{error.message}"
|
||||||
flash[:error] = "Ein Fehler ist beim Abrechnen aufgetreten: " + e
|
|
||||||
redirect_to :action => "new", :id => @order
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Close the order directly, without automaticly updating ordergroups account balances
|
# Close the order directly, without automaticly updating ordergroups account balances
|
||||||
def close_direct
|
def close_direct
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:id])
|
||||||
if @order.finished?
|
@order.close_direct!(@current_user)
|
||||||
@order.update_attributes(:state => 'closed', :updated_by => @current_user)
|
redirect_to finance_balancing_url, notice: "Bestellung wurde geschlossen."
|
||||||
flash[:notice] = 'Die Bestellung wurde auf "gebucht" gesetzt.'
|
rescue => error
|
||||||
redirect_to :action => 'listOrders', :id => @order
|
redirect_to finance_balancing_url, alert: "Bestellung kann nicht geschlossen werden: #{error.message}"
|
||||||
else
|
|
||||||
flash[:error] = 'Die Bestellung ist noch nicht beendet.'
|
|
||||||
redirect_to :action => 'listOrders', :id => @order
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,5 +6,78 @@ class Finance::GroupOrderArticlesController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@order_article = OrderArticle.find(params[:order_article_id])
|
@order_article = OrderArticle.find(params[:order_article_id])
|
||||||
|
@group_order_article = GroupOrderArticle.new(order_article: @order_article)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@group_order_article = GroupOrderArticle.new(params[:group_order_article])
|
||||||
|
@order_article = @group_order_article.order_article
|
||||||
|
|
||||||
|
# As we hide group_order_articles with a result of 0, we should not complain, when an existing group_order_article is found
|
||||||
|
goa = GroupOrderArticle.where(group_order_id: @group_order_article.group_order_id,
|
||||||
|
order_article_id: @order_article.id).first
|
||||||
|
|
||||||
|
if goa and goa.update_attributes(params[:group_order_article])
|
||||||
|
@group_order_article = goa
|
||||||
|
|
||||||
|
update_summaries(@group_order_article)
|
||||||
|
render :update
|
||||||
|
|
||||||
|
elsif @group_order_article.save
|
||||||
|
update_summaries(@group_order_article)
|
||||||
|
render :update
|
||||||
|
|
||||||
|
else # Validation failed, show form
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@group_order_article = GroupOrderArticle.find(params[:id])
|
||||||
|
@order_article = @group_order_article.order_article
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@group_order_article = GroupOrderArticle.find(params[:id])
|
||||||
|
@order_article = @group_order_article.order_article
|
||||||
|
|
||||||
|
if @group_order_article.update_attributes(params[:group_order_article])
|
||||||
|
update_summaries(@group_order_article)
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_result
|
||||||
|
group_order_article = GroupOrderArticle.find(params[:id])
|
||||||
|
@order_article = group_order_article.order_article
|
||||||
|
|
||||||
|
if params[:modifier] == '-'
|
||||||
|
group_order_article.update_attribute :result, group_order_article.result - 1
|
||||||
|
elsif params[:modifier] == '+'
|
||||||
|
group_order_article.update_attribute :result, group_order_article.result + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
update_summaries(group_order_article)
|
||||||
|
|
||||||
|
render :update
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
group_order_article = GroupOrderArticle.find(params[:id])
|
||||||
|
group_order_article.destroy
|
||||||
|
update_summaries(group_order_article)
|
||||||
|
@order_article = group_order_article.order_article
|
||||||
|
|
||||||
|
render :update
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def update_summaries(group_order_article)
|
||||||
|
# Update the price attribute of new GroupOrder
|
||||||
|
group_order_article.group_order.update_price!
|
||||||
|
# Update units_to_order of order_article
|
||||||
|
group_order_article.order_article.update_results! if group_order_article.order_article.article.is_a?(StockArticle)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Finance::OrderArticlesController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_finance
|
before_filter :authenticate_finance
|
||||||
|
|
||||||
layout false # We only use this controller to server js snippets, no need for layout rendering
|
layout false # We only use this controller to serve js snippets, no need for layout rendering
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@order = Order.find(params[:order_id])
|
@order = Order.find(params[:order_id])
|
||||||
|
|
13
app/helpers/finance/balancing_helper.rb
Normal file
13
app/helpers/finance/balancing_helper.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module Finance::BalancingHelper
|
||||||
|
def balancing_view_partial
|
||||||
|
view = params[:view] || 'edit_results'
|
||||||
|
case view
|
||||||
|
when 'edit_results' then
|
||||||
|
'edit_results_by_articles'
|
||||||
|
when 'groups_overview' then
|
||||||
|
'shared/articles_by_groups'
|
||||||
|
when 'articles_overview' then
|
||||||
|
'shared/articles_by_articles'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +1,10 @@
|
||||||
module Finance::OrderArticlesHelper
|
module Finance::OrderArticlesHelper
|
||||||
|
|
||||||
|
def new_order_articles_collection
|
||||||
|
if @order.stockit?
|
||||||
|
StockArticle.order(:name)
|
||||||
|
else
|
||||||
|
@order.supplier.articles.order(:name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,16 @@ class GroupOrderArticle < ActiveRecord::Base
|
||||||
|
|
||||||
localize_input_of :result
|
localize_input_of :result
|
||||||
|
|
||||||
|
# Setter used in group_order_article#new
|
||||||
|
# We have to create an group_order, if the ordergroup wasn't involved in the order yet
|
||||||
|
def ordergroup_id=(id)
|
||||||
|
self.group_order = GroupOrder.find_or_initialize_by_order_id_and_ordergroup_id(order_article.order_id, id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ordergroup_id
|
||||||
|
group_order.try(:ordergroup_id)
|
||||||
|
end
|
||||||
|
|
||||||
# Updates the quantity/tolerance for this GroupOrderArticle by updating both GroupOrderArticle properties
|
# Updates the quantity/tolerance for this GroupOrderArticle by updating both GroupOrderArticle properties
|
||||||
# and the associated GroupOrderArticleQuantities chronologically.
|
# and the associated GroupOrderArticleQuantities chronologically.
|
||||||
#
|
#
|
||||||
|
|
|
@ -194,6 +194,12 @@ class Order < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Close the order directly, without automaticly updating ordergroups account balances
|
||||||
|
def close_direct!(user)
|
||||||
|
raise "Bestellung wurde schon abgerechnet" if closed?
|
||||||
|
update_attributes! state: 'closed', updated_by: user
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def starts_before_ends
|
def starts_before_ends
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
%h2 Mengenänderung
|
|
||||||
%p
|
|
||||||
= group_order_article.group_order.ordergroup.name
|
|
||||||
hat von
|
|
||||||
= group_order_article.order_article.article.name
|
|
||||||
bekommen:
|
|
||||||
|
|
||||||
- remote_form_for group_order_article, |
|
|
||||||
:url => {:action => 'update_group_order_article', :id => group_order_article }, |
|
|
||||||
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
|
|
||||||
|
|
||||||
= form.error_messages
|
|
||||||
%p
|
|
||||||
%b Menge:
|
|
||||||
(Einheit:
|
|
||||||
= group_order_article.order_article.article.unit
|
|
||||||
)
|
|
||||||
= form.text_field :result, :size => "6"
|
|
||||||
= submit_tag "Speichern"
|
|
||||||
|
|
|
||||||
= link_to_function 'Abbrechen', "Element.hide('edit_box')"
|
|
|
@ -1,7 +0,0 @@
|
||||||
%h2
|
|
||||||
Bearbeiten von
|
|
||||||
= @order_article.article.name
|
|
||||||
|
|
||||||
- remote_form_for :order_article, :url => {:action => 'update_order_article', :id => @order_article }, |
|
|
||||||
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |
|
|
||||||
= render :partial => "order_article_form"
|
|
|
@ -7,7 +7,7 @@
|
||||||
%td Einheiten
|
%td Einheiten
|
||||||
%td Gesamtpreis
|
%td Gesamtpreis
|
||||||
%td{:colspan => "3",:style => "width:14em"}
|
%td{:colspan => "3",:style => "width:14em"}
|
||||||
= link_to '[Gruppe hinzufügen]', new_finance_group_order_article_path(order_id: order_article.order_id),
|
= link_to '[Gruppe hinzufügen]', new_finance_group_order_article_path(order_article_id: order_article.id),
|
||||||
remote: true
|
remote: true
|
||||||
%tbody
|
%tbody
|
||||||
- for group_order_article in order_article.group_order_articles.ordered.all(:include => [:group_order])
|
- for group_order_article in order_article.group_order_articles.ordered.all(:include => [:group_order])
|
||||||
|
@ -17,19 +17,17 @@
|
||||||
= group_order_article.group_order.ordergroup.name
|
= group_order_article.group_order.ordergroup.name
|
||||||
%td{:id => "group_order_article_#{group_order_article.id}_quantity", :style => "white-space:nowrap"}
|
%td{:id => "group_order_article_#{group_order_article.id}_quantity", :style => "white-space:nowrap"}
|
||||||
= group_order_article.result
|
= group_order_article.result
|
||||||
/= button_to_remote( "+", :url => {:action => "update_group_order_article_result", :id => group_order_article, :modifier => '+'}, :html => {:style => "float:left"}, :success => "Element.hide('loader');", :before => "Element.show('loader');")
|
= button_to "+", update_result_finance_group_order_article_path(group_order_article, modifier: '+'),
|
||||||
/= button_to_remote( "-", :url => {:action => "update_group_order_article_result", :id => group_order_article, :modifier => '-'}, :success => "Element.hide('loader');", :before => "Element.show('loader');")
|
method: :put, remote: true, style: 'float:left'
|
||||||
|
= button_to "-", update_result_finance_group_order_article_path(group_order_article, modifier: '-'),
|
||||||
|
method: :put, remote: true
|
||||||
%td.currency
|
%td.currency
|
||||||
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "")
|
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "")
|
||||||
%td.actions{:style=>"width:1em"}
|
%td.actions{:style=>"width:1em"}
|
||||||
= link_to icon(:edit), '#'
|
= link_to icon(:edit), edit_finance_group_order_article_path(group_order_article), remote: true
|
||||||
/:update => 'edit_box', |
|
|
||||||
/:url => {:action => 'edit_group_order_article', :id => group_order_article}, |
|
|
||||||
/:success => "Element.hide('loader'); Element.show('edit_box')" |
|
|
||||||
%td.actions{:style=>"width:1em"}
|
%td.actions{:style=>"width:1em"}
|
||||||
= link_to icon(:delete), '#'
|
= link_to icon(:delete), finance_group_order_article_path(group_order_article), method: :delete,
|
||||||
/:url => {:action => 'destroy_group_order_article', :id => group_order_article}, |
|
remote: true
|
||||||
/:confirm => 'Bist du sicher?', :method => 'post' |
|
|
||||||
%td
|
%td
|
||||||
%tfoot
|
%tfoot
|
||||||
%tr{:class => cycle('even', 'odd', :name => 'results')}
|
%tr{:class => cycle('even', 'odd', :name => 'results')}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
%h2
|
|
||||||
Neue Gruppenmenge für
|
|
||||||
= group_order_article.order_article.article.name
|
|
||||||
- remote_form_for group_order_article, :url => {:action => 'create_group_order_article'}, |
|
|
||||||
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
|
|
||||||
= form.error_messages
|
|
||||||
%p
|
|
||||||
Gruppe:
|
|
||||||
= form.select :ordergroup_id, Ordergroup.all(:order => "name").collect{ |og| [og.name, og.id] }
|
|
||||||
%p
|
|
||||||
Menge:
|
|
||||||
= form.text_field :result, :size => 5
|
|
||||||
= form.hidden_field :order_article_id
|
|
||||||
%p
|
|
||||||
= submit_tag "Speichern"
|
|
||||||
|
|
|
||||||
= link_to_function 'Abbrechen', "Element.hide('edit_box')"
|
|
|
@ -19,7 +19,7 @@
|
||||||
%td= order_article.price.tax
|
%td= order_article.price.tax
|
||||||
%td= order_article.price.deposit
|
%td= order_article.price.deposit
|
||||||
%td
|
%td
|
||||||
= link_to icon(:edit), edit_finance_order_order_article_path(@order, order_article), remote: true
|
= link_to icon(:edit), edit_finance_order_order_article_path(order_article.order, order_article), remote: true
|
||||||
%td
|
%td
|
||||||
= link_to icon(:delete), finance_order_order_article_path(@order, order_article), method: :delete,
|
= link_to icon(:delete), finance_order_order_article_path(order_article.order, order_article), method: :delete,
|
||||||
remote: true, confirm: 'Bist du sicher?'
|
remote: true, confirm: 'Bist du sicher?'
|
|
@ -11,6 +11,6 @@
|
||||||
%td= number_to_currency(group_order.price)
|
%td= number_to_currency(group_order.price)
|
||||||
%p
|
%p
|
||||||
%div{:style => "float:left"}
|
%div{:style => "float:left"}
|
||||||
= button_to "Abschließen", :action => "close", :id => @order
|
= button_to "Abschließen", close_finance_order_path(@order), method: :put
|
||||||
%div{:style => "float:right"}
|
%div{:style => "float:right"}
|
||||||
= link_to 'Zurück zur Abrechnung', :action => 'new', :id => @order
|
= link_to 'Zurück zur Abrechnung', new_finance_order_path(order_id: @order.id)
|
|
@ -58,6 +58,6 @@
|
||||||
%td= order.name
|
%td= order.name
|
||||||
%td= format_date(order.ends)
|
%td= format_date(order.ends)
|
||||||
%td{:class => "currency"}= number_to_currency(order.sum(:fc))
|
%td{:class => "currency"}= number_to_currency(order.sum(:fc))
|
||||||
%td= link_to "abrechnen", new_finance_order_path(id: order)
|
%td= link_to "abrechnen", new_finance_order_path(order_id: order.id)
|
||||||
- else
|
- else
|
||||||
Super, alles schon abgerechnet...
|
Super, alles schon abgerechnet...
|
|
@ -1,7 +1,4 @@
|
||||||
- title "beendete Bestellungen"
|
- title "beendete Bestellungen"
|
||||||
%p{:style => "width:30em"}
|
|
||||||
%i
|
|
||||||
Beschreibungstext für die Abrechnunsmodi ....
|
|
||||||
.left_column{:style => "width:70em"}
|
.left_column{:style => "width:70em"}
|
||||||
.box_title
|
.box_title
|
||||||
.column_content
|
.column_content
|
||||||
|
@ -18,15 +15,15 @@
|
||||||
%tbody
|
%tbody
|
||||||
- @orders.each do |order|
|
- @orders.each do |order|
|
||||||
%tr{:class => cycle("even","odd", :name => "order")}
|
%tr{:class => cycle("even","odd", :name => "order")}
|
||||||
%td= link_to truncate(order.name), :action => "new", :id => order
|
%td= link_to truncate(order.name), new_finance_order_path(order_id: order.id)
|
||||||
%td=h format_time(order.ends) unless order.ends.nil?
|
%td=h format_time(order.ends) unless order.ends.nil?
|
||||||
%td= order.closed? ? "abgerechnet (#{number_to_currency order.foodcoop_result})" : "beendet"
|
%td= order.closed? ? "abgerechnet (#{number_to_currency order.foodcoop_result})" : "beendet"
|
||||||
%td= order.updated_by.nil? ? '??' : order.updated_by.nick
|
%td= order.updated_by.nil? ? '??' : order.updated_by.nick
|
||||||
%td
|
%td
|
||||||
- unless order.closed?
|
- unless order.closed?
|
||||||
= link_to "abrechnen", :action => "new", :id => order
|
= link_to "abrechnen", new_finance_order_path(order_id: order.id)
|
||||||
|
|
|
|
||||||
= link_to 'direkt schließen', {:action => 'close_direct', :id => order}, |
|
= link_to 'direkt schließen', close_direct_finance_order_path(order),
|
||||||
:confirm => 'Wirklich die Bestellung schließen setzen?', :method => "post" |
|
:confirm => 'Wirklich die Bestellung schließen setzen?', :method => :put
|
||||||
- else
|
- else
|
||||||
%i derzeit gibt es keine beendeten Bestellungen
|
%i derzeit gibt es keine beendeten Bestellungen
|
|
@ -1,8 +1,5 @@
|
||||||
- title "#{@order.name} abrechnen"
|
- title "#{@order.name} abrechnen"
|
||||||
|
|
||||||
- if @order.closed?
|
|
||||||
%p
|
|
||||||
%b Achtung, Bestellung wurde schon abgerechnet!
|
|
||||||
.left_column{:style => 'width: 24em'}
|
.left_column{:style => 'width: 24em'}
|
||||||
.box_title
|
.box_title
|
||||||
%h2 Zusammenfassung
|
%h2 Zusammenfassung
|
||||||
|
@ -46,11 +43,11 @@
|
||||||
.box_title
|
.box_title
|
||||||
#editOrderNav
|
#editOrderNav
|
||||||
%ul
|
%ul
|
||||||
%li= link_to 'Gruppenübersicht', new_finance_order_path(@order, view: :groups_overview)
|
%li= link_to 'Bestellung bearbeiten', new_finance_order_path(order_id: @order.id, view: 'edit_results'), remote: true
|
||||||
/%li= remote_link_to 'Artikelübersicht', :update => 'results', :url => {:action => 'new', :id => @order, :view => 'articlesOverview'}
|
%li= link_to 'Gruppenübersicht', new_finance_order_path(order_id: @order.id, view: 'groups_overview'), remote: true
|
||||||
/%li= remote_link_to 'Bestellung bearbeiten', :update => 'results', :url => {:action => 'new', :id => @order, :view => 'editResults'}
|
%li= link_to 'Artikelübersicht', new_finance_order_path(order_id: @order.id, view: 'articles_overview'), remote: true
|
||||||
.column_content
|
.column_content
|
||||||
#results
|
#results
|
||||||
= render :partial => 'edit_results_by_articles'
|
= render partial: 'edit_results_by_articles'
|
||||||
%p= link_to_top
|
%p= link_to_top
|
||||||
#edit_box{:style => 'display:none'}
|
#edit_box{:style => 'display:none'}
|
1
app/views/finance/balancing/new.js.erb
Normal file
1
app/views/finance/balancing/new.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$('#results').html('<%= escape_javascript(render(partial: balancing_view_partial, locals: {order: @order})) %>');
|
9
app/views/finance/group_order_articles/_form.html.haml
Normal file
9
app/views/finance/group_order_articles/_form.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
%h2 Mengenänderung
|
||||||
|
%p
|
||||||
|
%b Artikel: #{@order_article.article.name}
|
||||||
|
|
||||||
|
- simple_form_for [:finance, @group_order_article], remote: true do |form|
|
||||||
|
= form.hidden_field :order_article_id
|
||||||
|
= form.input :ordergroup_id, as: :select, collection: Ordergroup.all.map { |g| [g.name, g.id] }
|
||||||
|
= form.input :result, hint: "Einheit: #{@order_article.article.unit}"
|
||||||
|
= form.submit 'Speichern'
|
1
app/views/finance/group_order_articles/edit.js.erb
Normal file
1
app/views/finance/group_order_articles/edit.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$.fancybox('<%= escape_javascript(render('form')) %>');
|
1
app/views/finance/group_order_articles/new.js.erb
Normal file
1
app/views/finance/group_order_articles/new.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$.fancybox('<%= escape_javascript(render("form")) %>');
|
5
app/views/finance/group_order_articles/update.js.erb
Normal file
5
app/views/finance/group_order_articles/update.js.erb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
$.fancybox.close();
|
||||||
|
$('#order_article_<%= @order_article.id %>').
|
||||||
|
html('<%= escape_javascript(render(partial: 'finance/balancing/order_article', locals: {order_article: @order_article})) %>');
|
||||||
|
$('#group_order_articles_<%= @order_article.id %>').
|
||||||
|
html('<%= escape_javascript(render(partial: 'finance/balancing/group_order_articles', locals: {order_article: @order_article})) %>');
|
|
@ -1,7 +1,6 @@
|
||||||
%h2 Artikel aktualisieren
|
%h2 Artikel aktualisieren
|
||||||
|
|
||||||
= form_for [:finance, @order, @order_article], remote: true do |form|
|
= form_for [:finance, @order, @order_article], remote: true do |form|
|
||||||
= @order_article.errors.try(:full_messages)
|
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%th Name
|
%th Name
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
Neuer gelieferter Artikel die Bestellung
|
Neuer gelieferter Artikel die Bestellung
|
||||||
|
|
||||||
= simple_form_for [:finance, @order, @order_article], remote: true do |form|
|
= simple_form_for [:finance, @order, @order_article], remote: true do |form|
|
||||||
= form.input :article_id, as: :select, collection: @order.supplier.articles.order(:name)
|
= form.input :article_id, as: :select, collection: new_order_articles_collection
|
||||||
= form.submit
|
= form.submit
|
|
@ -348,6 +348,9 @@ de:
|
||||||
ends: "Endet am"
|
ends: "Endet am"
|
||||||
order_article:
|
order_article:
|
||||||
article_id: Artikel aus dem Katalog wählen
|
article_id: Artikel aus dem Katalog wählen
|
||||||
|
group_order_article:
|
||||||
|
ordergroup_id: Bestellgruppe
|
||||||
|
result: Menge
|
||||||
invoice:
|
invoice:
|
||||||
supplier: Lieferant
|
supplier: Lieferant
|
||||||
number: Nummer
|
number: Nummer
|
||||||
|
|
|
@ -119,19 +119,26 @@ Foodsoft::Application.routes.draw do
|
||||||
|
|
||||||
namespace :finance do
|
namespace :finance do
|
||||||
root :to => 'balancing#index'
|
root :to => 'balancing#index'
|
||||||
|
match 'balancing/list' => 'balancing#list', :as => 'balancing'
|
||||||
|
|
||||||
resources :order, controller: 'balancing', path: 'balancing' do
|
resources :order, controller: 'balancing', path: 'balancing' do
|
||||||
member do
|
member do
|
||||||
get :edit_note
|
get :edit_note
|
||||||
put :update_note
|
put :update_note
|
||||||
|
|
||||||
|
get :confirm
|
||||||
|
put :close
|
||||||
|
put :close_direct
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :order_articles
|
resources :order_articles
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :group_order_articles
|
resources :group_order_articles do
|
||||||
|
member do
|
||||||
match 'balancing/list' => 'balancing#list', :as => 'balancing'
|
put :update_result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :invoices
|
resources :invoices
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// Show/Hide a specific DOM element
|
// Show/Hide a specific DOM element
|
||||||
$('a[data-toggle-this]').click(function() {
|
$('a[data-toggle-this]').live('click', function() {
|
||||||
$($(this).data('toggle-this')).toggle();
|
$($(this).data('toggle-this')).toggle();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove this item from DOM
|
// Remove this item from DOM
|
||||||
$('a[data-remove-this').click(function() {
|
$('a[data-remove-this]').live('click', function() {
|
||||||
$($(this).data('remove-this')).remove();
|
$($(this).data('remove-this')).remove();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue