Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Enhanced matrix pdf #489

wants to merge 2 commits into from

Conversation

FcFlodo
Copy link

@FcFlodo FcFlodo commented Aug 17, 2017

  • sort articles by description for easier localization
  • rotate header for enhanced readability and longer descriptions
  • add net price for easier check with supplier invoice
  • add unit to header for quantity-clarification

A bug in the prawn gem forced me to update the gem
prawnpdf/prawn#409
prawnpdf/prawn-table#32

I have uploaded the Gemfile.lock which has changed, but I am not sure if this has to be changed?

Copy link
Member

@paroga paroga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution! I'll check the changes on my local machine later, but I've added already some comments, if you want to address them in the meantime.

@@ -734,6 +734,7 @@ en:
- Article
- Unit
- Unit quantity
- Netto price
Copy link
Member

Choose a reason for hiding this comment

The 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

@@ -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)
Copy link
Member

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

Copy link
Author

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.

Copy link
Member

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.


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')]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid unnecessary whitespace changes

number_with_precision(article_price(a), precision: 2),
a.units]
end

#order_articles_data.sort_by!{|a| a[0].downcase}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid useless comments

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+')'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header << "#{name.truncate(35)} - (#{header_article.article.unit})" might be easier to read

@@ -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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this sorting via ActiveRecord instead?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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 ordered scope if you think a different sort order is useful everywhere; if it only makes sense here, don't use the .ordered scope but use active-record sorting. If you'd like case-insensitive sorting, indexes may also be needed.

Sorry for the condensed answer, if you need more explanation, please don't hesitate to ask. We'll do our best to help!


table.cells.border_width = 1
table.cells.border_color = '666666'
table.row_colors = ['ffffff','ececec']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you removed the indentation for this block

Gemfile Outdated
@@ -22,7 +22,7 @@ gem 'rails-i18n'

gem 'mysql2'
gem 'prawn'
gem 'prawn-table'
gem 'prawn-table', :git => 'https://github.com/straydogstudio/prawn-table.git', ref: '759a27b6'
Copy link
Member

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?

@wvengen
Copy link
Member

wvengen commented Sep 30, 2017

Hi @FcFlodo, thanks for your contribution! Do you see any opportunity to finish it?

@FcFlodo
Copy link
Author

FcFlodo commented Oct 8, 2017

Hi @wvengen and @paroga !
Sorry for the long delay, I couldn´t spare much time in the past few weeks for this project.

I tried to get my code running with the new prawn-version, but until now I haven´t found a way to solve this.

@wvengen
Copy link
Member

wvengen commented Oct 9, 2017

Hi @FcFlodo, no problem. What about removing the header rotation for now, so that the other improvements can be included? If then an solution is found for the issue, the rotated headers (which I can imagine would be much much nicer) can be included.

I also suggest to revive the discussion upstream. If there are others interested in the feature, it may get some traction. If not, then you could try to fix it upstream and get it included. Putting it into a separate repository would not have my preference, because that basically means that we'd need to maintain it.

@FcFlodo
Copy link
Author

FcFlodo commented Oct 10, 2017

Finished my contribution without the rotated headers. I will ask if the changes made by straydogstudio in the prawn-table gem could be implemented.

Copy link
Member

@wvengen wvengen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! I still have some remarks.
To get an idea of how the changes would look, would you be able to show the differences visually, e.g. as screenshot(s) or an upload of the new pdf? That would help reviewing. Thanks!

@@ -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)
Copy link
Member

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.

@@ -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}
Copy link
Member

Choose a reason for hiding this comment

The 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 ordered scope if you think a different sort order is useful everywhere; if it only makes sense here, don't use the .ordered scope but use active-record sorting. If you'd like case-insensitive sorting, indexes may also be needed.

Sorry for the condensed answer, if you need more explanation, please don't hesitate to ask. We'll do our best to help!

@paroga
Copy link
Member

paroga commented Nov 15, 2017

@FcFlodo: I did a bigger rewrite of the OrderPdf classes in #532. Does it solve your issues too?

@carermey
Copy link

hello.

we are using the foodsoft for our big wholesaler ordering! this extension:

sort articles by description for easier localization
rotate header for enhanced readability and longer descriptions
add net price for easier check with supplier invoice
add unit to header for quantity-clarification

would be absolute great !

If the articles would be ordert first by categorie and afterwards by produktname in alphabetical order would make the overview also much better !

Thank you a lot for your work on it !

Carermey

@yksflip
Copy link
Member

yksflip commented Jul 3, 2023

Hey,
this look's stale to me, is this still relevant?
If so, please feel free to reopen this!
Thanks again for your contribution!

@yksflip yksflip closed this Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants