class Receipts::Statement
Attributes
attributes[R]
bill_to[R]
company[R]
custom_font[R]
end_date[R]
id[R]
issue_date[R]
line_items[R]
logo[R]
message[R]
product[R]
start_date[R]
subheading[R]
Public Class Methods
new(attributes)
click to toggle source
Calls superclass method
# File lib/receipts/statement.rb, line 5 def initialize(attributes) @attributes = attributes @id = attributes.fetch(:id) @company = attributes.fetch(:company) @line_items = attributes.fetch(:line_items) @custom_font = attributes.fetch(:font, {}) @message = attributes.fetch(:message) { default_message } @subheading = attributes.fetch(:subheading) { default_subheading } @bill_to = Array(attributes.fetch(:bill_to)).join("\n") @issue_date = attributes.fetch(:issue_date) @start_date = attributes.fetch(:start_date) @end_date = attributes.fetch(:end_date) super(page_size: "LETTER") setup_fonts if custom_font.any? generate end
Private Instance Methods
charge_details()
click to toggle source
# File lib/receipts/statement.rb, line 67 def charge_details move_down 30 borders = line_items.length - 2 table(line_items, width: bounds.width, cell_style: {border_color: "cccccc", inline_format: true}) do cells.padding = 10 cells.borders = [] row(0..borders).borders = [:bottom] end end
default_message()
click to toggle source
# File lib/receipts/statement.rb, line 26 def default_message "For questions, contact us anytime at <color rgb='326d92'><link href='mailto:#{company.fetch(:email)}?subject=Charge ##{id}'><b>#{company.fetch(:email)}</b></link></color>." end
default_subheading()
click to toggle source
# File lib/receipts/statement.rb, line 30 def default_subheading "STATEMENT #%{id}" end
description()
click to toggle source
# File lib/receipts/statement.rb, line 48 def description move_down 8 text label(subheading % {id: id}), inline_format: true, leading: 4 end
generate()
click to toggle source
# File lib/receipts/statement.rb, line 34 def generate header description statement_details charge_details footer end
header(height: 24)
click to toggle source
# File lib/receipts/statement.rb, line 42 def header(height: 24) logo = company[:logo] return if logo.nil? image load_image(logo), height: height end
statement_details()
click to toggle source
# File lib/receipts/statement.rb, line 53 def statement_details move_down 10 font_size 9 line_items = [ [{content: "#{label("BILL TO")}\n#{bill_to}", rowspan: 3, padding: [0, 12, 0, 0]}, "#{label("INVOICE DATE")}\n#{issue_date}"], ["#{label("STATEMENT DATE")}\n#{issue_date}"], ["#{label("STATEMENT PERIOD")}\n#{start_date} - #{end_date}"] ] table(line_items, width: bounds.width, cell_style: {inline_format: true, overflow: :shrink_to_fit}) do cells.borders = [] end end