facturama 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/facturama/models/address.rb +16 -16
- data/lib/facturama/models/branch_office.rb +14 -14
- data/lib/facturama/models/cfdi.rb +80 -80
- data/lib/facturama/models/cfdi_relation.rb +10 -10
- data/lib/facturama/models/cfdi_relations.rb +12 -12
- data/lib/facturama/models/client.rb +19 -19
- data/lib/facturama/models/complement.rb +8 -8
- data/lib/facturama/models/connection_info.rb +36 -36
- data/lib/facturama/models/csd.rb +14 -14
- data/lib/facturama/models/image.rb +11 -11
- data/lib/facturama/models/item.rb +25 -25
- data/lib/facturama/models/model.rb +75 -75
- data/lib/facturama/models/product.rb +27 -27
- data/lib/facturama/models/product_tax.rb +14 -14
- data/lib/facturama/models/receiver.rb +15 -15
- data/lib/facturama/models/serie.rb +13 -13
- data/lib/facturama/models/tax.rb +14 -14
- data/lib/facturama/models/tax_entity.rb +21 -21
- data/lib/facturama/models/tax_stamp.rb +12 -12
- data/lib/facturama/version.rb +4 -4
- data/lib/samples/sample_api_web.rb +6 -6
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28eda0a8b4bf589cb2ef27d188c827065edfc8f3
|
4
|
+
data.tar.gz: 4333968490bfaaccdcbb92d0a6c19015a8c49185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1208f030a78ee3eb531125ec4e0c654ece40e41c0f5946730695e2de3410886d7520f7e92b4388795d866a957ac83ddd45b7692dce0fb1413e284bc116d5cd10
|
7
|
+
data.tar.gz: 39476b9258ad64ec3aee598d582be925a2fb4d0266d36903fc451de7a01e2300125e1aac11d1bd50c24d50216d1de74fe24f66f621dc1c88477b1d31199756c6
|
@@ -1,16 +1,16 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Address < Model
|
5
|
-
attr_accessor :Street,
|
6
|
-
:ExteriorNumber,
|
7
|
-
:InteriorNumber,
|
8
|
-
:Neighborhood,
|
9
|
-
:ZipCode,
|
10
|
-
:Locality,
|
11
|
-
:Municipality,
|
12
|
-
:State,
|
13
|
-
:Country
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Address < Model
|
5
|
+
attr_accessor :Street,
|
6
|
+
:ExteriorNumber,
|
7
|
+
:InteriorNumber,
|
8
|
+
:Neighborhood,
|
9
|
+
:ZipCode,
|
10
|
+
:Locality,
|
11
|
+
:Municipality,
|
12
|
+
:State,
|
13
|
+
:Country
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class BranchOffice < Model
|
5
|
-
attr_accessor :Id,
|
6
|
-
:Name,
|
7
|
-
:Description
|
8
|
-
#:Address
|
9
|
-
|
10
|
-
validates :Name, :Description, :Address, presence: true
|
11
|
-
has_one_object :Address
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class BranchOffice < Model
|
5
|
+
attr_accessor :Id,
|
6
|
+
:Name,
|
7
|
+
:Description
|
8
|
+
#:Address
|
9
|
+
|
10
|
+
validates :Name, :Description, :Address, presence: true
|
11
|
+
has_one_object :Address
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,80 +1,80 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
# CFDI de emisión (una factura)
|
3
|
-
|
4
|
-
|
5
|
-
module Facturama
|
6
|
-
|
7
|
-
module CfdiType
|
8
|
-
INGRESO = "I"
|
9
|
-
EGRESO = "E"
|
10
|
-
TRASLADO = "T"
|
11
|
-
PAGO = "P"
|
12
|
-
end
|
13
|
-
|
14
|
-
module CfdiStatus
|
15
|
-
ALL = "All"
|
16
|
-
ACTIVE = "Active"
|
17
|
-
CANCEL = "Cancel"
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
module InvoiceType
|
23
|
-
ISSUED = "Issued"
|
24
|
-
RECEIVED = "Received"
|
25
|
-
PAYROLL = "Payroll"
|
26
|
-
ISSUED_LITE = "issuedLite"
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
module FileFormat
|
31
|
-
XML = "Xml"
|
32
|
-
PDF = "Pdf"
|
33
|
-
HTML = "Html"
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
module Models
|
39
|
-
class Cfdi < Model
|
40
|
-
attr_accessor :Id, # Solo Response
|
41
|
-
:Folio, # Solo Response
|
42
|
-
:CertNumber, # Solo Response
|
43
|
-
:NameId,
|
44
|
-
:Date,
|
45
|
-
:Serie,
|
46
|
-
:PaymentAccountNumber,
|
47
|
-
:CurrencyExchangeRate,
|
48
|
-
:Currency,
|
49
|
-
:ExpeditionPlace,
|
50
|
-
:PaymentConditions,
|
51
|
-
#:Relations,
|
52
|
-
:CfdiType,
|
53
|
-
:PaymentForm,
|
54
|
-
:PaymentMethod,
|
55
|
-
#:Receiver,
|
56
|
-
:Items,
|
57
|
-
#:Complemento, _jr_* Complemento no se considera para eso
|
58
|
-
:Observations,
|
59
|
-
:OrderNumber,
|
60
|
-
:PaymentTerms, # Solo Response
|
61
|
-
:ExchangeRate, # Solo Response - puede ser el mismo que CurrencyExchangeRate
|
62
|
-
:Subtotal, # Solo Response
|
63
|
-
:Discount, # Solo Response
|
64
|
-
:Total, # Solo Response
|
65
|
-
#:Issuer, # Solo Response - Es una entidad fiscal
|
66
|
-
:Discount
|
67
|
-
#Taxes # Solo Response
|
68
|
-
#:Complement # Solo Response
|
69
|
-
|
70
|
-
|
71
|
-
validates :Email, :Rfc, :Name, presence: true
|
72
|
-
has_many_objects :Relations, :CfdiRelation
|
73
|
-
has_one_object :Receiver
|
74
|
-
has_many_objects :Issuer, :TaxEntity
|
75
|
-
#has_many_objects :Items, :Item
|
76
|
-
has_many_objects :Taxes, :Tax
|
77
|
-
has_one_object :Complement
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# CFDI de emisión (una factura)
|
3
|
+
|
4
|
+
|
5
|
+
module Facturama
|
6
|
+
|
7
|
+
module CfdiType
|
8
|
+
INGRESO = "I"
|
9
|
+
EGRESO = "E"
|
10
|
+
TRASLADO = "T"
|
11
|
+
PAGO = "P"
|
12
|
+
end
|
13
|
+
|
14
|
+
module CfdiStatus
|
15
|
+
ALL = "All"
|
16
|
+
ACTIVE = "Active"
|
17
|
+
CANCEL = "Cancel"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
module InvoiceType
|
23
|
+
ISSUED = "Issued"
|
24
|
+
RECEIVED = "Received"
|
25
|
+
PAYROLL = "Payroll"
|
26
|
+
ISSUED_LITE = "issuedLite"
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
module FileFormat
|
31
|
+
XML = "Xml"
|
32
|
+
PDF = "Pdf"
|
33
|
+
HTML = "Html"
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
module Models
|
39
|
+
class Cfdi < Model
|
40
|
+
attr_accessor :Id, # Solo Response
|
41
|
+
:Folio, # Solo Response
|
42
|
+
:CertNumber, # Solo Response
|
43
|
+
:NameId,
|
44
|
+
:Date,
|
45
|
+
:Serie,
|
46
|
+
:PaymentAccountNumber,
|
47
|
+
:CurrencyExchangeRate,
|
48
|
+
:Currency,
|
49
|
+
:ExpeditionPlace,
|
50
|
+
:PaymentConditions,
|
51
|
+
#:Relations,
|
52
|
+
:CfdiType,
|
53
|
+
:PaymentForm,
|
54
|
+
:PaymentMethod,
|
55
|
+
#:Receiver,
|
56
|
+
:Items,
|
57
|
+
#:Complemento, _jr_* Complemento no se considera para eso
|
58
|
+
:Observations,
|
59
|
+
:OrderNumber,
|
60
|
+
:PaymentTerms, # Solo Response
|
61
|
+
:ExchangeRate, # Solo Response - puede ser el mismo que CurrencyExchangeRate
|
62
|
+
:Subtotal, # Solo Response
|
63
|
+
:Discount, # Solo Response
|
64
|
+
:Total, # Solo Response
|
65
|
+
#:Issuer, # Solo Response - Es una entidad fiscal
|
66
|
+
:Discount
|
67
|
+
#Taxes # Solo Response
|
68
|
+
#:Complement # Solo Response
|
69
|
+
|
70
|
+
|
71
|
+
validates :Email, :Rfc, :Name, presence: true
|
72
|
+
has_many_objects :Relations, :CfdiRelation
|
73
|
+
has_one_object :Receiver
|
74
|
+
has_many_objects :Issuer, :TaxEntity
|
75
|
+
#has_many_objects :Items, :Item
|
76
|
+
has_many_objects :Taxes, :Tax
|
77
|
+
has_one_object :Complement
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class CfdiRelation < Model
|
5
|
-
attr_accessor :Uuid
|
6
|
-
|
7
|
-
validates :Uuid, presence: true
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class CfdiRelation < Model
|
5
|
+
attr_accessor :Uuid
|
6
|
+
|
7
|
+
validates :Uuid, presence: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class CfdiRelations < Model
|
5
|
-
attr_accessor :Type,
|
6
|
-
:Cfdis
|
7
|
-
|
8
|
-
validates :Type, :Cfdis, presence: true
|
9
|
-
has_many_objects :Cfdis, :CfdiRelation
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class CfdiRelations < Model
|
5
|
+
attr_accessor :Type,
|
6
|
+
:Cfdis
|
7
|
+
|
8
|
+
validates :Type, :Cfdis, presence: true
|
9
|
+
has_many_objects :Cfdis, :CfdiRelation
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Client < Model
|
5
|
-
attr_accessor :Email,
|
6
|
-
:EmailOp1,
|
7
|
-
:EmailOp2,
|
8
|
-
:Rfc,
|
9
|
-
:Name,
|
10
|
-
:CfdiUse,
|
11
|
-
:TaxResidence,
|
12
|
-
:NumRegIdTrib
|
13
|
-
|
14
|
-
|
15
|
-
has_one_object :Address
|
16
|
-
validates :Email, :Rfc, :Name, presence: true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Client < Model
|
5
|
+
attr_accessor :Email,
|
6
|
+
:EmailOp1,
|
7
|
+
:EmailOp2,
|
8
|
+
:Rfc,
|
9
|
+
:Name,
|
10
|
+
:CfdiUse,
|
11
|
+
:TaxResidence,
|
12
|
+
:NumRegIdTrib
|
13
|
+
|
14
|
+
|
15
|
+
has_one_object :Address
|
16
|
+
validates :Email, :Rfc, :Name, presence: true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Complement < Model
|
5
|
-
attr_accessor :TaxStamp
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Complement < Model
|
5
|
+
attr_accessor :TaxStamp
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class ConnectionInfo
|
5
|
-
|
6
|
-
#API Endpoints
|
7
|
-
URL_DEV='https://apisandbox.facturama.mx'
|
8
|
-
URL_PROD='https://api.facturama.mx'
|
9
|
-
|
10
|
-
def initialize(facturama_user, facturama_password, is_development = true)
|
11
|
-
@facturama_user = facturama_user
|
12
|
-
@facturama_password = facturama_password
|
13
|
-
@is_development = is_development
|
14
|
-
|
15
|
-
@uri_base = (is_development)? URL_DEV : URL_PROD
|
16
|
-
end
|
17
|
-
|
18
|
-
def uri_base
|
19
|
-
@uri_base
|
20
|
-
end
|
21
|
-
|
22
|
-
def facturama_user
|
23
|
-
@facturama_user
|
24
|
-
end
|
25
|
-
|
26
|
-
def facturama_password
|
27
|
-
@facturama_password
|
28
|
-
end
|
29
|
-
|
30
|
-
def is_development
|
31
|
-
@is_development
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class ConnectionInfo
|
5
|
+
|
6
|
+
#API Endpoints
|
7
|
+
URL_DEV='https://apisandbox.facturama.mx'
|
8
|
+
URL_PROD='https://api.facturama.mx'
|
9
|
+
|
10
|
+
def initialize(facturama_user, facturama_password, is_development = true)
|
11
|
+
@facturama_user = facturama_user
|
12
|
+
@facturama_password = facturama_password
|
13
|
+
@is_development = is_development
|
14
|
+
|
15
|
+
@uri_base = (is_development)? URL_DEV : URL_PROD
|
16
|
+
end
|
17
|
+
|
18
|
+
def uri_base
|
19
|
+
@uri_base
|
20
|
+
end
|
21
|
+
|
22
|
+
def facturama_user
|
23
|
+
@facturama_user
|
24
|
+
end
|
25
|
+
|
26
|
+
def facturama_password
|
27
|
+
@facturama_password
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_development
|
31
|
+
@is_development
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/facturama/models/csd.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Csd < Model
|
5
|
-
attr_accessor :Rfc,
|
6
|
-
:Certificate,
|
7
|
-
:PrivateKey,
|
8
|
-
:PrivateKeyPassword
|
9
|
-
|
10
|
-
validates :Certificate, :PrivateKey, :PrivateKeyPassword, presence: true
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Csd < Model
|
5
|
+
attr_accessor :Rfc,
|
6
|
+
:Certificate,
|
7
|
+
:PrivateKey,
|
8
|
+
:PrivateKeyPassword
|
9
|
+
|
10
|
+
validates :Certificate, :PrivateKey, :PrivateKeyPassword, presence: true
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Image < Model
|
5
|
-
attr_accessor :Image,
|
6
|
-
:Type
|
7
|
-
|
8
|
-
validates :Image, presence: true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Image < Model
|
5
|
+
attr_accessor :Image,
|
6
|
+
:Type
|
7
|
+
|
8
|
+
validates :Image, presence: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Item < Model
|
5
|
-
attr_accessor :ProductCode,
|
6
|
-
:IdentificationNumber,
|
7
|
-
:Description,
|
8
|
-
:Unit,
|
9
|
-
:UnitCode,
|
10
|
-
:UnitPrice,
|
11
|
-
:Quantity,
|
12
|
-
:Subtotal,
|
13
|
-
:Discount,
|
14
|
-
#:Taxes,
|
15
|
-
:CuentaPredial,
|
16
|
-
:Total,
|
17
|
-
:Taxes,
|
18
|
-
:UnitValue # solo Response
|
19
|
-
#:Complement _jr_* por el momento, no se consideran los complementos
|
20
|
-
|
21
|
-
validates :ProductCode, :Description, :UnitCode, :UnitPrice, :Quantity, :Subtotal, :Total, presence: true
|
22
|
-
#has_many_objects :Taxes, :Tax
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Item < Model
|
5
|
+
attr_accessor :ProductCode,
|
6
|
+
:IdentificationNumber,
|
7
|
+
:Description,
|
8
|
+
:Unit,
|
9
|
+
:UnitCode,
|
10
|
+
:UnitPrice,
|
11
|
+
:Quantity,
|
12
|
+
:Subtotal,
|
13
|
+
:Discount,
|
14
|
+
#:Taxes,
|
15
|
+
:CuentaPredial,
|
16
|
+
:Total,
|
17
|
+
:Taxes,
|
18
|
+
:UnitValue # solo Response
|
19
|
+
#:Complement _jr_* por el momento, no se consideran los complementos
|
20
|
+
|
21
|
+
validates :ProductCode, :Description, :UnitCode, :UnitPrice, :Quantity, :Subtotal, :Total, presence: true
|
22
|
+
#has_many_objects :Taxes, :Tax
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,75 +1,75 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'active_model'
|
3
|
-
|
4
|
-
module Facturama
|
5
|
-
module Models
|
6
|
-
class Model
|
7
|
-
|
8
|
-
include ActiveModel::Validations
|
9
|
-
include ActiveModel::Serializers::JSON
|
10
|
-
|
11
|
-
attr_accessor :all_errors
|
12
|
-
|
13
|
-
def initialize(values)
|
14
|
-
values.each_pair do |k, v|
|
15
|
-
send("#{k}=", v)
|
16
|
-
end
|
17
|
-
after_initialize
|
18
|
-
end
|
19
|
-
|
20
|
-
def after_initialize
|
21
|
-
end
|
22
|
-
|
23
|
-
def attributes
|
24
|
-
instance_values
|
25
|
-
end
|
26
|
-
|
27
|
-
def prepare_data
|
28
|
-
prepare_keys.to_json
|
29
|
-
end
|
30
|
-
|
31
|
-
def get_instance_values
|
32
|
-
instance_values.delete_if do |k, v|
|
33
|
-
%w(all_errors errors validation_context).include?(k)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
class << self
|
39
|
-
|
40
|
-
def has_many_objects(association, class_name)
|
41
|
-
define_writer(association, class_name)
|
42
|
-
define_reader(association)
|
43
|
-
end
|
44
|
-
|
45
|
-
def has_one_object(association)
|
46
|
-
define_writer(association, association)
|
47
|
-
define_reader(association)
|
48
|
-
end
|
49
|
-
|
50
|
-
def define_writer(association, class_name)
|
51
|
-
class_eval <<-CODE
|
52
|
-
def #{association}=(value)
|
53
|
-
@#{association} =
|
54
|
-
if value.class.name == "Array"
|
55
|
-
value.collect do |val|
|
56
|
-
#{class_name.to_s.camelize}.new(val)
|
57
|
-
end
|
58
|
-
else
|
59
|
-
#{class_name.to_s.camelize}.new(value)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
CODE
|
63
|
-
end
|
64
|
-
|
65
|
-
def define_reader(association)
|
66
|
-
attr_reader association
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'active_model'
|
3
|
+
|
4
|
+
module Facturama
|
5
|
+
module Models
|
6
|
+
class Model
|
7
|
+
|
8
|
+
include ActiveModel::Validations
|
9
|
+
include ActiveModel::Serializers::JSON
|
10
|
+
|
11
|
+
attr_accessor :all_errors
|
12
|
+
|
13
|
+
def initialize(values)
|
14
|
+
values.each_pair do |k, v|
|
15
|
+
send("#{k}=", v)
|
16
|
+
end
|
17
|
+
after_initialize
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_initialize
|
21
|
+
end
|
22
|
+
|
23
|
+
def attributes
|
24
|
+
instance_values
|
25
|
+
end
|
26
|
+
|
27
|
+
def prepare_data
|
28
|
+
prepare_keys.to_json
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_instance_values
|
32
|
+
instance_values.delete_if do |k, v|
|
33
|
+
%w(all_errors errors validation_context).include?(k)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
class << self
|
39
|
+
|
40
|
+
def has_many_objects(association, class_name)
|
41
|
+
define_writer(association, class_name)
|
42
|
+
define_reader(association)
|
43
|
+
end
|
44
|
+
|
45
|
+
def has_one_object(association)
|
46
|
+
define_writer(association, association)
|
47
|
+
define_reader(association)
|
48
|
+
end
|
49
|
+
|
50
|
+
def define_writer(association, class_name)
|
51
|
+
class_eval <<-CODE
|
52
|
+
def #{association}=(value)
|
53
|
+
@#{association} =
|
54
|
+
if value.class.name == "Array"
|
55
|
+
value.collect do |val|
|
56
|
+
#{class_name.to_s.camelize}.new(val)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
#{class_name.to_s.camelize}.new(value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
CODE
|
63
|
+
end
|
64
|
+
|
65
|
+
def define_reader(association)
|
66
|
+
attr_reader association
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
|
4
|
-
module Models
|
5
|
-
|
6
|
-
require_relative "product_tax"
|
7
|
-
|
8
|
-
class Product < Model
|
9
|
-
attr_accessor :Unit,
|
10
|
-
:UnitCode,
|
11
|
-
:IdentificationNumber,
|
12
|
-
:Name,
|
13
|
-
:Description,
|
14
|
-
:Price,
|
15
|
-
:CodeProdServ,
|
16
|
-
:CuentaPredial,
|
17
|
-
:Complement,
|
18
|
-
:Id,
|
19
|
-
:Taxes
|
20
|
-
|
21
|
-
|
22
|
-
validates :Unit, :Name, :Description, :Price, presence: true
|
23
|
-
#has_many_objects , :ProductTax
|
24
|
-
#has_many_objects :Taxes, ProductTax
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
|
4
|
+
module Models
|
5
|
+
|
6
|
+
require_relative "product_tax"
|
7
|
+
|
8
|
+
class Product < Model
|
9
|
+
attr_accessor :Unit,
|
10
|
+
:UnitCode,
|
11
|
+
:IdentificationNumber,
|
12
|
+
:Name,
|
13
|
+
:Description,
|
14
|
+
:Price,
|
15
|
+
:CodeProdServ,
|
16
|
+
:CuentaPredial,
|
17
|
+
:Complement,
|
18
|
+
:Id,
|
19
|
+
:Taxes
|
20
|
+
|
21
|
+
|
22
|
+
validates :Unit, :Name, :Description, :Price, presence: true
|
23
|
+
#has_many_objects , :ProductTax
|
24
|
+
#has_many_objects :Taxes, ProductTax
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class ProductTax < Model
|
5
|
-
attr_accessor :Name,
|
6
|
-
:Rate,
|
7
|
-
:IsRetention,
|
8
|
-
:IsFederalTax,
|
9
|
-
:IsQuota,
|
10
|
-
:Total
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class ProductTax < Model
|
5
|
+
attr_accessor :Name,
|
6
|
+
:Rate,
|
7
|
+
:IsRetention,
|
8
|
+
:IsFederalTax,
|
9
|
+
:IsQuota,
|
10
|
+
:Total
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Receiver < Model
|
5
|
-
attr_accessor :Id,
|
6
|
-
:Rfc,
|
7
|
-
:Name,
|
8
|
-
:CfdiUse,
|
9
|
-
:TaxResidence,
|
10
|
-
:TaxRegistrationNumber
|
11
|
-
|
12
|
-
validates :Rfc, presence: true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Receiver < Model
|
5
|
+
attr_accessor :Id,
|
6
|
+
:Rfc,
|
7
|
+
:Name,
|
8
|
+
:CfdiUse,
|
9
|
+
:TaxResidence,
|
10
|
+
:TaxRegistrationNumber
|
11
|
+
|
12
|
+
validates :Rfc, presence: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Serie < Model
|
5
|
-
attr_accessor :IdBranchOffice,
|
6
|
-
:Name,
|
7
|
-
:Description
|
8
|
-
:Folio
|
9
|
-
|
10
|
-
validates :IdBranchOffice, :Name, presence: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Serie < Model
|
5
|
+
attr_accessor :IdBranchOffice,
|
6
|
+
:Name,
|
7
|
+
:Description
|
8
|
+
:Folio
|
9
|
+
|
10
|
+
validates :IdBranchOffice, :Name, presence: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/facturama/models/tax.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class Tax < Model
|
5
|
-
attr_accessor :Total,
|
6
|
-
:Name,
|
7
|
-
:Base,
|
8
|
-
:Rate,
|
9
|
-
:Type,
|
10
|
-
:IsRetention,
|
11
|
-
:IsQuota
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class Tax < Model
|
5
|
+
attr_accessor :Total,
|
6
|
+
:Name,
|
7
|
+
:Base,
|
8
|
+
:Rate,
|
9
|
+
:Type,
|
10
|
+
:IsRetention,
|
11
|
+
:IsQuota
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class TaxEntity < Model
|
5
|
-
attr_accessor :FiscalRegime,
|
6
|
-
:ComercialName,
|
7
|
-
:Rfc,
|
8
|
-
:TaxName,
|
9
|
-
:Email,
|
10
|
-
:Phone,
|
11
|
-
#:TaxAddress,
|
12
|
-
:PasswordSat,
|
13
|
-
:UrlLogo #solo Response
|
14
|
-
|
15
|
-
validates :FiscalRegime, :Rfc, :TaxName, :Email, presence: true
|
16
|
-
has_many_objects :TaxAddress, :Address #solo Response
|
17
|
-
has_many_objects :IssuedIn, :Address #solo Response
|
18
|
-
has_many_objects :Csd, :Csd #solo Response
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class TaxEntity < Model
|
5
|
+
attr_accessor :FiscalRegime,
|
6
|
+
:ComercialName,
|
7
|
+
:Rfc,
|
8
|
+
:TaxName,
|
9
|
+
:Email,
|
10
|
+
:Phone,
|
11
|
+
#:TaxAddress,
|
12
|
+
:PasswordSat,
|
13
|
+
:UrlLogo #solo Response
|
14
|
+
|
15
|
+
validates :FiscalRegime, :Rfc, :TaxName, :Email, presence: true
|
16
|
+
has_many_objects :TaxAddress, :Address #solo Response
|
17
|
+
has_many_objects :IssuedIn, :Address #solo Response
|
18
|
+
has_many_objects :Csd, :Csd #solo Response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
module Models
|
4
|
-
class TaxStamp < Model
|
5
|
-
attr_accessor :Uuid,
|
6
|
-
:Date,
|
7
|
-
:CfdiSign,
|
8
|
-
:SatCertNumber,
|
9
|
-
:SatSign
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
module Models
|
4
|
+
class TaxStamp < Model
|
5
|
+
attr_accessor :Uuid,
|
6
|
+
:Date,
|
7
|
+
:CfdiSign,
|
8
|
+
:SatCertNumber,
|
9
|
+
:SatSign
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/facturama/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
module Facturama
|
3
|
-
VERSION = '0.0.1'
|
4
|
-
end
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Facturama
|
3
|
+
VERSION = '0.0.1'
|
4
|
+
end
|
@@ -318,7 +318,7 @@ module Facturama
|
|
318
318
|
|
319
319
|
|
320
320
|
puts "===== Ejemplo de CFDI - Fin ====="
|
321
|
-
end
|
321
|
+
end # sample_cfdis
|
322
322
|
|
323
323
|
|
324
324
|
|
@@ -365,7 +365,7 @@ module Facturama
|
|
365
365
|
)
|
366
366
|
|
367
367
|
|
368
|
-
end
|
368
|
+
end # sample_cfdis_create
|
369
369
|
|
370
370
|
|
371
371
|
def add_items_to_cfdi(facturama, currency, cfdi)
|
@@ -444,11 +444,11 @@ module Facturama
|
|
444
444
|
|
445
445
|
cfdi.Items = lst_items
|
446
446
|
|
447
|
-
end
|
447
|
+
end # add_items_to_cfdi
|
448
448
|
|
449
449
|
|
450
450
|
|
451
|
-
end
|
452
|
-
end
|
451
|
+
end # SampleApiWeb
|
452
|
+
end # Samples
|
453
453
|
|
454
|
-
end
|
454
|
+
end # Facturama
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facturama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facturama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -24,7 +24,22 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.1.0.rc1
|
27
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.2.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.2.3
|
41
|
+
description: Funcionalidad básica de creación de Cfdis empleando las APIs Web y Multiemisor.
|
42
|
+
Empleando rest-client y basic_active_model
|
28
43
|
email: info@facturama.mx
|
29
44
|
executables: []
|
30
45
|
extensions: []
|