sunat_books 0.0.1 → 0.0.2
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 +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +15 -0
- data/.travis.yml +9 -0
- data/Gemfile +2 -4
- data/Gemfile.lock +51 -16
- data/Makefile +2 -1
- data/README.mkd +8 -6
- data/lib/books/base.rb +70 -150
- data/lib/books/buys.rb +34 -82
- data/lib/books/count_sum.rb +4 -2
- data/lib/books/diary_entries.rb +112 -0
- data/lib/books/layouts/sales.yml +2 -2
- data/lib/books/locale.rb +6 -0
- data/lib/books/locales/es.yml +65 -0
- data/lib/books/page.rb +44 -0
- data/lib/books/pages_utils.rb +85 -0
- data/lib/books/sales.rb +40 -81
- data/lib/books/simplified_diary.rb +65 -117
- data/lib/books/utils.rb +105 -0
- data/lib/csv_books/base.rb +67 -0
- data/lib/csv_books/option_error.rb +6 -0
- data/lib/ple_books/base.rb +37 -22
- data/lib/ple_books/buys.rb +16 -13
- data/lib/ple_books/layouts/buys.yml +3 -3
- data/lib/ple_books/layouts/sales.yml +1 -1
- data/lib/ple_books/sales.rb +10 -4
- data/lib/sunat_books.rb +8 -4
- data/sunat_books.gemspec +13 -6
- data/test/books/base_test.rb +6 -0
- data/test/books/buys_test.rb +57 -0
- data/test/books/page_test.rb +24 -0
- data/test/books/pages_utils_test.rb +78 -0
- data/test/books/utils_test.rb +42 -0
- data/test/csv_books/base_test.rb +43 -0
- data/test/fixtures/base.rb +11 -0
- data/test/fixtures/company.rb +5 -0
- data/test/fixtures/ticket.rb +4 -9
- data/test/helper.rb +11 -13
- data/test/ple_books/buys_test.rb +49 -0
- data/test/ple_books_test.rb +34 -83
- metadata +109 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c52f9a2c0415858d8973ce2cd907c4e1852601
|
4
|
+
data.tar.gz: 6314b7690b3b93639de8f958c2b6d49c12b551a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d2c0b476c4d8781cdc4c961d2de5eed2462266b092e0747ba91cf8c42626da35666d6578bb3e126e850c7ddb84771703395191cb99f5a6681f241a7e18f605d
|
7
|
+
data.tar.gz: 4048c78841241a490d2b43101ca4cc259d7dd9186fb94e7957afef346a945a6c987e8a97fee7d70561359100cee0d09c1b043af91011673ef9c5f9e90be366f5
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Style/StringLiterals:
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
SupportedStyles:
|
8
|
+
- single_quotes
|
9
|
+
- double_quotes
|
10
|
+
|
11
|
+
Style/StringLiteralsInInterpolation:
|
12
|
+
EnforcedStyle: single_quotes
|
13
|
+
SupportedStyles:
|
14
|
+
- single_quotes
|
15
|
+
- double_quotes
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,47 +2,82 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
sunat_books (0.0.1)
|
5
|
-
activesupport
|
6
|
-
i18n
|
7
|
-
prawn
|
5
|
+
activesupport (> 4.1)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
prawn (~> 2.0)
|
8
|
+
prawn-table (~> 0.2)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
|
13
|
+
Ascii85 (1.0.2)
|
14
|
+
activesupport (5.0.2)
|
13
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
16
|
i18n (~> 0.7)
|
15
17
|
minitest (~> 5.1)
|
16
18
|
tzinfo (~> 1.1)
|
19
|
+
afm (0.2.2)
|
20
|
+
ast (2.3.0)
|
17
21
|
clap (1.0.0)
|
18
22
|
coderay (1.1.1)
|
19
|
-
concurrent-ruby (1.0.
|
23
|
+
concurrent-ruby (1.0.5)
|
20
24
|
cutest (1.2.3)
|
21
25
|
clap
|
22
|
-
|
26
|
+
faker (1.7.3)
|
27
|
+
i18n (~> 0.5)
|
28
|
+
hashery (2.1.2)
|
29
|
+
i18n (0.8.1)
|
23
30
|
method_source (0.8.2)
|
24
|
-
minitest (5.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
minitest (5.10.1)
|
32
|
+
parser (2.4.0.0)
|
33
|
+
ast (~> 2.2)
|
34
|
+
pdf-core (0.7.0)
|
35
|
+
pdf-inspector (1.2.1)
|
36
|
+
pdf-reader (~> 1.0)
|
37
|
+
pdf-reader (1.4.1)
|
38
|
+
Ascii85 (~> 1.0.0)
|
39
|
+
afm (~> 0.2.1)
|
40
|
+
hashery (~> 2.0)
|
41
|
+
ruby-rc4
|
42
|
+
ttfunk
|
43
|
+
powerpack (0.1.1)
|
44
|
+
prawn (2.2.2)
|
45
|
+
pdf-core (~> 0.7.0)
|
46
|
+
ttfunk (~> 1.5)
|
47
|
+
prawn-table (0.2.2)
|
48
|
+
prawn (>= 1.3.0, < 3.0.0)
|
29
49
|
pry (0.10.4)
|
30
50
|
coderay (~> 1.1.0)
|
31
51
|
method_source (~> 0.8.1)
|
32
52
|
slop (~> 3.4)
|
53
|
+
rainbow (2.2.2)
|
54
|
+
rake
|
55
|
+
rake (12.0.0)
|
56
|
+
rubocop (0.48.1)
|
57
|
+
parser (>= 2.3.3.1, < 3.0)
|
58
|
+
powerpack (~> 0.1)
|
59
|
+
rainbow (>= 1.99.1, < 3.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
62
|
+
ruby-progressbar (1.8.1)
|
63
|
+
ruby-rc4 (0.1.5)
|
33
64
|
slop (3.6.0)
|
34
|
-
thread_safe (0.3.
|
35
|
-
ttfunk (1.
|
65
|
+
thread_safe (0.3.6)
|
66
|
+
ttfunk (1.5.0)
|
36
67
|
tzinfo (1.2.2)
|
37
68
|
thread_safe (~> 0.1)
|
69
|
+
unicode-display_width (1.2.1)
|
38
70
|
|
39
71
|
PLATFORMS
|
40
72
|
ruby
|
41
73
|
|
42
74
|
DEPENDENCIES
|
43
|
-
cutest
|
44
|
-
|
75
|
+
cutest (~> 1.2)
|
76
|
+
faker (~> 1.7)
|
77
|
+
pdf-inspector (~> 1.2.0)
|
78
|
+
pry (~> 0.10)
|
79
|
+
rubocop (~> 0.48)
|
45
80
|
sunat_books!
|
46
81
|
|
47
82
|
BUNDLED WITH
|
48
|
-
1.
|
83
|
+
1.14.6
|
data/Makefile
CHANGED
data/README.mkd
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Sunat Books
|
2
|
-
|
2
|
+
[![Gem Version][rubygems-image]][rubygems-url]
|
3
|
+
[![Build Status][travis-image]][travis-url]
|
4
|
+
|
5
|
+
> A ruby gem for get accounting books for [SUNAT](https://www.sunat.gob.pe)
|
3
6
|
|
4
7
|
## Install
|
5
8
|
You can install via
|
@@ -30,8 +33,7 @@ to get the txt file for electronic books
|
|
30
33
|
ple = PleBooks::Buys.new(ruc, tickets, month, year)
|
31
34
|
```
|
32
35
|
|
33
|
-
|
34
|
-
https://
|
35
|
-
|
36
|
-
|
37
|
-
https://github.com/prawnpdf/prawn/issues/893
|
36
|
+
[rubygems-image]: https://badge.fury.io/rb/sunat_books.svg
|
37
|
+
[rubygems-url]: https://badge.fury.io/rb/sunat_books
|
38
|
+
[travis-image]: https://travis-ci.org/ccarruitero/sunat_books.svg?branch=master
|
39
|
+
[travis-url]: https://travis-ci.org/ccarruitero/sunat_books
|
data/lib/books/base.rb
CHANGED
@@ -1,86 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "prawn"
|
4
|
+
require "prawn/table"
|
5
|
+
require "yaml"
|
6
|
+
require_relative "utils"
|
7
|
+
require_relative "locale"
|
4
8
|
|
5
9
|
module Books
|
6
10
|
class Base < Prawn::Document
|
7
|
-
include
|
8
|
-
|
9
|
-
MONTHS = { 1 => "Enero", 2 => "Febrero", 3 => "marzo", 4 => "abril",
|
10
|
-
5 => "mayo", 6 => "junio", 7 => "julio", 8 => "agosto",
|
11
|
-
9 => "setiembre", 10 => "octubre", 11 => "noviembre",
|
12
|
-
12 => "diciembre" }
|
13
|
-
|
14
|
-
def formated_number float
|
15
|
-
number_to_currency(float, unit: '')
|
16
|
-
end
|
11
|
+
include Utils
|
12
|
+
include Prawn::Table::Interface
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
if a[key] != nil
|
21
|
-
options[:cell_style] = options[:cell_style].merge({align: a[key][0].to_sym})
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def txt txt
|
27
|
-
text txt, size: 8
|
28
|
-
end
|
29
|
-
|
30
|
-
def sub_head hash, book_name, blayout
|
31
|
-
arr = nil
|
32
|
-
current_key = nil
|
33
|
-
column_widths = {}
|
14
|
+
def sub_head(hash, book_name, blayout)
|
15
|
+
arr, current_key = nil
|
34
16
|
hash.each do |key, value|
|
35
17
|
k = I18n.t("books.#{book_name}.#{key}").mb_chars.upcase.to_s
|
36
|
-
v = value.collect
|
37
|
-
|
18
|
+
v = value.collect do |s|
|
19
|
+
I18n.t("books.#{book_name}.#{s}").mb_chars.upcase.to_s
|
20
|
+
end
|
21
|
+
arr = [[{ content: k, colspan: value.length }], v]
|
38
22
|
current_key = key
|
39
23
|
end
|
40
24
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
if column_widths.size != 0
|
50
|
-
multihead = make_table( arr, cell_style: {borders: [], size: 5, align: :center},
|
51
|
-
column_widths: column_widths) do
|
52
|
-
cells.padding = 1
|
53
|
-
end
|
54
|
-
else
|
55
|
-
multihead = make_table( arr,
|
56
|
-
cell_style: {borders: [], size: 5, width: 22, padding: 1, align: :center})
|
57
|
-
end
|
25
|
+
sub_head_table(blayout["widths"], arr, current_key)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sub_head_table(widths, arr, key)
|
29
|
+
column_widths = get_column_widths(widths, key)
|
30
|
+
options = sub_head_options(column_widths)
|
31
|
+
make_table(arr, options)
|
58
32
|
end
|
59
33
|
|
60
|
-
def
|
61
|
-
|
34
|
+
def sub_head_options(column_widths)
|
35
|
+
options = { cell_style: {
|
36
|
+
borders: [], size: 5, align: :center, padding: 1
|
37
|
+
} }
|
38
|
+
add_widths(column_widths, options, 22)
|
39
|
+
options
|
62
40
|
end
|
63
41
|
|
64
|
-
def book_title
|
42
|
+
def book_title(title)
|
65
43
|
text title, align: :center, size: 8
|
66
44
|
end
|
67
45
|
|
68
|
-
def book_header
|
46
|
+
def book_header(period, ruc, name, title = nil)
|
69
47
|
move_down 5
|
70
|
-
|
71
|
-
#txt "RUC: #{ruc}"
|
72
|
-
#txt "APELLIDOS Y NOMBRES, DENOMINACIÓN O RAZÓN SOCIAL: #{name.upcase}"
|
73
|
-
txt "#{name.upcase}"
|
48
|
+
txt name.to_s.upcase
|
74
49
|
txt "RUC: #{ruc}"
|
75
50
|
book_title("#{title} - #{period}")
|
76
51
|
move_down 5
|
77
52
|
end
|
78
53
|
|
79
|
-
def
|
80
|
-
|
54
|
+
def prawn_header(title, period, company)
|
55
|
+
repeat(:all) do
|
56
|
+
canvas do
|
57
|
+
bounding_box([bounds.left + 10, bounds.top - 10], width: 800) do
|
58
|
+
book_header period, company.ruc, company.name, title
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
81
62
|
end
|
82
63
|
|
83
|
-
def table_head
|
64
|
+
def table_head(fields, book_name, layout)
|
84
65
|
thead = []
|
85
66
|
fields.each do |h|
|
86
67
|
if h.class == Hash
|
@@ -93,65 +74,43 @@ module Books
|
|
93
74
|
thead
|
94
75
|
end
|
95
76
|
|
96
|
-
def table_body
|
77
|
+
def table_body(fields, ticket, widths, aligns)
|
97
78
|
tbody = []
|
98
79
|
fields.each do |f|
|
99
|
-
if f.
|
100
|
-
f
|
101
|
-
v = value.collect do |s|
|
102
|
-
begin
|
103
|
-
value = ticket.send(s)
|
104
|
-
value = formated_number(value) if value.class == BigDecimal
|
105
|
-
rescue
|
106
|
-
value = ""
|
107
|
-
end
|
108
|
-
value
|
109
|
-
end
|
110
|
-
options = {cell_style: {borders: [], size: 5}}
|
111
|
-
column_widths = nil
|
112
|
-
if !widths.nil?
|
113
|
-
widths.each do |w|
|
114
|
-
if w[key] != nil
|
115
|
-
column_widths = w[key].flatten
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
if column_widths != nil
|
120
|
-
options = options.merge({column_widths: column_widths})
|
121
|
-
else
|
122
|
-
options[:cell_style] = options[:cell_style].merge({width: 28})
|
123
|
-
end
|
124
|
-
if !aligns.nil?
|
125
|
-
add_align(aligns, options, key)
|
126
|
-
end
|
127
|
-
arr = make_table( [v], options)
|
128
|
-
tbody << arr
|
129
|
-
end
|
80
|
+
if f.is_a? Hash
|
81
|
+
table_hash(f, ticket, tbody, widths, aligns)
|
130
82
|
else
|
131
|
-
|
132
|
-
value = ticket.send(f)
|
133
|
-
rescue
|
134
|
-
value = ""
|
135
|
-
end
|
136
|
-
value = formated_number(value) if value.class == BigDecimal
|
137
|
-
tbody << value
|
83
|
+
tbody << field_value(ticket, f)
|
138
84
|
end
|
139
85
|
end
|
140
86
|
tbody
|
141
87
|
end
|
142
88
|
|
89
|
+
def table_hash(f, ticket, tbody, widths, aligns)
|
90
|
+
options = { cell_style: { borders: [], size: 5 } }
|
91
|
+
|
92
|
+
f.each do |key, value|
|
93
|
+
v = value.collect do |s|
|
94
|
+
value = field_value(ticket, s)
|
95
|
+
end
|
96
|
+
|
97
|
+
column_widths = get_column_widths(widths, key)
|
98
|
+
add_widths(column_widths, options, 28)
|
99
|
+
add_align(aligns, options, key) unless aligns.nil?
|
100
|
+
tbody << make_table([v], options)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
143
104
|
# diary
|
144
|
-
def get_counts
|
145
|
-
|
146
|
-
arr = arr.flatten.uniq.sort
|
105
|
+
def get_counts(tickets)
|
106
|
+
tickets.map(&:uniq_counts).flatten.uniq.sort
|
147
107
|
end
|
148
108
|
|
149
|
-
def get_mother_counts
|
150
|
-
|
151
|
-
arr = arr.flatten.uniq.sort
|
109
|
+
def get_mother_counts(tickets)
|
110
|
+
tickets.map(&:uniq_mother_counts).flatten.uniq.sort
|
152
111
|
end
|
153
112
|
|
154
|
-
def get_value
|
113
|
+
def get_value(ticket, count)
|
155
114
|
# active_amount = ticket.get_amount_by_position(count)
|
156
115
|
# pasive_amount = ticket.get_amount_by_position(count, false)
|
157
116
|
active_amount = ticket.get_amount_by_mother_count(count)
|
@@ -159,54 +118,15 @@ module Books
|
|
159
118
|
# if count === '401' && ticket.operation_type == 'compras'
|
160
119
|
# amount = amount * (-1)
|
161
120
|
# end
|
162
|
-
|
121
|
+
active_amount - pasive_amount
|
163
122
|
end
|
164
123
|
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
count_sums = row_counts.map { |count| CountSum.new(count) }
|
169
|
-
|
170
|
-
# get totals
|
171
|
-
tickets.each do |ticket|
|
172
|
-
count_sums.each do |count_sum|
|
173
|
-
count_sum.add get_value(ticket, count_sum.count)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# get ordered row
|
178
|
-
row_data = []
|
179
|
-
counts.each_with_index do |count, i|
|
180
|
-
sum_count = nil
|
181
|
-
count_sums.each do |count_sum|
|
182
|
-
sum_count = count_sum if count_sum.count == count
|
183
|
-
end
|
184
|
-
|
185
|
-
if sum_count
|
186
|
-
value = sum_count.total
|
187
|
-
else
|
188
|
-
value = 0
|
189
|
-
end
|
190
|
-
total_sums[i].add value
|
191
|
-
row_data << { content: formated_number(value), align: :right }
|
192
|
-
end
|
193
|
-
row_data
|
194
|
-
end
|
195
|
-
|
196
|
-
def make_sub_table content, width=nil
|
197
|
-
options = {cell_style: {width: width, size: 5, borders: [], align: :right}}
|
124
|
+
def make_sub_table(content, width = nil)
|
125
|
+
options = { cell_style: { width: width, size: 5, borders: [],
|
126
|
+
align: :right } }
|
198
127
|
content_row = []
|
199
|
-
content.each {|c| content_row << formated_number(c) }
|
200
|
-
make_table([content_row],options)
|
201
|
-
end
|
202
|
-
|
203
|
-
# Utils
|
204
|
-
def get_date year, month, day
|
205
|
-
parse_day(Date.new(year.to_i, month.to_i, day))
|
206
|
-
end
|
207
|
-
|
208
|
-
def parse_day day
|
209
|
-
day.strftime("%d-%m").to_s
|
128
|
+
content.each { |c| content_row << formated_number(c) }
|
129
|
+
make_table([content_row], options)
|
210
130
|
end
|
211
131
|
end
|
212
132
|
end
|
data/lib/books/buys.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "pages_utils"
|
2
5
|
|
3
6
|
module Books
|
4
7
|
class Buys < Base
|
5
|
-
|
8
|
+
include PagesUtils
|
6
9
|
|
7
10
|
def initialize(company, tickets, view, month, year)
|
8
11
|
# company => an object that respond to ruc and name methods
|
@@ -15,105 +18,54 @@ module Books
|
|
15
18
|
@company = company
|
16
19
|
@period = get_period(month, year)
|
17
20
|
@tickets = tickets
|
18
|
-
@pages = {}
|
19
21
|
@book_name = self.class.name.downcase.sub("books::", "")
|
20
22
|
dir = File.dirname(__FILE__)
|
21
23
|
@blayout = YAML.load_file("#{dir}/layouts/#{@book_name}.yml")
|
22
24
|
@page_max = 27
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
prawn_book
|
27
|
+
end
|
28
|
+
|
29
|
+
def prawn_book
|
30
|
+
prawn_header "REGISTRO DE COMPRAS", @period, @company
|
31
|
+
@pages = []
|
31
32
|
|
32
|
-
bounding_box([bounds.left + 3, bounds.top - 45], width: 800,
|
33
|
+
bounding_box([bounds.left + 3, bounds.top - 45], width: 800,
|
34
|
+
height: 530) do
|
35
|
+
setup_pages(@pages, @tickets.length, @page_max)
|
33
36
|
book_body
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
|
-
def final_row
|
38
|
-
[
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def final_row(foot_line_text, page)
|
41
|
+
[{ content: foot_line_text, colspan: 5 },
|
42
|
+
make_sub_table([page.bi_sum, page.igv_sum], 32),
|
43
|
+
make_sub_table([zero, zero], 25),
|
44
|
+
make_sub_table([zero, zero], 25),
|
45
|
+
formated_number(page.non_taxable),
|
46
|
+
zero, zero,
|
47
|
+
formated_number(page.total_sum)]
|
45
48
|
end
|
46
49
|
|
47
50
|
def book_body
|
48
|
-
# get total number of tickets
|
49
|
-
length = @tickets.length
|
50
|
-
page_num = (length / 27.0).ceil
|
51
|
-
page_num.times do |i|
|
52
|
-
pages[i + 1] = {
|
53
|
-
page_number: i + 1,
|
54
|
-
length: 0,
|
55
|
-
bi_sum: BigDecimal(0)
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
51
|
move_down 5
|
60
|
-
fields = @blayout["headers"]
|
61
|
-
widths = @blayout["widths"]
|
62
|
-
aligns = @blayout["align"]
|
63
52
|
data = []
|
53
|
+
fields = @blayout["headers"]
|
64
54
|
data << table_head(fields, @book_name, @blayout)
|
65
|
-
|
66
|
-
|
67
|
-
bi_sum = BigDecimal(0)
|
68
|
-
igv_sum = BigDecimal(0)
|
69
|
-
total_sum = BigDecimal(0)
|
70
|
-
non_taxable = BigDecimal(0)
|
71
|
-
|
72
|
-
|
73
|
-
if length > 0
|
74
|
-
@tickets.each do |ticket|
|
75
|
-
|
76
|
-
if @pages[n][:length] < @page_max
|
77
|
-
page = @pages[n]
|
78
|
-
page[:length] += 1
|
79
|
-
else
|
80
|
-
data << final_row('VIENEN', @pages[n])
|
81
|
-
|
82
|
-
n += 1
|
83
|
-
page = @pages[n]
|
84
|
-
page[:length] += 2
|
85
|
-
end
|
86
|
-
|
87
|
-
data << table_body(fields, ticket, widths, aligns)
|
88
|
-
|
89
|
-
bi_sum += ticket.taxable_to_taxable_export_bi
|
90
|
-
igv_sum += ticket.taxable_to_taxable_export_igv
|
91
|
-
total_sum += ticket.total_operation_buys
|
92
|
-
non_taxable += ticket.non_taxable unless ticket.non_taxable.nil?
|
93
|
-
page[:bi_sum] = bi_sum.round(2)
|
94
|
-
page[:igv_sum] = igv_sum.round(2)
|
95
|
-
page[:total_sum] = total_sum.round(2)
|
96
|
-
page[:non_taxable] = non_taxable.round(2)
|
97
|
-
if page[:length] == @page_max && @tickets.last != ticket
|
98
|
-
data << final_row('VAN', page)
|
99
|
-
elsif @tickets.last == ticket
|
100
|
-
data << final_row('TOTAL', page)
|
101
|
-
end
|
102
|
-
end
|
55
|
+
if @tickets.length.positive?
|
56
|
+
row_data(data, @blayout["widths"], @blayout["align"], fields, "buys")
|
103
57
|
else
|
104
|
-
data
|
105
|
-
@pages[n] = {}
|
106
|
-
page = @pages[n]
|
107
|
-
page[:bi_sum] = zero
|
108
|
-
page[:igv_sum] = zero
|
109
|
-
page[:total_sum] = zero
|
110
|
-
page[:non_taxable] = zero
|
58
|
+
not_moviment_page(data)
|
111
59
|
end
|
60
|
+
render_prawn_table(data)
|
61
|
+
end
|
112
62
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
63
|
+
def render_prawn_table(data)
|
64
|
+
table(data, header: true, cell_style: { borders: [], size: 5,
|
65
|
+
align: :right },
|
66
|
+
column_widths: { 0 => 22, 1 => 35, 2 => 30, 8 => 30,
|
67
|
+
10 => 30, 9 => 22, 11 => 33, 12 => 33 }) do
|
68
|
+
row(0).borders = %i[bottom top]
|
117
69
|
end
|
118
70
|
end
|
119
71
|
end
|
data/lib/books/count_sum.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Books
|
2
4
|
class CountSum
|
3
|
-
def initialize
|
5
|
+
def initialize(count_number, initial_value = BigDecimal(0))
|
4
6
|
@sum = initial_value
|
5
7
|
@count_number = count_number
|
6
8
|
end
|
7
9
|
|
8
|
-
def add
|
10
|
+
def add(value)
|
9
11
|
@sum += value
|
10
12
|
end
|
11
13
|
|