Merge branch 'master' of git://github.com/bennibu/foodsoft
This commit is contained in:
commit
15cec5b8f9
10 changed files with 99 additions and 56 deletions
|
@ -33,7 +33,16 @@ class Finance::BalancingController < ApplicationController
|
||||||
:order => sort
|
:order => sort
|
||||||
)
|
)
|
||||||
|
|
||||||
case params[:view]
|
if params[:sort] == "order_number"
|
||||||
|
@articles = @articles.sort { |a,b| a.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> b.article.order_number.gsub(/[a-zA-Z]/, "").to_i }
|
||||||
|
elsif params[:sort] == "order_number_reverse"
|
||||||
|
@articles = @articles.sort { |a,b| b.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> a.article.order_number.gsub(/[a-zA-Z]/, "").to_i }
|
||||||
|
end
|
||||||
|
|
||||||
|
view = params[:view]
|
||||||
|
params[:view] = nil
|
||||||
|
|
||||||
|
case view
|
||||||
when 'editResults'
|
when 'editResults'
|
||||||
render :partial => 'edit_results_by_articles' and return
|
render :partial => 'edit_results_by_articles' and return
|
||||||
when 'groupsOverview'
|
when 'groupsOverview'
|
||||||
|
@ -41,15 +50,6 @@ class Finance::BalancingController < ApplicationController
|
||||||
when 'articlesOverview'
|
when 'articlesOverview'
|
||||||
render :partial => 'shared/articles_by_articles', :locals => {:order => @order} and return
|
render :partial => 'shared/articles_by_articles', :locals => {:order => @order} and return
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.haml
|
|
||||||
format.js do
|
|
||||||
render :update do |page|
|
|
||||||
page.replace_html 'results', :partial => "edit_results_by_articles"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_note
|
def edit_note
|
||||||
|
@ -164,6 +164,7 @@ class Finance::BalancingController < ApplicationController
|
||||||
|
|
||||||
# Creates a new GroupOrderArticle
|
# Creates a new GroupOrderArticle
|
||||||
# If the the chosen Ordergroup hasn't ordered yet, a GroupOrder will also be created
|
# If the the chosen Ordergroup hasn't ordered yet, a GroupOrder will also be created
|
||||||
|
#FIXME: Clean up this messy code !
|
||||||
def create_group_order_article
|
def create_group_order_article
|
||||||
goa = GroupOrderArticle.new(params[:group_order_article])
|
goa = GroupOrderArticle.new(params[:group_order_article])
|
||||||
order_article = goa.order_article
|
order_article = goa.order_article
|
||||||
|
@ -177,6 +178,12 @@ class Finance::BalancingController < ApplicationController
|
||||||
goa.group_order = group_order
|
goa.group_order = group_order
|
||||||
end
|
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|
|
render :update do |page|
|
||||||
if goa.save
|
if goa.save
|
||||||
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
||||||
|
|
|
@ -152,7 +152,12 @@ class OrdersController < ApplicationController
|
||||||
# Renders the matrix PDF.
|
# Renders the matrix PDF.
|
||||||
def matrixPdf
|
def matrixPdf
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:id])
|
||||||
prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf"
|
unless @order.order_articles.ordered.empty?
|
||||||
|
prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf"
|
||||||
|
else
|
||||||
|
flash[:error] = "Es sind keine Artikel bestellt worden."
|
||||||
|
redirect_to @order
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# adds a Comment to the Order
|
# adds a Comment to the Order
|
||||||
|
|
|
@ -58,10 +58,13 @@ module ApplicationHelper
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_link_helper(text, param, per_page = (@per_page || 10), action = "list" )
|
def sort_link_helper(text, key, options = {})
|
||||||
key = param
|
per_page = options[:per_page] || 10
|
||||||
key += "_reverse" if params[:sort] == param
|
action = options[:action] || "list"
|
||||||
options = {
|
remote = options[:remote].nil? ? true : options[:remote]
|
||||||
|
key += "_reverse" if params[:sort] == key
|
||||||
|
|
||||||
|
link_options = {
|
||||||
:url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})),
|
:url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})),
|
||||||
:before => "Element.show('loader')",
|
:before => "Element.show('loader')",
|
||||||
:success => "Element.hide('loader')",
|
:success => "Element.hide('loader')",
|
||||||
|
@ -71,7 +74,12 @@ module ApplicationHelper
|
||||||
:title => _("Nach #{text} sortieren"),
|
:title => _("Nach #{text} sortieren"),
|
||||||
:href => url_for(:action => action, :params => params.merge({:sort => key, :page => nil, :per_page => per_page}))
|
:href => url_for(:action => action, :params => params.merge({:sort => key, :page => nil, :per_page => per_page}))
|
||||||
}
|
}
|
||||||
link_to_remote(text, options, html_options)
|
|
||||||
|
if remote
|
||||||
|
link_to_remote(text, link_options, html_options)
|
||||||
|
else
|
||||||
|
link_to(text, link_options[:url], html_options)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a link to the top of the website
|
# Generates a link to the top of the website
|
||||||
|
|
|
@ -32,6 +32,11 @@ class GroupOrderArticle < ActiveRecord::Base
|
||||||
|
|
||||||
named_scope :ordered, :conditions => 'result > 0'
|
named_scope :ordered, :conditions => 'result > 0'
|
||||||
|
|
||||||
|
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||||
|
def result=(result)
|
||||||
|
self[:result] = String.delocalized_decimal(result)
|
||||||
|
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.
|
||||||
#
|
#
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th[sort_td_class_helper "name"]{:colspan => "1"}
|
%th[sort_td_class_helper "name"]{:colspan => "1"}
|
||||||
= sort_link_helper "Artikel", "name", 1000, "new"
|
= sort_link_helper "Artikel", "name", :action => "new", :remote => false
|
||||||
%th[sort_td_class_helper "order_number"]
|
%th[sort_td_class_helper "order_number"]
|
||||||
= sort_link_helper "Nr.", "order_number", 1000, "new"
|
= sort_link_helper "Nr.", "order_number", :action => "new", :remote => false
|
||||||
%th Menge
|
%th Menge
|
||||||
%th GebGr * Einheit
|
%th GebGr * Einheit
|
||||||
%th Netto
|
%th Netto
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
%td{:colspan => "3",:style => "width:14em"}
|
%td{:colspan => "3",:style => "width:14em"}
|
||||||
= remote_link_to '[Gruppe hinzufügen]', :url => {:action => "new_group_order_article", :id => order_article}
|
= remote_link_to '[Gruppe hinzufügen]', :url => {:action => "new_group_order_article", :id => order_article}
|
||||||
%tbody
|
%tbody
|
||||||
- for group_order_article in order_article.group_order_articles.all(:include => [:group_order])
|
- for group_order_article in order_article.group_order_articles.ordered.all(:include => [:group_order])
|
||||||
%tr{:class => cycle('even', 'odd', :name => 'results')}[group_order_article]
|
%tr{:class => cycle('even', 'odd', :name => 'results')}[group_order_article]
|
||||||
%td
|
%td
|
||||||
%td{:style=>"width:50%"}
|
%td{:style=>"width:50%"}
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
%table.list
|
%table.list
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th= sort_link_helper "Name", "name", @per_page
|
%th= sort_link_helper "Name", "name", :per_page => @per_page
|
||||||
%th Kontakt
|
%th Kontakt
|
||||||
%th= sort_link_helper "Kontostand", "account_balance", @per_page
|
%th= sort_link_helper "Kontostand", "account_balance", :per_page => @per_page
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
- for group in @groups
|
- for group in @groups
|
||||||
|
|
|
@ -6,6 +6,7 @@ pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
||||||
end
|
end
|
||||||
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
||||||
pdf.stroke_horizontal_rule
|
pdf.stroke_horizontal_rule
|
||||||
|
pdf.move_down 2
|
||||||
pdf.text "Seite #{pdf.page_count}", :size => 8
|
pdf.text "Seite #{pdf.page_count}", :size => 8
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,6 +36,9 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
|
||||||
|
|
||||||
page_number += 1
|
page_number += 1
|
||||||
pdf.start_new_page(:layout => :landscape)
|
pdf.start_new_page(:layout => :landscape)
|
||||||
|
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
||||||
|
pdf.text title, :size => 10, :align => :center
|
||||||
|
end
|
||||||
|
|
||||||
# Collect order_articles for this page
|
# Collect order_articles for this page
|
||||||
current_order_articles = order_articles.select do |a|
|
current_order_articles = order_articles.select do |a|
|
||||||
|
@ -45,7 +49,7 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
|
||||||
# Make order_articles header
|
# Make order_articles header
|
||||||
header = [""]
|
header = [""]
|
||||||
for header_article in current_order_articles
|
for header_article in current_order_articles
|
||||||
name = header_article.article.name.split("-").join(" ").split(".").join(". ").split("/").join(" ")
|
name = header_article.article.name.gsub(/[-\/]/, " ").gsub(".", ". ")
|
||||||
name = name.split.collect { |w| truncate(w, :length => 8, :omission => "..") }.join(" ")
|
name = name.split.collect { |w| truncate(w, :length => 8, :omission => "..") }.join(" ")
|
||||||
header << truncate(name, :length => 30, :omission => " ..")
|
header << truncate(name, :length => 30, :omission => " ..")
|
||||||
end
|
end
|
||||||
|
@ -59,20 +63,21 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
|
||||||
for order_article in current_order_articles
|
for order_article in current_order_articles
|
||||||
# get the Ordergroup result for this order_article
|
# get the Ordergroup result for this order_article
|
||||||
goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id }
|
goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id }
|
||||||
group_result << ((goa.nil? || goa == 0) ? "" : goa.result.to_i)
|
group_result << ((goa.nil? || goa.result == 0) ? "" : goa.result.to_i)
|
||||||
end
|
end
|
||||||
groups_data << group_result
|
groups_data << group_result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make table
|
# Make table
|
||||||
widths = { } # Generate widths-hash for table layout
|
widths = {0 => 85} # Generate widths-hash for table layout
|
||||||
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
|
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 41 }) unless i == 0 }
|
||||||
|
logger.debug "Spaltenbreiten: #{widths.inspect}"
|
||||||
pdf.table groups_data,
|
pdf.table groups_data,
|
||||||
:font_size => 8,
|
:font_size => 8,
|
||||||
:border_style => :grid,
|
:border_style => :grid,
|
||||||
:vertical_padding => 3,
|
:vertical_padding => 3,
|
||||||
:headers => header,
|
:headers => header,
|
||||||
:widths => widths,
|
:column_widths => widths,
|
||||||
:row_colors => ['ffffff','ececec']
|
:row_colors => ['ffffff','ececec']
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class ModifyGroupOrderArticleResult < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
change_column :group_order_articles, :result, :decimal, :precision => 8, :scale => 3
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
change_column :group_order_articles, :result, :integer
|
||||||
|
end
|
||||||
|
end
|
64
db/schema.rb
64
db/schema.rb
|
@ -9,7 +9,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20090317175355) do
|
ActiveRecord::Schema.define(:version => 20090405131156) do
|
||||||
|
|
||||||
create_table "article_categories", :force => true do |t|
|
create_table "article_categories", :force => true do |t|
|
||||||
t.string "name", :default => "", :null => false
|
t.string "name", :default => "", :null => false
|
||||||
|
@ -28,25 +28,25 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "articles", :force => true do |t|
|
create_table "articles", :force => true do |t|
|
||||||
t.string "name", :default => "", :null => false
|
t.string "name", :default => "", :null => false
|
||||||
t.integer "supplier_id", :default => 0, :null => false
|
t.integer "supplier_id", :default => 0, :null => false
|
||||||
t.integer "article_category_id", :default => 0, :null => false
|
t.integer "article_category_id", :default => 0, :null => false
|
||||||
t.string "unit", :default => "", :null => false
|
t.string "unit", :default => "", :null => false
|
||||||
t.string "note"
|
t.string "note"
|
||||||
t.boolean "availability", :default => true, :null => false
|
t.boolean "availability", :default => true, :null => false
|
||||||
t.string "manufacturer"
|
t.string "manufacturer"
|
||||||
t.string "origin"
|
t.string "origin"
|
||||||
t.datetime "shared_updated_on"
|
t.datetime "shared_updated_on"
|
||||||
t.decimal "price"
|
t.decimal "price", :precision => 8, :scale => 2
|
||||||
t.float "tax"
|
t.float "tax"
|
||||||
t.decimal "deposit", :default => 0.0
|
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0
|
||||||
t.integer "unit_quantity", :default => 1, :null => false
|
t.integer "unit_quantity", :default => 1, :null => false
|
||||||
t.string "order_number"
|
t.string "order_number"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "quantity", :default => 0
|
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
|
t.integer "quantity", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "articles", ["name", "supplier_id"], :name => "index_articles_on_name_and_supplier_id"
|
add_index "articles", ["name", "supplier_id"], :name => "index_articles_on_name_and_supplier_id"
|
||||||
|
@ -93,12 +93,12 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "group_order_articles", :force => true do |t|
|
create_table "group_order_articles", :force => true do |t|
|
||||||
t.integer "group_order_id", :default => 0, :null => false
|
t.integer "group_order_id", :default => 0, :null => false
|
||||||
t.integer "order_article_id", :default => 0, :null => false
|
t.integer "order_article_id", :default => 0, :null => false
|
||||||
t.integer "quantity", :default => 0, :null => false
|
t.integer "quantity", :default => 0, :null => false
|
||||||
t.integer "tolerance", :default => 0, :null => false
|
t.integer "tolerance", :default => 0, :null => false
|
||||||
t.datetime "updated_on", :null => false
|
t.datetime "updated_on", :null => false
|
||||||
t.integer "result"
|
t.decimal "result", :precision => 8, :scale => 3
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "group_order_articles", ["group_order_id", "order_article_id"], :name => "goa_index", :unique => true
|
add_index "group_order_articles", ["group_order_id", "order_article_id"], :name => "goa_index", :unique => true
|
||||||
|
@ -115,22 +115,22 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
||||||
add_index "group_orders", ["ordergroup_id", "order_id"], :name => "index_group_orders_on_ordergroup_id_and_order_id", :unique => true
|
add_index "group_orders", ["ordergroup_id", "order_id"], :name => "index_group_orders_on_ordergroup_id_and_order_id", :unique => true
|
||||||
|
|
||||||
create_table "groups", :force => true do |t|
|
create_table "groups", :force => true do |t|
|
||||||
t.string "type", :default => "", :null => false
|
t.string "type", :default => "", :null => false
|
||||||
t.string "name", :default => "", :null => false
|
t.string "name", :default => "", :null => false
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.decimal "account_balance", :default => 0.0, :null => false
|
t.decimal "account_balance", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
t.datetime "account_updated"
|
t.datetime "account_updated"
|
||||||
t.datetime "created_on", :null => false
|
t.datetime "created_on", :null => false
|
||||||
t.boolean "role_admin", :default => false, :null => false
|
t.boolean "role_admin", :default => false, :null => false
|
||||||
t.boolean "role_suppliers", :default => false, :null => false
|
t.boolean "role_suppliers", :default => false, :null => false
|
||||||
t.boolean "role_article_meta", :default => false, :null => false
|
t.boolean "role_article_meta", :default => false, :null => false
|
||||||
t.boolean "role_finance", :default => false, :null => false
|
t.boolean "role_finance", :default => false, :null => false
|
||||||
t.boolean "role_orders", :default => false, :null => false
|
t.boolean "role_orders", :default => false, :null => false
|
||||||
t.boolean "weekly_task", :default => false
|
t.boolean "weekly_task", :default => false
|
||||||
t.integer "weekday"
|
t.integer "weekday"
|
||||||
t.string "task_name"
|
t.string "task_name"
|
||||||
t.string "task_description"
|
t.string "task_description"
|
||||||
t.integer "task_required_users", :default => 1
|
t.integer "task_required_users", :default => 1
|
||||||
t.datetime "deleted_at"
|
t.datetime "deleted_at"
|
||||||
t.string "contact_person"
|
t.string "contact_person"
|
||||||
t.string "contact_phone"
|
t.string "contact_phone"
|
||||||
|
@ -152,16 +152,16 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
||||||
create_table "invoices", :force => true do |t|
|
create_table "invoices", :force => true do |t|
|
||||||
t.integer "supplier_id"
|
t.integer "supplier_id"
|
||||||
t.integer "delivery_id"
|
t.integer "delivery_id"
|
||||||
|
t.integer "order_id"
|
||||||
t.string "number"
|
t.string "number"
|
||||||
t.date "date"
|
t.date "date"
|
||||||
t.date "paid_on"
|
t.date "paid_on"
|
||||||
t.text "note"
|
t.text "note"
|
||||||
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
t.integer "order_id"
|
|
||||||
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
t.decimal "deposit_credit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
t.decimal "deposit_credit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "memberships", :force => true do |t|
|
create_table "memberships", :force => true do |t|
|
||||||
|
@ -211,6 +211,10 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
||||||
t.decimal "foodcoop_result", :precision => 8, :scale => 2
|
t.decimal "foodcoop_result", :precision => 8, :scale => 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "schema_info", :id => false, :force => true do |t|
|
||||||
|
t.integer "version"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "stock_changes", :force => true do |t|
|
create_table "stock_changes", :force => true do |t|
|
||||||
t.integer "delivery_id"
|
t.integer "delivery_id"
|
||||||
t.integer "order_id"
|
t.integer "order_id"
|
||||||
|
|
Loading…
Reference in a new issue