Last active
July 10, 2016 10:05
-
-
Save hidakatsuya/f3828deb31c0109b843d1604d9ed2237 to your computer and use it in GitHub Desktop.
Code for Concept Thinreports v1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thinreports' | |
report = Thinreports::Report.new | |
user = User.find(params[:id]) | |
report.layout 'estimate_cover.tlf' | |
report.start_new_page do |page| | |
page.item(:subtitle).value = "#{@user.name} 様" | |
end | |
report.layout 'estimate.tlf' | |
estimates.each do |estimate| | |
# 毎ページ表示: Yes | |
# id: default | |
report.header do |header| | |
header.item(:no).value = estimate.no | |
end | |
report.header(:estimate_header) do |header| | |
header.item(:user_name).value = user.name | |
header.item(:total_price).value = estimate.total_price | |
header.item(:logo).src = user.logo.path | |
header.item(:stamp).src = estimate.stamp.path | |
end | |
report.footer(:sub_footer) do |footer| | |
footer.item(:no).value = estimate.no | |
end | |
estimate.items.each.with_index(1) do |item, no| | |
report.details.add do |detail| | |
detail.item(:no).value = no | |
detail.item(:name).value = item.name | |
detail.item(:quantity).value = item.quantity | |
detail.item(:price).value = item.price | |
end | |
end | |
report.details.add(:total) do |detail| | |
detail.item(:price).value = detail.total_price | |
detail.item(:tax).value = detail.tax | |
detail.item(:total_price).value = detail.total_price_with_tax | |
end | |
report.break | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment