clinvoice 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +8 -0
- data/bin/clinvoice +6 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/clinvoice.gemspec +32 -0
- data/lib/clinvoice.rb +68 -0
- data/lib/clinvoice/data.rb +31 -0
- data/lib/clinvoice/generate_next_template.rb +16 -0
- data/lib/clinvoice/generate_pdf.rb +35 -0
- data/lib/clinvoice/helper.rb +9 -0
- data/lib/clinvoice/initialize_template.rb +35 -0
- data/lib/clinvoice/render_items.rb +36 -0
- data/lib/clinvoice/render_name_and_address.rb +23 -0
- data/lib/clinvoice/render_notes.rb +14 -0
- data/lib/clinvoice/render_title.rb +16 -0
- data/lib/clinvoice/render_total.rb +20 -0
- data/lib/clinvoice/version.rb +5 -0
- metadata +30 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91cafc96e465f58bae419d2fa0c98afd7deb9c87fefbd1fd012503f95da54a3e
|
4
|
+
data.tar.gz: 3896731fa5455499b5a244f255a4783cb1a9188d9598712cae1b2af830d7bbde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2b92a43c80a24486f82e75e447090319af551ba96bd2bcf48b6d33c9ffcdd326b3e91f3ae645ef91e20d5e24ea94beb278c239de36fa5538631e4b752a645d0
|
7
|
+
data.tar.gz: d146ee8a6259498a254dd30212f2c7d625346deb5998d443b5e10f409e4d22960d2a02a842b12226050e0cfda63988c5063baae2400347315debc207fb7260f4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at andrewaguiar6@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Andrew S Aguiar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Clinvoice
|
2
|
+
|
3
|
+
Generates invoices using command line based on yaml files
|
4
|
+
|
5
|
+
```shell
|
6
|
+
clinvoice init <datafile> # starts a new template with id 1 and empty entries.
|
7
|
+
clinvoice new <filename> # generates a pdf invoice based on a data file `yml`.
|
8
|
+
clinvoice next <datafile> # generates the next data file `yml`.
|
9
|
+
```
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'clinvoice'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install clinvoice
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
1 - Create a new client template:
|
30
|
+
|
31
|
+
$ clinvoice init doge-client
|
32
|
+
|
33
|
+
This will create a `doge-client-1.yml` data file.
|
34
|
+
|
35
|
+
2 - Edit the data file:
|
36
|
+
|
37
|
+
$ vim doge-client-1.yml
|
38
|
+
|
39
|
+
3 - Now we can generate our pdf invoice based on the data file
|
40
|
+
|
41
|
+
$ clinvoice new doge-client-1
|
42
|
+
|
43
|
+
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`.
|
44
|
+
|
45
|
+
4 - Generate a next datafile
|
46
|
+
|
47
|
+
$ clinvoice next doge-client
|
48
|
+
|
49
|
+
This will create a `doge-client-2.yml` data file, based on the last data file id + 1.
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clinvoice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
64
|
+
|
65
|
+
## Code of Conduct
|
66
|
+
|
67
|
+
Everyone interacting in the Clinvoice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/clinvoice/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/clinvoice
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
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__)
|
data/bin/setup
ADDED
data/clinvoice.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'clinvoice/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'clinvoice'
|
10
|
+
spec.version = Clinvoice::VERSION
|
11
|
+
spec.authors = ['Andrew S Aguiar']
|
12
|
+
spec.email = ['andrewaguiar6@gmail.com']
|
13
|
+
spec.summary = 'Generates invoices using command line'
|
14
|
+
spec.description = 'Generates invoices using command line based on yaml file'
|
15
|
+
spec.homepage = 'https://github.com/andrewaguiar/clinvoice'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.bindir = 'bin'
|
25
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_dependency 'prawn', '~> 2.2'
|
31
|
+
spec.add_dependency 'prawn-table', '~> 0.2.2'
|
32
|
+
end
|
data/lib/clinvoice.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'clinvoice/initialize_template'
|
4
|
+
require 'clinvoice/generate_next_template'
|
5
|
+
require 'clinvoice/generate_pdf'
|
6
|
+
require 'clinvoice/version'
|
7
|
+
|
8
|
+
module Clinvoice
|
9
|
+
def self.execute(args)
|
10
|
+
show_usage_and_exit! if args.empty?
|
11
|
+
|
12
|
+
command = args[0]
|
13
|
+
file = args[1]
|
14
|
+
|
15
|
+
case command
|
16
|
+
when 'init'
|
17
|
+
Clinvoice::InitializeTemplate.call(file)
|
18
|
+
when 'new'
|
19
|
+
Clinvoice::GeneratePDF.call(file)
|
20
|
+
when 'next'
|
21
|
+
Clinvoice::GenerateNextTemplate.call(file)
|
22
|
+
else
|
23
|
+
show_usage_and_exit!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.show_usage_and_exit!
|
28
|
+
puts <<~USAGE
|
29
|
+
Usage:
|
30
|
+
|
31
|
+
clinvoice init <datafile> # starts a new template with id 1 and empty entries.
|
32
|
+
clinvoice new <filename> # generates a pdf invoice based on a data file `yml`.
|
33
|
+
clinvoice next <datafile> # generates the next data file `yml`.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
|
37
|
+
- datafile: the yaml template without number and extention, example 'doge' ('doge-*.yml' templates)
|
38
|
+
- filename: the yaml template with number but without extention, example 'doge-3' ('doge-3.yml' templates)
|
39
|
+
|
40
|
+
Examples / Flow:
|
41
|
+
|
42
|
+
1 - First lets create a new client template:
|
43
|
+
|
44
|
+
`$ clinvoice init doge-client`
|
45
|
+
|
46
|
+
This will create a `doge-client-1.yml` data file, lets edit it and generate our pdf invoice.
|
47
|
+
|
48
|
+
2 - Edit the data file:
|
49
|
+
|
50
|
+
`$ vim doge-client-1.yml`
|
51
|
+
|
52
|
+
3 - Now we can generate our pdf invoice based on the data file
|
53
|
+
|
54
|
+
`$ clinvoice new doge-client-1`
|
55
|
+
|
56
|
+
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`.
|
57
|
+
|
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
|
+
USAGE
|
65
|
+
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Clinvoice
|
6
|
+
class Data
|
7
|
+
attr_reader :invoice_id, :contractor, :client, :items, :notes, :total, :file
|
8
|
+
|
9
|
+
def initialize(file)
|
10
|
+
@file = file
|
11
|
+
|
12
|
+
data = YAML.load_file("#{file}.yml")['data']
|
13
|
+
|
14
|
+
@invoice_id = data['id']
|
15
|
+
@currency = data['currency']
|
16
|
+
@contractor = data['contractor']
|
17
|
+
@client = data['client']
|
18
|
+
@items = data['items'].map do |item|
|
19
|
+
[
|
20
|
+
item['description'],
|
21
|
+
item['unit_cost'],
|
22
|
+
item['quantity'],
|
23
|
+
item['quantity'] * item['unit_cost']
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
@notes = data['notes']
|
28
|
+
@total = @items.map(&:last).sum
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'prawn'
|
4
|
+
require 'prawn/table'
|
5
|
+
require 'clinvoice/data'
|
6
|
+
require 'clinvoice/helper'
|
7
|
+
require 'clinvoice/render_items'
|
8
|
+
require 'clinvoice/render_name_and_address'
|
9
|
+
require 'clinvoice/render_notes'
|
10
|
+
require 'clinvoice/render_title'
|
11
|
+
require 'clinvoice/render_total'
|
12
|
+
|
13
|
+
module Clinvoice
|
14
|
+
module GeneratePDF
|
15
|
+
def self.call(file)
|
16
|
+
data = Clinvoice::Data.new(file)
|
17
|
+
|
18
|
+
Prawn::Document.generate("#{data.file}.pdf") do |pdf|
|
19
|
+
Prawn::Font::AFM.hide_m17n_warning = true
|
20
|
+
|
21
|
+
pdf.font 'Helvetica'
|
22
|
+
|
23
|
+
Clinvoice::RenderTitle.call(pdf)
|
24
|
+
|
25
|
+
pdf.font_size 9
|
26
|
+
|
27
|
+
Clinvoice::RenderNameAndAddress.call(pdf, 'From', data.contractor)
|
28
|
+
Clinvoice::RenderNameAndAddress.call(pdf, 'To', data.client)
|
29
|
+
Clinvoice::RenderItems.call(pdf, data.items)
|
30
|
+
Clinvoice::RenderTotal.call(pdf, data.total)
|
31
|
+
Clinvoice::RenderNotes.call(pdf, data.notes)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module InitializeTemplate
|
5
|
+
def self.call(file)
|
6
|
+
template_content = <<~TEMPLATE
|
7
|
+
data:
|
8
|
+
id: 1
|
9
|
+
currency: "USD"
|
10
|
+
contractor:
|
11
|
+
name: "You"
|
12
|
+
address:
|
13
|
+
line1: "123, Street, 451233"
|
14
|
+
line2: "City, State, Country"
|
15
|
+
client:
|
16
|
+
name: "Your Client"
|
17
|
+
address:
|
18
|
+
line1: "123, Street, 451233"
|
19
|
+
line2: "City, State, Country"
|
20
|
+
items:
|
21
|
+
-
|
22
|
+
description: "Example service 1"
|
23
|
+
quantity: 1
|
24
|
+
unit_cost: 1.00
|
25
|
+
-
|
26
|
+
description: "Example service 2"
|
27
|
+
quantity: 1
|
28
|
+
unit_cost: 2.00
|
29
|
+
notes: "footer notes optional"
|
30
|
+
TEMPLATE
|
31
|
+
|
32
|
+
File.write("#{file}-1.yml", template_content)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module RenderItems
|
5
|
+
def self.call(pdf, items)
|
6
|
+
pdf.move_down 20
|
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
|
23
|
+
style(row(1..-1).columns(0..-1), padding: [4, 5, 4, 5], borders: [:bottom], border_color: 'dddddd')
|
24
|
+
style(row(0), background_color: 'e9e9e9', border_color: 'dddddd', font_style: :bold)
|
25
|
+
style(row(0).columns(0..-1), borders: %i[top bottom])
|
26
|
+
style(row(0).columns(0), borders: %i[top left bottom])
|
27
|
+
style(row(0).columns(-1), borders: %i[top right bottom])
|
28
|
+
style(row(-1), border_width: 2)
|
29
|
+
style(column(2..-1), align: :right)
|
30
|
+
style(columns(0), width: 280)
|
31
|
+
end
|
32
|
+
|
33
|
+
pdf.move_down 10
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module RenderNameAndAddress
|
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
|
9
|
+
|
10
|
+
pdf.move_down 12
|
11
|
+
pdf.text_box entity['name'], at: [8, pdf.cursor]
|
12
|
+
pdf.move_down 12
|
13
|
+
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
|
18
|
+
end
|
19
|
+
|
20
|
+
pdf.move_down 10
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module RenderNotes
|
5
|
+
def self.call(pdf, notes)
|
6
|
+
return unless notes
|
7
|
+
|
8
|
+
pdf.table([['Notes'], [notes]], width: 275) do
|
9
|
+
style(row(0..-1).columns(0..-1), padding: [1, 0, 1, 0], borders: [])
|
10
|
+
style(row(0).columns(0), font_style: :bold)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module RenderTitle
|
5
|
+
def self.call(pdf)
|
6
|
+
pdf.move_down 5
|
7
|
+
|
8
|
+
pdf.font 'Helvetica', style: :bold
|
9
|
+
pdf.font_size 20
|
10
|
+
pdf.text_box 'INVOICE', at: [230, pdf.cursor]
|
11
|
+
pdf.font 'Helvetica', style: :normal
|
12
|
+
|
13
|
+
pdf.move_down 30
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clinvoice
|
4
|
+
module RenderTotal
|
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
|
11
|
+
style(row(0), font_style: :bold)
|
12
|
+
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
|
+
style(column(1), align: :right)
|
15
|
+
end
|
16
|
+
|
17
|
+
pdf.move_down 25
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clinvoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew S Aguiar
|
@@ -69,10 +69,37 @@ dependencies:
|
|
69
69
|
description: Generates invoices using command line based on yaml file
|
70
70
|
email:
|
71
71
|
- andrewaguiar6@gmail.com
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- clinvoice
|
74
|
+
- console
|
75
|
+
- setup
|
73
76
|
extensions: []
|
74
77
|
extra_rdoc_files: []
|
75
|
-
files:
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
|
+
- CODE_OF_CONDUCT.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/clinvoice
|
88
|
+
- bin/console
|
89
|
+
- bin/setup
|
90
|
+
- clinvoice.gemspec
|
91
|
+
- lib/clinvoice.rb
|
92
|
+
- lib/clinvoice/data.rb
|
93
|
+
- lib/clinvoice/generate_next_template.rb
|
94
|
+
- lib/clinvoice/generate_pdf.rb
|
95
|
+
- lib/clinvoice/helper.rb
|
96
|
+
- lib/clinvoice/initialize_template.rb
|
97
|
+
- lib/clinvoice/render_items.rb
|
98
|
+
- lib/clinvoice/render_name_and_address.rb
|
99
|
+
- lib/clinvoice/render_notes.rb
|
100
|
+
- lib/clinvoice/render_title.rb
|
101
|
+
- lib/clinvoice/render_total.rb
|
102
|
+
- lib/clinvoice/version.rb
|
76
103
|
homepage: https://github.com/andrewaguiar/clinvoice
|
77
104
|
licenses:
|
78
105
|
- MIT
|