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
@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 << I18n.t('documents.order_by_articles.rows')
for goa in order_article.group_order_articles
dimrows = []
for goa in order_article.group_order_articles.ordered
rows << [goa.group_order.ordergroup.name,
"#{goa.quantity} + #{goa.tolerance}",
goa.result,
number_with_precision(order_article.price.fc_price * goa.result, precision: 2)]
dimrows << rows.length if goa.result == 0
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|
table.columns(1..2).align = :right
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
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_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
move_down 10
end

View file

@ -12,12 +12,10 @@ class OrderByGroups < OrderPdf
def body
# Start rendering
@order.group_orders.each do |group_order|
text group_order.ordergroup.name, size: 9, style: :bold
@order.group_orders.ordered.each do |group_order|
total = 0
rows = []
rows << I18n.t('documents.order_by_groups.rows') # Table Header
dimrows = []
group_order_articles = group_order.group_order_articles.ordered
group_order_articles.each do |goa|
@ -25,15 +23,20 @@ class OrderByGroups < OrderPdf
sub_total = price * goa.result
total += sub_total
rows << [goa.order_article.article.name,
"#{goa.quantity} + #{goa.tolerance}",
goa.result,
number_with_precision(price, precision: 2),
goa.order_article.price.unit_quantity,
goa.order_article.article.unit,
number_with_precision(sub_total, precision: 2)]
dimrows << rows.length if goa.result == 0
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
table.cells.borders = []
table.row(0).borders = [:bottom]
@ -41,8 +44,14 @@ class OrderByGroups < OrderPdf
table.cells.border_width = 1
table.cells.border_color = '666666'
table.columns(1..3).align = :right
table.columns(5).align = :right
table.column(0).width = 240
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
move_down 15

View file

@ -17,6 +17,8 @@ class GroupOrder < ActiveRecord::Base
scope :in_open_orders, joins(:order).merge(Order.open)
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
def load_data
data = {}

View file

@ -14,7 +14,7 @@ class GroupOrderArticle < ActiveRecord::Base
validates_inclusion_of :tolerance, :in => 0..99
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

View file

@ -2,8 +2,10 @@
%thead
%tr
%th{:style => 'width:70%'}= t '.ordergroup'
%th= t '.ordered'
%th= t '.received'
%th
%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'
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
@ -13,8 +15,8 @@
= order_article.article.name
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})"
%tbody
- for goa in order_article.group_order_articles
%tr{:class => cycle('even', 'odd', :name => 'groups')}
- for goa in order_article.group_order_articles.ordered
%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= "#{goa.quantity} + #{goa.tolerance}"
%td

View file

@ -3,7 +3,9 @@
%tr
%th{:style => "width:40%"}= t '.name'
%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
%acronym{:title => t('.fc_price_desc')}= t '.fc_price'
%th
@ -11,10 +13,10 @@
%th= t '.unit'
%th= t '.price'
- for group_order in order.group_orders.all
- for group_order in order.group_orders.ordered
%thead
%tr
%th{:colspan => "6"}
%th{:colspan => "7"}
%h4= group_order.ordergroup.name
%tbody
- total = 0
@ -22,17 +24,19 @@
- fc_price = goa.order_article.price.fc_price
- subTotal = fc_price * goa.result
- 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= goa.result
%td= "#{goa.quantity} + #{goa.tolerance}"
%td
%b= goa.result
%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{:colspan => "6"} Summe
%th= number_to_currency(total)
%tr
%th(colspan="6")
%th(colspan="7")
- reset_cycle("articles")

View file

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

View file

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