sw_fac 0.3.58 → 0.3.62
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sw_fac/config.rb +19 -3
- data/lib/sw_fac/facturacion.rb +929 -722
- data/lib/sw_fac/tools.rb +9 -9
- data/lib/sw_fac/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d61f419dde54d73f680114a9784046d689271cc4b3e662a7cdb42fe6c1967e
|
4
|
+
data.tar.gz: 5b395feeed206cb98d58c7feeb5188a28acbfa4917d14e97f09c5495072b3a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e1b5f8b105e7151c4652a9bdbcac84762a7f995695d3e5919983d60da53066b699baeb5bcd9468a5de7326b76300d1e50ac1cedcffff45613b55e10bcdd055
|
7
|
+
data.tar.gz: dfb86927d6bea35ba34826705dfc297b49dc4befe0d35f9ba765b718046a6208e8ea7a4cc53bc48f8a59c722b145d68c853f9b7fe4ee306537894a4ccc2c8280
|
data/lib/sw_fac/config.rb
CHANGED
@@ -4,6 +4,8 @@ module SwFac
|
|
4
4
|
attr_reader :pem, :serial, :cadena, :key_pass, :pem_cadena
|
5
5
|
|
6
6
|
def initialize(production_token, development_token, rfc, razon, regimen, doc_key_path, key_pass, doc_cer_path, production=false)
|
7
|
+
puts "---- SwFacturacion:config:initialize"
|
8
|
+
|
7
9
|
@production_token = production_token.to_s
|
8
10
|
@dev_token = development_token.to_s
|
9
11
|
@rfc = rfc.to_s
|
@@ -21,7 +23,12 @@ module SwFac
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def key_to_pem
|
26
|
+
puts "---- SwFacturacion:config:key_to_pem"
|
27
|
+
|
28
|
+
puts "-- 1"
|
24
29
|
@pem = %x[openssl pkcs8 -inform DER -in #{@doc_key_path} -passin pass:#{@key_pass}]
|
30
|
+
# @pem = %x[openssl rsa -inform DER -in #{@doc_key_path} -passin pass:#{@key_pass}]
|
31
|
+
puts "-- 2"
|
25
32
|
@pem_cadena = @pem.clone
|
26
33
|
@pem_cadena.slice!("-----BEGIN PRIVATE KEY-----")
|
27
34
|
@pem_cadena.slice!("-----END PRIVATE KEY-----")
|
@@ -29,21 +36,27 @@ module SwFac
|
|
29
36
|
end
|
30
37
|
|
31
38
|
def serial_number
|
39
|
+
puts "---- SwFacturacion:config:serial_number"
|
40
|
+
|
32
41
|
response = %x[openssl x509 -inform DER -in #{@doc_cer_path} -noout -serial]
|
33
42
|
d_begin = response.index(/\d/)
|
34
43
|
number = (response[d_begin..-1]).chomp
|
35
44
|
final_serial = ""
|
36
45
|
|
37
46
|
number.each_char.with_index do |s, index|
|
38
|
-
|
39
|
-
|
40
|
-
|
47
|
+
if (index + 1).even?
|
48
|
+
final_serial << s
|
49
|
+
end
|
41
50
|
end
|
51
|
+
|
42
52
|
@serial = final_serial
|
53
|
+
|
43
54
|
end
|
44
55
|
|
45
56
|
|
46
57
|
def cer_cadena
|
58
|
+
puts "---- SwFacturacion:config:cer_cadena"
|
59
|
+
|
47
60
|
file = File.read(@doc_cer_path)
|
48
61
|
text_certificate = OpenSSL::X509::Certificate.new(file)
|
49
62
|
cert_string = text_certificate.to_s
|
@@ -64,6 +77,9 @@ module SwFac
|
|
64
77
|
<cfdi:Receptor /><cfdi:Conceptos></cfdi:Conceptos>
|
65
78
|
<cfdi:Impuestos></cfdi:Impuestos></cfdi:Comprobante>)
|
66
79
|
|
80
|
+
DocBaseCero = %(<?xml version="1.0" encoding="utf-8"?><cfdi:Comprobante xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd" Version="3.3" xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><cfdi:Emisor />
|
81
|
+
<cfdi:Receptor /><cfdi:Conceptos></cfdi:Conceptos></cfdi:Comprobante>)
|
82
|
+
|
67
83
|
Doc_concepto = %(<cfdi:Concepto ClaveProdServ="25172504" NoIdentificacion="COST37125R17" Cantidad="1" ClaveUnidad="H87" Unidad="Pieza" Descripcion="Producto de prueba" ValorUnitario="1000.00" Importe="1000.00"><cfdi:Impuestos><cfdi:Traslados><cfdi:Traslado Base="1000.00" Impuesto="002" TipoFactor="Tasa" TasaOCuota="0.160000" Importe="160.00" /></cfdi:Traslados></cfdi:Impuestos></cfdi:Concepto>)
|
68
84
|
|
69
85
|
|