Skip to content

Commit

Permalink
configurable company details
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Mar 25, 2024
1 parent af703af commit 6b75f2c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ task :receipt do
address: "123 Fake Street\nNew York City, NY 10012",
phone: "(555) 867-5309",
email: "[email protected]",
logo: File.expand_path("./examples/images/logo.png")
tax_id: "Tax ID: 123456789",
logo: File.expand_path("./examples/images/logo.png"),
printable_details: [:tax_id, nil, :address, :phone, :email]
},
details: [
["Receipt Number", "123"],
Expand Down
Binary file modified examples/receipt.pdf
Binary file not shown.
9 changes: 3 additions & 6 deletions lib/receipts/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,11 @@ def render_details(details, margin_top: 16)
table(details, cell_style: {borders: [], inline_format: true, padding: [0, 8, 2, 0]})
end

def render_billing_details(company:, recipient:, margin_top: 16)
def render_billing_details(company:, recipient:, margin_top: 16, printable_details: nil)
move_down margin_top

company_details = [
company[:address],
company[:phone],
company[:email]
].compact.join("\n")
printable_details ||= company.fetch(:printable_details, [:address, :phone, :email])
company_details = company.values_at(*printable_details).compact.join("\n")

line_items = [
[
Expand Down

0 comments on commit 6b75f2c

Please sign in to comment.