First part of stock-integratino. Orders with supplier_id == 0 become stockorders.

This commit is contained in:
Benjamin Meichsner 2009-02-05 16:40:02 +01:00
parent 251ced4fa1
commit 1912a3fd80
30 changed files with 112 additions and 95 deletions

View File

@ -53,9 +53,7 @@ class OrdersController < ApplicationController
# Page to create a new order. # Page to create a new order.
def new def new
@supplier = Supplier.find(params[:supplier_id]) @order = Order.new :ends => 4.days.from_now, :supplier_id => params[:supplier_id]
@order = @supplier.orders.build :ends => 4.days.from_now
@template_orders = @supplier.orders.finished :order => 'starts DESC', :limit => 5
end end
# Save a new order. # Save a new order.
@ -104,13 +102,13 @@ class OrdersController < ApplicationController
# Renders the groups-orderd PDF. # Renders the groups-orderd PDF.
def groupsPdf def groupsPdf
@order = Order.find(params[:id]) @order = Order.find(params[:id])
prawnto :filename => "#{Date.today}_#{@order.supplier.name}_GruppenSortierung.pdf" prawnto :filename => "#{Date.today}_#{@order.name}_GruppenSortierung.pdf"
end end
# Renders the articles-orderd PDF. # Renders the articles-orderd PDF.
def articlesPdf def articlesPdf
@order = Order.find(params[:id]) @order = Order.find(params[:id])
prawnto :filename => "#{Date.today}_#{@order.supplier.name}_ArtikelSortierung.pdf", prawnto :filename => "#{Date.today}_#{@order.name}_ArtikelSortierung.pdf",
:prawn => { :left_margin => 48, :prawn => { :left_margin => 48,
:right_margin => 48, :right_margin => 48,
:top_margin => 48, :top_margin => 48,
@ -120,7 +118,7 @@ class OrdersController < ApplicationController
# Renders the fax PDF. # Renders the fax PDF.
def faxPdf def faxPdf
@order = Order.find(params[:id]) @order = Order.find(params[:id])
prawnto :filename => "#{Date.today}_#{@order.supplier.name}_FAX.pdf" prawnto :filename => "#{Date.today}_#{@order.name}_FAX.pdf"
end end
# Renders the fax-text-file # Renders the fax-text-file
@ -147,13 +145,13 @@ class OrdersController < ApplicationController
end end
send_data text, send_data text,
:type => 'text/plain; charset=utf-8; header=present', :type => 'text/plain; charset=utf-8; header=present',
:disposition => "attachment; filename=#{order.supplier.name}" :disposition => "attachment; filename=#{order.name}"
end end
# 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.supplier.name}_Matrix.pdf" prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf"
end end
# adds a Comment to the Order # adds a Comment to the Order

View File

@ -32,6 +32,7 @@ class Article < ActiveRecord::Base
belongs_to :supplier belongs_to :supplier
belongs_to :article_category belongs_to :article_category
has_many :article_prices, :order => "created_at" has_many :article_prices, :order => "created_at"
has_many :stock_changes
named_scope :in_stock, :conditions => "quantity > 0", :order => 'suppliers.name', :include => :supplier named_scope :in_stock, :conditions => "quantity > 0", :order => 'suppliers.name', :include => :supplier
named_scope :available, :conditions => {:availability => true} named_scope :available, :conditions => {:availability => true}
@ -172,8 +173,9 @@ class Article < ActiveRecord::Base
end end
end end
def update_quantity(amount) # Update the quantity of items in stock
update_attribute :quantity, quantity + amount def update_quantity!
update_attribute :quantity, stock_changes.collect(&:quantity).sum
end end
protected protected

View File

@ -26,8 +26,8 @@ class GroupOrder < ActiveRecord::Base
validates_numericality_of :price validates_numericality_of :price
validates_uniqueness_of :ordergroup_id, :scope => :order_id # order groups can only order once per order validates_uniqueness_of :ordergroup_id, :scope => :order_id # order groups can only order once per order
named_scope :open, lambda { {:conditions => ["order_id IN (?)", Order.open.collect{|o| o.id}]} } named_scope :open, lambda { {:conditions => ["order_id IN (?)", Order.open.collect(&:id)]} }
named_scope :finished, lambda { {:conditions => ["order_id IN (?)", Order.finished.collect{|o| o.id}]} } named_scope :finished, lambda { {:conditions => ["order_id IN (?)", Order.finished.collect(&:id)]} }
# Updates the "price" attribute. # Updates the "price" attribute.
# This will be the maximum value of an order # This will be the maximum value of an order

View File

@ -154,8 +154,8 @@ class GroupOrderArticle < ActiveRecord::Base
memoize :calculate_result memoize :calculate_result
# Returns order result, # Returns order result,
# either calcualted on the fly or fetched from quantity_/tolerance_result # either calcualted on the fly or fetched from result attribute
# After an order is finished, there is only the result # Result is set when finishing the order.
def result(type = :total) def result(type = :total)
self[:result] || calculate_result[type] self[:result] || calculate_result[type]
end end

View File

@ -28,21 +28,44 @@ class Order < ActiveRecord::Base
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id" belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id"
# Validations # Validations
validates_presence_of :supplier_id, :starts validates_presence_of :starts
validate_on_create :starts_before_ends, :include_articles validate :starts_before_ends, :include_articles
# Callbacks # Callbacks
after_update :update_price_of_group_orders after_update :update_price_of_group_orders
# Finders # Finders
named_scope :open, :conditions => { :state => 'open' }, named_scope :open, :conditions => {:state => 'open'}, :order => 'ends DESC'
:order => 'ends DESC' named_scope :finished, :conditions => "state = 'finished' OR state = 'closed'", :order => 'ends DESC'
named_scope :finished, :conditions => "state = 'finished' OR state = 'closed'", named_scope :finished_not_closed, :conditions => {:state => 'finished'}, :order => 'ends DESC'
:order => 'ends DESC' named_scope :closed, :conditions => {:state => 'closed'}, :order => 'ends DESC'
named_scope :finished_not_closed, :conditions => { :state => 'finished' }, named_scope :stockit, :conditions => {:supplier_id => 0}, :order => 'ends DESC'
:order => 'ends DESC'
named_scope :closed, :conditions => { :state => 'closed' }, def stockit?
:order => 'ends DESC' supplier_id == 0
end
def name
stockit? ? "Lager" : supplier.name
end
def articles_for_ordering
if stockit?
Article.in_stock.all(:include => :article_category,
:order => 'article_categories.name, articles.name').group_by { |a| a.article_category.name }
else
supplier.articles.available.all.group_by { |a| a.article_category.name }
end
end
# Fetch last orders from same supplier, to generate an article selection proposal
def templates
if stockit?
Order.stockit :limit => 5
else
supplier.orders.finished :limit => 5
end
end
# Create or destroy OrderArticle associations on create/update # Create or destroy OrderArticle associations on create/update
def article_ids=(ids) def article_ids=(ids)
@ -163,7 +186,7 @@ class Order < ActiveRecord::Base
# Sets order.status to 'close' and updates all Ordergroup.account_balances # Sets order.status to 'close' and updates all Ordergroup.account_balances
def close!(user) def close!(user)
raise "Bestellung wurde schon abgerechnet" if closed? raise "Bestellung wurde schon abgerechnet" if closed?
transaction_note = "Bestellung: #{supplier.name}, bis #{ends.strftime('%d.%m.%Y')}" transaction_note = "Bestellung: #{name}, bis #{ends.strftime('%d.%m.%Y')}"
gos = group_orders.all(:include => :ordergroup) # Fetch group_orders gos = group_orders.all(:include => :ordergroup) # Fetch group_orders
gos.each { |group_order| group_order.update_price! } # Update prices of group_orders gos.each { |group_order| group_order.update_price! } # Update prices of group_orders

View File

@ -20,15 +20,11 @@ class StockChange < ActiveRecord::Base
validates_numericality_of :quantity validates_numericality_of :quantity
after_save :update_article_quantity after_save :update_article_quantity
after_destroy :remove_added_quantity after_destroy :update_article_quantity
protected protected
def update_article_quantity def update_article_quantity
article.update_quantity(quantity) article.update_quantity!
end
def remove_added_quantity
article.update_quantity(quantity * -1)
end end
end end

View File

@ -41,11 +41,6 @@ class Supplier < ActiveRecord::Base
# for the sharedLists-App # for the sharedLists-App
belongs_to :shared_supplier belongs_to :shared_supplier
# Returns all articles for this supplier that are available, grouped by article category and ordered by name.
def get_articles_for_ordering
articles.available.all.group_by { |a| a.article_category.name }
end
# sync all articles with the external database # sync all articles with the external database
# returns an array with articles(and prices), which should be updated (to use in a form) # returns an array with articles(and prices), which should be updated (to use in a form)
# also returns an array with outlisted_articles, which should be deleted # also returns an array with outlisted_articles, which should be deleted

View File

@ -1,4 +1,4 @@
%b=h order.supplier.name %b=h order.name
%br/ %br/
= "von #{format_date(order.starts)} bis #{format_date(order.ends)}" = "von #{format_date(order.starts)} bis #{format_date(order.ends)}"
%p %p

View File

@ -55,7 +55,7 @@
%tbody %tbody
- @orders.each do |order| - @orders.each do |order|
%tr{:class => cycle("even","odd", :name => "order")} %tr{:class => cycle("even","odd", :name => "order")}
%td= order.supplier.name %td= order.name
%td= format_date(order.ends) %td= format_date(order.ends)
%td{:class => "currency"}= number_to_currency(order.sum(:fc)) %td{:class => "currency"}= number_to_currency(order.sum(:fc))
%td= link_to "abrechnen", :action => "new", :id => order %td= link_to "abrechnen", :action => "new", :id => order

View File

@ -18,7 +18,7 @@
%tbody %tbody
- @orders.each do |order| - @orders.each do |order|
%tr{:class => cycle("even","odd", :name => "order")} %tr{:class => cycle("even","odd", :name => "order")}
%td= link_to truncate(order.supplier.name), :action => "new", :id => order %td= link_to truncate(order.name), :action => "new", :id => order
%td=h format_time(order.ends) unless order.ends.nil? %td=h format_time(order.ends) unless order.ends.nil?
%td= order.closed? ? "abgerechnet (#{number_to_currency order.profit})" : "beendet" %td= order.closed? ? "abgerechnet (#{number_to_currency order.profit})" : "beendet"
%td= order.updated_by.nil? ? '??' : order.updated_by.nick %td= order.updated_by.nil? ? '??' : order.updated_by.nick

View File

@ -1,4 +1,4 @@
- title "#{@order.supplier.name} abrechnen" - title "#{@order.name} abrechnen"
- if @order.closed? - if @order.closed?
%p %p

View File

@ -24,6 +24,7 @@
Artikelverwaltung Artikelverwaltung
%ul %ul
%li= link_to "Artikel aktualisieren", suppliers_path %li= link_to "Artikel aktualisieren", suppliers_path
%li= link_to "Lagerverwaltung", :controller => 'stockit'
%li= link_to "Lieferanten verwalten", suppliers_path %li= link_to "Lieferanten verwalten", suppliers_path
// Finance // Finance

View File

@ -1,6 +1,6 @@
Liebe <%= group.name %>, Liebe <%= group.name %>,
die Bestellung für "<%= order.supplier.name %>" wurde am <%= order.ends.strftime('%d.%m.%Y um %H:%M') %> von <%= order.updated_by.nick %> beendet. die Bestellung für "<%= order.name %>" wurde am <%= order.ends.strftime('%d.%m.%Y um %H:%M') %> von <%= order.updated_by.nick %> beendet.
Für Euch wurden die folgenden Artikel bestellt: Für Euch wurden die folgenden Artikel bestellt:
<% for group_order_article in group_order.group_order_articles.all(:include => :order_article) <% for group_order_article in group_order.group_order_articles.all(:include => :order_article)

View File

@ -11,7 +11,7 @@
- group_order = order.group_order(@ordergroup) # Get GroupOrder if possible - group_order = order.group_order(@ordergroup) # Get GroupOrder if possible
- order_class = group_order ? "" : "color:grey" - order_class = group_order ? "" : "color:grey"
%tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class} %tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class}
%td= link_to order.supplier.name, :action => 'my_order_result', :id => order %td= link_to order.name, :action => 'my_order_result', :id => order
%td= format_time(order.ends) %td= format_time(order.ends)
%td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--" %td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--"

View File

@ -1,10 +1,10 @@
- title "Dein Bestellergebnis für #{@order.supplier.name}" - title "Dein Bestellergebnis für #{@order.name}"
#element_navigation #element_navigation
= link_to_unless @order.previous == @order, "<< #{@order.previous.supplier.name}", :action => "my_order_result", :id => @order.previous = link_to_unless @order.previous == @order, "<< #{@order.previous.name}", :action => "my_order_result", :id => @order.previous
| |
= link_to _("Overview"), :controller => 'ordering' = link_to _("Overview"), :controller => 'ordering'
| |
= link_to_unless @order.next == @order, "#{@order.next.supplier.name} >>", :action => "my_order_result", :id => @order.next = link_to_unless @order.next == @order, "#{@order.next.name} >>", :action => "my_order_result", :id => @order.next
// Order summary // Order summary
.left_column{:style => "width:45em"} .left_column{:style => "width:45em"}
@ -16,7 +16,7 @@
%td{:style => "width:50%"} %td{:style => "width:50%"}
%p %p
Lieferant: Lieferant:
%b=h @order.supplier.name %b=h @order.name
- unless @order.note.blank? - unless @order.note.blank?
%p %p
Notiz: Notiz:
@ -43,7 +43,7 @@
%table %table
- for order in Order.open - for order in Order.open
%tr %tr
%td= link_to order.supplier.name, :action => 'order', :id => order %td= link_to order.name, :action => 'order', :id => order
%td= "("+ time_ago_in_words(order.ends) + ")" if order.ends %td= "("+ time_ago_in_words(order.ends) + ")" if order.ends
// Article box // Article box

View File

@ -1,33 +1,33 @@
<h1>Bestellen</h1> <h1>Bestellen</h1>
<div class="left_column" style="width:49em"> <div class="left_column" style="width:49em">
<div class="box_title"><h2><%=h @order.supplier.name %></h2></div> <div class="box_title"><h2><%=h @order.name %></h2></div>
<div class="column_content"> <div class="column_content">
<table> <table>
<tr valign="top"> <tr valign="top">
<td width="60%"> <td width="60%">
<p><b><%=_ "Supplier" %>:</b> <%=h @order.supplier.name %></p> <p><b>Lieferant:</b> <%=h @order.name %></p>
<p><b><%=_ "End" %>:</b> <%=h format_time(@order.ends) %></p> <p><b>Ende:</b> <%=h format_time(@order.ends) %></p>
<% if @group_order && @group_order.updated_by -%> <% if @group_order && @group_order.updated_by -%>
<p><b><%=_ "person ordered at last" %>:</b> <%=h @group_order.updated_by.nick if @group_order.updated_by %> (<%= format_time(@group_order.updated_on) %>)</p> <p><b>Zuletzt bestellt:</b> <%=h @group_order.updated_by.nick if @group_order.updated_by %> (<%= format_time(@group_order.updated_on) %>)</p>
<% end -%> <% end -%>
<p><b><%=_ "Credit available"%>:</b> <%= number_to_currency(@availableFunds) %></p> <p><b>Verfügbares Guthaben:</b> <%= number_to_currency(@availableFunds) %></p>
</td> </td>
<td> <td>
<% unless @order.note.empty? %> <% unless @order.note.empty? %>
<p> <p>
<b><%=_ "Note" %>:</b> <b>Notiz:</b>
</p> </p>
<%= simple_format(@order.note) %> <%= simple_format(@order.note) %>
<% end %> <% end %>
<% unless @order.supplier.min_order_quantity.nil? || @order.supplier.min_order_quantity.empty? %> <% unless @order.stockit? || @order.supplier.min_order_quantity.blank? -%>
<p> <p>
<b><%=_ "Minimum order quantity" %>:</b> <b>Mindestellmenge:</b>
<%=h @order.supplier.min_order_quantity %> <%=h @order.supplier.min_order_quantity %>
</p> </p>
<% end %> <% end -%>
<p> <p>
<b><%=_ "Order quanitity so far" %>:</b> <b>Gesamtbestellmenge bisher:</b>
<%= number_to_currency @order.sum %> <%= number_to_currency @order.sum %>
</p> </p>
</td> </td>
@ -39,14 +39,14 @@
<%- if !@other_orders.empty? -%> <%- if !@other_orders.empty? -%>
<div class="right_column" style="width:22em"> <div class="right_column" style="width:22em">
<div class="box_title"> <div class="box_title">
<h2><%=_ "Other orders" %></h2> <h2>Andere Bestellungen</h2>
</div> </div>
<div class="column_content"> <div class="column_content">
<table> <table>
<% for order in @other_orders -%> <% for order in @other_orders -%>
<tr> <tr>
<td> <td>
<%= link_to_function order.supplier.name, "if (confirmSwitchOrder()) (window.location = '#{ url_for(:action => 'order', :id => order) }' )" %> <%= link_to_function order.name, "if (confirmSwitchOrder()) (window.location = '#{ url_for(:action => 'order', :id => order) }' )" %>
</td> </td>
<td>noch <%= time_ago_in_words(order.ends) if order.ends -%></td> <td>noch <%= time_ago_in_words(order.ends) if order.ends -%></td>
</tr> </tr>
@ -61,21 +61,23 @@
<div class="single_column"> <div class="single_column">
<% form_tag(:action => 'saveOrder', :id => @order) do %> <% form_tag(:action => 'saveOrder', :id => @order) do %>
<div class="box_title"> <div class="box_title">
<h2><%=_ "Articles" %></h2> <h2>Artikel</h2>
</div> </div>
<div class="column_content"> <div class="column_content">
<table id="order" class="list"> <table id="order" class="list">
<thead> <thead>
<tr> <tr>
<th><%=_ "Name" %></th> <th>Name</th>
<th></th> <th></th>
<th><%=_ "Manufacturer" %></th> <th>Herstellerin</th>
<th style="width:7em;"><%=_ "Package" %></th> <th style="width:7em;"><%= @order.stockit? ? "im Lager" : "Gebinde" -%></th>
<th style="width:4.5em;"><%=_ "Price" %></th> <th style="width:4.5em;">Preis</th>
<th id="col_packages"><acronym title="<%=_ "totally ordered packages" %>"><%=_ "Ord."%></acronym></th> <th id="col_packages"><acronym title="insgesamt bestellte Gebinde">Best</acronym></th>
<th id="col_required"><%=_ "Quantity" %></th> <th id="col_required">Menge</th>
<th id="col_tolerance"><%=_ "Tolerance" %></th> <% unless @order.stockit? -%>
<th><%=_ "Amount" %></th> <th id="col_tolerance">Toleranz</th>
<% end -%>
<th>Summe</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -104,7 +106,7 @@
</td> </td>
<td><%=h order_article.article.origin %></td> <td><%=h order_article.article.origin %></td>
<td><%=h truncate order_article.article.manufacturer, :length => 11 %></td> <td><%=h truncate order_article.article.manufacturer, :length => 11 %></td>
<td><%= @unit[i] %> * <%=h order_article.article.unit %></td> <td><%= @order.stockit? ? order_article.article.quantity_available : @unit[i] %> * <%=h order_article.article.unit %></td>
<td><%= number_to_currency(@price[i]) %></td> <td><%= number_to_currency(@price[i]) %></td>
<td id="units_<%= i %>"><%= order_article.units_to_order %></td> <td id="units_<%= i %>"><%= order_article.units_to_order %></td>
<td style="text-align:right;"> <td style="text-align:right;">

View File

@ -7,7 +7,7 @@
= form.hidden_field :supplier_id = form.hidden_field :supplier_id
%p %p
Lieferant: Lieferant:
= @order.supplier.name = @order.name
%p %p
Notiz Notiz
%br/ %br/
@ -31,7 +31,7 @@
%option{:value => "-1", :selected => "selected"}=_ "Choose an order..." %option{:value => "-1", :selected => "selected"}=_ "Choose an order..."
- i = -1 - i = -1
- for order in @template_orders - for order in @template_orders
%option{:value => (i += 1)}= "#{h(order.supplier.name)} bis #{order.ends.strftime('%d. %b')}" %option{:value => (i += 1)}= "#{h(order.name)} bis #{order.ends.strftime('%d. %b')}"
%table.list %table.list
%tr %tr
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" } %th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
@ -41,7 +41,7 @@
%th=_ "Manufacturer" %th=_ "Manufacturer"
%th=_ "Unit quantity" %th=_ "Unit quantity"
%th=_ "Price" %th=_ "Price"
- for category_name, articles in @order.supplier.get_articles_for_ordering - for category_name, articles in @order.articles_for_ordering
%tr{:style => "background-color:#EFEFEF"} %tr{:style => "background-color:#EFEFEF"}
%td %td
%td{:colspan => "6", :style => "text-align:left"} %td{:colspan => "6", :style => "text-align:left"}
@ -65,6 +65,3 @@
- if (@template_orders && !@template_orders.empty?) - if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script' = render :partial => 'template_orders_script'

View File

@ -12,7 +12,7 @@
%tbody %tbody
- @orders.each do |order| - @orders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'orders')} %tr{:class => cycle('even', 'odd', :name => 'orders')}
%td=h order.supplier.name %td=h order.name
%td=h format_time(order.starts) %td=h format_time(order.starts)
%td=h format_time(order.ends) %td=h format_time(order.ends)
%td= order.state %td= order.state

View File

@ -1,5 +1,5 @@
end_date = @order.ends.strftime('%d.%m.%Y') end_date = @order.ends.strftime('%d.%m.%Y')
title = "#{@order.supplier.name} | beendet am #{end_date}" title = "#{@order.name} | beendet am #{end_date}"
# Define header and footer # Define header and footer
pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do

View File

@ -25,7 +25,7 @@ end
# Recipient # Recipient
pdf.bounding_box [pdf.margin_box.left,pdf.margin_box.top-60], :width => 200 do pdf.bounding_box [pdf.margin_box.left,pdf.margin_box.top-60], :width => 200 do
pdf.text @order.supplier.name pdf.text @order.name
pdf.move_down 5 pdf.move_down 5
pdf.text @order.supplier.address pdf.text @order.supplier.address
pdf.move_down 5 pdf.move_down 5

View File

@ -1,5 +1,5 @@
end_date = @order.ends.strftime('%d.%m.%Y') end_date = @order.ends.strftime('%d.%m.%Y')
title = "Gruppensortierung für #{@order.supplier.name}, beendet am #{end_date}" title = "Gruppensortierung für #{@order.name}, beendet am #{end_date}"
# Define header and footer # Define header and footer
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do

View File

@ -24,7 +24,7 @@
- for order in @open_orders - for order in @open_orders
- active = (order.open? and order.ends < Time.now) ? " active" : "" - active = (order.open? and order.ends < Time.now) ? " active" : ""
%tr{:class => cycle('even', 'odd', :name => 'open_orders') + active} %tr{:class => cycle('even', 'odd', :name => 'open_orders') + active}
%td=h order.supplier.name %td=h order.name
%td=h format_time(order.ends) unless order.ends.nil? %td=h format_time(order.ends) unless order.ends.nil?
%td=h truncate(order.note) %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 => _("Are you really sure to finish the order?"), :method => :post

View File

@ -1,4 +1,4 @@
title = "#{@order.supplier.name}, beendet am #{@order.ends.strftime('%d.%m.%Y')}" title = "#{@order.name}, beendet am #{@order.ends.strftime('%d.%m.%Y')}"
# Define header and footer # Define header and footer
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do

View File

@ -1,7 +1,7 @@
- title _("New order") - title "Neue Bestellung anlegen"
- form_for @order do |form| - form_for @order do |form|
= render :partial => 'form', :locals => { :form => form } = render :partial => 'form', :locals => { :form => form }
= submit_tag _("Put the order online") = submit_tag "Bestellung online stellen"
| |
= link_to "Abbrechen", orders_path = link_to "Abbrechen", orders_path

View File

@ -1,10 +1,10 @@
- title _("Show order") - title "Bestellung: #{@order.name}"
#element_navigation #element_navigation
= link_to_unless @order.previous == @order, "<< #{@order.previous.supplier.name}", @order.previous = link_to_unless @order.previous == @order, "<< #{@order.previous.name}", @order.previous
| |
= link_to _("Overview"), orders_path = link_to _("Overview"), orders_path
| |
= link_to_unless @order.next == @order, "#{@order.next.supplier.name} >>", @order.next = link_to_unless @order.next == @order, "#{@order.next.name} >>", @order.next
// Order summary // Order summary
.left_column{:style => "width:65em"} .left_column{:style => "width:65em"}
@ -16,7 +16,7 @@
%b{:style => "color:red"}=_ "Order isn't closed yet" %b{:style => "color:red"}=_ "Order isn't closed yet"
%p %p
Lieferant: Lieferant:
%b=h @order.supplier.name %b=h @order.name
- unless @order.note.empty? - unless @order.note.empty?
%p %p
Notiz: Notiz:

View File

@ -13,7 +13,7 @@
- total = 0 - total = 0
- Order.open.each do |order| - Order.open.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'open_orders')} %tr{:class => cycle('even', 'odd', :name => 'open_orders')}
%td= link_to h(order.supplier.name), :controller => 'ordering', :action => 'order', :id => order %td= link_to h(order.name), :controller => 'ordering', :action => 'order', :id => order
%td=h format_time(order.ends) unless order.ends.nil? %td=h format_time(order.ends) unless order.ends.nil?
- if group_order = order.group_order(@ordergroup) - if group_order = order.group_order(@ordergroup)
- total += group_order.price - total += group_order.price

View File

@ -7,7 +7,8 @@
options_for_select([" -- Lieferantin wählen --", ""] + | options_for_select([" -- Lieferantin wählen --", ""] + |
Supplier.find(:all).collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), | Supplier.find(:all).collect {|s| [ s.name, url_for(new_supplier_delivery_path(s))] }), |
:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" | :onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;" |
%p
= link_to "Lagerbestellung online stellen", new_order_path(:supplier_id => 0)
%p %p
%table.list %table.list
%thead %thead

View File

@ -4,6 +4,8 @@ ActionController::Routing::Routes.draw do |map|
map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks' map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks'
map.resources :orders, :member => { :finish => :post, :add_comment => :post } map.resources :orders, :member => { :finish => :post, :add_comment => :post }
map.resources :stock_orders, :member => { :finish => :post, :add_comment => :post },
:controller => 'orders'
map.resources :messages, :only => [:index, :show, :new, :create], map.resources :messages, :only => [:index, :show, :new, :create],
:member => { :reply => :get, :user => :get, :group => :get } :member => { :reply => :get, :user => :get, :group => :get }

View File

@ -77,10 +77,10 @@ class RefactorOrderLogic < ActiveRecord::Migration
# #
# # == GroupOrder # # == GroupOrder
# change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true # change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
#
# == GroupOrderArticle # # == GroupOrderArticle
# The total order result in ordergroup is now saved! # # The total order result in ordergroup is now saved!
add_column :group_order_articles, :result, :integer, :default => nil # add_column :group_order_articles, :result, :integer, :default => nil
end end
def self.down def self.down

View File

@ -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 => 20090120184410) do ActiveRecord::Schema.define(:version => 20090119155930) 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