From a29053b4e98cf6f4e76738b5d75c37eee45c27d6 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Sun, 1 Mar 2009 18:45:34 +0100 Subject: [PATCH] Some language fixes. Finished migration path. --- app/models/article_price.rb | 4 +- app/views/ordering/my_order_result.haml | 8 +- app/views/ordering/order.rhtml | 10 +- app/views/orders/_form.html.haml | 2 +- app/views/orders/edit.html.haml | 4 +- app/views/orders/index.haml | 8 +- app/views/orders/matrixPdf.pdf.prawn | 10 +- app/views/orders/show.haml | 6 +- .../20090120184410_road_to_version_three.rb | 289 +++++++++--------- 9 files changed, 172 insertions(+), 169 deletions(-) diff --git a/app/models/article_price.rb b/app/models/article_price.rb index 18e26040..c9e4f220 100644 --- a/app/models/article_price.rb +++ b/app/models/article_price.rb @@ -34,11 +34,11 @@ class ArticlePrice < ActiveRecord::Base # The financial gross, net plus tax and deposit. def gross_price - ((price + deposit) * (tax / 100 + 1)) + ((price + deposit) * (tax / 100 + 1)).round(2) end # The price for the foodcoop-member. def fc_price - (gross_price * (APP_CONFIG[:price_markup] / 100 + 1)) + (gross_price * (APP_CONFIG[:price_markup] / 100 + 1)).round(2) end end diff --git a/app/views/ordering/my_order_result.haml b/app/views/ordering/my_order_result.haml index a4dbc3b0..5b31c818 100644 --- a/app/views/ordering/my_order_result.haml +++ b/app/views/ordering/my_order_result.haml @@ -2,7 +2,7 @@ #element_navigation = link_to_unless @order.previous == @order, "<< #{@order.previous.name}", :action => "my_order_result", :id => @order.previous | - = link_to _("Overview"), :controller => 'ordering' + = link_to "Übersicht", :controller => 'ordering' | = link_to_unless @order.next == @order, "#{@order.next.name} >>", :action => "my_order_result", :id => @order.next @@ -30,9 +30,9 @@ %b=h number_to_currency(@group_order.price) - else %b Du hast nicht bestellt. - %p - = "Abgerechnet von #{@order.updated_by.nick}" if @order.finished? - = "Bestellung" if @order.closed? + - if @order.closed? + %p + = "Abgerechnet von #{@order.updated_by.nick}" = link_to "Kommentare lesen/schreiben", "#comments" // directly switch to active orders diff --git a/app/views/ordering/order.rhtml b/app/views/ordering/order.rhtml index 87c09880..654cf55f 100644 --- a/app/views/ordering/order.rhtml +++ b/app/views/ordering/order.rhtml @@ -39,7 +39,7 @@ <% unless order_article.article.note.blank? %> - <%= order_article.article.name %> <%= image_tag "lamp_grey.png", {:alt => _("Show note"), :size => "15x16", :border => "0", :onmouseover => "$('note_#{i}').show();", :onmouseout => "$('note_#{i}').hide();" }%> + <%= order_article.article.name %> <%= image_tag "lamp_grey.png", {:alt => "Notiz zeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{i}').show();", :onmouseout => "$('note_#{i}').hide();" }%> <% else %> <%= order_article.article.name %> <% end %> @@ -81,20 +81,20 @@ - <%=_ "Total amount" %>: <%= total %> € + Gesamtbetrag: <%= total %> € - <%=_ "Credit available"%>: <%= number_to_currency(@availableFunds) %> + Verfügbares Guthaben: <%= number_to_currency(@availableFunds) %> - <%=_ "New account balance"%>: <%= @ordergroup.account_balance - total %> + Neuer Kontostand: <%= @ordergroup.account_balance - total %> <%= link_to_top %> - <%= submit_tag( _("Save order"), :id => 'submit_button' ) %> | <%= link_to _("Cancel"), :controller => 'ordering' %> + <%= submit_tag( "Bestellung speichern", :id => 'submit_button' ) %> | <%= link_to "Abbrechen", :controller => 'ordering' %> diff --git a/app/views/orders/_form.html.haml b/app/views/orders/_form.html.haml index f725a4b4..4eb25ea9 100644 --- a/app/views/orders/_form.html.haml +++ b/app/views/orders/_form.html.haml @@ -67,7 +67,7 @@ %tr %td{:colspan => "6"} = check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" } - =_ "Select all" + Alle auswählen - if (@template_orders && !@template_orders.empty?) = render :partial => 'template_orders_script' \ No newline at end of file diff --git a/app/views/orders/edit.html.haml b/app/views/orders/edit.html.haml index d370c653..7f3095bc 100644 --- a/app/views/orders/edit.html.haml +++ b/app/views/orders/edit.html.haml @@ -2,6 +2,6 @@ - form_for @order do |form| = render :partial => 'form', :locals => { :form => form } - = submit_tag _("Save") + = submit_tag "Speichern" | - = link_to _("Cancel"), :action => 'show', :id => @order \ No newline at end of file + = link_to "Abbrechen", :action => 'show', :id => @order \ No newline at end of file diff --git a/app/views/orders/index.haml b/app/views/orders/index.haml index 6f8183dd..d73338b5 100644 --- a/app/views/orders/index.haml +++ b/app/views/orders/index.haml @@ -5,7 +5,7 @@ - form_tag do Neue Bestellung anlegen für %select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"} - %option{:selected => 'selected'}=_ "Choose a supplier..." + %option{:selected => 'selected'} Lieferant auswählen... = options_for_suppliers_to_select %br/ .left_column{:style => "width:55em"} @@ -27,13 +27,13 @@ %td=h order.name %td=h format_time(order.ends) unless order.ends.nil? %td=h truncate(order.note) - %td= link_to "Beenden", finish_order_path(order), :confirm => _("Are you really sure to finish the order?"), :method => :post + %td= link_to "Beenden", finish_order_path(order), :confirm => "Bist Du sicher die Bestellung zu beenden?", :method => :post %td = link_to "Anzeigen", order = link_to icon(:edit), edit_order_path(order) - = link_to icon(:delete), order, :confirm => _("Are you really sure you want to destroy the order?"), :method => :delete + = link_to icon(:delete), order, :confirm => "Bist Du sicher die Bestellung zu beenden?", :method => :delete - else - =_ "There aren't open orders at the moment." + Derzeit gibt es keine laufende Bestellungen. .left_column{:style => "width:75em"} .box_title diff --git a/app/views/orders/matrixPdf.pdf.prawn b/app/views/orders/matrixPdf.pdf.prawn index 7f451634..c89f5608 100644 --- a/app/views/orders/matrixPdf.pdf.prawn +++ b/app/views/orders/matrixPdf.pdf.prawn @@ -18,13 +18,13 @@ pdf.text "Insgesamt #{order_articles.size} Artikel", :size => 8 pdf.move_down 10 order_articles_data = order_articles.collect do |a| - [a.article.name, a.article.unit, a.price.unit_quantity, a.price.fc_price, a.units_to_order] + [a.article.name, a.article.unit, a.price.unit_quantity, number_with_precision(a.price.fc_price), a.units_to_order] end pdf.table order_articles_data, :font_size => 8, :border_style => :grid, :vertical_padding => 3, - :headers => ["Artikel", "Einheit", "Gebinde", "Preis", "Menge"], + :headers => ["Artikel", "Einheit", "Gebinde", "FC-Preis", "Menge"], :align => { 3 => :right } @@ -46,15 +46,15 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do header = [""] for header_article in current_order_articles name = header_article.article.name.split("-").join(" ").split(".").join(". ").split("/").join(" ") - name = name.split.collect { |w| truncate(w, 8, "..") }.join(" ") - header << truncate(name, 30, " ..") + name = name.split.collect { |w| truncate(w, :length => 8, :omission => "..") }.join(" ") + header << truncate(name, :length => 30, :omission => " ..") end # Collect group results groups_data = [] for group_order in @order.group_orders.all(:include => :ordergroup) - group_result = [truncate(group_order.ordergroup.name, 20)] + group_result = [truncate(group_order.ordergroup.name, :length => 20)] for order_article in current_order_articles # get the Ordergroup result for this order_article diff --git a/app/views/orders/show.haml b/app/views/orders/show.haml index cf259f54..31e1c840 100644 --- a/app/views/orders/show.haml +++ b/app/views/orders/show.haml @@ -2,7 +2,7 @@ #element_navigation = link_to_unless @order.previous == @order, "<< #{@order.previous.name}", @order.previous | - = link_to _("Overview"), orders_path + = link_to "Übersicht", orders_path | = link_to_unless @order.next == @order, "#{@order.next.name} >>", @order.next @@ -13,7 +13,7 @@ .column_content - if @order.finished? and !@order.closed? %p - %b{:style => "color:red"}=_ "Order isn't closed yet" + %b{:style => "color:red"} Bestellung wurde noch nicht abgerechnet. %p Lieferant: %b=h @order.name @@ -33,7 +33,7 @@ = "[#{@order.group_orders.find(:all, :include => :ordergroup).collect{|g| g.ordergroup.name}.join(', ')}]" %p - Netto/Bruttosumme aller Artikel + Netto/Bruttosumme aller Artikel: %b= "#{number_to_currency(@order.sum(:net))} / #{number_to_currency(@order.sum(:gross))}" %p Bestellte Artikel: diff --git a/db/migrate/20090120184410_road_to_version_three.rb b/db/migrate/20090120184410_road_to_version_three.rb index fb61f552..96d2d249 100644 --- a/db/migrate/20090120184410_road_to_version_three.rb +++ b/db/migrate/20090120184410_road_to_version_three.rb @@ -1,148 +1,151 @@ + +class OrderGroup < Group; end # Needed for renaming of OrderGroup to Ordergroup + class RoadToVersionThree < ActiveRecord::Migration def self.up # TODO: Combine migrations since foodsoft3-development into one file # and try to build a migration path from old data. -# # == Message -# drop_table :messages -# create_table :messages do |t| -# t.references :sender -# t.text :recipients_ids -# t.string :subject, :null => false -# t.text :body -# t.integer :email_state, :default => 0, :null => false -# t.boolean :private, :default => false -# t.datetime :created_at -# end -# -# # Acts_as_paranoid -# add_column :suppliers, :deleted_at, :datetime -# add_column :articles, :deleted_at, :datetime -# add_column :groups, :deleted_at, :datetime -# -# # == Workgroups -# # Migrate all groups to workgroups -# Group.find(:all, :conditions => { :type => "" }).each do |workgroup| -# workgroup.update_attribute(:type, "Workgroup") -# end -# -# # == Ordergroups -# remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note -# # rename from OrderGroup to Ordergroup -# rename_column :financial_transactions, :order_group_id, :ordergroup_id -# rename_column :group_orders, :order_group_id, :ordergroup_id -# rename_column :tasks, :group_id, :workgroup_id -# remove_index :group_orders, :name => "index_group_orders_on_order_group_id_and_order_id" -# add_index :group_orders, [:ordergroup_id, :order_id], :unique => true -# -# Group.find(:all, :conditions => { :type => "OrderGroup" }).each do |ordergroup| -# ordergroup.update_attribute(:type, "Ordergroup") -# end -# # move contact-infos from users to ordergroups -# add_column :groups, :contact_person, :string -# add_column :groups, :contact_phone, :string -# add_column :groups, :contact_address, :string -# Ordergroup.all.each do |ordergroup| -# contact = ordergroup.users.first -# if contact -# ordergroup.update_attributes :contact_person => contact.name, -# :contact_phone => contact.phone, :contact_address => contact.address -# end -# end -# remove_column :users, :address -# -# # == Order -# drop_table :orders -# drop_table :group_order_results -# drop_table :order_article_results -# drop_table :group_order_article_results -# GroupOrder.delete_all; OrderArticle.delete_all; GroupOrderArticle.delete_all; GroupOrderArticleQuantity.delete_all -# -# create_table :orders do |t| -# t.references :supplier -# t.text :note -# t.datetime :starts -# t.datetime :ends -# t.string :state, :default => "open" # Statemachine ... open -> finished -> closed -# t.integer :lock_version, :default => 0, :null => false -# t.integer :updated_by_user_id -# end -# -# # == Invoice -# create_table :invoices do |t| -# t.references :supplier -# t.references :delivery -# t.references :order -# t.string :number -# t.date :date -# t.date :paid_on -# t.text :note -# t.decimal :amount, :null => false, :precision => 8, :scale => 2, :default => 0.0 -# 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.timestamps -# end -# -# # == Delivery -# create_table :deliveries do |t| -# t.integer :supplier_id -# t.date :delivered_on -# t.datetime :created_at -# end -# -# # == Comment -# drop_table :comments -# create_table :order_comments do |t| -# t.references :order -# t.references :user -# t.text :text -# t.datetime :created_at -# end -# -# # == Article -# rename_column :articles, :net_price, :price -# remove_column :articles, :gross_price -# -# # == ArticlePrice -# create_table :article_prices do |t| -# t.references :article -# t.decimal :price, :precision => 8, :scale => 2, :default => 0.0, :null => false -# t.decimal :tax, :precision => 8, :scale => 2, :default => 0.0, :null => false -# t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false -# t.integer :unit_quantity -# t.datetime :created_at -# end -# # Create price history for every Article -# Article.all.each do |a| -# a.article_prices.create :price => a.price, :tax => a.tax, -# :deposit => a.deposit, :unit_quantity => a.unit_quantity -# end -# # Every Article has now a Category. Fix it if neccessary. -# Article.all(:conditions => { :article_category_id => nil }).each do |article| -# article.update_attribute(:article_category, ArticleCategory.first) -# end -# # order-articles -# add_column :order_articles, :article_price_id, :integer -# -# # == GroupOrder -# change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true -# -# # == GroupOrderArticle -# # The total order result in ordergroup is now saved! -# add_column :group_order_articles, :result, :integer, :default => nil -# -# # == StockArticle -# add_column :articles, :type, :string -# add_column :articles, :quantity, :integer, :default => 0 -# -# # == StockChanges -# create_table :stock_changes do |t| -# t.references :delivery -# t.references :order -# t.references :stock_article -# t.integer :quantity, :default => 0 -# t.datetime :created_at -# end + # == Message + drop_table :messages + create_table :messages do |t| + t.references :sender + t.text :recipients_ids + t.string :subject, :null => false + t.text :body + t.integer :email_state, :default => 0, :null => false + t.boolean :private, :default => false + t.datetime :created_at + end + + # Acts_as_paranoid + add_column :suppliers, :deleted_at, :datetime + add_column :articles, :deleted_at, :datetime + add_column :groups, :deleted_at, :datetime + + # == Workgroups + puts "Migrate all groups to workgroups.." + Group.find(:all, :conditions => { :type => "" }).each do |workgroup| + workgroup.update_attribute(:type, "Workgroup") + end + + # == Ordergroups + remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note + # rename from OrderGroup to Ordergroup + rename_column :financial_transactions, :order_group_id, :ordergroup_id + rename_column :group_orders, :order_group_id, :ordergroup_id + rename_column :tasks, :group_id, :workgroup_id + remove_index :group_orders, :name => "index_group_orders_on_order_group_id_and_order_id" + add_index :group_orders, [:ordergroup_id, :order_id], :unique => true + + Group.find(:all, :conditions => { :type => "OrderGroup" }).each do |ordergroup| + ordergroup.update_attribute(:type, "Ordergroup") + end + # move contact-infos from users to ordergroups + add_column :groups, :contact_person, :string + add_column :groups, :contact_phone, :string + add_column :groups, :contact_address, :string + Ordergroup.all.each do |ordergroup| + contact = ordergroup.users.first + if contact + ordergroup.update_attributes :contact_person => contact.name, + :contact_phone => contact.phone, :contact_address => contact.address + end + end + remove_column :users, :address + + # == Order + drop_table :orders + drop_table :group_order_results + drop_table :order_article_results + drop_table :group_order_article_results + GroupOrder.delete_all; OrderArticle.delete_all; GroupOrderArticle.delete_all; GroupOrderArticleQuantity.delete_all + + create_table :orders do |t| + t.references :supplier + t.text :note + t.datetime :starts + t.datetime :ends + t.string :state, :default => "open" # Statemachine ... open -> finished -> closed + t.integer :lock_version, :default => 0, :null => false + t.integer :updated_by_user_id + end + + # == Invoice + create_table :invoices do |t| + t.references :supplier + t.references :delivery + t.references :order + t.string :number + t.date :date + t.date :paid_on + t.text :note + t.decimal :amount, :null => false, :precision => 8, :scale => 2, :default => 0.0 + 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.timestamps + end + + # == Delivery + create_table :deliveries do |t| + t.integer :supplier_id + t.date :delivered_on + t.datetime :created_at + end + + # == Comment + drop_table :comments + create_table :order_comments do |t| + t.references :order + t.references :user + t.text :text + t.datetime :created_at + end + + # == Article + rename_column :articles, :net_price, :price + remove_column :articles, :gross_price + + # == ArticlePrice + create_table :article_prices do |t| + t.references :article + t.decimal :price, :precision => 8, :scale => 2, :default => 0.0, :null => false + t.decimal :tax, :precision => 8, :scale => 2, :default => 0.0, :null => false + t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false + t.integer :unit_quantity + t.datetime :created_at + end + # Create price history for every Article + Article.all.each do |a| + a.article_prices.create :price => a.price, :tax => a.tax, + :deposit => a.deposit, :unit_quantity => a.unit_quantity + end + # Every Article has now a Category. Fix it if neccessary. + Article.all(:conditions => { :article_category_id => nil }).each do |article| + article.update_attribute(:article_category, ArticleCategory.first) + end + # order-articles + add_column :order_articles, :article_price_id, :integer + + # == GroupOrder + change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true + + # == GroupOrderArticle + # The total order result in ordergroup is now saved! + add_column :group_order_articles, :result, :integer, :default => nil + + # == StockArticle + add_column :articles, :type, :string + add_column :articles, :quantity, :integer, :default => 0 + + # == StockChanges + create_table :stock_changes do |t| + t.references :delivery + t.references :order + t.references :stock_article + t.integer :quantity, :default => 0 + t.datetime :created_at + end # == StockTaking create_table :stock_takings do |t| @@ -152,9 +155,9 @@ class RoadToVersionThree < ActiveRecord::Migration end add_column :stock_changes, :stock_taking_id, :integer -# # == User -# # Ativate all Users for notification on upcoming tasks -# User.all.each { |u| u.settings['notify.upcoming_tasks'] = 1 } + # == User + # Ativate all Users for notification on upcoming tasks + User.all.each { |u| u.settings['notify.upcoming_tasks'] = 1 } end def self.down