Created
May 26, 2009 23:21
-
-
Save railsdog/118354 to your computer and use it in GitHub Desktop.
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 'prawn/layout' | |
require 'prawn/format' | |
bill_address = @order.bill_address | |
ship_address = @order.ship_address | |
image "#{RAILS_ROOT}/public/images/site/client_logo.jpg", :at => [0,720], :scale => 0.65 | |
image "#{RAILS_ROOT}/public/images/site/invoice_label.png", :at => [300,720], :scale => 0.65 | |
move_down 75 | |
font "Helvetica", :style => :bold, :size => 14 | |
text "Order Number: #{@order.number}" | |
font "Helvetica", :size => 8 | |
text @order.created_at.to_s(:long) | |
# Address Stuff | |
bounding_box [0,600], :width => 540 do | |
move_down 2 | |
data = [["<b>Bill Address</b>", "<b>Ship Address</b>"]] | |
table data, | |
:position => :center, | |
:border_width => 0.5, | |
:vertical_padding => 2, | |
:horizontal_padding => 6, | |
:font_size => 9, | |
:border_style => :underline_header, | |
:column_widths => { 0 => 270, 1 => 270 } | |
horizontal_rule | |
bounding_box [0,0], :width => 540 do | |
move_down 2 | |
data2 = [["#{bill_address.firstname} #{bill_address.lastname}", "#{ship_address.firstname} #{ship_address.lastname}"], | |
[bill_address.address1, ship_address.address1]] | |
data2 << [bill_address.address2, ship_address.address2] unless bill_address.address2.blank? and ship_address.address2.blank? | |
data2 << ["#{@order.bill_address.city}, #{(@order.bill_address.state ? @order.bill_address.state.abbr : "")} #{@order.bill_address.zipcode}", | |
"#{@order.ship_address.city}, #{(@order.ship_address.state ? @order.ship_address.state.abbr : "")} #{@order.ship_address.zipcode}"] | |
data2 << [bill_address.country.name, ship_address.country.name] | |
data2 << [bill_address.phone, ship_address.phone] | |
table data2, | |
:position => :center, | |
:border_width => 0.0, | |
:vertical_padding => 0, | |
:horizontal_padding => 6, | |
:font_size => 9, | |
:column_widths => { 0 => 270, 1 => 270 } | |
end | |
move_down 2 | |
stroke do | |
line_width 0.5 | |
line bounds.top_left, bounds.top_right | |
line bounds.top_left, bounds.bottom_left | |
line bounds.top_right, bounds.bottom_right | |
line bounds.bottom_left, bounds.bottom_right | |
end | |
end | |
move_down 30 | |
# Line Items | |
bounding_box [0,cursor], :width => 540, :height => 400 do | |
move_down 2 | |
data = [["<b>House SKU</b>", "<b>Item Description</b>", "<b>Price</b>", "<b>Qty</b>", "<b>Total</b>"]] | |
table data, | |
:position => :center, | |
:border_width => 0, | |
:vertical_padding => 2, | |
:horizontal_padding => 6, | |
:font_size => 9, | |
:column_widths => { 0 => 75, 1 => 290, 2 => 75, 3 => 50, 4 => 50 } | |
horizontal_rule | |
move_down 10 | |
bounding_box [0,cursor], :width => 540 do | |
move_down 2 | |
data2 = [] | |
@order.line_items.each do |item| | |
data2 << [item.variant.product.house_sku, | |
item.product_name, | |
number_to_currency(item.price), | |
item.quantity, | |
number_to_currency(item.price * item.quantity)] | |
end | |
table data2, | |
:position => :center, | |
:border_width => 0.0, | |
:vertical_padding => 5, | |
:horizontal_padding => 6, | |
:font_size => 9, | |
:column_widths => { 0 => 75, 1 => 290, 2 => 75, 3 => 50, 4 => 50 } | |
end | |
font "Helvetica", :size => 9 | |
bounding_box [bounds.right - 225, bounds.bottom + 50], :width => 150 do | |
text "<b>Subtotal:</b>", :align=>:right | |
text "<b>Tax:</b>", :align=>:right | |
text "<b>Shipping</b> (#{@order.shipments.first.shipping_method.name}) <b>:</b>", :align=>:right | |
text "<b>Order Total:</b>", :align=>:right | |
end | |
bounding_box [bounds.right - 60, bounds.bottom + 50], :width => 70 do | |
text number_to_currency(@order.item_total) , :align=>:left | |
text number_to_currency(@order.tax_amount), :align=>:left | |
text number_to_currency(@order.ship_amount), :align=>:left | |
text number_to_currency(@order.total), :align=>:left | |
end | |
move_down 2 | |
stroke do | |
line_width 0.5 | |
line bounds.top_left, bounds.top_right | |
line bounds.top_left, bounds.bottom_left | |
line bounds.top_right, bounds.bottom_right | |
line bounds.bottom_left, bounds.bottom_right | |
end | |
end | |
footer [margin_box.left, margin_box.bottom + 75] do | |
font "Helvetica", :size => 8 | |
text "Client is not responsible for typographical errors or omissions." | |
text "Note that client never sells, rents, or shares your email address." | |
text "Copyright 2009, Client" | |
text "All items come with a 7 day return policy upon receipt of merchandise" | |
text "All returns are subject to a minimum restocking fee of 5% packages 15%." | |
text "Shipping is not refundable." | |
text "Special orders are non-refundable" | |
text "In order to return a product prior authorization with a RMA number is mandatory" | |
text "All returned items must be in original un-opened packaging with seal intact." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment