-
Notifications
You must be signed in to change notification settings - Fork 146
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
Enhanced matrix pdf #489
Changes from all commits
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 |
---|---|---|
@@ -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 = 21 # 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,7 +13,7 @@ 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 | ||
|
@@ -26,13 +26,15 @@ def body | |
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 | ||
|
||
table order_articles_data, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table| | ||
table.cells.border_width = 1 | ||
table.cells.border_color = '666666' | ||
table.column(3).text_color = 'aeaeae' | ||
end | ||
|
||
page_number = 0 | ||
|
@@ -51,12 +53,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})" | ||
|
||
end | ||
|
||
# Collect group results | ||
groups_data = [header] | ||
|
||
|
@@ -73,14 +77,19 @@ def body | |
end | ||
|
||
# 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| | ||
column_widths = [55] | ||
(MAX_ARTICLES_PER_PAGE + 1).times { |i| column_widths << 32 unless i == 0 } | ||
table groups_data, column_widths: column_widths, cell_style: {size: fontsize(5), overflow: :shrink_to_fit } do |table| | ||
|
||
table.rows(0).padding = 2 | ||
table.rows(0).height = 35 | ||
table.rows(0).overflow = :truncate | ||
table.rows(0).min_font_size = 8 | ||
table.cells.border_width = 1 | ||
table.cells.border_color = '666666' | ||
table.row_colors = ['ffffff','ececec'] | ||
end | ||
|
||
end | ||
end | ||
|
||
|
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.
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 comment
The 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 comment
The 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).
Or do you need a newer prawn? If you do, please rebase on current
master
.