facturacr 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9347f02d87a3cf5599258541e486b1b0c91735cc
4
- data.tar.gz: 32a56051c0e0d579399da56d9e0548f3e329b6c0
3
+ metadata.gz: 784afc0b9e27eeef2d3dbd6770bc37c74c268a4e
4
+ data.tar.gz: 0c1db15bd3360912262cf5ec191432464ee6a9f0
5
5
  SHA512:
6
- metadata.gz: 6ec19d44a5a664ddac2c185de4348fd81c42302f3649c9f36a3ecbf990b13c57c081e7e1c6fdf392d15318c67effcd7cb5c6f734f57b57af2044833877f04c0d
7
- data.tar.gz: 7b82f3c149283c3b8f5cae6b2684f656b880631ccfa457c29f9b3fcb67b7d2f0975075b0ca38fafb6cdbf111a4d3d37beaf850b6b663c839559a8fe77c621c4e
6
+ metadata.gz: 6e2da292a67d329622eeccd529d0f19232f0c028fc5dd27d53c1184d748f8b121739df10c1c6e392db14566415ad979c9c8aa3cc97c8a69e3f5007f17ccc4a6c
7
+ data.tar.gz: 3d88d6d3e26ccf50d3ec7f0a9db6a6f83e160ea61eab479a12a3c1ae54c4eaf9ad24d9a0897ee52c0949498d6b56dd78d330fe05f94da76875230a8506a51ce3
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
@@ -53,11 +53,11 @@ module FE
53
53
  private
54
54
 
55
55
  def totals_ok?
56
- errors[:taxable_total] << "invalid amount" unless @taxable_total == (@services_taxable_total + @goods_taxable_total).round(5)
57
- errors[:exent_total] << "invalid amount" unless @exent_total == (@services_exent_total + @goods_exent_total).round(5)
58
- errors[:subtotal] << "invalid amount" unless @subtotal == (@taxable_total + @exent_total).round(5)
59
- errors[:gross_total] << "invalid amount" unless @gross_total == (@subtotal - @discount_total).round(5)
60
- errors[:net_total] << "invalid amount" unless @net_total == (@gross_total + @tax_total).round(5)
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
@@ -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
@@ -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 = Fe::DataProvider.new(:file, 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" => "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica",
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"=>"https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica",
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"=>"https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica",
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"
@@ -1,3 +1,3 @@
1
1
  module FE
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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 = Fe::DataProvider.new(:file, 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: 1.0.0
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-08-02 00:00:00.000000000 Z
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler