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
|
||||
)
|
||||
|
||||
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'
|
||||
render :partial => 'edit_results_by_articles' and return
|
||||
when 'groupsOverview'
|
||||
|
@ -41,15 +50,6 @@ class Finance::BalancingController < ApplicationController
|
|||
when 'articlesOverview'
|
||||
render :partial => 'shared/articles_by_articles', :locals => {:order => @order} and return
|
||||
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
|
||||
|
||||
def edit_note
|
||||
|
@ -164,6 +164,7 @@ class Finance::BalancingController < ApplicationController
|
|||
|
||||
# Creates a new GroupOrderArticle
|
||||
# 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
|
||||
goa = GroupOrderArticle.new(params[:group_order_article])
|
||||
order_article = goa.order_article
|
||||
|
@ -177,6 +178,12 @@ class Finance::BalancingController < ApplicationController
|
|||
goa.group_order = group_order
|
||||
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
|
||||
|
|
|
@ -152,7 +152,12 @@ class OrdersController < ApplicationController
|
|||
# Renders the matrix PDF.
|
||||
def matrixPdf
|
||||
@order = Order.find(params[:id])
|
||||
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
|
||||
|
||||
# adds a Comment to the Order
|
||||
|
|
|
@ -58,10 +58,13 @@ module ApplicationHelper
|
|||
return result
|
||||
end
|
||||
|
||||
def sort_link_helper(text, param, per_page = (@per_page || 10), action = "list" )
|
||||
key = param
|
||||
key += "_reverse" if params[:sort] == param
|
||||
options = {
|
||||
def sort_link_helper(text, key, options = {})
|
||||
per_page = options[:per_page] || 10
|
||||
action = options[:action] || "list"
|
||||
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})),
|
||||
:before => "Element.show('loader')",
|
||||
:success => "Element.hide('loader')",
|
||||
|
@ -71,7 +74,12 @@ module ApplicationHelper
|
|||
:title => _("Nach #{text} sortieren"),
|
||||
: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
|
||||
|
||||
# Generates a link to the top of the website
|
||||
|
|
|
@ -32,6 +32,11 @@ class GroupOrderArticle < ActiveRecord::Base
|
|||
|
||||
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
|
||||
# and the associated GroupOrderArticleQuantities chronologically.
|
||||
#
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
%thead
|
||||
%tr
|
||||
%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"]
|
||||
= sort_link_helper "Nr.", "order_number", 1000, "new"
|
||||
= sort_link_helper "Nr.", "order_number", :action => "new", :remote => false
|
||||
%th Menge
|
||||
%th GebGr * Einheit
|
||||
%th Netto
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
%td{:colspan => "3",:style => "width:14em"}
|
||||
= remote_link_to '[Gruppe hinzufügen]', :url => {:action => "new_group_order_article", :id => order_article}
|
||||
%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]
|
||||
%td
|
||||
%td{:style=>"width:50%"}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
%th= sort_link_helper "Name", "name", @per_page
|
||||
%th= sort_link_helper "Name", "name", :per_page => @per_page
|
||||
%th Kontakt
|
||||
%th= sort_link_helper "Kontostand", "account_balance", @per_page
|
||||
%th= sort_link_helper "Kontostand", "account_balance", :per_page => @per_page
|
||||
%th
|
||||
%tbody
|
||||
- for group in @groups
|
||||
|
|
|
@ -6,6 +6,7 @@ pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
|||
end
|
||||
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
||||
pdf.stroke_horizontal_rule
|
||||
pdf.move_down 2
|
||||
pdf.text "Seite #{pdf.page_count}", :size => 8
|
||||
end
|
||||
|
||||
|
@ -35,6 +36,9 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
|
|||
|
||||
page_number += 1
|
||||
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
|
||||
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
|
||||
header = [""]
|
||||
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(" ")
|
||||
header << truncate(name, :length => 30, :omission => " ..")
|
||||
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
|
||||
# get the Ordergroup result for this order_article
|
||||
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
|
||||
groups_data << group_result
|
||||
end
|
||||
|
||||
# Make table
|
||||
widths = { } # Generate widths-hash for table layout
|
||||
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
|
||||
widths = {0 => 85} # Generate widths-hash for table layout
|
||||
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 41 }) unless i == 0 }
|
||||
logger.debug "Spaltenbreiten: #{widths.inspect}"
|
||||
pdf.table groups_data,
|
||||
:font_size => 8,
|
||||
:border_style => :grid,
|
||||
:vertical_padding => 3,
|
||||
:headers => header,
|
||||
:widths => widths,
|
||||
:column_widths => widths,
|
||||
:row_colors => ['ffffff','ececec']
|
||||
|
||||
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
|
22
db/schema.rb
22
db/schema.rb
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.string "name", :default => "", :null => false
|
||||
|
@ -37,16 +37,16 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
|||
t.string "manufacturer"
|
||||
t.string "origin"
|
||||
t.datetime "shared_updated_on"
|
||||
t.decimal "price"
|
||||
t.decimal "price", :precision => 8, :scale => 2
|
||||
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.string "order_number"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "quantity", :default => 0
|
||||
t.datetime "deleted_at"
|
||||
t.string "type"
|
||||
t.integer "quantity", :default => 0
|
||||
end
|
||||
|
||||
add_index "articles", ["name", "supplier_id"], :name => "index_articles_on_name_and_supplier_id"
|
||||
|
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
|||
t.integer "quantity", :default => 0, :null => false
|
||||
t.integer "tolerance", :default => 0, :null => false
|
||||
t.datetime "updated_on", :null => false
|
||||
t.integer "result"
|
||||
t.decimal "result", :precision => 8, :scale => 3
|
||||
end
|
||||
|
||||
add_index "group_order_articles", ["group_order_id", "order_article_id"], :name => "goa_index", :unique => true
|
||||
|
@ -118,7 +118,7 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
|||
t.string "type", :default => "", :null => false
|
||||
t.string "name", :default => "", :null => false
|
||||
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 "created_on", :null => false
|
||||
t.boolean "role_admin", :default => false, :null => false
|
||||
|
@ -152,16 +152,16 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
|
|||
create_table "invoices", :force => true do |t|
|
||||
t.integer "supplier_id"
|
||||
t.integer "delivery_id"
|
||||
t.integer "order_id"
|
||||
t.string "number"
|
||||
t.date "date"
|
||||
t.date "paid_on"
|
||||
t.text "note"
|
||||
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_credit", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
create_table "schema_info", :id => false, :force => true do |t|
|
||||
t.integer "version"
|
||||
end
|
||||
|
||||
create_table "stock_changes", :force => true do |t|
|
||||
t.integer "delivery_id"
|
||||
t.integer "order_id"
|
||||
|
|
Loading…
Reference in a new issue