gerador_nfe 1.0.0
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 +7 -0
- data/lib/nfe.rb +31 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1b135ec6b33d58f2b233b9b1a7e11628913bd7baf407533b32f09f02dea57de7
|
4
|
+
data.tar.gz: 66111b465aacb490c48c20bb3a509aaa03b3806e153880283c6df6ec0ed7a427
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52143b686dcc26ec462cfd84e663ac40254ec4fe0ac20a53194f9c567372e18954c8282d47ba30ae4a63b3592f74c94587d751c827db12fff57e42c5786203ef
|
7
|
+
data.tar.gz: 86538cfd2d8e57f06004ce79d2705bee1cefcc79466a67f20b511ff20e234b2af2dbb40787f15aa7e0dc2158a755c8cccdb63e0629f46eb5d98575066c366c1a
|
data/lib/nfe.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class NFE
|
2
|
+
def self.valid?(key44)
|
3
|
+
return false if key44.blank?
|
4
|
+
dig = key44.split("").last.to_i
|
5
|
+
dig == digit(key44)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.digit(key44)
|
9
|
+
dig = key44.split("").last.to_i
|
10
|
+
key = key44.split("")[0..42].map(&:to_i)
|
11
|
+
multipliers = ([2,3,4,5,6,7,8,9] * 6).reverse
|
12
|
+
multipliers.shift(5)
|
13
|
+
|
14
|
+
key_multiplied = []
|
15
|
+
key[0..key.size-1].size.times do |index|
|
16
|
+
key_multiplied << key[index] * multipliers[index]
|
17
|
+
end
|
18
|
+
rest = key_multiplied.sum % 11
|
19
|
+
return 0 if rest == 0 || rest == 1
|
20
|
+
11 - rest
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.generate
|
24
|
+
randon_digits_valid = false
|
25
|
+
while !randon_digits_valid do
|
26
|
+
randon_digits = 43.times.map{ Random.rand(0..9) }.join
|
27
|
+
randon_digits_valid = digit([randon_digits, 0].join)
|
28
|
+
end
|
29
|
+
[randon_digits, digit([randon_digits, 0].join)].join
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gerador_nfe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luiz Filipe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Gerador e validador de cahves nfe
|
14
|
+
email: luizfilipeneves@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/nfe.rb
|
20
|
+
homepage: https://rubygems.org/gems/gerador_nfe
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.0.6
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Gerador e validador de chaves nfe
|
43
|
+
test_files: []
|