facturacr 1.0 → 1.0.1
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 +1 -0
- data/lib/facturacr/data_provider.rb +1 -1
- data/lib/facturacr/document.rb +1 -1
- data/lib/facturacr/document/summary.rb +5 -5
- data/lib/facturacr/signed_document.rb +1 -1
- data/lib/facturacr/signer/signer.rb +12 -4
- data/lib/facturacr/version.rb +1 -1
- data/lib/facturacr/xml_document.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 784afc0b9e27eeef2d3dbd6770bc37c74c268a4e
|
4
|
+
data.tar.gz: 0c1db15bd3360912262cf5ec191432464ee6a9f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e2da292a67d329622eeccd529d0f19232f0c028fc5dd27d53c1184d748f8b121739df10c1c6e392db14566415ad979c9c8aa3cc97c8a69e3f5007f17ccc4a6c
|
7
|
+
data.tar.gz: 3d88d6d3e26ccf50d3ec7f0a9db6a6f83e160ea61eab479a12a3c1ae54c4eaf9ad24d9a0897ee52c0949498d6b56dd78d330fe05f94da76875230a8506a51ce3
|
data/.gitignore
CHANGED
@@ -8,7 +8,7 @@ module FE
|
|
8
8
|
def initialize(source, data)
|
9
9
|
source = source.to_s.to_sym
|
10
10
|
raise ArgumentError, "source (#{source}) is not valid" if !SOURCES.include?(source)
|
11
|
-
raise ArgumentError, "#{data} does not exist" if
|
11
|
+
raise ArgumentError, "#{data} does not exist" if source.eql?(:file) && !File.exists?(data)
|
12
12
|
|
13
13
|
if source.eql?(:string)
|
14
14
|
@contents = data
|
data/lib/facturacr/document.rb
CHANGED
@@ -42,7 +42,7 @@ module FE
|
|
42
42
|
attr_accessor :serial, :date, :issuer, :receiver, :condition, :credit_term,
|
43
43
|
:payment_type, :service_type, :reference_information,
|
44
44
|
:regulation, :number, :document_type, :security_code,
|
45
|
-
:items, :references, :namespaces, :summary, :document_situation
|
45
|
+
:items, :references, :namespaces, :summary, :document_situation, :headquarters, :terminal
|
46
46
|
|
47
47
|
validates :date, presence: true
|
48
48
|
validates :number, presence: true
|
@@ -53,11 +53,11 @@ module FE
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def totals_ok?
|
56
|
-
errors[:taxable_total] << "invalid amount"
|
57
|
-
errors[:exent_total] << "invalid amount"
|
58
|
-
errors[:subtotal] << "invalid amount"
|
59
|
-
errors[:gross_total] << "invalid amount"
|
60
|
-
errors[:net_total] << "invalid amount"
|
56
|
+
errors[:taxable_total] << "invalid amount" if (@taxable_total - (@services_taxable_total + @goods_taxable_total).round(5)).abs > 0.0005
|
57
|
+
errors[:exent_total] << "invalid amount" if (@exent_total - (@services_exent_total + @goods_exent_total).round(5)).abs > 0.0005
|
58
|
+
errors[:subtotal] << "invalid amount" if (@subtotal - (@taxable_total + @exent_total).round(5)).abs > 0.0005
|
59
|
+
errors[:gross_total] << "invalid amount" if (@gross_total - (@subtotal - @discount_total).round(5)).abs > 0.0005
|
60
|
+
errors[:net_total] << "invalid amount" if (@net_total - (@gross_total + @tax_total).round(5)).abs > 0.0005
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -8,7 +8,7 @@ module FE
|
|
8
8
|
# Backwards compatibility with v0.1.4
|
9
9
|
if xml_provider.is_a?(String)
|
10
10
|
raise ArgumentError, "File: #{xml_provider} does not exist" unless File.exists?(xml_provider)
|
11
|
-
xml_provider =
|
11
|
+
xml_provider = FE::DataProvider.new(:file, xml_provider)
|
12
12
|
end
|
13
13
|
raise ArgumentError, "Invalid Argument" unless xml_provider.is_a?(FE::DataProvider)
|
14
14
|
|
@@ -23,7 +23,14 @@ module FE
|
|
23
23
|
XADES = "http://uri.etsi.org/01903/v1.3.2#"
|
24
24
|
XADES141 = "http://uri.etsi.org/01903/v1.4.1#"
|
25
25
|
SIGNATURE_POLICY = "https://tribunet.hacienda.go.cr/docs/esquemas/2016/v4/Resolucion%20Comprobantes%20Electronicos%20%20DGT-R-48-2016.pdf"
|
26
|
-
|
26
|
+
|
27
|
+
XMLNS_MAP = {
|
28
|
+
"FacturaElectronica" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica",
|
29
|
+
"NotaCreditoElectronica" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/notaCreditoElectronica",
|
30
|
+
"TiqueteElectronico" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/tiqueteElectronico",
|
31
|
+
"NotaDebitoElectronica" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/notaDebitoElectronica",
|
32
|
+
"MensajeReceptor" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/mensajeReceptor"
|
33
|
+
}
|
27
34
|
|
28
35
|
def initialize(args = {})
|
29
36
|
document_provider = args[:xml_provider]
|
@@ -36,6 +43,7 @@ module FE
|
|
36
43
|
@p12 = OpenSSL::PKCS12.new(key_provider.contents,args[:pin])
|
37
44
|
@x509 = @p12.certificate
|
38
45
|
@output_path = args[:output_path]
|
46
|
+
@document_tag = @doc.elements.first.name
|
39
47
|
end
|
40
48
|
|
41
49
|
def sign
|
@@ -88,7 +96,7 @@ module FE
|
|
88
96
|
def build_key_info_element
|
89
97
|
builder = Nokogiri::XML::Builder.new
|
90
98
|
attributes = {
|
91
|
-
"xmlns" =>
|
99
|
+
"xmlns" => XMLNS_MAP[@document_tag],
|
92
100
|
"xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
|
93
101
|
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
94
102
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
@@ -115,7 +123,7 @@ module FE
|
|
115
123
|
signing_time = DateTime.now.rfc3339
|
116
124
|
builder = Nokogiri::XML::Builder.new
|
117
125
|
attributes = {
|
118
|
-
"xmlns"=>
|
126
|
+
"xmlns"=>XMLNS_MAP[@document_tag],
|
119
127
|
"xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
|
120
128
|
"xmlns:xades" => "http://uri.etsi.org/01903/v1.3.2#",
|
121
129
|
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
@@ -168,7 +176,7 @@ module FE
|
|
168
176
|
|
169
177
|
builder = builder = Nokogiri::XML::Builder.new
|
170
178
|
attributes = {
|
171
|
-
"xmlns"=>
|
179
|
+
"xmlns"=>XMLNS_MAP[@document_tag],
|
172
180
|
"xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
|
173
181
|
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
174
182
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
|
data/lib/facturacr/version.rb
CHANGED
@@ -11,7 +11,7 @@ module FE
|
|
11
11
|
# Backwards compatibility with v0.1.4
|
12
12
|
if xml_provider.is_a?(String)
|
13
13
|
raise ArgumentError, "File: #{xml_provider} does not exist" unless File.exists?(xml_provider)
|
14
|
-
xml_provider =
|
14
|
+
xml_provider = FE::DataProvider.new(:file, xml_provider)
|
15
15
|
end
|
16
16
|
raise ArgumentError, "Invalid Argument" unless xml_provider.is_a?(FE::DataProvider)
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facturacr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Sauter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|