process_decl_IVA 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.rvmrc +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +113 -0
- data/Guardfile +70 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/Rakefile +12 -0
- data/bin/process_decl_iva +6 -0
- data/lib/process_decl_IVA/version.rb +5 -0
- data/lib/process_decl_iva/calculate.rb +76 -0
- data/lib/process_decl_iva/process_expenses/e_fatura.rb +65 -0
- data/lib/process_decl_iva/process_reservations/talkguest.rb +27 -0
- data/lib/process_decl_iva/version.rb +5 -0
- data/lib/process_decl_iva.rb +78 -0
- data/process_decl_iva.gemspec +38 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48a5f131ff22c3fecab3952e538a5a610bea3621936ed0e34f5eecdfc71850e2
|
4
|
+
data.tar.gz: 115971ff81315d02200d0f906ba2b322701e7c42e66f6c58974d6a8806e88d9b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5bb4bf5e1abd434ffcd5d51e0dd40c0b70fd762b9c2477eb723dafdb5058c2a090e09ea1c94988830be86b6710a33374d4463b46685a6676af7625abb4bbbc2
|
7
|
+
data.tar.gz: a421d36a86cc29d55af943e56c666aba40e809c032be8cad4254707f0211fb82f87cd0acb57e158689629c0fa3d2cb16ca310de3776f61887111298ba3bdfb55
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
process_decl_IVA
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.2.2
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm gemset use process_decl_IVA
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
process_decl_IVA (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
ffi (1.15.5)
|
13
|
+
formatador (1.1.0)
|
14
|
+
guard (2.18.0)
|
15
|
+
formatador (>= 0.2.4)
|
16
|
+
listen (>= 2.7, < 4.0)
|
17
|
+
lumberjack (>= 1.0.12, < 2.0)
|
18
|
+
nenv (~> 0.1)
|
19
|
+
notiffany (~> 0.0)
|
20
|
+
pry (>= 0.13.0)
|
21
|
+
shellany (~> 0.0)
|
22
|
+
thor (>= 0.18.1)
|
23
|
+
guard-compat (1.2.1)
|
24
|
+
guard-rspec (4.7.3)
|
25
|
+
guard (~> 2.1)
|
26
|
+
guard-compat (~> 1.1)
|
27
|
+
rspec (>= 2.99.0, < 4.0)
|
28
|
+
json (2.6.3)
|
29
|
+
language_server-protocol (3.17.0.3)
|
30
|
+
lint_roller (1.0.0)
|
31
|
+
listen (3.8.0)
|
32
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
33
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
34
|
+
lumberjack (1.2.8)
|
35
|
+
method_source (1.0.0)
|
36
|
+
nenv (0.3.0)
|
37
|
+
notiffany (0.1.3)
|
38
|
+
nenv (~> 0.1)
|
39
|
+
shellany (~> 0.0)
|
40
|
+
parallel (1.23.0)
|
41
|
+
parser (3.2.2.3)
|
42
|
+
ast (~> 2.4.1)
|
43
|
+
racc
|
44
|
+
pry (0.14.2)
|
45
|
+
coderay (~> 1.1)
|
46
|
+
method_source (~> 1.0)
|
47
|
+
racc (1.7.1)
|
48
|
+
rainbow (3.1.1)
|
49
|
+
rake (11.3.0)
|
50
|
+
rb-fsevent (0.11.2)
|
51
|
+
rb-inotify (0.10.1)
|
52
|
+
ffi (~> 1.0)
|
53
|
+
regexp_parser (2.8.1)
|
54
|
+
rexml (3.2.5)
|
55
|
+
rspec (3.12.0)
|
56
|
+
rspec-core (~> 3.12.0)
|
57
|
+
rspec-expectations (~> 3.12.0)
|
58
|
+
rspec-mocks (~> 3.12.0)
|
59
|
+
rspec-core (3.12.2)
|
60
|
+
rspec-support (~> 3.12.0)
|
61
|
+
rspec-expectations (3.12.3)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.12.0)
|
64
|
+
rspec-mocks (3.12.5)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.12.0)
|
67
|
+
rspec-support (3.12.0)
|
68
|
+
rubocop (1.52.1)
|
69
|
+
json (~> 2.3)
|
70
|
+
parallel (~> 1.10)
|
71
|
+
parser (>= 3.2.2.3)
|
72
|
+
rainbow (>= 2.2.2, < 4.0)
|
73
|
+
regexp_parser (>= 1.8, < 3.0)
|
74
|
+
rexml (>= 3.2.5, < 4.0)
|
75
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
76
|
+
ruby-progressbar (~> 1.7)
|
77
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
78
|
+
rubocop-ast (1.29.0)
|
79
|
+
parser (>= 3.2.1.0)
|
80
|
+
rubocop-performance (1.18.0)
|
81
|
+
rubocop (>= 1.7.0, < 2.0)
|
82
|
+
rubocop-ast (>= 0.4.0)
|
83
|
+
ruby-progressbar (1.13.0)
|
84
|
+
shellany (0.0.1)
|
85
|
+
standard (1.29.0)
|
86
|
+
language_server-protocol (~> 3.17.0.2)
|
87
|
+
lint_roller (~> 1.0)
|
88
|
+
rubocop (~> 1.52.0)
|
89
|
+
standard-custom (~> 1.0.0)
|
90
|
+
standard-performance (~> 1.1.0)
|
91
|
+
standard-custom (1.0.1)
|
92
|
+
lint_roller (~> 1.0)
|
93
|
+
standard-performance (1.1.0)
|
94
|
+
lint_roller (~> 1.0)
|
95
|
+
rubocop-performance (~> 1.18.0)
|
96
|
+
standardrb (1.0.1)
|
97
|
+
standard
|
98
|
+
thor (1.2.2)
|
99
|
+
unicode-display_width (2.4.2)
|
100
|
+
|
101
|
+
PLATFORMS
|
102
|
+
x86_64-linux
|
103
|
+
|
104
|
+
DEPENDENCIES
|
105
|
+
bundler (~> 2)
|
106
|
+
guard-rspec
|
107
|
+
process_decl_IVA!
|
108
|
+
pry
|
109
|
+
rake (~> 11.3.0)
|
110
|
+
standardrb
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
2.4.10
|
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w[erb haml slim])
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Nuno Costa
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Process Declaraçao Periodica do IVA
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
```
|
6
|
+
gem install process_decl_IVA
|
7
|
+
```
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Pass in the year and quarter like:
|
12
|
+
|
13
|
+
```
|
14
|
+
$ Y=2023 T=3 bin/process_decl_iva
|
15
|
+
```
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
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.
|
20
|
+
|
21
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nunommc/process_decl_IVA
|
26
|
+
|
27
|
+
1. Fork the repo
|
28
|
+
2. Make changes
|
29
|
+
3. Run test suite with `bundle exec rspec`
|
30
|
+
4. Run `bundle exec standardrb` to standardize code formatting
|
31
|
+
5. Submit a PR
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
Copyright (c) 2023 Nuno Costa, released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
module ProcessDeclIva
|
2
|
+
class Calculate
|
3
|
+
VAT = 0.23
|
4
|
+
|
5
|
+
def initialize(
|
6
|
+
from_last_period:,
|
7
|
+
total_vat:,
|
8
|
+
other_commissions:,
|
9
|
+
sales_vat:,
|
10
|
+
sales_amount:
|
11
|
+
)
|
12
|
+
|
13
|
+
@from_last_period = from_last_period
|
14
|
+
@total_expenses_vat = total_vat
|
15
|
+
@other_commissions = other_commissions
|
16
|
+
@sales_vat = sales_vat
|
17
|
+
@sales_amount = sales_amount
|
18
|
+
end
|
19
|
+
|
20
|
+
# Total serviços prestados
|
21
|
+
def field_1
|
22
|
+
@sales_amount
|
23
|
+
end
|
24
|
+
|
25
|
+
# IVA liquidado serviços prestados
|
26
|
+
def field_2
|
27
|
+
@sales_vat
|
28
|
+
end
|
29
|
+
|
30
|
+
# Serviços efetuados por sujeitos passivos de outros Estados membros cujo imposto foi liquidado pelo declarante
|
31
|
+
# Comissoes
|
32
|
+
def field_16
|
33
|
+
(field_1 + field_2) * 0.15 + @other_commissions
|
34
|
+
end
|
35
|
+
|
36
|
+
# [16] * IVA
|
37
|
+
def field_17
|
38
|
+
field_16 * VAT
|
39
|
+
end
|
40
|
+
|
41
|
+
# Imposto Dedutivel: Outros bens e serviços
|
42
|
+
def field_24
|
43
|
+
@total_expenses_vat + field_17
|
44
|
+
end
|
45
|
+
|
46
|
+
# Excesso a reportar para o período anterior
|
47
|
+
def field_61
|
48
|
+
@from_last_period
|
49
|
+
end
|
50
|
+
|
51
|
+
def field_96
|
52
|
+
field_61 + field_24 - field_2 - field_17
|
53
|
+
end
|
54
|
+
|
55
|
+
# Operações localizadas em Portugal em que, na qualidade de adquirente, liquidou o IVA devido
|
56
|
+
# Países comunitários
|
57
|
+
def field_97
|
58
|
+
field_16
|
59
|
+
end
|
60
|
+
|
61
|
+
def call
|
62
|
+
{
|
63
|
+
"1" => field_1,
|
64
|
+
"2" => field_2,
|
65
|
+
"16" => field_16,
|
66
|
+
"17" => field_17,
|
67
|
+
"24" => field_24,
|
68
|
+
"61" => field_61,
|
69
|
+
"96" => field_96,
|
70
|
+
"97" => field_97
|
71
|
+
}.each do |field_nr, value|
|
72
|
+
puts ["| ", field_nr.ljust(4), "| ", value.round(2).to_s.ljust(10), "|"].join
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
# CSV::Converters[:mytime] = lambda{|s|
|
4
|
+
# begin
|
5
|
+
# Time.parse(s)
|
6
|
+
# rescue ArgumentError
|
7
|
+
# s
|
8
|
+
# end
|
9
|
+
# }
|
10
|
+
|
11
|
+
# class NumericWithCurrencyConverter < CSV::Converter
|
12
|
+
# def initialize(field_info)
|
13
|
+
# super
|
14
|
+
# @currency_regex = /[$€]/
|
15
|
+
# end
|
16
|
+
|
17
|
+
# def call(value, field_info)
|
18
|
+
# return value unless value.is_a?(String)
|
19
|
+
# value.gsub(@currency_regex, '').to_f
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
CSV::Converters[:numeric_with_currency] = lambda do |f|
|
24
|
+
f.is_a?(String) ? f.gsub(/[$€]/, "").tr(",", ".").strip : f
|
25
|
+
rescue # encoding conversion or date parse errors
|
26
|
+
f
|
27
|
+
end
|
28
|
+
|
29
|
+
module ProcessDeclIva::ProcessExpenses
|
30
|
+
class EFatura
|
31
|
+
def initialize(csv)
|
32
|
+
@csv = CSV.parse(
|
33
|
+
csv,
|
34
|
+
headers: true,
|
35
|
+
converters: %i[numeric_with_currency numeric],
|
36
|
+
liberal_parsing: true,
|
37
|
+
col_sep: ";"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :csv
|
42
|
+
attr_accessor :total, :total_vat
|
43
|
+
|
44
|
+
def call
|
45
|
+
transform_credit_notes
|
46
|
+
|
47
|
+
@total = sum_by("Total")
|
48
|
+
@total_vat = sum_by("IVA")
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def sum_by(column_name)
|
54
|
+
csv.map { |row| row[column_name].to_f }.sum
|
55
|
+
end
|
56
|
+
|
57
|
+
def transform_credit_notes
|
58
|
+
csv.select { |row| row["Tipo"] =~ /crédito/i }.each do |row|
|
59
|
+
row["Total"] *= -1
|
60
|
+
row["IVA"] *= -1
|
61
|
+
row["Base Tributável"] *= -1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
module ProcessDeclIva::ProcessReservations
|
4
|
+
class Talkguest
|
5
|
+
def initialize(csv)
|
6
|
+
@csv = CSV.parse(csv, headers: true)
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :csv
|
10
|
+
attr_accessor :sales_amount, :sales_vat
|
11
|
+
|
12
|
+
def call
|
13
|
+
@sales_amount = sum_by("Base Incidência")
|
14
|
+
@sales_vat = sum_by("Total Do IVA")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def sum_by(column_name)
|
20
|
+
rows.map { |row| row[column_name].to_f }.sum
|
21
|
+
end
|
22
|
+
|
23
|
+
def rows
|
24
|
+
csv.reject { |r| ![0, "0", "FALSE"].include?(r["Anulado"]) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "process_decl_iva/version"
|
4
|
+
require_relative "process_decl_iva/process_reservations/talkguest"
|
5
|
+
require_relative "process_decl_iva/process_expenses/e_fatura"
|
6
|
+
require_relative "process_decl_iva/calculate"
|
7
|
+
|
8
|
+
module ProcessDeclIva
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
class Runner
|
12
|
+
def initialize
|
13
|
+
@year = ENV.fetch("Y")
|
14
|
+
@quarter = ENV.fetch("T")
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
reporte = ask("Introduza o reporte do trimestre passado [0.00]")
|
19
|
+
reporte = 0.0 if reporte.to_f.zero?
|
20
|
+
|
21
|
+
reservations_csv_path = prompt_file("Indique o ficheiro CSV com as reservas do ultimo trimestre", "docs/#{@year}/reservasT#{@quarter}.csv")
|
22
|
+
|
23
|
+
expenses_csv_path = prompt_file("Indique o ficheiro CSV com as despesas do ultimo trimestre", "docs/#{@year}/faturasT#{@quarter}.csv")
|
24
|
+
|
25
|
+
other_commissions = ask("Indique se ocorreu em algumas outras comissoes no trimestre anterior [0.00]")
|
26
|
+
other_commissions = 0.0 if other_commissions.to_f.zero?
|
27
|
+
|
28
|
+
reservations_csv = File.read(reservations_csv_path)
|
29
|
+
expenses_csv = File.read(expenses_csv_path)
|
30
|
+
|
31
|
+
reservations_service = ProcessReservations::Talkguest.new(reservations_csv)
|
32
|
+
|
33
|
+
expenses_service = ProcessExpenses::EFatura.new(expenses_csv)
|
34
|
+
|
35
|
+
reservations_service.call
|
36
|
+
expenses_service.call
|
37
|
+
|
38
|
+
Calculate.new(
|
39
|
+
from_last_period: reporte.to_f,
|
40
|
+
total_vat: expenses_service.total_vat,
|
41
|
+
other_commissions: other_commissions.to_f,
|
42
|
+
sales_vat: reservations_service.sales_vat,
|
43
|
+
sales_amount: reservations_service.sales_amount
|
44
|
+
).call
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def ask(string)
|
50
|
+
puts string
|
51
|
+
$stdin.gets.strip
|
52
|
+
end
|
53
|
+
|
54
|
+
def yes?(question)
|
55
|
+
answer = ask(question).downcase
|
56
|
+
answer == "y" || answer == "yes"
|
57
|
+
end
|
58
|
+
|
59
|
+
def prompt_file(question, file_path = nil)
|
60
|
+
question_with_default = question.dup
|
61
|
+
|
62
|
+
if file_path
|
63
|
+
question_with_default << " [#{file_path}]"
|
64
|
+
end
|
65
|
+
answer = ask(question_with_default)
|
66
|
+
answer = file_path if answer.empty? && file_path
|
67
|
+
|
68
|
+
unless File.exist?(answer)
|
69
|
+
puts "O ficheiro nao existe. Verifique se esta na pasta corrente ou indique o endereço completo"
|
70
|
+
|
71
|
+
exit(-1)
|
72
|
+
end
|
73
|
+
|
74
|
+
puts
|
75
|
+
answer
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/process_decl_iva/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "process_decl_IVA"
|
7
|
+
spec.version = ProcessDeclIva::VERSION
|
8
|
+
spec.authors = ["Nuno Costa"]
|
9
|
+
spec.email = ["nuno.mmc@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Script para auxiliar no preenchimento da Declaração periódica do IVA"
|
12
|
+
spec.description = 'Processa o CSV do mapa de reservas exportado da Talkguest e o CSV exportado do e-fatura
|
13
|
+
para um dado trimestre, e demonstra que valores têm que ser preenchidos na declaração periódica do IVA'
|
14
|
+
spec.homepage = "https://process-decl-IVA.github.io"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 2.6.0"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
20
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "bin"
|
30
|
+
spec.executables = ["process_decl_iva"]
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 2"
|
34
|
+
spec.add_development_dependency "guard-rspec"
|
35
|
+
spec.add_development_dependency "pry"
|
36
|
+
spec.add_development_dependency "standardrb"
|
37
|
+
spec.add_development_dependency "rake", "~> 11.3.0"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: process_decl_IVA
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nuno Costa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: standardrb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 11.3.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 11.3.0
|
83
|
+
description: |-
|
84
|
+
Processa o CSV do mapa de reservas exportado da Talkguest e o CSV exportado do e-fatura
|
85
|
+
para um dado trimestre, e demonstra que valores têm que ser preenchidos na declaração periódica do IVA
|
86
|
+
email:
|
87
|
+
- nuno.mmc@gmail.com
|
88
|
+
executables:
|
89
|
+
- process_decl_iva
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".rspec"
|
94
|
+
- ".rubocop.yml"
|
95
|
+
- ".ruby-gemset"
|
96
|
+
- ".ruby-version"
|
97
|
+
- ".rvmrc"
|
98
|
+
- CHANGELOG.md
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
101
|
+
- Guardfile
|
102
|
+
- LICENSE
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- bin/process_decl_iva
|
106
|
+
- lib/process_decl_IVA/version.rb
|
107
|
+
- lib/process_decl_iva.rb
|
108
|
+
- lib/process_decl_iva/calculate.rb
|
109
|
+
- lib/process_decl_iva/process_expenses/e_fatura.rb
|
110
|
+
- lib/process_decl_iva/process_reservations/talkguest.rb
|
111
|
+
- lib/process_decl_iva/version.rb
|
112
|
+
- process_decl_iva.gemspec
|
113
|
+
homepage: https://process-decl-IVA.github.io
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
homepage_uri: https://process-decl-IVA.github.io
|
118
|
+
source_code_uri: https://process-decl-IVA.github.io
|
119
|
+
changelog_uri: https://process-decl-IVA.github.io/blob/main/CHANGELOG.md
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 2.6.0
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubygems_version: 3.4.10
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Script para auxiliar no preenchimento da Declaração periódica do IVA
|
139
|
+
test_files: []
|