Merge branch 'order-display-improvements' of https://github.com/foodcoop-adam/foodsoft into foodcoop-adam-order-display-improvements

This commit is contained in:
Benjamin Meichsner 2013-09-18 17:16:04 +02:00
commit 7e659e2374
8 changed files with 66 additions and 34 deletions

View file

@ -12,20 +12,29 @@ class OrderByArticles < OrderPdf
def body def body
@order.order_articles.ordered.each do |order_article| @order.order_articles.ordered.each do |order_article|
text "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity.to_s} | #{number_with_precision(order_article.price.fc_price, precision: 2)})",
style: :bold, size: 10
rows = [] rows = []
rows << I18n.t('documents.order_by_articles.rows') dimrows = []
for goa in order_article.group_order_articles for goa in order_article.group_order_articles.ordered
rows << [goa.group_order.ordergroup.name, rows << [goa.group_order.ordergroup.name,
"#{goa.quantity} + #{goa.tolerance}",
goa.result, goa.result,
number_with_precision(order_article.price.fc_price * goa.result, precision: 2)] number_with_precision(order_article.price.fc_price * goa.result, precision: 2)]
dimrows << rows.length if goa.result == 0
end end
next if rows.length == 0
rows.unshift I18n.t('documents.order_by_articles.rows') # table header
table rows, column_widths: [200,40,40], cell_style: {size: 8, overflow: :shrink_to_fit} do |table| text "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity.to_s} | #{number_with_precision(order_article.price.fc_price, precision: 2)})",
table.columns(1..2).align = :right style: :bold, size: 10
table rows, cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
table.column(0).width = 200
table.columns(1..3).align = :right
table.column(2).font_style = :bold
table.cells.border_width = 1 table.cells.border_width = 1
table.cells.border_color = '666666' table.cells.border_color = '666666'
table.rows(0).border_bottom_width = 2
# dim rows which were ordered but not received
dimrows.each { |ri| table.row(ri).text_color = '999999' }
end end
move_down 10 move_down 10
end end

View file

@ -12,12 +12,10 @@ class OrderByGroups < OrderPdf
def body def body
# Start rendering # Start rendering
@order.group_orders.each do |group_order| @order.group_orders.ordered.each do |group_order|
text group_order.ordergroup.name, size: 9, style: :bold
total = 0 total = 0
rows = [] rows = []
rows << I18n.t('documents.order_by_groups.rows') # Table Header dimrows = []
group_order_articles = group_order.group_order_articles.ordered group_order_articles = group_order.group_order_articles.ordered
group_order_articles.each do |goa| group_order_articles.each do |goa|
@ -25,15 +23,20 @@ class OrderByGroups < OrderPdf
sub_total = price * goa.result sub_total = price * goa.result
total += sub_total total += sub_total
rows << [goa.order_article.article.name, rows << [goa.order_article.article.name,
"#{goa.quantity} + #{goa.tolerance}",
goa.result, goa.result,
number_with_precision(price, precision: 2), number_with_precision(price, precision: 2),
goa.order_article.price.unit_quantity, goa.order_article.price.unit_quantity,
goa.order_article.article.unit, goa.order_article.article.unit,
number_with_precision(sub_total, precision: 2)] number_with_precision(sub_total, precision: 2)]
dimrows << rows.length if goa.result == 0
end end
rows << [ I18n.t('documents.order_by_groups.sum'), nil, nil, nil, nil, number_with_precision(total, precision: 2)] next if rows.length == 0
rows << [ I18n.t('documents.order_by_groups.sum'), nil, nil, nil, nil, nil, number_with_precision(total, precision: 2)]
rows.unshift I18n.t('documents.order_by_groups.rows') # Table Header
table rows, column_widths: [250,50,50,50,50,50], cell_style: {size: 8, overflow: :shrink_to_fit} do |table| text group_order.ordergroup.name, size: 9, style: :bold
table rows, width: 500, cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
# borders # borders
table.cells.borders = [] table.cells.borders = []
table.row(0).borders = [:bottom] table.row(0).borders = [:bottom]
@ -41,8 +44,14 @@ class OrderByGroups < OrderPdf
table.cells.border_width = 1 table.cells.border_width = 1
table.cells.border_color = '666666' table.cells.border_color = '666666'
table.columns(1..3).align = :right table.column(0).width = 240
table.columns(5).align = :right table.column(2).font_style = :bold
table.columns(1..4).align = :right
table.column(6).align = :right
table.column(6).font_style = :bold
# dim rows which were ordered but not received
dimrows.each { |ri| table.row(ri).text_color = '999999' }
end end
move_down 15 move_down 15

View file

@ -17,6 +17,8 @@ class GroupOrder < ActiveRecord::Base
scope :in_open_orders, joins(:order).merge(Order.open) scope :in_open_orders, joins(:order).merge(Order.open)
scope :in_finished_orders, joins(:order).merge(Order.finished_not_closed) scope :in_finished_orders, joins(:order).merge(Order.finished_not_closed)
scope :ordered, :include => :ordergroup, :order => 'groups.name'
# Generate some data for the javascript methods in ordering view # Generate some data for the javascript methods in ordering view
def load_data def load_data
data = {} data = {}

View file

@ -14,7 +14,7 @@ class GroupOrderArticle < ActiveRecord::Base
validates_inclusion_of :tolerance, :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 validates_uniqueness_of :order_article_id, :scope => :group_order_id # just once an article per group order
scope :ordered, :conditions => 'result > 0' scope :ordered, :conditions => 'group_order_articles.result > 0 OR group_order_articles.quantity > 0 OR group_order_articles.tolerance > 0', :include => {:group_order => :ordergroup}, :order => 'groups.name'
localize_input_of :result localize_input_of :result

View file

@ -2,8 +2,10 @@
%thead %thead
%tr %tr
%th{:style => 'width:70%'}= t '.ordergroup' %th{:style => 'width:70%'}= t '.ordergroup'
%th= t '.ordered' %th
%th= t '.received' %acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered'
%th
%acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received'
%th= t '.price' %th= t '.price'
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price]) - for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
@ -13,8 +15,8 @@
= order_article.article.name = order_article.article.name
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})" = "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})"
%tbody %tbody
- for goa in order_article.group_order_articles - for goa in order_article.group_order_articles.ordered
%tr{:class => cycle('even', 'odd', :name => 'groups')} %tr{:class => [cycle('even', 'odd', :name => 'groups'), if goa.result == 0 then 'unavailable' end]}
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name %td{:style => "width:70%"}=h goa.group_order.ordergroup.name
%td= "#{goa.quantity} + #{goa.tolerance}" %td= "#{goa.quantity} + #{goa.tolerance}"
%td %td

View file

@ -3,7 +3,9 @@
%tr %tr
%th{:style => "width:40%"}= t '.name' %th{:style => "width:40%"}= t '.name'
%th %th
%acronym{:title => t('.units_desc')}= t '.units' %acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered'
%th
%acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received'
%th %th
%acronym{:title => t('.fc_price_desc')}= t '.fc_price' %acronym{:title => t('.fc_price_desc')}= t '.fc_price'
%th %th
@ -11,10 +13,10 @@
%th= t '.unit' %th= t '.unit'
%th= t '.price' %th= t '.price'
- for group_order in order.group_orders.all - for group_order in order.group_orders.ordered
%thead %thead
%tr %tr
%th{:colspan => "6"} %th{:colspan => "7"}
%h4= group_order.ordergroup.name %h4= group_order.ordergroup.name
%tbody %tbody
- total = 0 - total = 0
@ -22,17 +24,19 @@
- fc_price = goa.order_article.price.fc_price - fc_price = goa.order_article.price.fc_price
- subTotal = fc_price * goa.result - subTotal = fc_price * goa.result
- total += subTotal - total += subTotal
%tr{:class => cycle('even', 'odd', :name => 'articles')} %tr{:class => [cycle('even', 'odd', :name => 'articles'), if goa.result == 0 then 'unavailable' end]}
%td{:style => "width:40%"}=h goa.order_article.article.name %td{:style => "width:40%"}=h goa.order_article.article.name
%td= goa.result %td= "#{goa.quantity} + #{goa.tolerance}"
%td
%b= goa.result
%td= number_to_currency(fc_price) %td= number_to_currency(fc_price)
%td= goa.order_article.price.unit_quantity %td= goa.order_article.price.unit_quantity
%td= goa.order_article.article.unit %td= goa.order_article.article.unit
%td= number_to_currency(subTotal) %td= number_to_currency(subTotal)
%tr{:class => cycle('even', 'odd', :name => 'articles')} %tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "5"} Summe %th{:colspan => "6"} Summe
%th= number_to_currency(total) %th= number_to_currency(total)
%tr %tr
%th(colspan="6") %th(colspan="7")
- reset_cycle("articles") - reset_cycle("articles")

View file

@ -482,14 +482,16 @@ de:
filename: Bestellung %{name}-%{date} - Artikelsortierung filename: Bestellung %{name}-%{date} - Artikelsortierung
rows: rows:
- Bestellgruppe - Bestellgruppe
- Menge - Bestellt
- Bekommen
- Preis - Preis
title: ! 'Artikelsortierung der Bestellung: %{name}, beendet am %{date}' title: ! 'Artikelsortierung der Bestellung: %{name}, beendet am %{date}'
order_by_groups: order_by_groups:
filename: Bestellung %{name}-%{date} - Gruppensortierung filename: Bestellung %{name}-%{date} - Gruppensortierung
rows: rows:
- Artikel - Artikel
- Menge - Bestellt
- Bekommen
- Preis - Preis
- GebGr - GebGr
- Einheit - Einheit
@ -505,6 +507,7 @@ de:
- Gebinde - Gebinde
- Einheit - Einheit
- Preis/Einheit - Preis/Einheit
- Summe
total: Gesamtpreis total: Gesamtpreis
order_matrix: order_matrix:
filename: Bestellung %{name}-%{date} - Sortiermatrix filename: Bestellung %{name}-%{date} - Sortiermatrix

View file

@ -484,14 +484,16 @@ en:
filename: Order %{name}-%{date} - by articles filename: Order %{name}-%{date} - by articles
rows: rows:
- Order group - Order group
- Amount - Ordered
- Received
- Price - Price
title: ! 'Order sorted by articles: %{name}, closed at %{date}' title: ! 'Order sorted by articles: %{name}, closed at %{date}'
order_by_groups: order_by_groups:
filename: Order %{name}-%{date} - by group filename: Order %{name}-%{date} - by group
rows: rows:
- Article - Article
- Amount - Ordered
- Received
- Price - Price
- Unit quantity - Unit quantity
- Unit - Unit
@ -1457,11 +1459,14 @@ en:
title: Foodsoft login title: Foodsoft login
user: User user: User
shared: shared:
articles:
ordered: Ordered
ordered_desc: Number of articles as ordered by member (amount + tolerance)
received: Received
received_desc: Number of articles that (will be) received by member
articles_by_articles: articles_by_articles:
ordered: Ordered (Amount + Tolerance)
ordergroup: Ordergroup ordergroup: Ordergroup
price: Total price price: Total price
received: Received
articles_by_groups: articles_by_groups:
fc_price: FC-Price fc_price: FC-Price
fc_price_desc: Price including taxes, deposit and Foodcoop-charge fc_price_desc: Price including taxes, deposit and Foodcoop-charge
@ -1470,8 +1475,6 @@ en:
unit: Unit unit: Unit
unit_quantity: Lot quantity unit_quantity: Lot quantity
unit_quantity_desc: How many units per lot. unit_quantity_desc: How many units per lot.
units: Amount
units_desc: Assigned units
group: group:
access: Access to access: Access to
activated: activated activated: activated