caesar-tax 0.1.1 → 0.1.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/lib/caesar.rb +48 -1
- data/lib/qr_code.rb +28 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f02bbb2a55c94c2df8c5295cca036594d4cca467572aedb98fca6f198208f076
|
4
|
+
data.tar.gz: 7b8a0f54f4ffac6623614449df9d37fec11bbcb7af9f707c57279a3841538d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb596a7bd644dc5fb7a2dffb638ac9dcb1bfe6996c17c6ff190f42b0a7578d8e5483fa04a6e02e2436143d586a808a2fd5a0a738df5b93a915710c81dff5be2
|
7
|
+
data.tar.gz: 5a749fbcd1f2c0ded30186c31a2b040c945bfb107accb069c00b7326a0119077e5ce571369e7783830c487aaee00c7b8fd9003fa7b395f8e77670143a5c9796a
|
data/lib/caesar.rb
CHANGED
@@ -7,6 +7,8 @@ require 'verhoeff'
|
|
7
7
|
require 'qr_code'
|
8
8
|
|
9
9
|
class Caesar
|
10
|
+
include QrGenerator
|
11
|
+
|
10
12
|
def initialize
|
11
13
|
@seed = nil
|
12
14
|
@authorization_number = nil
|
@@ -15,6 +17,12 @@ class Caesar
|
|
15
17
|
@transaction_date = nil
|
16
18
|
@amount_total = nil
|
17
19
|
@control_code = nil
|
20
|
+
@owner_document = nil
|
21
|
+
@amount_base = nil
|
22
|
+
@amount_discount = 0
|
23
|
+
@amount_rate = 0
|
24
|
+
@amount_taxed = 0
|
25
|
+
@amount_fiscal = 0
|
18
26
|
end
|
19
27
|
|
20
28
|
# @param [String] seed_str
|
@@ -64,6 +72,41 @@ class Caesar
|
|
64
72
|
self
|
65
73
|
end
|
66
74
|
|
75
|
+
# @param [Float] amount
|
76
|
+
# @return [Caesar]
|
77
|
+
def amount_discount(amount)
|
78
|
+
@amount_discount = amount
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
# @param [Float] amount
|
83
|
+
# @return [Caesar]
|
84
|
+
def amount_fiscal(amount)
|
85
|
+
@amount_fiscal = amount
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param [Float] amount
|
90
|
+
# @return [Caesar]
|
91
|
+
def amount_rate(amount)
|
92
|
+
@amount_rate = amount
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param [Float] amount
|
97
|
+
# @return [Caesar]
|
98
|
+
def amount_taxed(amount)
|
99
|
+
@amount_taxed = amount
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param [Float] number
|
104
|
+
# @return [Caesar]
|
105
|
+
def owner_document(number)
|
106
|
+
@owner_document = number
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
67
110
|
# @return [String]
|
68
111
|
attr_reader :control_code
|
69
112
|
|
@@ -106,6 +149,10 @@ class Caesar
|
|
106
149
|
self
|
107
150
|
end
|
108
151
|
|
152
|
+
def str_format
|
153
|
+
"#{@owner_document}|#{@invoice_number}|#{@authorization_number}|#{@transaction_date}|#{@amount_total}|#{@amount_base}|#{@control_code}|#{@client_document}|#{@amount_rate}|#{@amount_taxed}|#{@amount_fiscal}|#{@amount_discount}"
|
154
|
+
end
|
155
|
+
|
109
156
|
private
|
110
157
|
|
111
158
|
# @param [String] message_alleged
|
@@ -179,4 +226,4 @@ class Caesar
|
|
179
226
|
def control_exception_for(value)
|
180
227
|
raise ArgumentError, "#{value.inspect} is Nil" if value.nil?
|
181
228
|
end
|
182
|
-
end
|
229
|
+
end
|
data/lib/qr_code.rb
CHANGED
@@ -1,4 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
3
|
+
require 'rqrcode'
|
4
|
+
|
5
|
+
# Extension for Caesar
|
2
6
|
module QrGenerator
|
7
|
+
@qr_code = nil
|
8
|
+
|
9
|
+
# @return [Object]
|
10
|
+
def to_qr
|
11
|
+
control_exception_for(@owner_document)
|
12
|
+
@qr_code = RQRCode::QRCode.new(str_format)
|
13
|
+
end
|
3
14
|
|
4
|
-
|
15
|
+
# @param [String] path
|
16
|
+
# @return [Object]
|
17
|
+
def save(path)
|
18
|
+
to_qr
|
19
|
+
png = @qr_code.as_png(bit_depth: 1,
|
20
|
+
border_modules: 4,
|
21
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
22
|
+
color: 'black',
|
23
|
+
file: nil,
|
24
|
+
fill: 'white',
|
25
|
+
module_px_size: 6,
|
26
|
+
resize_exactly_to: false,
|
27
|
+
resize_gte_to: false,
|
28
|
+
size: 200)
|
29
|
+
IO.write(path, png.to_s)
|
30
|
+
end
|
31
|
+
end
|