facturama 0.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.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/lib/facturama.rb +56 -0
  3. data/lib/facturama/facturama_api_multi.rb +37 -0
  4. data/lib/facturama/facturama_api_web.rb +55 -0
  5. data/lib/facturama/models/address.rb +16 -0
  6. data/lib/facturama/models/branch_office.rb +14 -0
  7. data/lib/facturama/models/cfdi.rb +80 -0
  8. data/lib/facturama/models/cfdi_relation.rb +10 -0
  9. data/lib/facturama/models/cfdi_relations.rb +12 -0
  10. data/lib/facturama/models/client.rb +19 -0
  11. data/lib/facturama/models/complement.rb +8 -0
  12. data/lib/facturama/models/connection_info.rb +36 -0
  13. data/lib/facturama/models/csd.rb +14 -0
  14. data/lib/facturama/models/exception/facturama_exception.rb +18 -0
  15. data/lib/facturama/models/exception/model_exception.rb +11 -0
  16. data/lib/facturama/models/image.rb +11 -0
  17. data/lib/facturama/models/item.rb +25 -0
  18. data/lib/facturama/models/model.rb +75 -0
  19. data/lib/facturama/models/product.rb +27 -0
  20. data/lib/facturama/models/product_tax.rb +14 -0
  21. data/lib/facturama/models/receiver.rb +15 -0
  22. data/lib/facturama/models/serie.rb +13 -0
  23. data/lib/facturama/models/tax.rb +14 -0
  24. data/lib/facturama/models/tax_entity.rb +21 -0
  25. data/lib/facturama/models/tax_stamp.rb +12 -0
  26. data/lib/facturama/services/branch_office_service.rb +16 -0
  27. data/lib/facturama/services/catalog_service.rb +42 -0
  28. data/lib/facturama/services/cfdi_multi_service.rb +164 -0
  29. data/lib/facturama/services/cfdi_service.rb +172 -0
  30. data/lib/facturama/services/client_service.rb +19 -0
  31. data/lib/facturama/services/crud_service.rb +41 -0
  32. data/lib/facturama/services/csd_service.rb +16 -0
  33. data/lib/facturama/services/http_service.rb +152 -0
  34. data/lib/facturama/services/product_service.rb +16 -0
  35. data/lib/facturama/version.rb +4 -0
  36. data/lib/samples/sample_api.rb +17 -0
  37. data/lib/samples/sample_api_multi.rb +352 -0
  38. data/lib/samples/sample_api_web.rb +454 -0
  39. metadata +94 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7999419b05b8f97908b36ee2d703339657aa6a25
4
+ data.tar.gz: c44375cb7214cd1cb3f3f8973e3d0cb4c060bcc6
5
+ SHA512:
6
+ metadata.gz: 11666d04cdd47bf690dbbf22e2110f34e39088c2d040ef9ee341dbeb5db2a15bae1fa30b37693252dabbb6f8c6d347e027d41105e62b5474fbedd08f84c9c4bc
7
+ data.tar.gz: 0e1c5b43b9055f8f98b4c3bcf8fc4742fd0b1c0bf3be672389c7b57a7712bd4d15664722e5f5899c764f4bc096d1a32c0591ef60116d804b07059627d3ace825
@@ -0,0 +1,56 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+
4
+ #Conectividad
5
+ #require 'rest-client'
6
+ #require 'json'
7
+
8
+
9
+
10
+ module Facturama
11
+
12
+
13
+ #MODELOS
14
+ require_relative 'facturama/version'
15
+ require_relative 'facturama/models/model'
16
+ require_relative 'facturama/models/product_tax.rb'
17
+ require_relative 'facturama/models/product'
18
+ require_relative 'facturama/models/address'
19
+ require_relative 'facturama/models/client'
20
+ require_relative 'facturama/models/cfdi_relation'
21
+ require_relative 'facturama/models/cfdi_relations'
22
+ require_relative 'facturama/models/cfdi'
23
+ require_relative 'facturama/models/receiver'
24
+ require_relative 'facturama/models/tax'
25
+ require_relative 'facturama/models/item'
26
+ require_relative 'facturama/models/branch_office'
27
+ require_relative 'facturama/models/csd'
28
+ require_relative 'facturama/models/serie'
29
+ require_relative 'facturama/models/image'
30
+ require_relative 'facturama/models/complement'
31
+ require_relative 'facturama/models/tax_stamp'
32
+ require_relative 'facturama/models/tax_entity'
33
+
34
+
35
+
36
+ # SERVICIOS
37
+ require_relative 'facturama/services/http_service'
38
+ require_relative 'facturama/services/crud_service'
39
+ require_relative 'facturama/services/client_service'
40
+ require_relative 'facturama/services/product_service'
41
+ require_relative 'facturama/services/catalog_service'
42
+ require_relative 'facturama/services/branch_office_service'
43
+ require_relative 'facturama/services/cfdi_service'
44
+ require_relative 'facturama/services/csd_service'
45
+ require_relative 'facturama/services/cfdi_multi_service'
46
+
47
+ require_relative 'facturama/facturama_api_web'
48
+ require_relative 'facturama/facturama_api_multi'
49
+
50
+
51
+
52
+
53
+ end
54
+
55
+
56
+
@@ -0,0 +1,37 @@
1
+
2
+ require_relative "models/connection_info.rb"
3
+
4
+ module Facturama
5
+
6
+ require 'logger'
7
+ require 'base64'
8
+ require 'rest-client'
9
+ require 'uri'
10
+
11
+ class FacturamaApiMulti
12
+
13
+ def initialize(facturama_user, facturama_password, is_development = true)
14
+ @connection_info = Facturama::Models::ConnectionInfo.new(facturama_user, facturama_password, is_development)
15
+
16
+
17
+ @cfdi_service = Facturama::Services::CfdiMultiService.new(@connection_info)
18
+ @csd_service = Facturama::Services::CsdService.new(@connection_info)
19
+
20
+ end
21
+
22
+
23
+ # CSD
24
+ def csds
25
+ @csd_service
26
+ end
27
+
28
+ # CFDI (Facturas)
29
+ def cfdis
30
+ @cfdi_service
31
+ end
32
+
33
+
34
+ end # class FacturamaApiMulti
35
+
36
+
37
+ end
@@ -0,0 +1,55 @@
1
+
2
+ require_relative "models/connection_info.rb"
3
+
4
+ module Facturama
5
+
6
+ require 'logger'
7
+ require 'base64'
8
+ require 'rest-client'
9
+ require 'uri'
10
+
11
+ class FacturamaApiWeb
12
+
13
+ def initialize(facturama_user, facturama_password, is_development = true)
14
+
15
+ @connection_info = Facturama::Models::ConnectionInfo.new(facturama_user, facturama_password, is_development)
16
+
17
+ @client_service = Facturama::Services::ClientService.new(@connection_info)
18
+ @product_service = Facturama::Services::ProductService.new(@connection_info)
19
+ @catalog_service = Facturama::Services::CatalogService.new(@connection_info)
20
+ @branch_office_service = Facturama::Services::BranchOfficeService.new(@connection_info)
21
+ @cfdi_service = Facturama::Services::CfdiService.new(@connection_info)
22
+
23
+ end
24
+
25
+
26
+ # Clientes
27
+ def clients
28
+ @client_service
29
+ end
30
+
31
+ # Artículos ( Productos o servicios para los conceptos )
32
+ def products
33
+ @product_service
34
+ end
35
+
36
+ # Catálogo
37
+ def catalog
38
+ @catalog_service
39
+ end
40
+
41
+ # Lugares de expedición (Sucursales)
42
+ def branch_office
43
+ @branch_office_service
44
+ end
45
+
46
+ # CFDI (Facturas)
47
+ def cfdis
48
+ @cfdi_service
49
+ end
50
+
51
+
52
+ end # class FacturamaApi
53
+
54
+
55
+ end
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +1,18 @@
1
+
2
+ require_relative 'model_exception'
3
+
4
+
5
+ class FacturamaException < Exception
6
+
7
+ def initialize( exception_message, exception_details = nil )
8
+ super exception_message
9
+
10
+ @details = exception_details
11
+ end
12
+
13
+
14
+ def details
15
+ @details
16
+ end
17
+
18
+ end
@@ -0,0 +1,11 @@
1
+
2
+ class ModelException
3
+
4
+ def initialize
5
+ @message = ""
6
+ @details = ""
7
+ end
8
+
9
+
10
+
11
+ end
@@ -0,0 +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
@@ -0,0 +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