clinvoice 1.0.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/Gemfile.lock +29 -0
- data/README.md +26 -0
- data/clinvoice.gemspec +1 -1
- data/generate-gem +4 -0
- data/lib/clinvoice.rb +0 -10
- data/lib/clinvoice/data.rb +16 -3
- data/lib/clinvoice/generate_pdf.rb +3 -1
- data/lib/clinvoice/helper.rb +12 -0
- data/lib/clinvoice/render_basic_info.rb +31 -0
- data/lib/clinvoice/render_items.rb +22 -16
- data/lib/clinvoice/render_name_and_address.rb +4 -10
- data/lib/clinvoice/render_notes.rb +8 -2
- data/lib/clinvoice/render_total.rb +8 -6
- data/lib/clinvoice/version.rb +1 -1
- metadata +13 -12
- data/bin/console +0 -15
- data/lib/clinvoice/generate_next_template.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d98b8850af7ae69833611a1d4d36e9fe926fcb46cca1342e406a439baa7eb8e
|
4
|
+
data.tar.gz: ac0c250ee74f5d4150224c067525a82a9c58bff8aeb8f8ffbd9fed863648437c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc3d74d09e9469d489bf1459b6b91773d99550954f1eb10f891b14274a0f0de3d3df805192ece5eaf5ec88dfb1e0423e91b34af357e2d5c705700293e68cf8d
|
7
|
+
data.tar.gz: f7e204e69992eea428ef0b7be5b23dcd02f2cfa5bd044c36f691e68c14a5f156787ddfacc015294a34e220c926f2faeddbde086b32d0731b32b726e6a32a3b13
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.5.5
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clinvoice (2.1.1)
|
5
|
+
prawn (~> 2.2)
|
6
|
+
prawn-table (~> 0.2.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
pdf-core (0.9.0)
|
12
|
+
prawn (2.4.0)
|
13
|
+
pdf-core (~> 0.9.0)
|
14
|
+
ttfunk (~> 1.7)
|
15
|
+
prawn-table (0.2.2)
|
16
|
+
prawn (>= 1.3.0, < 3.0.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
ttfunk (1.7.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 2.2.10)
|
25
|
+
clinvoice!
|
26
|
+
rake (~> 10.0)
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
2.2.25
|
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
|
data/clinvoice.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler', '~>
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.2.10'
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_dependency 'prawn', '~> 2.2'
|
31
31
|
spec.add_dependency 'prawn-table', '~> 0.2.2'
|
data/generate-gem
ADDED
data/lib/clinvoice.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'clinvoice/initialize_template'
|
4
|
-
require 'clinvoice/generate_next_template'
|
5
4
|
require 'clinvoice/generate_pdf'
|
6
5
|
require 'clinvoice/version'
|
7
6
|
|
@@ -17,8 +16,6 @@ module Clinvoice
|
|
17
16
|
Clinvoice::InitializeTemplate.call(file)
|
18
17
|
when 'new'
|
19
18
|
Clinvoice::GeneratePDF.call(file)
|
20
|
-
when 'next'
|
21
|
-
Clinvoice::GenerateNextTemplate.call(file)
|
22
19
|
else
|
23
20
|
show_usage_and_exit!
|
24
21
|
end
|
@@ -30,7 +27,6 @@ module Clinvoice
|
|
30
27
|
|
31
28
|
clinvoice init <datafile> # starts a new template with id 1 and empty entries.
|
32
29
|
clinvoice new <filename> # generates a pdf invoice based on a data file `yml`.
|
33
|
-
clinvoice next <datafile> # generates the next data file `yml`.
|
34
30
|
|
35
31
|
Args:
|
36
32
|
|
@@ -55,12 +51,6 @@ module Clinvoice
|
|
55
51
|
|
56
52
|
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`.
|
57
53
|
|
58
|
-
4 - Generate a next datafile
|
59
|
-
|
60
|
-
`$ clinvoice next doge-client`
|
61
|
-
|
62
|
-
This will create a `doge-client-2.yml` data file, based on the last data file id + 1.
|
63
|
-
|
64
54
|
USAGE
|
65
55
|
|
66
56
|
exit
|
data/lib/clinvoice/data.rb
CHANGED
@@ -4,16 +4,29 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
module Clinvoice
|
6
6
|
class Data
|
7
|
-
attr_reader :invoice_id,
|
7
|
+
attr_reader :invoice_id,
|
8
|
+
:issue_date,
|
9
|
+
:due_date,
|
10
|
+
:currency,
|
11
|
+
:contractor,
|
12
|
+
:client,
|
13
|
+
:items,
|
14
|
+
:notes,
|
15
|
+
:total,
|
16
|
+
:file
|
8
17
|
|
9
18
|
def initialize(file)
|
10
|
-
|
19
|
+
filename = file.end_with?('.yml') ? file : "#{file}.yml"
|
11
20
|
|
12
|
-
data = YAML.load_file(
|
21
|
+
data = YAML.load_file(filename)['data']
|
13
22
|
|
23
|
+
@file = file
|
14
24
|
@invoice_id = data['id']
|
15
25
|
@currency = data['currency']
|
26
|
+
@issue_date = data['issue_date']
|
16
27
|
@contractor = data['contractor']
|
28
|
+
@issue_date = data['issue_date']
|
29
|
+
@due_date = data['due_date']
|
17
30
|
@client = data['client']
|
18
31
|
@items = data['items'].map do |item|
|
19
32
|
[
|
@@ -4,8 +4,9 @@ require 'prawn'
|
|
4
4
|
require 'prawn/table'
|
5
5
|
require 'clinvoice/data'
|
6
6
|
require 'clinvoice/helper'
|
7
|
-
require 'clinvoice/
|
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)
|
data/lib/clinvoice/helper.rb
CHANGED
@@ -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,31 @@
|
|
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
|
+
|
16
|
+
if data.issue_date
|
17
|
+
Clinvoice::Helper.new_bold_line(pdf, "Issue Date")
|
18
|
+
Clinvoice::Helper.new_line(pdf, data.issue_date)
|
19
|
+
|
20
|
+
pdf.move_down 10
|
21
|
+
end
|
22
|
+
|
23
|
+
if data.issue_date
|
24
|
+
Clinvoice::Helper.new_bold_line(pdf, "Due Date")
|
25
|
+
Clinvoice::Helper.new_line(pdf, data.due_date)
|
26
|
+
|
27
|
+
pdf.move_down 10
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -2,24 +2,10 @@
|
|
2
2
|
|
3
3
|
module Clinvoice
|
4
4
|
module RenderItems
|
5
|
-
def self.call(pdf,
|
5
|
+
def self.call(pdf, data_items)
|
6
6
|
pdf.move_down 20
|
7
7
|
|
8
|
-
|
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
|
7
|
-
pdf
|
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
|
15
|
-
pdf
|
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(
|
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
|
-
|
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
|
data/lib/clinvoice/version.rb
CHANGED
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:
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew S Aguiar
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,29 +71,30 @@ 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: []
|
78
77
|
files:
|
79
78
|
- ".gitignore"
|
80
79
|
- ".rspec"
|
80
|
+
- ".tool-versions"
|
81
81
|
- ".travis.yml"
|
82
82
|
- CODE_OF_CONDUCT.md
|
83
83
|
- Gemfile
|
84
|
+
- Gemfile.lock
|
84
85
|
- LICENSE.txt
|
85
86
|
- README.md
|
86
87
|
- Rakefile
|
87
88
|
- bin/clinvoice
|
88
|
-
- bin/console
|
89
89
|
- bin/setup
|
90
90
|
- clinvoice.gemspec
|
91
|
+
- generate-gem
|
91
92
|
- lib/clinvoice.rb
|
92
93
|
- lib/clinvoice/data.rb
|
93
|
-
- lib/clinvoice/generate_next_template.rb
|
94
94
|
- lib/clinvoice/generate_pdf.rb
|
95
95
|
- lib/clinvoice/helper.rb
|
96
96
|
- lib/clinvoice/initialize_template.rb
|
97
|
+
- lib/clinvoice/render_basic_info.rb
|
97
98
|
- lib/clinvoice/render_items.rb
|
98
99
|
- lib/clinvoice/render_name_and_address.rb
|
99
100
|
- lib/clinvoice/render_notes.rb
|
@@ -104,7 +105,7 @@ homepage: https://github.com/andrewaguiar/clinvoice
|
|
104
105
|
licenses:
|
105
106
|
- MIT
|
106
107
|
metadata: {}
|
107
|
-
post_install_message:
|
108
|
+
post_install_message:
|
108
109
|
rdoc_options: []
|
109
110
|
require_paths:
|
110
111
|
- lib
|
@@ -119,9 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubyforge_project:
|
123
|
-
rubygems_version: 2.7.
|
124
|
-
signing_key:
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.7.6.2
|
125
|
+
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Generates invoices using command line
|
127
128
|
test_files: []
|
data/bin/console
DELETED
@@ -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__)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Clinvoice
|
4
|
-
module GenerateNextTemplate
|
5
|
-
def self.call(file)
|
6
|
-
last_data_file = Dir["#{file}-*.yml"].max
|
7
|
-
template_content = File.read(last_data_file)
|
8
|
-
|
9
|
-
next_id = template_content.scan(/id: (\d*)/).first.first.to_i + 1
|
10
|
-
|
11
|
-
next_template_content = template_content.sub(/id: (\d*)/, "id: #{next_id}")
|
12
|
-
|
13
|
-
File.write("#{file}-#{next_id}.yml", next_template_content)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|