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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/caesar.rb +48 -1
  3. data/lib/qr_code.rb +28 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c6687a2794b5eea12233ac557c1287615de35dc5e9f0b7ecb3d61c4c84eb19b
4
- data.tar.gz: 3d9e9981463b69ee793554f1bf5a1ec5420f9008903975c5a8da514174b74a76
3
+ metadata.gz: f02bbb2a55c94c2df8c5295cca036594d4cca467572aedb98fca6f198208f076
4
+ data.tar.gz: 7b8a0f54f4ffac6623614449df9d37fec11bbcb7af9f707c57279a3841538d83
5
5
  SHA512:
6
- metadata.gz: 4b024cc4aa91a238c62a47dc0331321b1d869fec31254d07f33e0b8653ea69c9eac99746f0ded6f7c75be67d3415e295ecdba41ecaf5eee3f68310ad896b4d8f
7
- data.tar.gz: 3c9ce75f858e2fbda53fbc3bfd1ce228015363fd0c77ab130a8d27bd539739bdde54aa65367af337719220e9802e8eb0e6a64d9749304969b2812b4b90a2d760
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
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caesar-tax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Daniel Coca Calvimontes