Complete refactoring of orders-workflow.
OrderResult tables are removed. Data consistency is now possible through new article.price-history (ArticlePrice). Balancing-workflow needs to be updated.
This commit is contained in:
parent
80287aeea4
commit
9eb2125f15
98 changed files with 1121 additions and 1717 deletions
31
app/views/orders/_articles.html.haml
Normal file
31
app/views/orders/_articles.html.haml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
%table
|
||||
%tr
|
||||
%th Name
|
||||
%th Gebinde
|
||||
%th Netto/FC-Preis
|
||||
%th Bestellte Einheiten
|
||||
%th Volle Gebinde
|
||||
- total_net, total_gross, counter = 0, 0, 0
|
||||
- order.get_articles.each do |category_name, order_articles|
|
||||
%tr{:style => "background-color:#EFEFEF"}
|
||||
%td{:style => "text-align:left; color: grey;"}=h category_name
|
||||
%td{:colspan => "9"}
|
||||
- order_articles.each do |order_article|
|
||||
- net_price = order_article.price.price
|
||||
- fc_price = order_article.price.fc_price
|
||||
- units = order_article.units_to_order
|
||||
- unit_quantity = order_article.price.unit_quantity
|
||||
- total_net += units * unit_quantity * net_price
|
||||
- total_gross += units * unit_quantity * fc_price
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color: #{units > 0 ? 'green' : 'red'}"}
|
||||
%td=h order_article.article.name
|
||||
%td= "#{unit_quantity} x #{order_article.article.unit}"
|
||||
%td= "#{number_to_currency(net_price)} / #{number_to_currency(fc_price)}"
|
||||
%td= "#{order_article.quantity} + #{order_article.tolerance}" if unit_quantity > 1
|
||||
%td= units
|
||||
%p
|
||||
Summe (Netto/FC-Preise):
|
||||
= "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}"
|
||||
%p
|
||||
Bestellte Artikel.
|
||||
= order.order_articles.ordered.count
|
||||
23
app/views/orders/_articles_by_articles.html.haml
Normal file
23
app/views/orders/_articles_by_articles.html.haml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
.legend
|
||||
%table.legend{:style => "margin-bottom:1em"}
|
||||
%tr
|
||||
%th{:colspan => '3'} Legende
|
||||
%tr
|
||||
%th{:style => 'width:70%'} Bestellgruppe
|
||||
%th Menge
|
||||
%th Gesamtpreis
|
||||
|
||||
- for order_article in order.order_articles.all(:include => [:article, :article_price])
|
||||
%table{:style => "margin-bottom:1em"}
|
||||
%thead
|
||||
%tr
|
||||
%th{:colspan => "3"}
|
||||
= order_article.article.name
|
||||
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.fc_price)})"
|
||||
%tbody
|
||||
- for goa in order_article.group_order_articles
|
||||
%tr{:class => cycle('even', 'odd', :name => 'groups')}
|
||||
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name
|
||||
%td= "#{goa.quantity} (#{goa.tolerance})"
|
||||
%td= number_to_currency(order_article.price.fc_price * goa.quantity)
|
||||
- reset_cycle('groups')
|
||||
36
app/views/orders/_articles_by_groups.html.haml
Normal file
36
app/views/orders/_articles_by_groups.html.haml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
.legend
|
||||
%table.legend{:style => "margin-bottom:1em"}
|
||||
%tr
|
||||
%th{:style => "width:40%"} Name
|
||||
%th
|
||||
%acronym{:title => "zugeteilte Einheiten (davon aus Toleranzmenge)"} Menge
|
||||
%th
|
||||
%acronym{:title => "Preis incl. MwSt, Pfand und Foodcoop-Aufschlag"} FC-Preis
|
||||
%th
|
||||
%acronym{:title => "Gebindegröße"} GebGr
|
||||
%th Einheit
|
||||
%th Gesamtpreis
|
||||
|
||||
- for group_order in order.group_orders.all
|
||||
%table{:style => "margin-bottom:1em"}
|
||||
%thead
|
||||
%tr
|
||||
%th{:colspan => "6"}=h group_order.ordergroup.name
|
||||
%tbody
|
||||
- total = 0
|
||||
- for goa in group_order.group_order_articles.all(:include => :order_article)
|
||||
- fc_price = goa.order_article.price.fc_price
|
||||
- subTotal = fc_price * goa.quantity
|
||||
- total += subTotal
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles')}
|
||||
%td{:style => "width:40%"}=h goa.order_article.article.name
|
||||
%td= "#{goa.quantity} (#{goa.tolerance})"
|
||||
%td= number_to_currency(fc_price)
|
||||
%td= goa.order_article.price.unit_quantity
|
||||
%td= goa.order_article.article.unit
|
||||
%td= number_to_currency(subTotal)
|
||||
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles')}
|
||||
%th{:colspan => "5"} Summe
|
||||
%th= number_to_currency(total)
|
||||
- reset_cycle("articles")
|
||||
|
|
@ -1,31 +1,28 @@
|
|||
= error_messages_for 'order'
|
||||
= form.error_messages
|
||||
|
||||
.single_column
|
||||
.box_title
|
||||
%h2=_ "Order"
|
||||
%h2 Bestellung
|
||||
.column_content
|
||||
= hidden_field 'order', 'supplier_id'
|
||||
= form.hidden_field :supplier_id
|
||||
%p
|
||||
=h _("Supplier") + ": #{@order.supplier.name}"
|
||||
Lieferant:
|
||||
= @order.supplier.name
|
||||
%p
|
||||
%label{:for => 'order_name'}=_ "Name"
|
||||
Notiz
|
||||
%br/
|
||||
= text_field 'order', 'name'
|
||||
= form.text_area :note, :cols => 50, :rows => 5
|
||||
%p
|
||||
%label{:for => 'order_note'}=_ "Note"
|
||||
Start
|
||||
%br/
|
||||
= text_area 'order', 'note', :cols => 50, :rows => 5
|
||||
= form.datetime_select :starts, :start_year => Time.now.year - 1
|
||||
%p
|
||||
%label{:for => 'order_starts'}=_ "Start"
|
||||
Ende
|
||||
%br/
|
||||
= datetime_select 'order', 'starts', :start_year => Time.now.year - 1
|
||||
%p
|
||||
%label{:for => 'order_ends'}=_ "End"
|
||||
%br/
|
||||
= datetime_select 'order', 'ends', :start_year => Time.now.year - 1, :include_blank => true
|
||||
= form.datetime_select :ends, :start_year => Time.now.year - 1, :include_blank => true
|
||||
|
||||
.box_title
|
||||
%h2=_ "Articles"
|
||||
%h2 Artikel
|
||||
.column_content
|
||||
- if (@template_orders && !@template_orders.empty?)
|
||||
%p
|
||||
|
|
@ -34,7 +31,7 @@
|
|||
%option{:value => "-1", :selected => "selected"}=_ "Choose an order..."
|
||||
- i = -1
|
||||
- for order in @template_orders
|
||||
%option{:value => (i += 1)}=h order.name
|
||||
%option{:value => (i += 1)}=h order.supplier.name
|
||||
%table.list
|
||||
%tr
|
||||
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
|
||||
|
|
@ -52,14 +49,15 @@
|
|||
- for article in articles
|
||||
/ check if the article is selected
|
||||
- included = @order.order_articles.detect { |order_article| order_article.article_id == article.id }
|
||||
%tr{:class => cycle('even', 'odd') + (included ? ' selected' : ''), :id => article.id.to_s, :onclick => "checkRow('#{article.id}')"}
|
||||
%td= check_box_tag "order[article_ids][]", article.id.to_s, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" }
|
||||
- included_class = included ? ' selected' : ''
|
||||
%tr{:class => cycle('even', 'odd') + ' click-me' + included_class, :id => article.id.to_s, :onclick => "checkRow('#{article.id}')"}
|
||||
%td= check_box_tag "order[article_ids][]", article.id, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" }
|
||||
%td=h article.name
|
||||
%td=h truncate article.note, 25
|
||||
%td=h truncate article.origin, 15
|
||||
%td=h truncate article.manufacturer, 15
|
||||
%td=h truncate article.note, :length => 25
|
||||
%td=h truncate article.origin, :length => 15
|
||||
%td=h truncate article.manufacturer, :length => 15
|
||||
%td= "#{article.unit_quantity} x #{article.unit}"
|
||||
%td= "#{number_to_currency(article.net_price)} / #{number_to_currency(article.gross_price)}"
|
||||
%td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}"
|
||||
%tr
|
||||
%td{:colspan => "6"}
|
||||
= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
= pagination_links_remote @orders, :params => {:sort => params[:sort]}
|
||||
%table.list{:style => "width: 100%"}
|
||||
%thead
|
||||
%tr
|
||||
%th=_ "Name"
|
||||
%th[sort_td_class_helper "supplier"]
|
||||
= sort_link_helper _("Supplier"), "supplier"
|
||||
%th=_ "Start"
|
||||
%th[sort_td_class_helper "ends"]
|
||||
= sort_link_helper _("End"), "ends"
|
||||
%th=_ "Status"
|
||||
%th{:colspan => "2"}
|
||||
%tbody
|
||||
- @orders.each do |order|
|
||||
%tr{:class => cycle('even', 'odd', :name => 'orders') + ((!order.finished? and order.ends < Time.now) ? " active" : "")}
|
||||
%td= link_to order.name, :action => "show", :id => order
|
||||
%td=h order.supplier ? order.supplier.name : _("nonexistent")
|
||||
%td=h format_time(order.starts)
|
||||
%td=h format_time(order.ends)
|
||||
%td= order.status == _("expired") ? link_to( _("finish now") + (" !!"), {:action => 'finish', :id => order}, :confirm => _("Are you really sure to finish the order?"), :method => "post") : order.status
|
||||
%td= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => _('Edit')), :action => 'edit', :id => order) unless order.finished?
|
||||
%td= link_to image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => _("Destroy")), { :action => 'destroy', :id => order }, :confirm => _("Are you really sure you want to destroy the order?"), :method => "post"
|
||||
19
app/views/orders/_orders.html.haml
Normal file
19
app/views/orders/_orders.html.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
= pagination_links_remote @orders, :params => {:sort => params[:sort]}
|
||||
%table.list{:style => "width: 100%"}
|
||||
%thead
|
||||
%tr
|
||||
%th[sort_td_class_helper "supplier"]
|
||||
= sort_link_helper "Lieferant", "supplier"
|
||||
%th Start
|
||||
%th[sort_td_class_helper "ends"]
|
||||
= sort_link_helper "Ende", "ends"
|
||||
%th Status
|
||||
%th{:colspan => "2"}
|
||||
%tbody
|
||||
- @orders.each do |order|
|
||||
%tr{:class => cycle('even', 'odd', :name => 'orders')}
|
||||
%td=h order.supplier.name
|
||||
%td=h format_time(order.starts)
|
||||
%td=h format_time(order.ends)
|
||||
%td= order.state
|
||||
%td= link_to "Anzeigen", order
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><acronym title="Bestellnummer">Nr.</acronym></th>
|
||||
<th><acronym title="Gebinde insgesamt">Menge</acronym></th>
|
||||
<th>Artikel</th>
|
||||
<th><acronym title="Gebindegröße">GebGr</acronym></th>
|
||||
<th>Einheit</th>
|
||||
<th>Notiz</th>
|
||||
<th><acronym title="Bruttopreis inkl. MwSt, Aufschlag, Pfand">Preis</acronym></th>
|
||||
<th>MwSt</th>
|
||||
<th>Pfand</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for article in @order_articles %>
|
||||
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
|
||||
<td><%=h article.order_number %></td>
|
||||
<td><%=h article.units_to_order %></td>
|
||||
<td><%=h article.name %></td>
|
||||
<td><%=h article.unit_quantity %></td>
|
||||
<td><%=h article.unit %></td>
|
||||
<td><%=h article.note %></td>
|
||||
<td><%= number_to_currency(article.gross_price) %></td>
|
||||
<td><%=h article.tax %></td>
|
||||
<td><%=h article.deposit %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<div class="legend">
|
||||
<table style="margin-bottom:1em" class="legend">
|
||||
<tr>
|
||||
<th colspan="3">Legende</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:70%">Bestellgruppe</td>
|
||||
<td>Menge</td>
|
||||
<td>Gesamtpreis</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% for article in @order_articles %>
|
||||
<table style="margin-bottom:1em">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3"><%= article.name %> (<%= article.unit %> | <%= article.unit_quantity %> | <%= number_to_currency(article.gross_price) %>)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for result in article.group_order_article_results %>
|
||||
<tr class="<%= cycle('even', 'odd', :name => 'groups') %>">
|
||||
<td style="width:70%"><%=h result.group_order_result.group_name %></td>
|
||||
<td><%=h result.quantity %> (<%=h result.tolerance %>)</td>
|
||||
<td><%= number_to_currency(article.gross_price * result.quantity) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%- reset_cycle("groups") -%>
|
||||
<% end %>
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
<div class="legend">
|
||||
<table style="margin-bottom:1em" class="legend">
|
||||
<tr>
|
||||
<th style="width:40%">Name</th>
|
||||
<th><acronym title="zugeteilte Einheiten (davon aus Toleranzmenge)">Menge</acronym></th>
|
||||
<th><acronym title="Bruttopreis incl. MwSt, Aufschlag, Pfand">Preis</acronym></th>
|
||||
<th><acronym title="Gebindegröße">GebGr</acronym></th>
|
||||
<th>Einheit</th>
|
||||
<th>Gesamtpreis</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% for groupOrderResult in @order.group_order_results %>
|
||||
<table style="margin-bottom:1em">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="6"><%=h groupOrderResult.group_name %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
total = 0
|
||||
for result in groupOrderResult.group_order_article_results
|
||||
price = result.order_article_result.gross_price
|
||||
quantity = result.quantity
|
||||
subTotal = price * quantity
|
||||
total += subTotal
|
||||
%>
|
||||
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
|
||||
<td style="width:40%"><%=h result.order_article_result.name %></td>
|
||||
<td><%=h quantity %> (<%=h result.tolerance %>)</td>
|
||||
<td><%= number_to_currency(price) %></td>
|
||||
<td><%=h result.order_article_result.unit_quantity %></td>
|
||||
<td><%=h result.order_article_result.unit %></td>
|
||||
<td><%= number_to_currency(subTotal) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
|
||||
<th colspan="5">Summe</th>
|
||||
<th><%= number_to_currency(total) %></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<%- reset_cycle("articles") -%>
|
||||
<% end %>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
%table
|
||||
%tr
|
||||
%th=_ "Name"
|
||||
%th=_ "Unit quantity"
|
||||
%th=_ "Price"
|
||||
%th=_ "Units ordered"
|
||||
%th=_ "Result/Unit quantity"
|
||||
- totalNetto, totalBrutto, counter = 0, 0, 0
|
||||
- @order_articles.each do |category, order_articles|
|
||||
%tr{:style => "background-color:#EFEFEF"}
|
||||
%td{:style => "text-align:left; color: grey;"}=h category
|
||||
%td{:colspan => "9"}
|
||||
- order_articles.each do |order_article|
|
||||
- nettoPrice = order_article.article.net_price
|
||||
- bruttoPrice = order_article.article.gross_price
|
||||
- units = order_article.units_to_order
|
||||
- unitQuantity = order_article.article.unit_quantity
|
||||
- totalNetto += units * unitQuantity * nettoPrice
|
||||
- totalBrutto += units * unitQuantity * bruttoPrice
|
||||
- counter += 1 if units > 0
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color: #{units > 0 ? 'green' : 'red'}"}
|
||||
%td=h order_article.article.name
|
||||
%td= "#{unitQuantity} x #{order_article.article.unit}"
|
||||
%td= "#{number_to_currency(nettoPrice)} / #{number_to_currency(bruttoPrice)}"
|
||||
%td= "#{order_article.quantity} + #{order_article.tolerance}" if unitQuantity > 1
|
||||
%td= units
|
||||
%p
|
||||
=_ "Total value"
|
||||
=_ "(net/gross)"
|
||||
= "#{number_to_currency(totalNetto)} / #{number_to_currency(totalBrutto)}"
|
||||
%p
|
||||
=_ "Ordered articles:"
|
||||
= counter
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
# Get ActiveRecord objects
|
||||
order_articles = @order.order_article_results
|
||||
end_date = @order.ends.strftime('%d.%m.%Y')
|
||||
title = "#{@order.name} | beendet am #{end_date}"
|
||||
title = "#{@order.supplier.name} | beendet am #{end_date}"
|
||||
|
||||
# Define header and footer
|
||||
pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do
|
||||
|
|
@ -14,15 +12,16 @@ end
|
|||
|
||||
# Start rendering
|
||||
|
||||
for article in order_articles
|
||||
pdf.text "#{article.name} (#{article.unit} | #{article.unit_quantity.to_s} | #{number_to_currency(article.gross_price)})",
|
||||
for order_article in @order.order_articles.ordered
|
||||
pdf.text "#{order_article.article.name} (#{order_article.article.unit} |\
|
||||
#{order_article.price.unit_quantity.to_s} | #{number_to_currency(order_article.price.fc_price)})",
|
||||
:style => :bold, :size => 10
|
||||
pdf.move_down 5
|
||||
data = []
|
||||
for result in article.group_order_article_results
|
||||
data << [result.group_order_result.group_name,
|
||||
result.quantity,
|
||||
article.gross_price * result.quantity]
|
||||
for goa in order_article.group_order_articles
|
||||
data << [goa.group_order.ordergroup.name,
|
||||
goa.quantity,
|
||||
number_with_precision(order_article.price.fc_price * goa.quantity)]
|
||||
end
|
||||
|
||||
pdf.table data,
|
||||
|
|
@ -31,6 +30,7 @@ for article in order_articles
|
|||
:widths => { 0 => 200, 1 => 40, 2 => 40 },
|
||||
:border_style => :grid,
|
||||
:row_colors => ['ffffff','ececec'],
|
||||
:vertical_padding => 3
|
||||
:vertical_padding => 3,
|
||||
:align => { 2 => :right }
|
||||
pdf.move_down 10
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
- title _("Edit order")
|
||||
|
||||
- form_tag :action => 'update', :id => @order do
|
||||
= render :partial => 'form'
|
||||
- form_for @order do |form|
|
||||
= render :partial => 'form', :locals => { :form => form }
|
||||
= submit_tag _("Save")
|
||||
|
|
||||
= link_to _("Cancel"), :action => 'show', :id => @order
|
||||
|
|
@ -41,12 +41,13 @@ pdf.text "Ansprechpartner: " + @order.supplier.contact_person
|
|||
pdf.move_down 10
|
||||
|
||||
# Articles
|
||||
data = @order.order_article_results.collect do |a|
|
||||
[a.order_number, a.units_to_order, a.name,
|
||||
a.unit_quantity, a.unit, a.net_price]
|
||||
data = @order.order_articles.all(:include => :article).collect do |a|
|
||||
[a.article.order_number, a.units_to_order, a.article.name,
|
||||
a.price.unit_quantity, a.article.unit, a.price.price]
|
||||
end
|
||||
pdf.table data,
|
||||
:font_size => 8,
|
||||
:vertical_padding => 3,
|
||||
:border_style => :grid,
|
||||
:headers => ["BestellNr.", "Menge","Name", "Gebinde", "Einheit","Preis/Einheit"]
|
||||
:headers => ["BestellNr.", "Menge","Name", "Gebinde", "Einheit","Preis/Einheit"],
|
||||
:align => {0 => :left}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
end_date = @order.ends.strftime('%d.%m.%Y')
|
||||
title = "Gruppensortierung für #{@order.name}, beendet am #{end_date}"
|
||||
title = "Gruppensortierung für #{@order.supplier.name}, beendet am #{end_date}"
|
||||
|
||||
# Define header and footer
|
||||
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
||||
|
|
@ -12,28 +12,28 @@ end
|
|||
|
||||
|
||||
# Start rendering
|
||||
groups = @order.group_order_results.size
|
||||
groups = @order.group_orders.size
|
||||
counter = 1
|
||||
for group_result in @order.group_order_results
|
||||
pdf.text group_result.group_name, :style => :bold
|
||||
for group_order in @order.group_orders
|
||||
pdf.text group_order.ordergroup.name, :style => :bold
|
||||
pdf.move_down 5
|
||||
pdf.text "Gruppe #{counter.to_s}/#{groups.to_s}", :size => 8
|
||||
pdf.move_down 5
|
||||
|
||||
total = 0
|
||||
data = []
|
||||
group_result.group_order_article_results.each do |result|
|
||||
price = result.order_article_result.gross_price
|
||||
quantity = result.quantity
|
||||
group_order.group_order_articles.each do |goa|
|
||||
price = goa.order_article.price.fc_price
|
||||
quantity = goa.quantity
|
||||
sub_total = price * quantity
|
||||
total += sub_total
|
||||
data << [result.order_article_result.name,
|
||||
quantity, price,
|
||||
result.order_article_result.unit_quantity,
|
||||
result.order_article_result.unit,
|
||||
sub_total]
|
||||
data << [goa.order_article.article.name,
|
||||
quantity, number_with_precision(price),
|
||||
goa.order_article.price.unit_quantity,
|
||||
goa.order_article.article.unit,
|
||||
number_with_precision(sub_total)]
|
||||
end
|
||||
data << [ {:text => "Summe", :colspan => 5}, total]
|
||||
data << [ {:text => "Summe", :colspan => 5}, number_with_precision(total)]
|
||||
|
||||
pdf.table data,
|
||||
:font_size => 8,
|
||||
|
|
@ -41,7 +41,8 @@ for group_result in @order.group_order_results
|
|||
:vertical_padding => 3,
|
||||
:headers => ["Artikel", "Menge", "Preis", "GebGr", "Einheit", "Summe"],
|
||||
:widths => { 0 => 250 },
|
||||
:row_colors => ['ffffff','ececec']
|
||||
:row_colors => ['ffffff','ececec'],
|
||||
:align => { 0 => :right, 5 => :right }
|
||||
|
||||
counter += 1
|
||||
pdf.move_down 10
|
||||
|
|
|
|||
|
|
@ -3,39 +3,40 @@
|
|||
- if @current_user.role_orders?
|
||||
%p
|
||||
- form_tag do
|
||||
=_ "New Order"
|
||||
=_ "for"
|
||||
Neue Bestellung anlegen für
|
||||
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"}
|
||||
%option{:selected => 'selected'}=_ "Choose a supplier..."
|
||||
= options_for_select(Supplier.find(:all).collect {|s| [ s.name, url_for(:action => "new", :id => s)] })
|
||||
= options_for_select(Supplier.find(:all).collect {|s| [ s.name, url_for(:action => "new", :supplier_id => s)] })
|
||||
%br/
|
||||
.left_column{:style => "width:55em"}
|
||||
.box_title
|
||||
%h2=_ "Running orders"
|
||||
%h2 Laufende Bestellungen
|
||||
.column_content
|
||||
- if (@current_orders.length > 0)
|
||||
- unless @open_orders.empty?
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
%th=_ "Name"
|
||||
%th=_ "Supplier"
|
||||
%th=_ "End"
|
||||
%th Lieferant
|
||||
%th Ende
|
||||
%th Notiz
|
||||
%th{:colspan => "2"}
|
||||
%tbody
|
||||
- for order in @current_orders
|
||||
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
|
||||
%td= link_to order.name, :controller => 'orders', :action => 'show', :id => order
|
||||
- for order in @open_orders
|
||||
- active = (order.open? and order.ends < Time.now) ? " active" : ""
|
||||
%tr{:class => cycle('even', 'odd', :name => 'open_orders') + active}
|
||||
%td=h order.supplier.name
|
||||
%td=h format_time(order.ends) unless order.ends.nil?
|
||||
%td= link_to _("finish"), {:action => 'finish', :id => order}, :confirm => _("Are you really sure to finish the order?"), :method => "post"
|
||||
%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 image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => _("Edit")), :action => 'edit', :id => order
|
||||
= link_to image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => _("Destroy")), { :action => 'destroy', :id => order }, :confirm => _("Are you really sure you want to destroy the order?"), :method => "post"
|
||||
= 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
|
||||
- else
|
||||
=_ "There aren't current orders at the moment."
|
||||
=_ "There aren't open orders at the moment."
|
||||
|
||||
.left_column{:style => "width:75em"}
|
||||
.box_title
|
||||
%h2=_ "Expired/finished orders"
|
||||
%h2 Beendete Bestellungen
|
||||
.column_content#orders_table
|
||||
= render :partial => 'list'
|
||||
= render :partial => 'orders'
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
title = "#{@order.name}, beendet am #{@order.ends.strftime('%d.%m.%Y')}"
|
||||
title = "#{@order.supplier.name}, beendet am #{@order.ends.strftime('%d.%m.%Y')}"
|
||||
|
||||
# Define header and footer
|
||||
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
|
||||
|
|
@ -9,64 +9,64 @@ pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
|||
pdf.text "Seite #{pdf.page_count}", :size => 8
|
||||
end
|
||||
|
||||
max_articles_per_page = 17 # How many articles shoud written on a page
|
||||
articles = @order.order_article_results
|
||||
max_order_articles_per_page = 17 # How many order_articles shoud written on a page
|
||||
order_articles = @order.order_articles
|
||||
|
||||
pdf.text "Artikelübersicht", :style => :bold
|
||||
pdf.move_down 5
|
||||
pdf.text "Insgesamt #{articles.size} Artikel", :size => 8
|
||||
pdf.text "Insgesamt #{order_articles.size} Artikel", :size => 8
|
||||
pdf.move_down 10
|
||||
|
||||
articles_data = articles.collect do |a|
|
||||
[a.name, a.unit, a.unit_quantity, a.gross_price, a.units_to_order]
|
||||
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]
|
||||
end
|
||||
pdf.table articles_data,
|
||||
pdf.table order_articles_data,
|
||||
:font_size => 8,
|
||||
:border_style => :grid,
|
||||
:vertical_padding => 3,
|
||||
:headers => ["Artikel", "Einheit", "Gebinde", "Preis", "Menge"]
|
||||
:headers => ["Artikel", "Einheit", "Gebinde", "Preis", "Menge"],
|
||||
:align => { 3 => :right }
|
||||
|
||||
|
||||
page_number = 0
|
||||
total_num_articles = articles.size
|
||||
total_num_order_articles = order_articles.size
|
||||
|
||||
while (page_number * max_articles_per_page < total_num_articles) do # Start page generating
|
||||
while (page_number * max_order_articles_per_page < total_num_order_articles) do # Start page generating
|
||||
|
||||
page_number += 1
|
||||
pdf.start_new_page(:layout => :landscape)
|
||||
|
||||
# Collect articles for this page
|
||||
current_articles = articles.select do |a|
|
||||
articles.index(a) >= (page_number-1) * max_articles_per_page and
|
||||
articles.index(a) < page_number * max_articles_per_page
|
||||
# Collect order_articles for this page
|
||||
current_order_articles = order_articles.select do |a|
|
||||
order_articles.index(a) >= (page_number-1) * max_order_articles_per_page and
|
||||
order_articles.index(a) < page_number * max_order_articles_per_page
|
||||
end
|
||||
|
||||
# Make articles header
|
||||
# Make order_articles header
|
||||
header = [""]
|
||||
for header_article in current_articles
|
||||
name = header_article.name.split("-").join(" ").split(".").join(". ").split("/").join(" ")
|
||||
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, " ..")
|
||||
end
|
||||
|
||||
# Collect group results
|
||||
groups_data = []
|
||||
for group_order_result in @order.group_order_results
|
||||
for group_order in @order.group_orders.all(:include => :ordergroup)
|
||||
|
||||
group_result = [truncate(group_order_result.group_name, 20)]
|
||||
group_result = [truncate(group_order.ordergroup.name, 20)]
|
||||
|
||||
for article in current_articles
|
||||
# get the OrdergroupResult for this article
|
||||
result = GroupOrderArticleResult.find(:first,
|
||||
:conditions => ['order_article_result_id = ? AND group_order_result_id = ?', article.id, group_order_result.id])
|
||||
group_result << ((result.nil? || result == 0) ? "" : result.quantity.to_i)
|
||||
for order_article in current_order_articles
|
||||
# get the Ordergroup result for this order_article
|
||||
goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id }
|
||||
group_result << ((goa.nil? || goa == 0) ? "" : goa.quantity.to_i)
|
||||
end
|
||||
groups_data << group_result
|
||||
end
|
||||
|
||||
# Make table
|
||||
widths = { }
|
||||
(max_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
|
||||
widths = { } # Generate widths-hash for table layout
|
||||
(max_order_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
|
||||
pdf.table groups_data,
|
||||
:font_size => 8,
|
||||
:border_style => :grid,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
- title _("New order")
|
||||
|
||||
- form_tag :action => 'create' do
|
||||
= render :partial => 'form'
|
||||
- form_for @order do |form|
|
||||
= render :partial => 'form', :locals => { :form => form }
|
||||
= submit_tag _("Put the order online")
|
||||
|
|
||||
= link_to _("Cancel"), :action => 'index'
|
||||
= link_to "Abbrechen", orders_path
|
||||
|
|
@ -1,90 +1,88 @@
|
|||
- title _("Show order")
|
||||
#element_navigation
|
||||
= link_to_unless @order.previous == @order, _("Previous order"), :action => "show", :id => @order.previous
|
||||
= link_to_unless @order.previous == @order, _("Previous order"), @order.previous
|
||||
|
|
||||
= link_to _("Overview"), :controller => 'orders'
|
||||
= link_to _("Overview"), orders_path
|
||||
|
|
||||
= link_to_unless @order.next == @order, _("Next order"), :action => "show", :id => @order.next
|
||||
= link_to_unless @order.next == @order, _("Next order"), @order.next
|
||||
|
||||
// Order summary
|
||||
.left_column{:style => "width:55em"}
|
||||
.left_column{:style => "width:65em"}
|
||||
.box_title
|
||||
%h2=_ "Summary"
|
||||
%h2 Zusammenfassung
|
||||
.column_content
|
||||
- if !@order.booked? and @finished
|
||||
- if @order.finished? and !@order.closed?
|
||||
%p
|
||||
%b{:style => "color:red"}=_ "Order isn't balanced yet"
|
||||
%b{:style => "color:red"}=_ "Order isn't closed yet"
|
||||
%p
|
||||
= _("Name") + ":"
|
||||
%b=h @order.name
|
||||
|
|
||||
= _("Supplier") + ":"
|
||||
%b=h @order.supplier ? @order.supplier.name : _('nonexistent')
|
||||
Lieferant:
|
||||
%b=h @order.supplier.name
|
||||
- unless @order.note.empty?
|
||||
%p
|
||||
= _("Note") + ":"
|
||||
Notiz:
|
||||
=h @order.note
|
||||
%p
|
||||
= _("Begin") + ":"
|
||||
Beginn:
|
||||
%b=h format_time(@order.starts)
|
||||
|
|
||||
= _("End") + ":"
|
||||
Ende:
|
||||
%b=h format_time(@order.ends)
|
||||
%p
|
||||
= _("Groups ordered") + ":"
|
||||
%b= @group_orders.size
|
||||
- unless @finished
|
||||
= "[#{@group_orders.collect{|g| g.ordergroup.name}.join(', ')}]" unless @group_orders.empty?
|
||||
- else
|
||||
= "[#{@group_orders.collect{|g| g.group_name}.join(', ')}]" unless @group_orders.empty?
|
||||
Gruppenbestellungen:
|
||||
%b= @order.group_orders.count
|
||||
= "[#{@order.group_orders.find(:all, :include => :ordergroup).collect{|g| g.ordergroup.name}.join(', ')}]"
|
||||
|
||||
%p
|
||||
=_ "Total price"
|
||||
%b= number_to_currency(@order.sumPrice('gross'))
|
||||
- if @order.finished
|
||||
Bruttosummer aller Artikel
|
||||
%b= number_to_currency(@order.sum(:gross))
|
||||
- if @order.finished?
|
||||
|
|
||||
=_ "Ordered articles:"
|
||||
%b= @order_articles.size
|
||||
- unless @finished
|
||||
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Edit'), :action => 'edit', :id => @order)
|
||||
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Delete'), { :action => 'destroy', :id => @order }, :confirm => "Willst du wirklich die Bestellung '#{@order.name}' löschen?", :method => "post")
|
||||
= link_to('[beenden]', {:action => 'finish', :id => @order}, :confirm => "Willst du wirklich die Bestellung '#{@order.name}' beenden?", :method => "post")
|
||||
- else
|
||||
Bestellte Artikel:
|
||||
%b= @order.order_articles.ordered.count
|
||||
|
||||
- if @order.open?
|
||||
%p
|
||||
= link_to_remote _("All articles"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'normal'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
||||
= link_to icon(:edit), edit_order_path(@order)
|
||||
= link_to icon(:delete), @order, :confirm => "Willst du wirklich die Bestellung löschen?", :method => :delete
|
||||
= link_to '[beenden]', finish_order_path(@order), :method => :post
|
||||
|
||||
- unless @order.open?
|
||||
%p
|
||||
= update_articles_link(@order, "Artikelübersicht", :normal)
|
||||
|
|
||||
= link_to_remote _("Sort by groups"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'groups'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'groupsPdf', :id => @order, :format => :pdf }, { :title => _("Download file") }
|
||||
= update_articles_link(@order, "Sortiert nach Gruppen", :groups)
|
||||
= link_to_pdf(@order, 'groupsPdf')
|
||||
|
|
||||
= link_to_remote _("Sort by articles"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'articles'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'articlesPdf', :id => @order, :format => :pdf}, { :title => _("Download file") }
|
||||
= update_articles_link(@order, "Sortiert nach Artikeln", :articles)
|
||||
= link_to_pdf(@order, 'articlesPdf')
|
||||
|
|
||||
=_ "Matrix" + ":"
|
||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'matrixPdf', :id => @order, :format => :pdf }, { :title => _("Download file") }
|
||||
Matrix:
|
||||
= link_to_pdf(@order, 'matrixPdf')
|
||||
|
|
||||
=_ "FAX-template" + ":"
|
||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'faxPdf', :id => @order, :format => :pdf }, { :title => _("Download file") }
|
||||
Faxvorlage:
|
||||
= link_to_pdf(@order, 'faxPdf')
|
||||
= link_to image_tag("text_file.png", :size => "16x16", :border => "0", :alt => "Textdatei erstellen"), { :action => 'text_fax_template', :id => @order }, { :title => _("Download file") }
|
||||
|
|
||||
= link_to 'Kommentare', '#comments'
|
||||
|
||||
// Ordered articles
|
||||
.single_column{:style => "clear:both; width:70em;"}
|
||||
.box_title
|
||||
%h2=_ "Articles"
|
||||
.column_content#result
|
||||
- unless @finished
|
||||
= render :partial => "show_unfinished"
|
||||
- else
|
||||
= render :partial => "showResult"
|
||||
%h2 Artikel
|
||||
.column_content#articles
|
||||
= render :partial => 'articles', :locals => { :order => @order }
|
||||
|
||||
// comments
|
||||
- if @finished
|
||||
.single_column{:style => "width:70em;"}
|
||||
.box_title
|
||||
%h2=_ "Comments"
|
||||
.column_content#comments
|
||||
= render :partial => "/shared/comments"
|
||||
%p
|
||||
= link_to_remote "neuer Kommentar", :url => {:action => 'newComment', :id => @order}
|
||||
#newComment
|
||||
= link_to_top
|
||||
.single_column{:style => "width:70em;"}
|
||||
.box_title
|
||||
%h2 Kommentare
|
||||
.column_content#comments
|
||||
= render :partial => "/shared/comments", :locals => { :comments => @order.comments }
|
||||
%p
|
||||
- form_for :comment, :url => add_comment_order_path(@order) do |form|
|
||||
%p
|
||||
%b Neuen Kommentar hinzufügen:
|
||||
%br/
|
||||
= form.text_area :comment, :cols => 50, :rows => 6
|
||||
%br/
|
||||
= submit_tag "Kommentar hinzufügen"
|
||||
|
||||
= link_to_top
|
||||
Loading…
Add table
Add a link
Reference in a new issue