-
Notifications
You must be signed in to change notification settings - Fork 147
Enhanced matrix pdf #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced matrix pdf #489
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,13 @@ GIT | |
specs: | ||
localize_input (0.1.0) | ||
|
||
GIT | ||
remote: https://github.com/straydogstudio/prawn-table.git | ||
revision: 759a27b6fef2e682c035fc83f2182e53c3270279 | ||
ref: 759a27b6 | ||
specs: | ||
prawn-table (0.2.1) | ||
|
||
GIT | ||
remote: https://github.com/technoweenie/acts_as_versioned.git | ||
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b | ||
|
@@ -217,7 +224,7 @@ GEM | |
libv8 (3.16.14.17) | ||
loofah (2.0.3) | ||
nokogiri (>= 1.5.9) | ||
mail (2.6.6) | ||
mail (2.6.4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these version changes to a lower version really necessary? i don't think so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No they are not necessary. The Gemfile.lock changed automatically and I was not sure if I should upload it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you would like to remove these changes, that would clean it up a bit (and avoid a conflict). |
||
mime-types (>= 1.16, < 4) | ||
mailcatcher (0.6.4) | ||
activesupport (~> 4.0) | ||
|
@@ -237,7 +244,7 @@ GEM | |
mime-types-data (~> 3.2015) | ||
mime-types-data (3.2016.0521) | ||
mini-smtp-server (0.0.2) | ||
mini_portile2 (2.2.0) | ||
mini_portile2 (2.1.0) | ||
minitest (5.10.1) | ||
mono_logger (1.1.0) | ||
multi_json (1.12.1) | ||
|
@@ -246,17 +253,15 @@ GEM | |
net-ssh (>= 2.6.5) | ||
net-ssh (3.1.1) | ||
netrc (0.11.0) | ||
nokogiri (1.8.0) | ||
mini_portile2 (~> 2.2.0) | ||
pdf-core (0.6.1) | ||
nokogiri (1.7.1) | ||
mini_portile2 (~> 2.1.0) | ||
pdf-core (0.7.0) | ||
polyamorous (1.3.1) | ||
activerecord (>= 3.0) | ||
polyglot (0.3.5) | ||
prawn (2.1.0) | ||
pdf-core (~> 0.6.1) | ||
ttfunk (~> 1.4.0) | ||
prawn-table (0.2.2) | ||
prawn (>= 1.3.0, < 3.0.0) | ||
prawn (2.2.2) | ||
pdf-core (~> 0.7.0) | ||
ttfunk (~> 1.5) | ||
protected_attributes (1.1.0) | ||
activemodel (>= 4.0.1, < 5.0) | ||
pry (0.10.3) | ||
|
@@ -437,7 +442,7 @@ GEM | |
thread_safe (0.3.6) | ||
tilt (2.0.7) | ||
tins (1.13.2) | ||
ttfunk (1.4.0) | ||
ttfunk (1.5.1) | ||
twitter-bootstrap-rails (2.2.8) | ||
actionpack (>= 3.1) | ||
execjs | ||
|
@@ -512,7 +517,7 @@ DEPENDENCIES | |
meta_request | ||
mysql2 | ||
prawn | ||
prawn-table | ||
prawn-table! | ||
protected_attributes (= 1.1.0) | ||
pry-rescue | ||
pry-stack_explorer | ||
|
@@ -549,4 +554,4 @@ DEPENDENCIES | |
whenever | ||
|
||
BUNDLED WITH | ||
1.11.2 | ||
1.15.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# encoding: utf-8 | ||
class OrderMatrix < OrderPdf | ||
|
||
MAX_ARTICLES_PER_PAGE = 16 # How many order_articles shoud written on a page | ||
MAX_ARTICLES_PER_PAGE = 22 # How many order_articles shoud written on a page | ||
|
||
def filename | ||
I18n.t('documents.order_matrix.filename', :name => @order.name, :date => @order.ends.to_date) + '.pdf' | ||
|
@@ -13,22 +13,26 @@ def title | |
end | ||
|
||
def body | ||
order_articles = @order.order_articles.ordered | ||
order_articles = @order.order_articles.sort_by{|a| a.article.name.downcase} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do this sorting via ActiveRecord instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did the sorting still with sort_by, because I was afraid, that I make unwanted changes in the database with ActiveRecord sorting. Feel free to change this if this is a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorting belongs in the database, this is a memory hog and doesn't scale for large orders. Please reconsider the Sorry for the condensed answer, if you need more explanation, please don't hesitate to ask. We'll do our best to help! |
||
|
||
text I18n.t('documents.order_matrix.heading'), style: :bold | ||
move_down 5 | ||
text I18n.t('documents.order_matrix.total', :count => order_articles.size), size: fontsize(8) | ||
move_down 10 | ||
|
||
order_articles_data = [I18n.t('documents.order_matrix.rows')] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please avoid unnecessary whitespace changes |
||
|
||
order_articles.each do |a| | ||
order_articles_data << [a.article.name, | ||
a.article.unit, | ||
a.price.unit_quantity, | ||
number_to_currency(a.price.price * a.price.unit_quantity), | ||
number_with_precision(article_price(a), precision: 2), | ||
a.units] | ||
end | ||
|
||
#order_articles_data.sort_by!{|a| a[0].downcase} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please avoid useless comments |
||
|
||
table order_articles_data, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table| | ||
table.cells.border_width = 1 | ||
|
@@ -51,12 +55,14 @@ def body | |
|
||
# Make order_articles header | ||
header = [""] | ||
|
||
for header_article in current_order_articles | ||
name = header_article.article.name.gsub(/[-\/]/, " ").gsub(".", ". ") | ||
name = name.split.collect { |w| w.truncate(8) }.join(" ") | ||
header << name.truncate(30) | ||
name = name.split.collect { |w| w.truncate(20) }.join(" ") | ||
header << name.truncate(35)+' - ('+header_article.article.unit+')' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
end | ||
|
||
# Collect group results | ||
groups_data = [header] | ||
|
||
|
@@ -74,13 +80,22 @@ def body | |
|
||
# Make table | ||
column_widths = [85] | ||
(MAX_ARTICLES_PER_PAGE + 1).times { |i| column_widths << 41 unless i == 0 } | ||
table groups_data, column_widths: column_widths, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table| | ||
table.cells.border_width = 1 | ||
table.cells.border_color = '666666' | ||
table.row_colors = ['ffffff','ececec'] | ||
(MAX_ARTICLES_PER_PAGE + 1).times { |i| column_widths << 30 unless i == 0 } | ||
table groups_data, column_widths: column_widths, cell_style: {size: fontsize(8), overflow: :shrink_to_fit } do |table| | ||
|
||
table.rows(0).rotate = 90 | ||
table.rows(0).padding = 2 | ||
table.rows(0).height = 90 | ||
table.rows(0).overflow = :truncate | ||
table.rows(0).align = :left | ||
table.rows(0).min_font_size = 6 | ||
# table.rows(0).valign = :bottom | ||
|
||
table.cells.border_width = 1 | ||
table.cells.border_color = '666666' | ||
table.row_colors = ['ffffff','ececec'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you removed the indentation for this block |
||
end | ||
|
||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -734,6 +734,7 @@ en: | |
- Article | ||
- Unit | ||
- Unit quantity | ||
- Netto price | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you compare it to the other translations "Nettopreis" in german is usually "Price" in english please also update the other languages. the translation should be easy to find |
||
- FC-Price | ||
- Amount | ||
title: 'Order sorting matrix: %{name}, closed at %{date}' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this revision is from 2014. the latest upstream version is from 2016. do you see any chance that the commit from straydogstudio gets accepted in upstream? I do not like the idea of using such an outdated version. If the merge in upstream is not possible: Could you rebase the commit from straydogstudio to upstream master, publish them in a new repository and use that in the Gemfile?