receipts 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1606d916a395c1e22c80566221f2db3ad1ed035ec3d426d2500b4beffe1f0f8d
4
- data.tar.gz: a5d29e51729f90104dceb3ff6faf6a4b3a27f7a404789664895821e62b416752
3
+ metadata.gz: a074319e14c0aaf9a5e4776d854c90810273092e58d7672046f7a6ef4d01a6d5
4
+ data.tar.gz: e4d3bf9feb0a135357a6666ca46a8c9298d0d623223101c0649c7c9b2b45248f
5
5
  SHA512:
6
- metadata.gz: 8a372a3605d3535d4f5fca1bac41a22470541b8717ed51fb8383e0250df0c1a97b7ef104fc388d8e3439572854cb82b925441cb8196336ef6996e411e8b68b2c
7
- data.tar.gz: 971fe78bd36d9858a45afcdf4035575c51f373f33b1defb9637cde49f38501d322874132e22f06209ed1a05ed6e56a5fe7a1ea56bbbafd49f46977c4214e19b5
6
+ metadata.gz: e22ececba2faf58b41ed4b677bbf351b6dadb51eb0c2e54b9930949eceb7bbc68d29aba7a642e44c47d76d9486669d324cd642befb920576398a13d392e8e303
7
+ data.tar.gz: 179cbdbf4fbaa3de6de2d1e76a0c9087bc91b9fa36c639f3d5824f112a32a1199662fd0ae87efa3d18f69be6744d3762e495e85cb111e67106a7bde81b90c7e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ### Unreleased
2
2
 
3
+ * Add `display: []` for configuring company details that are rendered
4
+
5
+ ```ruby
6
+ r = Receipts::Receipt.new(
7
+ company: {
8
+ name: "Example, LLC",
9
+ address: "123 Fake Street\nNew York City, NY 10012",
10
+ phone: "(555) 867-5309",
11
+ email: "support@example.com",
12
+ iban: "123456789",
13
+ logo: File.expand_path("./examples/images/logo.png"),
14
+ display: [:address, :phone, :email, :iban]
15
+ },
16
+ # ...
17
+ )
18
+ ```
19
+
3
20
  ### 2.3.0
4
21
 
5
22
  * Add `column_widths:` option to specify line item column widths #35
data/README.md CHANGED
@@ -107,6 +107,8 @@ You can pass the following options to generate a PDF:
107
107
  logo: "https://www.ruby-lang.org/images/header-ruby-logo@2x.png" # Downloaded with OpenURI
108
108
  ```
109
109
 
110
+ * `display: []` - Customize the company details rendered. By default, renders `[:address, :phone, :email]` under the company name. Items in the array should be Symbols matching keys in the `company` hash to be displayed.
111
+
110
112
  * `details` - Array of details about the Receipt, Invoice, Statement. Typically, this is receipt numbers, issue date, due date, status, etc.
111
113
 
112
114
  * `line_items` - Array of line items to be displayed in table format.
@@ -151,7 +153,7 @@ If not set, it will fall back to Prawn's default behavior.
151
153
 
152
154
  `details` and `line_items` allow inline formatting with Prawn. This allows you to use HTML tags to format text: `<b>` `<i>` `<u>` `<strikethrough>` `<sub>` `<sup>` `<font>` `<color>` `<link>`
153
155
 
154
- See [the Prawn docs](https://prawnpdf.org/api-docs/2.3.0/Prawn/Text.html#text-instance_method) for more information.
156
+ See [the Prawn docs](https://prawnpdf.org/) for more information.
155
157
 
156
158
  #### Page Size
157
159
 
data/Rakefile CHANGED
@@ -36,7 +36,9 @@ task :receipt do
36
36
  address: "123 Fake Street\nNew York City, NY 10012",
37
37
  phone: "(555) 867-5309",
38
38
  email: "support@example.com",
39
- logo: File.expand_path("./examples/images/logo.png")
39
+ iban: "123456789",
40
+ logo: File.expand_path("./examples/images/logo.png"),
41
+ display: [:address, :phone, :email, nil, :iban]
40
42
  },
41
43
  details: [
42
44
  ["Receipt Number", "123"],
data/examples/invoice.pdf CHANGED
Binary file
data/examples/receipt.pdf CHANGED
Binary file
Binary file
data/lib/receipts/base.rb CHANGED
@@ -64,14 +64,11 @@ module Receipts
64
64
  table(details, cell_style: {borders: [], inline_format: true, padding: [0, 8, 2, 0]})
65
65
  end
66
66
 
67
- def render_billing_details(company:, recipient:, margin_top: 16)
67
+ def render_billing_details(company:, recipient:, margin_top: 16, display_values: nil)
68
68
  move_down margin_top
69
69
 
70
- company_details = [
71
- company[:address],
72
- company[:phone],
73
- company[:email]
74
- ].compact.join("\n")
70
+ display_values ||= company.fetch(:display, [:address, :phone, :email])
71
+ company_details = company.values_at(*display_values).compact.join("\n")
75
72
 
76
73
  line_items = [
77
74
  [
@@ -1,3 +1,3 @@
1
1
  module Receipts
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: receipts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-05 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn