clinvoice 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91cafc96e465f58bae419d2fa0c98afd7deb9c87fefbd1fd012503f95da54a3e
4
- data.tar.gz: 3896731fa5455499b5a244f255a4783cb1a9188d9598712cae1b2af830d7bbde
3
+ metadata.gz: 1b15d22bdc4eac1154f8ff91961d2ad3675f3046b17792a418310b02242478a5
4
+ data.tar.gz: 0ec6a774d8e43916edf4d408aef4ac883195dd232262016f7fbe939721c2c70a
5
5
  SHA512:
6
- metadata.gz: a2b92a43c80a24486f82e75e447090319af551ba96bd2bcf48b6d33c9ffcdd326b3e91f3ae645ef91e20d5e24ea94beb278c239de36fa5538631e4b752a645d0
7
- data.tar.gz: d146ee8a6259498a254dd30212f2c7d625346deb5998d443b5e10f409e4d22960d2a02a842b12226050e0cfda63988c5063baae2400347315debc207fb7260f4
6
+ metadata.gz: 9828213ba2f5e4fa094bdbcb538811f8bd592a0f3f014a67142889630e591b2da66be54d9b4d1567a053635fa0d494255ff9e98d520f1faea1ae2bc235c6e969
7
+ data.tar.gz: 9048ed41925013e8ee3326dd77daa039c79e2fd8c4155e98fb0b31c7330e23170039fe1717cf89bf65db0c72984ad5690b054e43f4e047f4d4921481ab2d1504
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ clinvoice (1.0.0)
5
+ prawn (~> 2.2)
6
+ prawn-table (~> 0.2.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ pdf-core (0.7.0)
12
+ prawn (2.2.2)
13
+ pdf-core (~> 0.7.0)
14
+ ttfunk (~> 1.5)
15
+ prawn-table (0.2.2)
16
+ prawn (>= 1.3.0, < 3.0.0)
17
+ rake (10.5.0)
18
+ ttfunk (1.5.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 1.16)
25
+ clinvoice!
26
+ rake (~> 10.0)
27
+
28
+ BUNDLED WITH
29
+ 1.16.4
data/README.md CHANGED
@@ -32,6 +32,32 @@ Or install it yourself as:
32
32
 
33
33
  This will create a `doge-client-1.yml` data file.
34
34
 
35
+ ```yaml
36
+ data:
37
+ id: 1
38
+ currency: "USD"
39
+ contractor:
40
+ name: "You"
41
+ address:
42
+ line1: "123, Street, 451233"
43
+ line2: "City, State, Country"
44
+ client:
45
+ name: "Your Client"
46
+ address:
47
+ line1: "123, Street, 451233"
48
+ line2: "City, State, Country"
49
+ items:
50
+ -
51
+ description: "Example service 1"
52
+ quantity: 1
53
+ unit_cost: 1.00
54
+ -
55
+ description: "Example service 2"
56
+ quantity: 1
57
+ unit_cost: 2.00
58
+ notes: "footer notes optional"
59
+ ```
60
+
35
61
  2 - Edit the data file:
36
62
 
37
63
  $ vim doge-client-1.yml
@@ -4,15 +4,22 @@ require 'yaml'
4
4
 
5
5
  module Clinvoice
6
6
  class Data
7
- attr_reader :invoice_id, :contractor, :client, :items, :notes, :total, :file
7
+ attr_reader :invoice_id,
8
+ :currency,
9
+ :contractor,
10
+ :client,
11
+ :items,
12
+ :notes,
13
+ :total,
14
+ :file
8
15
 
9
16
  def initialize(file)
10
- @file = file
11
-
12
17
  data = YAML.load_file("#{file}.yml")['data']
13
18
 
19
+ @file = file
14
20
  @invoice_id = data['id']
15
21
  @currency = data['currency']
22
+ @issue_date = data['issue_date']
16
23
  @contractor = data['contractor']
17
24
  @client = data['client']
18
25
  @items = data['items'].map do |item|
@@ -4,8 +4,9 @@ require 'prawn'
4
4
  require 'prawn/table'
5
5
  require 'clinvoice/data'
6
6
  require 'clinvoice/helper'
7
- require 'clinvoice/render_items'
7
+ require 'clinvoice/render_basic_info'
8
8
  require 'clinvoice/render_name_and_address'
9
+ require 'clinvoice/render_items'
9
10
  require 'clinvoice/render_notes'
10
11
  require 'clinvoice/render_title'
11
12
  require 'clinvoice/render_total'
@@ -24,6 +25,7 @@ module Clinvoice
24
25
 
25
26
  pdf.font_size 9
26
27
 
28
+ Clinvoice::RenderBasicInfo.call(pdf, data)
27
29
  Clinvoice::RenderNameAndAddress.call(pdf, 'From', data.contractor)
28
30
  Clinvoice::RenderNameAndAddress.call(pdf, 'To', data.client)
29
31
  Clinvoice::RenderItems.call(pdf, data.items)
@@ -5,5 +5,17 @@ module Clinvoice
5
5
  def self.format_currency(number)
6
6
  format('$%.2f', number.to_f)
7
7
  end
8
+
9
+ def self.new_line(pdf, text)
10
+ pdf.text_box text.to_s, at: [8, pdf.cursor]
11
+ pdf.move_down 12
12
+ end
13
+
14
+ def self.new_bold_line(pdf, text)
15
+ pdf.font 'Helvetica', style: :bold
16
+ pdf.text_box text.to_s, at: [8, pdf.cursor]
17
+ pdf.font 'Helvetica', style: :normal
18
+ pdf.move_down 12
19
+ end
8
20
  end
9
21
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Clinvoice
4
+ module RenderBasicInfo
5
+ def self.call(pdf, data)
6
+ Clinvoice::Helper.new_bold_line(pdf, "Invoice ID")
7
+ Clinvoice::Helper.new_line(pdf, data.invoice_id)
8
+
9
+ pdf.move_down 10
10
+
11
+ Clinvoice::Helper.new_bold_line(pdf, "Currency")
12
+ Clinvoice::Helper.new_line(pdf, data.currency)
13
+
14
+ pdf.move_down 10
15
+ end
16
+ end
17
+ end
@@ -2,24 +2,10 @@
2
2
 
3
3
  module Clinvoice
4
4
  module RenderItems
5
- def self.call(pdf, items)
5
+ def self.call(pdf, data_items)
6
6
  pdf.move_down 20
7
7
 
8
- header = ['Description', 'Unit Cost', 'Quantity', 'Line Total']
9
- blank_line = [' ', ' ', ' ', ' ']
10
-
11
- formatted_items = items.map do |item|
12
- [
13
- item[0],
14
- Clinvoice::Helper.format_currency(item[1]),
15
- item[2],
16
- Clinvoice::Helper.format_currency(item[3])
17
- ]
18
- end
19
-
20
- rows = [header] + formatted_items + [blank_line]
21
-
22
- pdf.table(rows, width: pdf.bounds.width) do
8
+ pdf.table(items(data_items), width: pdf.bounds.width) do
23
9
  style(row(1..-1).columns(0..-1), padding: [4, 5, 4, 5], borders: [:bottom], border_color: 'dddddd')
24
10
  style(row(0), background_color: 'e9e9e9', border_color: 'dddddd', font_style: :bold)
25
11
  style(row(0).columns(0..-1), borders: %i[top bottom])
@@ -32,5 +18,25 @@ module Clinvoice
32
18
 
33
19
  pdf.move_down 10
34
20
  end
21
+
22
+ private
23
+
24
+ def self.items(data_items)
25
+ header = ['Description', 'Unit Cost', 'Quantity', 'Line Total']
26
+ blank_line = [' ', ' ', ' ', ' ']
27
+
28
+ [header] + formatted_items(data_items) + [blank_line]
29
+ end
30
+
31
+ def self.formatted_items(items)
32
+ items.map do |item|
33
+ [
34
+ item[0],
35
+ Clinvoice::Helper.format_currency(item[1]),
36
+ item[2],
37
+ Clinvoice::Helper.format_currency(item[3])
38
+ ]
39
+ end
40
+ end
35
41
  end
36
42
  end
@@ -3,18 +3,12 @@
3
3
  module Clinvoice
4
4
  module RenderNameAndAddress
5
5
  def self.call(pdf, label, entity)
6
- pdf.font 'Helvetica', style: :bold
7
- pdf.text_box label, at: [8, pdf.cursor]
8
- pdf.font 'Helvetica', style: :normal
6
+ Clinvoice::Helper.new_bold_line(pdf, label)
7
+ Clinvoice::Helper.new_line(pdf, entity['name'])
9
8
 
10
- pdf.move_down 12
11
- pdf.text_box entity['name'], at: [8, pdf.cursor]
12
- pdf.move_down 12
13
9
  if entity['address']
14
- pdf.text_box entity['address']['line1'], at: [8, pdf.cursor]
15
- pdf.move_down 12
16
- pdf.text_box entity['address']['line2'], at: [8, pdf.cursor]
17
- pdf.move_down 12
10
+ Clinvoice::Helper.new_line(pdf, entity['address']['line1'])
11
+ Clinvoice::Helper.new_line(pdf, entity['address']['line2'])
18
12
  end
19
13
 
20
14
  pdf.move_down 10
@@ -5,10 +5,16 @@ module Clinvoice
5
5
  def self.call(pdf, notes)
6
6
  return unless notes
7
7
 
8
- pdf.table([['Notes'], [notes]], width: 275) do
9
- style(row(0..-1).columns(0..-1), padding: [1, 0, 1, 0], borders: [])
8
+ pdf.table(items(notes), width: 275) do
10
9
  style(row(0).columns(0), font_style: :bold)
10
+ style(row(0..-1).columns(0..-1), padding: [1, 0, 1, 0], borders: [])
11
11
  end
12
12
  end
13
+
14
+ private
15
+
16
+ def self.items(notes)
17
+ [['Notes'], [notes]]
18
+ end
13
19
  end
14
20
  end
@@ -3,18 +3,20 @@
3
3
  module Clinvoice
4
4
  module RenderTotal
5
5
  def self.call(pdf, total)
6
- invoice_services_totals_data = [
7
- ['Total', Clinvoice::Helper.format_currency(total)]
8
- ]
9
-
10
- pdf.table(invoice_services_totals_data, position: 425, width: 115) do
6
+ pdf.table(items(total), position: 425, width: 115) do
11
7
  style(row(0), font_style: :bold)
12
8
  style(row(0), background_color: 'e9e9e9', border_color: 'dddddd', font_style: :bold)
13
- style(row(0..1).columns(0..1), padding: [3, 5, 3, 5], borders: [])
14
9
  style(column(1), align: :right)
10
+ style(row(0..1).columns(0..1), padding: [3, 5, 3, 5], borders: [])
15
11
  end
16
12
 
17
13
  pdf.move_down 25
18
14
  end
15
+
16
+ private
17
+
18
+ def self.items(total)
19
+ [['Total', Clinvoice::Helper.format_currency(total)]]
20
+ end
19
21
  end
20
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clinvoice
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clinvoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew S Aguiar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-18 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,7 +71,6 @@ email:
71
71
  - andrewaguiar6@gmail.com
72
72
  executables:
73
73
  - clinvoice
74
- - console
75
74
  - setup
76
75
  extensions: []
77
76
  extra_rdoc_files: []
@@ -81,11 +80,11 @@ files:
81
80
  - ".travis.yml"
82
81
  - CODE_OF_CONDUCT.md
83
82
  - Gemfile
83
+ - Gemfile.lock
84
84
  - LICENSE.txt
85
85
  - README.md
86
86
  - Rakefile
87
87
  - bin/clinvoice
88
- - bin/console
89
88
  - bin/setup
90
89
  - clinvoice.gemspec
91
90
  - lib/clinvoice.rb
@@ -94,6 +93,7 @@ files:
94
93
  - lib/clinvoice/generate_pdf.rb
95
94
  - lib/clinvoice/helper.rb
96
95
  - lib/clinvoice/initialize_template.rb
96
+ - lib/clinvoice/render_basic_info.rb
97
97
  - lib/clinvoice/render_items.rb
98
98
  - lib/clinvoice/render_name_and_address.rb
99
99
  - lib/clinvoice/render_notes.rb
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'clinvoice'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)