Order refactoring part two: Balancing workflow was adapted to the new order schema. Article modification is still missing.

This commit is contained in:
Benjamin Meichsner 2009-01-29 21:28:22 +01:00
parent 9eb2125f15
commit 190a777278
53 changed files with 568 additions and 603 deletions

View file

@ -1,9 +1,10 @@
class Finance::BalancingController < ApplicationController
before_filter :authenticate_finance
verify :method => :post, :only => [:close_direct]
def index
@financial_transactions = FinancialTransaction.find(:all, :order => "created_on DESC", :limit => 8)
@orders = Order.find(:all, :conditions => 'finished = 1 AND booked = 0', :order => 'ends DESC')
@orders = Order.finished
@unpaid_invoices = Invoice.unpaid
end
@ -16,202 +17,178 @@ class Finance::BalancingController < ApplicationController
@comments = @order.comments
case params[:view]
when 'editResults'
render :partial => 'editResults'
render :partial => 'edit_results_by_articles'
when 'groupsOverview'
render :partial => 'groupsOverview'
render :partial => 'shared/articles_by_groups', :locals => {:order => @order}
when 'articlesOverview'
render :partial => 'articlesOverview'
when "editNote"
render :partial => "editNote"
render :partial => 'shared/articles_by_articles', :locals => {:order => @order}
end
end
def newArticleResult
def edit_note
@order = Order.find(params[:id])
@article = @order.order_article_results.build(:tax => 7, :deposit => 0)
render :update do |page|
page["edit_box"].replace_html :partial => "newArticleResult"
page["edit_box"].show
end
render :partial => 'edit_note'
end
def createArticleResult
render :update do |page|
@article = OrderArticleResult.new(params[:order_article_result])
@article.fc_markup = APP_CONFIG[:price_markup]
@article.make_gross if @article.tax && @article.deposit && @article.price
if @article.valid?
@article.save
@order = @article.order
page["edit_box"].hide
page["order_summary"].replace_html :partial => 'summary'
page.insert_html :bottom, "result_table", :partial => "articleResults"
page["order_article_result_#{@article.id}"].visual_effect :highlight, :duration => 2
page["group_order_article_results_#{@article.id}"].show
else
page["edit_box"].replace_html :partial => "newArticleResult"
end
end
end
def editArticleResult
@article = OrderArticleResult.find(params[:id])
render :update do |page|
page["edit_box"].replace_html :partial => 'editArticleResult'
page["edit_box"].show
end
end
def updateArticleResult
@article = OrderArticleResult.find(params[:id])
@article.attributes=(params[:order_article_result]) # update attributes but doesn't save
@article.make_gross
@order = @article.order
@ordered_articles = @order.order_article_results
@group_orders = @order.group_order_results
render :update do |page|
if @article.save
page["edit_box"].hide
page["order_summary"].replace_html :partial => 'summary'
page["order_summary"].visual_effect :highlight, :duration => 2
page["order_article_result_#{@article.id}"].replace_html :partial => 'articleResult'
page['order_article_result_'+@article.id.to_s].visual_effect :highlight, :delay => 0.5, :duration => 2
page["group_order_article_results_#{@article.id}"].replace_html :partial => "groupOrderArticleResults"
else
page['edit_box'].replace_html :partial => 'editArticleResult'
end
end
end
def destroyArticleResult
if @article = OrderArticleResult.find(params[:id]).destroy
@order = @article.order
render :update do |page|
page["order_article_result_#{@article.id}"].remove
page["group_order_article_results_#{@article.id}"].remove
page["order_summary"].replace_html :partial => 'summary'
page["order_summary"].visual_effect :highlight, :duration => 2
end
end
end
def newGroupResult
@result = OrderArticleResult.find(params[:id]).group_order_article_results.build
render :update do |page|
page["edit_box"].replace_html :partial => "newGroupResult"
page["edit_box"].show
end
end
# Creates a new GroupOrderArticleResult
# If the the chosen Ordergroup hasn't ordered yet, a GroupOrderResult will created
def createGroupResult
@result = GroupOrderArticleResult.new(params[:group_order_article_result])
order = @result.order_article_result.order
orderGroup = Ordergroup.find(params[:group_order_article_result][:group_order_result_id])
# creates a new GroupOrderResult if necessary
unless @result.group_order_result = GroupOrderResult.find(:first,
:conditions => ["group_order_results.group_name = ? AND group_order_results.order_id = ?", orderGroup.name, order.id ])
@result.group_order_result = GroupOrderResult.create(:order => order, :group_name => orderGroup.name)
end
render :update do |page|
if @result.valid? && @result.save
@result.group_order_result.updatePrice #updates the price attribute
article = @result.order_article_result
page["edit_box"].hide
page.insert_html :after, "groups_results_#{article.id}", :partial => "groupResults"
page["group_order_article_result_#{@result.id}"].visual_effect :highlight, :duration => 2
page["groups_amount"].replace_html number_to_currency(article.order.sum('groups'))
page["profit"].replace_html number_to_currency(article.order.profit)
page["profit"].visual_effect :highlight, :duration => 2
# get the new sums for quantity and price and replace it
total = article.total
page["totalArticleQuantity_#{article.id}"].replace_html total[:quantity]
page["totalArticlePrice_#{article.id}"].replace_html number_to_currency(total[:price])
else
page["edit_box"].replace_html :partial => "newGroupResult"
end
end
end
def updateGroupResult
@result = GroupOrderArticleResult.find(params[:id])
render :update do |page|
if params[:group_order_article_result]
if @result.update_attribute(:quantity, params[:group_order_article_result][:quantity])
order = @result.group_order_result.order
groups_amount = order.sum(:groups)
article = @result.order_article_result
total = article.total
page["edit_box"].hide
page["groups_amount"].replace_html number_to_currency(groups_amount)
page["profit"].replace_html number_to_currency(order.profit)
page["groups_amount"].visual_effect :highlight, :duration => 2
page["profit"].visual_effect :highlight, :duration => 2
page["group_order_article_result_#{@result.id}"].replace_html :partial => "groupResult"
page["group_order_article_result_#{@result.id}"].visual_effect :highlight, :duration => 2
page["totalArticleQuantity_#{article.id}"].replace_html total[:quantity]
page["totalArticlePrice_#{article.id}"].replace_html total[:price]
page["sum_of_article_#{article.id}"].visual_effect :highlight, :duration => 2
end
else
page["edit_box"].replace_html :partial => 'editGroupResult'
page["edit_box"].show
end
end
end
def destroyGroupResult
@result = GroupOrderArticleResult.find(params[:id])
if @result.destroy
render :update do |page|
article = @result.order_article_result
page["group_order_article_result_#{@result.id}"].remove
page["groups_amount"].replace_html number_to_currency(article.order.sum('groups'))
page["profit"].replace_html number_to_currency(article.order.profit)
page["profit"].visual_effect :highlight, :duration => 2
total = article.total # get total quantity and price for the ArticleResult
page["totalArticleQuantity_#{article.id}"].replace_html total[:quantity]
page["totalArticleQuantity_#{article.id}"].visual_effect :highlight, :duration => 2
page["totalArticlePrice_#{article.id}"].replace_html number_to_currency(total[:price])
page["totalArticlePrice_#{article.id}"].visual_effect :highlight, :duration => 2
end
end
end
def editOrderSummary
@order = Order.find(params[:id])
render :update do |page|
page["edit_box"].replace_html :partial => 'editSummary'
page["edit_box"].show
end
end
def updateOrderSummary
def update_note
@order = Order.find(params[:id])
render :update do |page|
if @order.update_attributes(params[:order])
page["note"].replace_html simple_format(@order.note)
page["edit_box"].hide
page["order_summary"].replace_html :partial => "summary"
page["clear_invoice"].visual_effect :highlight, :duration => 2
else
page["edit_box"].replace_html :partial => 'editSummary'
page["results"].replace_html :partial => "edit_note"
end
end
end
def updateOrderNote
@order = Order.find(params[:id])
#TODO: Implement create/update of articles/article_prices...
# def new_order_article
# @order = Order.find(params[:id])
# order_article = @order.order_articles.build(:tax => 7, :deposit => 0)
# render :update do |page|
# page["edit_box"].replace_html :partial => "new_order_article", :locals => {:order_article => order_article}
# page["edit_box"].show
# end
# end
#
# def create_order_article
# @order = Order.find(params[:order_article][:order_id])
# order_article = OrderArticle.new(params[:order_article])
#
# render :update do |page|
# if order_article.save
# page["edit_box"].hide
# page["summary"].replace_html :partial => 'summary'
# page.insert_html :bottom, "result_table", :partial => "order_article_result", :locals => {:order_article => order_article}
# page["order_article_#{order_article.id}"].visual_effect :highlight, :duration => 2
# page["group_order_articles_#{order_article.id}"].show
# else
# page["edit_box"].replace_html :partial => "new_order_article", :locals => {:order_article => order_article}
# end
# end
# end
#
# def editArticleResult
# @article = OrderArticleResult.find(params[:id])
# render :update do |page|
# page["edit_box"].replace_html :partial => 'editArticleResult'
# page["edit_box"].show
# end
# end
#
# def updateArticleResult
# @article = OrderArticleResult.find(params[:id])
# @article.attributes=(params[:order_article_result]) # update attributes but doesn't save
# @article.make_gross
# @order = @article.order
# @ordered_articles = @order.order_article_results
# @group_orders = @order.group_order_results
# render :update do |page|
# if @article.save
# page["edit_box"].hide
# page["summary"].replace_html :partial => 'summary'
# page["summary"].visual_effect :highlight, :duration => 2
# page["order_article_result_#{@article.id}"].replace_html :partial => 'articleResult'
# page['order_article_result_'+@article.id.to_s].visual_effect :highlight, :delay => 0.5, :duration => 2
# page["group_order_article_results_#{@article.id}"].replace_html :partial => "groupOrderArticleResults"
# else
# page['edit_box'].replace_html :partial => 'editArticleResult'
# end
# end
# end
def destroy_order_article
order_article = OrderArticle.find(params[:id])
order_article.destroy
@order = order_article.order
render :update do |page|
if @order.update_attribute(:note, params[:order][:note])
page["note"].replace_html simple_format(@order.note)
page["results"].replace_html :partial => "groupsOverview"
else
page["results"].replace_html :partial => "editNote"
page["order_article_#{order_article.id}"].remove
page["group_order_articles_#{order_article.id}"].remove
page["summary"].replace_html :partial => 'summary', :locals => {:order => @order}
page["summary"].visual_effect :highlight, :duration => 2
end
end
def new_group_order_article
group_order_article = OrderArticle.find(params[:id]).group_order_articles.build
render :update do |page|
page["edit_box"].replace_html :partial => "new_group_order_article",
:locals => {:group_order_article => group_order_article}
page["edit_box"].show
end
end
# Creates a new GroupOrderArticle
# If the the chosen Ordergroup hasn't ordered yet, a GroupOrder will also be created
def create_group_order_article
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
goa.group_order = group_order
end
render :update do |page|
if goa.save
goa.group_order.update_price! # Updates the price attribute of new GroupOrder
page["edit_box"].hide
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! # Updates the price attribute of new GroupOrder
page["edit_box"].hide
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 destroy_group_order_article
goa = GroupOrderArticle.find(params[:id])
goa.destroy
goa.group_order.update_price! # Updates the price attribute of new GroupOrder
render :update do |page|
page["edit_box"].hide
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
:locals => {:order_article => goa.order_article}
page["group_order_article_#{goa.id}"].visual_effect :highlight, :duration => 2
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
page["order_profit"].visual_effect :highlight, :duration => 2
end
end
# before the order will booked, a view lists all Ordergroups and its order_prices
@ -232,13 +209,11 @@ class Finance::BalancingController < ApplicationController
end
end
# Set all GroupOrders that belong to this finished order to status 'booked'.
def setAllBooked
# Close the order directly, without automaticly updating ordergroups account balances
def close_direct
@order = Order.find(params[:id])
if (@order.finished?)
@order.booked = true
@order.updated_by = @current_user
@order.save!
if @order.finished?
@order.update_attributes(:state => 'closed', :updated_by => @current_user)
flash[:notice] = 'Die Bestellung wurde auf "gebucht" gesetzt.'
redirect_to :action => 'listOrders', :id => @order
else

View file

@ -19,7 +19,8 @@ class Finance::InvoicesController < ApplicationController
end
def new
@invoice = Invoice.new(:supplier_id => params[:supplier_id], :delivery_id => params[:delivery_id])
@invoice = Invoice.new :supplier_id => params[:supplier_id],
:delivery_id => params[:delivery_id], :order_id => params[:order_id]
respond_to do |format|
format.html # new.html.erb
@ -36,15 +37,16 @@ class Finance::InvoicesController < ApplicationController
def create
@invoice = Invoice.new(params[:invoice])
respond_to do |format|
if @invoice.save
flash[:notice] = 'Invoice was successfully created.'
format.html { redirect_to([:finance, @invoice]) }
format.xml { render :xml => @invoice, :status => :created, :location => @invoice }
flash[:notice] = "Rechnung wurde erstellt."
if @invoice.order
# Redirect to balancing page
redirect_to :controller => 'balancing', :action => 'new', :id => @invoice.order
else
format.html { render :action => "new" }
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
redirect_to [:finance, @invoice]
end
else
render :action => "new"
end
end

View file

@ -44,8 +44,8 @@ class OrdersController < ApplicationController
if params[:view] # Articles-list will be replaced
partial = case params[:view]
when 'normal' then "articles"
when 'groups'then 'articles_by_groups'
when 'articles'then 'articles_by_articles'
when 'groups'then 'shared/articles_by_groups'
when 'articles'then 'shared/articles_by_articles'
end
render :partial => partial, :locals => {:order => @order} if partial
end

View file

@ -111,4 +111,10 @@ module ApplicationHelper
image_tag icons[name][:file], options
end
# Remote links with default 'loader'.gif during request
def remote_link_to(text, options={})
remote_options = {:before => "Element.show('loader')", :success => "Element.hide('loader')"}
link_to_remote(text, remote_options.merge(options))
end
end

View file

@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090120184410
#
# Table name: groups
#
@ -21,6 +21,7 @@
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# deleted_at :datetime
#
# Groups organize the User.

View file

@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 20090114101610
# Schema version: 20090120184410
#
# Table name: group_orders
#
@ -9,7 +9,7 @@
# price :decimal(8, 2) default(0.0), not null
# lock_version :integer(4) default(0), not null
# updated_on :datetime not null
# updated_by_user_id :integer(4) default(0), not null
# updated_by_user_id :integer(4)
#
# A GroupOrder represents an Order placed by an Ordergroup.
@ -23,7 +23,6 @@ class GroupOrder < ActiveRecord::Base
validates_presence_of :order_id
validates_presence_of :ordergroup_id
validates_presence_of :updated_by
validates_numericality_of :price
validates_uniqueness_of :ordergroup_id, :scope => :order_id # order groups can only order once per order

View file

@ -20,12 +20,13 @@ class GroupOrderArticle < ActiveRecord::Base
belongs_to :order_article
has_many :group_order_article_quantities, :dependent => :destroy
validates_presence_of :group_order_id
validates_presence_of :order_article_id
validates_presence_of :group_order_id, :order_article_id
validates_inclusion_of :quantity, :in => 0..99
validates_inclusion_of :tolerance, :in => 0..99
validates_uniqueness_of :order_article_id, :scope => :group_order_id # just once an article per group order
attr_accessor :ordergroup_id # To create an new GroupOrder if neccessary
# Updates the quantity/tolerance for this GroupOrderArticle by updating both GroupOrderArticle properties
# and the associated GroupOrderArticleQuantities chronologically.
#

View file

@ -43,4 +43,9 @@ class Invoice < ActiveRecord::Base
def deposit_credit=(deposit)
self[:deposit_credit] = String.delocalized_decimal(deposit)
end
# Amount without deposit
def net_amount
amount - deposit + deposit_credit
end
end

View file

@ -82,9 +82,13 @@ class Order < ActiveRecord::Base
memoize :get_articles
# Returns the defecit/benefit for the foodcoop
def profit(with_markup = true)
groups_sum = with_markup ? sum(:groups) : sum(:groups_without_markup)
groups_sum - invoice_amount + deposit - deposit_credit
# Requires a valid invoice, belonging to this order
def profit(options = {})
markup = options[:with_markup] || true
if invoice
groups_sum = markup ? sum(:groups) : sum(:groups_without_markup)
groups_sum - invoice.net_amount
end
end
# Returns the all round price of a finished order

View file

@ -24,19 +24,39 @@ class OrderArticle < ActiveRecord::Base
validates_presence_of :order_id
validates_presence_of :article_id
validates_uniqueness_of :article_id, :scope => :order_id # an article can only have one record per order
validate :article_and_price_exist
named_scope :ordered, :conditions => "units_to_order >= 1"
# TODO: How to create/update articles/article_prices during balancing
# # Accessors for easy create of new order_articles in balancing process
# attr_accessor :name, :order_number, :units_to_order, :unit_quantity, :unit, :net_price, :tax, :deposit
#
# before_validation_on_create :create_new_article
# This method returns either the Article or the ArticlePrice
# The latter will be set, when the the order is finished
def price
article_price || article
end
# Count quantities of belonging group_orders.
# In balancing this can differ from ordered (by supplier) quantity for this article.
def group_orders_sum
quantity = group_order_articles.collect(&:quantity).sum
{:quantity => quantity, :price => quantity * price.fc_price}
end
private
def validate
def article_and_price_exist
errors.add(:article, "muss angegeben sein und einen aktuellen Preis haben") if !(article = Article.find(article_id)) || article.fc_price.nil?
end
# def create_new_article
# old_article = order.articles.find_by_name(name) # Check if there is already an Article with this name
# unless old_article
# self.article.build
# end
# end
end

View file

@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090120184410
#
# Table name: groups
#
@ -21,6 +21,7 @@
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# deleted_at :datetime
#
# Ordergroups can order, they are "children" of the class Group

View file

@ -152,6 +152,11 @@ class User < ActiveRecord::Base
ordergroups.first
end
def ordergroup_name
ordergroup = find_ordergroup
ordergroup ? ordergroup.name : "keine Bestellgruppe"
end
# Find all tasks, for which the current user should be responsible
# but which aren't accepted yet
def unaccepted_tasks

View file

@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 20090113111624
# Schema version: 20090120184410
#
# Table name: groups
#
@ -21,6 +21,7 @@
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# deleted_at :datetime
#
class Workgroup < Group

View file

@ -1,21 +0,0 @@
%td= @article.name
%td= link_to_function image_tag("arrow_down_red.png", :size => "16x16", :border => 0), "Element.toggle('group_order_article_results_#{@article.id}')"
%td= @article.order_number
%td= @article.units_to_order
%td= @article.unit_quantity.to_s + ' * ' + @article.unit.to_s
%td= number_to_currency(@article.price)
%td= number_to_currency(@article.fc_price)
%td= @article.tax
%td= @article.deposit
%td
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Artikel ändern'), |
:url => {:action => 'editArticleResult', :id => @article}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td
= link_to_remote image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Artikel löschen'), |
:url => {:action => 'destroyArticleResult', :id => @article}, |
:confirm => 'Bist du sicher?', |
:method => 'post', |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |

View file

@ -1,29 +0,0 @@
= error_messages_for 'article'
%p
%b Notiz:
= @form.text_field 'note', :size => 30
%table
%tr
%th Name
%th Nr.
%th
%abbr{:title=>"Anzahl gelieferter Gebinde"} Menge
%th GebGr
%th Einheit
%th netto
%th MwSt.
%th Pfand
%tr
%td= @form.text_field 'name', :size => 20
%td= @form.text_field 'order_number', :size => 3
%td= @form.text_field 'units_to_order', :size => 5
%td= @form.text_field 'unit_quantity', :size => 3
%td= @form.text_field 'unit', :size => 5
%td= @form.text_field 'price', :size => 3
%td= @form.text_field 'tax', :size => 3
%td= @form.text_field 'deposit', :size => 3
= @form.hidden_field "order_id"
%br/
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -1,5 +0,0 @@
%tr{:class => cycle('even', 'odd', :name => 'articles')}[@article]
= render :partial => 'articleResult'
%tr{:id => "group_order_article_results_#{@article.id}", :class => "results", :style => "display:none"}
= render :partial => 'groupOrderArticleResults'

View file

@ -1,17 +0,0 @@
%p
%b
Gelieferte Artikel:
= @order.order_article_results.size
- for article in @order.order_article_results
%table{:style=> "margin-bottom:1em; width:40em;"}[article]
%thead
%tr
%th{:colspan => "3"}= article.name + " (" + article.unit + " | " + article.unit_quantity.to_s + " | " + article.fc_price.to_s + ")"
%tbody
- for result in article.group_order_article_results
%tr{ :class => cycle('even', 'odd', :name => 'group')}
%td{:style=>"width:70%"}= result.group_order_result.group_name
%td= result.quantity
%td= article.fc_price * result.quantity
- reset_cycle("group")

View file

@ -1,20 +0,0 @@
%h2 Mengenänderung
%p
= @result.group_order_result.group_name
hat von
= @result.order_article_result.name
bekommen:
- remote_form_for 'group_order_article_result', @result, :url => {:action => 'updateGroupResult', :id => @result }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= error_messages_for 'group_order_article_result'
%p
%b Menge:
(Einheit:
= @result.order_article_result.unit
)
= form.text_field "quantity", :size => "6"
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -1,10 +0,0 @@
%h2 Notiz bearbeiten
- remote_form_for 'order', @order, :url => {:action => 'updateOrderNote', :id => @order}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
%br/
= form.text_area "note", :size => "60x20"
%p
= submit_tag "Speichern"
|
= link_to_remote 'Abbrechen', :update => 'results', :url => { :action => 'edit', :id => @order, :view => 'groupsOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"

View file

@ -1,27 +0,0 @@
%h2 Bestelldaten ändern
- remote_form_for 'order', @order, :url => {:action => 'updateOrderSummary', :id => @order}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= error_messages_for 'order'
%table{:style => "width:10em"}
%tr
%td Rechnungsnummer:
%td= form.text_field "invoice_number", :size => 10
%tr
%td Rechnungsdatum:
%td= form.text_field "invoice_date", :size => 10
%tr
%td
%abbr{:title => "(incl. Pfand/Gutschriften)"} Rechnungsbeitrag
%td= form.text_field 'invoice_amount', :size => 10
%tr
%td
%abbr{:title => "z.B Kistepfand"} extra Pfand
%td= form.text_field 'deposit', :size => 10
%tr
%td Pfandgutschrift
%td= form.text_field 'deposit_credit', :size => 10
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,21 @@
%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 :quantity, :size => "6"
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,9 @@
%h2 Notiz bearbeiten
- remote_form_for 'order', @order, :url => {:action => 'update_note', :id => @order}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= form.error_messages
= form.text_area "note", :size => "60x20"
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -1,12 +1,12 @@
%p{:style => "float:left"}
%b Lieferung bearbeiten
%p{:style => "float:right"}
= link_to_remote "Artikel hinzufügen", :url => {:action => "newArticleResult", :id => @order}
//= remote_link_to "Artikel hinzufügen", :url => {:action => "newArticleResult", :id => @order}
%table{:class => "ordered_articles", :style => "clear:both"}
%thead
%tr
%th{:colspan => "2"} Artikel
%th{:colspan => "1"} Artikel
%th Nr.
%th Menge
%th GebGr * Einheit
@ -16,5 +16,5 @@
%th Pfand
%th{:colspan => "2"}
%tbody#result_table
- for @article in @order.order_article_results
= render :partial => "articleResults"
- for order_article in @order.order_articles.all(:include => [:article, :article_price])
= render :partial => "order_article_result", :locals => {:order_article => order_article}

View file

@ -1,25 +0,0 @@
%td{:colspan => "7"}
%p
Notiz:
= @article.note
%table
%thead
%tr
%td
%td{:style => "width:8em"} Gruppe
%td Einheiten
%td Gesamtpreis
%td{:colspan => "3",:style => "width:14em"}
= link_to_remote '[Gruppe hinzufügen]', :url => {:action => "newGroupResult", :id => @article}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%tbody{:id => "groups_results_#{@article.id}"}
- for @result in @article.group_order_article_results
= render :partial => "groupResults"
%tfoot
%tr{:class => cycle('even', 'odd', :name => 'results'), :id => "sum_of_article_#{@article.id}"}
%td
%td{:style => "width:8em"} Summe
%td{:id => "totalArticleQuantity_#{@article.id}"}= @article.total[:quantity]
%td{:id => "totalArticlePrice_#{@article.id}", :class => "currency"}
= number_to_currency(@article.total[:price])
%td{:colspan => "3"}
- reset_cycle('results')

View file

@ -1,17 +0,0 @@
%td
%td{:style=>"width:50%"}= @result.group_order_result.group_name
%td{:id => "group_order_article_result_#{@result.id}_quantity"}= @result.quantity
%td{:class => "currency"}= number_to_currency(@result.order_article_result.fc_price * @result.quantity)
%td{:style=>"width:1em", :class => "actions"}
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Menge ändern'), |
:url => {:action => 'updateGroupResult', :id => @result}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td{:style=>"width:1em", :class => "actions"}
= link_to_remote image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Gruppenergebnis löschen'), |
:url => {:action => 'destroyGroupResult', :id => @result}, |
:confirm => 'Bist du sicher?', |
:method => 'post', |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td

View file

@ -1,2 +0,0 @@
%tr{:class => cycle('even', 'odd', :name => 'results')}[@result]
= render :partial => "groupResult"

View file

@ -0,0 +1,39 @@
%td{:colspan => "7"}
%table
%thead
%tr
%td
%td{:style => "width:8em"} Gruppe
%td Einheiten
%td Gesamtpreis
%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])
%tr{:class => cycle('even', 'odd', :name => 'results')}[group_order_article]
%td
%td{:style=>"width:50%"}
= group_order_article.group_order.ordergroup.name
%td{:id => "group_order_article_#{group_order_article.id}_quantity"}
= group_order_article.quantity
%td.currency
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.quantity, :unit => "")
%td.actions{:style=>"width:1em"}
= remote_link_to icon(:edit), :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"}
= remote_link_to icon(:delete), |
:url => {:action => 'destroy_group_order_article', :id => group_order_article}, |
:confirm => 'Bist du sicher?', :method => 'post' |
%td
%tfoot
%tr{:class => cycle('even', 'odd', :name => 'results')}
%td
%td{:style => "width:8em"} Summe
%td{:id => "group_orders_sum_quantity_#{order_article.id}"}
= order_article.group_orders_sum[:quantity]
%td{:id => "group_orders_sum_price_#{order_article.id}", :class => "currency"}
= number_to_currency(order_article.group_orders_sum[:price], :unit => "")
%td{:colspan => "3"}
- reset_cycle('results')

View file

@ -1,30 +0,0 @@
%p
%b
Gruppenbestellungen:
= @order.group_order_results.size
- for groupOrderResult in @order.group_order_results
%p
%table{:style => "width:40em"}[groupOrderResult]
%thead
%tr
%th{:colspan => "6"}= groupOrderResult.group_name
%tbody
- total = 0
- for result in groupOrderResult.group_order_article_results
- price = result.order_article_result.fc_price
- quantity = result.quantity
- subTotal = price * quantity
- total += subTotal
%tr{:class => cycle('even', 'odd', :name => 'article')}
%td= result.order_article_result.name
%td= quantity
%td{:class => "currency"}= number_to_currency(price)
%td= result.order_article_result.unit_quantity
%td= result.order_article_result.unit
%td= number_to_currency(subTotal)
%tfoot
%tr{:class => cycle('even', 'odd', :name => 'article')}
%td{:colspan => "5"} Summe
%td
%b= number_to_currency(total)
- reset_cycle("article")

View file

@ -0,0 +1,24 @@
- if invoice
%table
%tr
%td Rechnungsnummer:
%td= invoice.number
%tr
%td Rechnungsdatum:
%td= invoice.date
%tr
%td Rechnungsbetrag:
%td.curreny= number_to_currency invoice.amount
%tr
%td - Pfand berechnet:
%td.curreny= number_to_currency invoice.deposit
%tr
%td + Pfand gutgeschrieben:
%td.curreny= number_to_currency invoice.deposit_credit
%tr
%td pfandbereinigter Betrag:
%td.curreny= number_to_currency invoice.net_amount
- else
Eine Rechnung für diese Bestellung anlegen:
= link_to "Neue Rechnung erstellen", new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier)

View file

@ -1,7 +0,0 @@
%h2
Neuer gelieferter Artikel die Bestellung
- remote_form_for 'order_article_result', @article, :url => {:action => 'createArticleResult' }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |@form| |
= render :partial => "articleResultForm"

View file

@ -1,17 +0,0 @@
%h2
Neue Gruppenmenge für
= @result.order_article_result.name
- remote_form_for 'group_order_article_result', @result, :url => {:action => 'createGroupResult'}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |@form| |
= error_messages_for 'result'
%p
Gruppe:
= @form.select "group_order_result_id", Ordergroup.find(:all, :order => "name").collect {|og| [og.name, og.id] }
%p
Menge:
= @form.text_field "quantity", :size => 5
= @form.hidden_field "order_article_result_id"
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,17 @@
%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 "quantity", :size => 5
= form.hidden_field "order_article_id"
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,7 @@
%h2
Neuer gelieferter Artikel die Bestellung
- remote_form_for order_article, :url => {:action => 'create_order_article' }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= render :partial => 'order_article_form', :locals => {:form => form}

View file

@ -0,0 +1,18 @@
%td.closed
= link_to_function order_article.article.name, |
"Element.toggle('group_order_articles_#{order_article.id}'); |
Element.toggleClassName(this.up('td'), 'open')" |
%td= order_article.article.order_number
%td= order_article.units_to_order
%td= order_article.price.unit_quantity.to_s + ' * ' + order_article.article.unit.to_s
%td= number_to_currency(order_article.price.price, :unit => "")
%td= number_to_currency(order_article.price.fc_price, :unit => "")
%td= order_article.price.tax
%td= order_article.price.deposit
%td
//= remote_link_to icon(:edit), |
//:url => {:action => 'edit_order_article', :id => order_article} |
%td
= remote_link_to icon(:delete), :confirm => 'Bist du sicher?', |
:url => {:action => 'destroy_order_article', :id => order_article}, |
:method => :post |

View file

@ -0,0 +1,26 @@
= form.error_messages
%table
%tr
%th Name
%th Nr.
%th
%abbr{:title=>"Anzahl gelieferter Gebinde"} Menge
%th GebGr
%th Einheit
%th netto
%th MwSt.
%th Pfand
%tr
%td= form.text_field 'name', :size => 20
%td= form.text_field 'order_number', :size => 3
%td= form.text_field 'units_to_order', :size => 5
%td= form.text_field 'unit_quantity', :size => 3
%td= form.text_field 'unit', :size => 5
%td= form.text_field 'net_price', :size => 3
%td= form.text_field 'tax', :size => 3
%td= form.text_field 'deposit', :size => 3
= form.hidden_field "order_id"
%br/
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,5 @@
%tr{:class => cycle('even', 'odd', :name => 'articles')}[order_article]
= render :partial => 'order_article', :locals => {:order_article => order_article}
%tr{:id => "group_order_articles_#{order_article.id}", :class => "results", :style => "display:none"}
= render :partial => 'group_order_articles', :locals => {:order_article => order_article}

View file

@ -1,60 +1,23 @@
%b=h order.supplier.name
%br/
= "von #{format_date(order.starts)} bis #{format_date(order.ends)}"
%p
%b=h @order.supplier ? @order.supplier.name : _('nonexistent')
| Rechnungsnummer:
= @order.invoice_number
| Rechnungsdatum:
= @order.invoice_date
|
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Rechnungsbetrag ändern'), |
:url => {:action => "editOrderSummary", :id => @order}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%table
%table
%tr
%td{:colspan => "2"}
%b Foodcoop
%td{:colspan => "2"}
%b Lieferant
%td Nettobetrag:
%td= number_to_currency(order.sum(:clear))
%tr
%td
%abbr{:title => "gelieferten Artikel x Nettopreis"} Nettobetrag:
%td= number_to_currency(@order.sum(:clear))
%td
Rechnungsbetrag
%small (incl. Pfand/Gutschriften)
%td#invoice_amount= number_to_currency(@order.invoice_amount)
%td Bruttobetrag:
%td= number_to_currency(order.sum(:gross))
%tr
%td
%abbr{:title => "Nettobetrag mit Pfand und MwSt."} Bruttobetrag:
%td= number_to_currency(@order.sum(:gross))
%td
%span - extra Pfand
%small (Kistenpfand etc.)
%td#deposit= number_to_currency(@order.deposit)
%td FC-Betrag:
%td= number_to_currency(order.sum(:fc))
%tr
%td
%abbr{:title => "Bruttobetrag mit Foodcoop Aufschlag"} FC Summe:
%td= number_to_currency(@order.sum(:fc))
%td{:style => "border-bottom: 1px solid grey"}
+ Pfandgutschriften
%td{:style => "border-bottom: 1px solid grey"}
#deposit_credit= number_to_currency(@order.deposit_credit)
%td Summe der Gruppenbeträge:
%td= number_to_currency(order.sum(:groups))
%tr
%td
%abbr{:title => "Zugeteilte Mengen x Bruttopreise (inkl. Aufschlag)"} Gruppenbeträge:
%td#groups_amount= number_to_currency(@order.sum(:groups))
%td
Summe
%small (Rechungsbetrag ohne Pfand)
%td#clear_invoice= number_to_currency(@order.invoice_amount - @order.deposit + @order.deposit_credit)
%td FC Gewinn ohne Aufschlag:
%td= number_to_currency(order.profit(:with_markup => false))
%tr
%td{:colspan => "4"}
%abbr{:title => "Gruppenbeträge ohne Aufschlag minus Rechnung ohne Pfand. |
Im Idealfall sollte hier 0.00 stehen."} Differenz ohne Aufschlag: |
%span#profit= number_to_currency(@order.profit(false))
%tr
%td{:colspan => "4"}
%b
%abbr{:title => "= Gruppenbeträge - Rechnung ohne Pfand"} Differenz mit Aufschlag
= "(#{number_to_percentage(APP_CONFIG[:price_markup])}):"
%span#profit= number_to_currency(@order.profit)
%td FC Gewinn mit Aufschlag:
%td#order_profit= number_to_currency(order.profit)

View file

@ -1,16 +1,16 @@
%h1 Bestellung abschließen
.single_column#confirm{:style => "width:35em"}
-title "Bestellung abschließen"
%div{:style => "width: 40em"}
%p
Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert.
%br/
Die Konten werden wie folgt belastet:
%table.list{:style => "width:35em"}
- for groupResult in @order.group_order_results
- for group_order in @order.group_orders
%tr{:class => cycle('even', 'odd')}
%td= groupResult.group_name
%td= number_to_currency(groupResult.price)
%td= group_order.ordergroup.name
%td= number_to_currency(group_order.price)
%p
%div{:style => "float:left"}
= button_to "Abschließen", :action => "close", :id => @order
%div{:style => "float:right"}
= link_to 'Zurück zur Abrechnung', :action => "new", :id => @order
= link_to 'Zurück zur Abrechnung', :action => 'new', :id => @order

View file

@ -48,7 +48,7 @@
%table.list
%thead
%tr
%th Name
%th Lieferant
%th Ende
%th Betrag(FC)
%th
@ -58,6 +58,6 @@
%td= order.supplier.name
%td= format_date(order.ends)
%td{:class => "currency"}= number_to_currency(order.sum(:fc))
%td= link_to "abrechnen", :action => "editOrder", :id => order
%td= link_to "abrechnen", :action => "new", :id => order
- else
Super, alles schon abgerechnet...

View file

@ -1,11 +1,7 @@
%h1 beendete Bestellungen
%p
- title "beendete Bestellungen"
%p{:style => "width:30em"}
%i
Aktuell gibt es die Möglichkeit eine Bestellung mittels dem "abrechnen"-link zu verbuchen, d.h.
nach Bearbeitung der Liefermengen die Gruppenbeträge automatisiert zu verbuchen,
%br/
oder die Bestellung manuell abzurechnen (Kontostände selbst zu aktualisieren) und mittels "auf gebucht setzen"
die Bestellung als abgeschlossen zu deklarieren.
Beschreibungstext für die Abrechnunsmodi ....
.left_column{:style => "width:70em"}
.box_title
.column_content
@ -32,6 +28,7 @@
- unless order.closed?
= link_to "abrechnen", :action => "new", :id => order
|
= link_to 'auf "gebucht" setzen', {:action => 'setAllBooked', :id => order}, :confirm => 'Wirklich alle Gruppenbestellungen für diese Bestellung auf "gebucht" setzen?', :method => "post"
= link_to 'direkt schließen', {:action => 'close_direct', :id => order}, |
:confirm => 'Wirklich die Bestellung schließen setzen?', :method => "post" |
- else
%i derzeit gibt es keine beendeten Bestellungen

View file

@ -1,37 +1,44 @@
%h1 Bestellung abrechnen
- title "#{@order.supplier.name} abrechnen"
- if @order.closed?
%p
%b Achtung, Bestellung wurde schon abgerechnet!
.left_column{:style => 'width: 50em'}
.left_column{:style => 'width: 24em'}
.box_title
%h2
= @order.supplier.name + " | " + format_date(@order.starts) + ' --> ' + format_date(@order.ends)
%h2 Zusammenfassung
.column_content#summary
#order_summary
= render :partial => "summary"
= render :partial => "summary", :locals => {:order => @order}
.left_column{:style => 'width: 24em'}
.box_title
%h2 Rechnung
.column_content#invoice
= render :partial => "invoice", :locals => {:invoice => @order.invoice}
.right_column{:style => 'width: 20em'}
.box_title
%h2 Aktionen
.column_content
%ul
- unless @order.invoice
%li= link_to "Rechnung anlegen", new_finance_invoice_path(:order_id => @order)
- unless @order.closed?
%li= link_to "Bestellung abschließen", :action => "confirm", :id => @order
.right_column{:style => 'clear:both;width: 28%'}
.box_title
%h2 Protokoll
%h2 Notizen/Protokoll
.column_content
#note
- unless @order.note.empty?
= simple_format @order.note
- else
%p Hier kannst Du deine Abrechnung kommentieren
%small Protokoll bearbeiten:
= link_to_remote image_tag("b_edit.png", :size => "16x16", :border => "0"), |
:update => 'results', :url => { :action => 'new', :id => @order, :view => 'editNote' }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" |
%hr/
= remote_link_to "Notiz bearbeiten", |
:update => 'edit_box', :url => {:action => 'edit_note', :id => @order}, |
:success => "Element.hide('loader'); Element.show('edit_box')" |
.box_title
%h2 Kommentare
.column_content
#comments
= render :partial => 'shared/comments'
@ -39,11 +46,11 @@
.box_title
#editOrderNav
%ul
%li= link_to_remote 'Gruppenübersicht', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'groupsOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%li= link_to_remote 'Artikelübersicht', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'articlesOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%li= link_to_remote 'Bestellung bearbeiten', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'editResults' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%li= remote_link_to 'Gruppenübersicht', :update => 'results', :url => {:action => 'new', :id => @order, :view => 'groupsOverview'}
%li= remote_link_to 'Artikelübersicht', :update => 'results', :url => {:action => 'new', :id => @order, :view => 'articlesOverview'}
%li= remote_link_to 'Bestellung bearbeiten', :update => 'results', :url => {:action => 'new', :id => @order, :view => 'editResults'}
.column_content
#results
= render :partial => 'groupsOverview'
= render :partial => 'edit_results_by_articles'
%p= link_to_top
#edit_box{:style => 'display:none'}

View file

@ -1,9 +1,12 @@
- form_for([:finance, @invoice]) do |f|
= f.error_messages
= f.hidden_field :delivery_id
= f.hidden_field :order_id
- if @invoice.delivery
%p= "Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft."
- if @invoice.order
%p= "Diese Rechnung ist mit einer #{link_to "Bestellung", @invoice.order} verknüpft."
%p
= f.label :supplier_id
%br/
@ -24,6 +27,14 @@
= f.label :amount
%br/
= f.text_field :amount
%p
= f.label :deposit
%br/
= f.text_field :deposit
%p
= f.label :deposit_credit
%br/
= f.text_field :deposit_credit
%p
= f.label :note
%br/

View file

@ -1,13 +1,9 @@
- unless comments.empty?
- comments.each do |comment|
.comment[comment]
%h3
= "#{comment.user.find_ordergroup.name} :" if comment.user.find_ordergroup
= simple_format(comment.text)
.timestamp
Erstellt am
= format_time(comment.created_at)
von
=h comment.user.nick
%b=h "#{comment.user.ordergroup_name}"
= "(#{comment.user.nick} am #{format_time(comment.created_at)}):"
= simple_format(comment.text)
- else
es gibt derzeit keine Kommentare.

View file

@ -5,7 +5,7 @@ class ActsAsParanoid < ActiveRecord::Migration
end
def self.down
remove_column :suppliers, :deleted_at, :datetime
remove_column :articles, :deleted_at, :datetime
remove_column :suppliers, :deleted_at
remove_column :articles, :deleted_at
end
end

View file

@ -3,64 +3,67 @@ class RefactorOrderLogic < ActiveRecord::Migration
# TODO: Combine migrations since foodsoft3-development into one file
# and try to build a migration path from old data.
# articles
rename_column :articles, :net_price, :price
remove_column :articles, :gross_price
# # articles
# rename_column :articles, :net_price, :price
# remove_column :articles, :gross_price
#
# # orders
# 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
#
# # invoices
# add_column :invoices, :order_id, :integer
# add_column :invoices, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
# add_column :invoices, :deposit_credit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
#
# # comments
# drop_table :comments
# create_table :order_comments do |t|
# t.references :order
# t.references :user
# t.text :text
# t.datetime :created_at
# end
#
# # article_prices
# 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
#
# # ordergroups
# add_column :groups, :deleted_at, :datetime
# orders
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
# invoices
add_column :invoices, :order_id, :integer
add_column :invoices, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
add_column :invoices, :deposit_credit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
# comments
drop_table :comments
create_table :order_comments do |t|
t.references :order
t.references :user
t.text :text
t.datetime :created_at
end
# article_prices
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
# ordergroups
add_column :groups, :deleted_at, :datetime
# GroupOrders
change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
end
def self.down

View file

@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090120184410) do
ActiveRecord::Schema.define(:version => 20090119155930) do
create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false
@ -107,7 +107,7 @@ ActiveRecord::Schema.define(:version => 20090120184410) do
t.decimal "price", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.integer "lock_version", :default => 0, :null => false
t.datetime "updated_on", :null => false
t.integer "updated_by_user_id", :default => 0, :null => false
t.integer "updated_by_user_id"
end
add_index "group_orders", ["ordergroup_id", "order_id"], :name => "index_group_orders_on_ordergroup_id_and_order_id", :unique => true

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

View file

@ -243,6 +243,16 @@ td.currency, td.actions {
text-align: right;
padding-right: 0.5em; }
td.closed {
background: url(/images/arrow_right_red.png) no-repeat center left; }
td.closed a {
display: block;
text-decoration: none;
padding-left: 20px; }
td.open {
background: url(/images/arrow_down_red.png) no-repeat center left; }
div.edit_form {
border: 2px solid #e3e3e3;
background: #f5f5f5;
@ -252,7 +262,7 @@ div.edit_form {
#edit_article, #edit_box {
position: fixed;
top: 23%;
top: 5em;
left: 10em;
width: 55em;
background: #FBFBFB;

View file

@ -243,6 +243,16 @@ td.currency, td.actions {
text-align: right;
padding-right: 0.5em; }
td.closed {
background: url(/images/arrow_right_red.png) no-repeat center left; }
td.closed a {
display: block;
text-decoration: none;
padding-left: 20px; }
td.open {
background: url(/images/arrow_down_red.png) no-repeat center left; }
div.edit_form {
border: 2px solid #e3e3e3;
background: #f5f5f5;
@ -252,7 +262,7 @@ div.edit_form {
#edit_article, #edit_box {
position: fixed;
top: 23%;
top: 5em;
left: 10em;
width: 55em;
background: #FBFBFB;

View file

@ -270,6 +270,14 @@ table.ordered_articles
td.currency, td.actions
:text-align right
:padding-right 0.5em
td.closed
background: url(/images/arrow_right_red.png) no-repeat center left
a
display: block
text-decoration: none
padding-left: 20px
td.open
background: url(/images/arrow_down_red.png) no-repeat center left
// ************************************* for edit formulars */
div.edit_form
@ -281,7 +289,7 @@ div.edit_form
#edit_article, #edit_box
:position fixed
:top 23%
:top 5em
:left 10em
:width 55em
:background #FBFBFB

View file

@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090120184410
#
# Table name: groups
#
@ -21,6 +21,7 @@
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# deleted_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html