buho_cfdi 0.1.12

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1b1a5815e9597ace3a445c00c8bd9ec0da338b1495dd124e4b1399429e0f1359
4
+ data.tar.gz: 304d66631a2204f7ef1c3e449f431ce9fe77287d56556778f5796639c731c2c7
5
+ SHA512:
6
+ metadata.gz: b0d8dc4db977fcbaa78a324bcdf9b43d8f1aee5200673ef47ef987e240d427997c60b88468e8752e0617dd3959c273f8df166e95c822e7a5c04d5a08f3475f5f
7
+ data.tar.gz: 200807adad5e8473c445634acd58de675ab78031e7fc0b128a13c6335477a1115f8e7c1de5bb7de529dab4090d7ae5cc596a99fbe07767c637cd157e0f0691f2
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .DS_Store
13
+ xml_example.xml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 1.17.3
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ group :development, :test do
6
+ gem 'coveralls', require: false
7
+ end
8
+
9
+ # Specify your gem's dependencies in buho_cfdi.gemspec
10
+ gemspec
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ buho_cfdi (0.1.12)
5
+ activemodel (~> 5.2.3)
6
+ nokogiri (~> 1.6, >= 1.6.8)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (5.2.4.2)
12
+ activesupport (= 5.2.4.2)
13
+ activesupport (5.2.4.2)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.1.6)
20
+ coveralls (0.8.23)
21
+ json (>= 1.8, < 3)
22
+ simplecov (~> 0.16.1)
23
+ term-ansicolor (~> 1.3)
24
+ thor (>= 0.19.4, < 2.0)
25
+ tins (~> 1.6)
26
+ diff-lcs (1.3)
27
+ docile (1.3.2)
28
+ i18n (1.8.2)
29
+ concurrent-ruby (~> 1.0)
30
+ json (2.3.0)
31
+ method_source (1.0.0)
32
+ mini_portile2 (2.4.0)
33
+ minitest (5.14.0)
34
+ nokogiri (1.10.9)
35
+ mini_portile2 (~> 2.4.0)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ rake (13.0.1)
40
+ rspec (3.9.0)
41
+ rspec-core (~> 3.9.0)
42
+ rspec-expectations (~> 3.9.0)
43
+ rspec-mocks (~> 3.9.0)
44
+ rspec-core (3.9.1)
45
+ rspec-support (~> 3.9.1)
46
+ rspec-expectations (3.9.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.9.0)
49
+ rspec-mocks (3.9.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.9.0)
52
+ rspec-support (3.9.2)
53
+ simplecov (0.16.1)
54
+ docile (~> 1.1)
55
+ json (>= 1.8, < 3)
56
+ simplecov-html (~> 0.10.0)
57
+ simplecov-html (0.10.2)
58
+ sync (0.5.0)
59
+ term-ansicolor (1.7.1)
60
+ tins (~> 1.0)
61
+ thor (1.0.1)
62
+ thread_safe (0.3.6)
63
+ tins (1.24.1)
64
+ sync
65
+ tzinfo (1.2.7)
66
+ thread_safe (~> 0.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ buho_cfdi!
73
+ bundler (~> 1.17)
74
+ coveralls
75
+ pry (~> 0.13.0)
76
+ rake (>= 12.3.3)
77
+ rspec (~> 3.0)
78
+
79
+ BUNDLED WITH
80
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,185 @@
1
+ # BuhoCfdi
2
+
3
+ CFDI generator for 3.3 version.
4
+
5
+ [![Build Status](https://travis-ci.com/buhocontable/buho_cfdi.svg?token=pvfqse1g1Y1nVGRwY4DL&branch=master)](https://travis-ci.com/buhocontable/buho_cfdi) [![Coverage Status](https://coveralls.io/repos/github/buhocontable/buho_cfdi/badge.svg?branch=master)](https://coveralls.io/github/buhocontable/buho_cfdi?branch=master)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'buho_cfdi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install buho_cfdi
22
+
23
+ ## Usage
24
+
25
+ Create an instance of `BuhoCfdi::XmlProcessor` and pass to it the params.
26
+
27
+ ```ruby
28
+ buho = BuhoCfdi::XmlProcessor.new(params)
29
+ ```
30
+
31
+ Then process the xml with the params. `buho` var has all necesary info to create a xml schema. Execute the instance method `#process_xml` that will create a `#cfdi` instance method with all info needed about the cfdi and the xml.
32
+
33
+ ```ruby
34
+
35
+ # => Execute the instance method
36
+ buho.process_xml
37
+
38
+ # => Access to cfdi object was created
39
+ buho.cfdi
40
+
41
+ ```
42
+
43
+ To access to the XML string.
44
+
45
+ ```ruby
46
+
47
+ # =>
48
+ buho.cfdi.to_xml
49
+
50
+ ```
51
+
52
+ ## Params Examples
53
+
54
+ Format:
55
+
56
+ ```ruby
57
+ params = {
58
+ "receipt": {
59
+ "version": "3.3",
60
+ "serie": "shuhsuhsuhsw",
61
+ "folio_number": "74777e8e8e",
62
+ "date": "sjsjjsjs",
63
+ "stamp": "jsjsjsjjs",
64
+ "payment_method": "ikskskskis",
65
+ "certificate_number": "osiskksj",
66
+ "certificate": "jsjsjsjjsjs",
67
+ "payment_conditions": "kjsksisosos",
68
+ "subtotal": "jiksksksks",
69
+ "discount": "jjjsjsjsjsj",
70
+ "currency": "jsjksjdhdhd",
71
+ "exchange_rate": "jsjsjdhdfhd",
72
+ "total": "isjsxjdjf",
73
+ "type_of_receipt": "jjsjsjjfd",
74
+ "payment_method": "jjsjsjsjsd",
75
+ "expedition_place": "jsjsjsjjs",
76
+ "confirmation": "jjsjsjsjsjdjd",
77
+ "cfdi_related_attributes": {
78
+ "relationship_type": "jhususjujsujdius",
79
+ "related_attributes": [
80
+ {
81
+ "uuid": "ijisjisjisjisjisj"
82
+ }
83
+ ]
84
+ },
85
+ "issuer_attributes": {
86
+ "rfc": "hudshududhs",
87
+ "name": "jdsjidjsijdi",
88
+ "fiscal_regime": "jdisjdisjid"
89
+ },
90
+ "receiver_attributes": {
91
+ "rfc": "jdisjdisj",
92
+ "name": "jdsjdijsijds",
93
+ "tax_residency": "udisjdisjidjisjd",
94
+ "tax_identity_registration_number": "djisjdisjidjsidjis",
95
+ "cfdi_usage": "disjdisidisdjs"
96
+ },
97
+ "concepts_attributes": [
98
+ {
99
+ "prod_or_svc_key": "shusuh",
100
+ "identification_number": "shusuhuhs",
101
+ "quantity": "hsuhusuhs",
102
+ "unit_measure_key": "hsuushuhsuhs",
103
+ "unit_measure": "hsuhsuhushush",
104
+ "description": "shshushushush",
105
+ "unit_value": "suhushuhsuhsu",
106
+ "amount": "shushuhsuhs",
107
+ "discount": "shusuush",
108
+ "transferred_attributes": [
109
+ {
110
+ "base": "yysysy",
111
+ "tax": "uususuus",
112
+ "factor_type": "sjisjijis",
113
+ "rate_or_fee": "jsisjijsijs",
114
+ "import": "jsijsijsij"
115
+ }
116
+ ],
117
+ "detained_attributes": [
118
+ {
119
+ "base": "sjisjijsijs",
120
+ "tax": "sjisjijsijsi",
121
+ "factor_type": "sjijsijsijsi",
122
+ "rate_or_fee": "ssijisjisj",
123
+ "import": "sjijsisijisj"
124
+ }
125
+ ],
126
+ "customs_information_attributes": {
127
+ "requirement_number": "ysyhysh"
128
+ },
129
+ "property_account_attributes": {
130
+ "number": "hushuhsuhsu"
131
+ },
132
+ "part_attributes": {
133
+ "prod_or_svc_key": "suhushushuhs",
134
+ "identification_number": "uhsuhsuhsuhush",
135
+ "quantity": "hsuhsuhushu",
136
+ "unit_measure": "hsuhushushu",
137
+ "description": "shushushush",
138
+ "unit_value": "shuhushushu",
139
+ "amount": "suhsuhushushu"
140
+ }
141
+ }
142
+ ],
143
+ "taxes_attributes": {
144
+ "total_taxes_transferred": "hushusushuhs",
145
+ "total_taxes_detained": "hsuhsuhsuhush",
146
+ "transferred_attributes": [
147
+ {
148
+ "tax": "shuhsusuhush",
149
+ "factor_type": "shusuhsusuhs",
150
+ "rate_or_fee": "sussuhsuhus",
151
+ "import": "shuhusuhsuhsu"
152
+ }
153
+ ],
154
+ "detained_attributes": [
155
+ {
156
+ "tax": "hsuhushussh",
157
+ "import": "suhuhsuhsuhs"
158
+ }
159
+ ]
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ ## Development
166
+
167
+ To install this gem onto your local machine, run `bundle exec rake build` and `bundle exec rake install`. You can also run `irb` for an interactive prompt that will allow you to experiment.
168
+
169
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
170
+
171
+ ## Contributing
172
+
173
+ Bug report or pull request are welcome. Make a pull request:
174
+
175
+ - Clone the repo
176
+ - Create a new feature branch
177
+ - Commit your changes
178
+ - Push the new branch
179
+ - Create new pull-request
180
+
181
+ Please write tests if necessary.
182
+
183
+ ## License
184
+
185
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "buho_cfdi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,45 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "buho_cfdi/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "buho_cfdi"
7
+ spec.version = BuhoCfdi::VERSION
8
+ spec.authors = ["Armando Alejandre", "Pablo Icaza", "Oscar Cocom"]
9
+ spec.email = ["armando1339@gmail.com", "pablo@buhocontable.com", "oscar@buhocontable.com"]
10
+
11
+ spec.summary = %q{CFDI generator for 3.3 version.}
12
+ spec.description = %q{CFDI generator for 3.3 version.}
13
+ spec.homepage = "https://buhocontable.com/"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/buhocontable/buho_cfdi"
23
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency "activemodel", "~> 5.2.3"
39
+ spec.add_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
40
+
41
+ spec.add_development_dependency "bundler", "~> 1.17"
42
+ spec.add_development_dependency "rake", ">= 12.3.3"
43
+ spec.add_development_dependency "rspec", "~> 3.0"
44
+ spec.add_development_dependency "pry", "~> 0.13.0"
45
+ end
Binary file
@@ -0,0 +1,47 @@
1
+ require "buho_cfdi/version"
2
+ require "nokogiri"
3
+ require "buho_cfdi/i18n"
4
+ require "buho_cfdi/base_node"
5
+
6
+ require_relative "buho_cfdi/nodes/collection"
7
+ require_relative "buho_cfdi/nodes/cfdi_related"
8
+ require_relative "buho_cfdi/nodes/concept"
9
+ require_relative "buho_cfdi/nodes/customs_information"
10
+ require_relative "buho_cfdi/nodes/issuer"
11
+ require_relative "buho_cfdi/nodes/receipt"
12
+ require_relative "buho_cfdi/nodes/receiver"
13
+ require_relative "buho_cfdi/nodes/related"
14
+ require_relative "buho_cfdi/nodes/tax_detained"
15
+ require_relative "buho_cfdi/nodes/tax_transferred"
16
+ require_relative "buho_cfdi/nodes/property_account"
17
+ require_relative "buho_cfdi/nodes/part"
18
+ require_relative "buho_cfdi/nodes/taxes"
19
+ require_relative "buho_cfdi/nodes/detained"
20
+ require_relative "buho_cfdi/nodes/transferred"
21
+
22
+ require "buho_cfdi/params_builder"
23
+ require "buho_cfdi/strategy"
24
+ require "buho_cfdi/certificate"
25
+ require "buho_cfdi/key"
26
+
27
+ module BuhoCfdi
28
+ class XmlProcessor
29
+ attr_accessor :strategy, :receipt, :cfdi
30
+
31
+ def initialize(params)
32
+ @strategy = XML_BUILDING_STRATEGY
33
+
34
+ @receipt = BuhoCfdi::ParamsBuilder.new(params).receipt
35
+ end
36
+
37
+ def process_xml
38
+ @cfdi = strategy.call(receipt)
39
+
40
+ # file = File.new('xml_example.xml', 'w+')
41
+ # file.write(cfdi.to_xml)
42
+ # file.close
43
+
44
+ cfdi
45
+ end
46
+ end
47
+ end