bravo 0.2.0 → 0.3.0
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.
- data/CHANGELOG +4 -0
- data/VERSION +1 -1
- data/bravo.gemspec +3 -2
- data/lib/bravo.rb +1 -0
- data/lib/bravo/bill.rb +27 -15
- data/lib/bravo/core_ext/hash.rb +1 -1
- data/lib/bravo/core_ext/string.rb +12 -0
- data/lib/bravo/version.rb +1 -1
- data/spec/bravo/bill_spec.rb +4 -10
- metadata +5 -4
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bravo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bravo}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Leandro Marcucci"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-07}
|
13
13
|
s.description = %q{Adaptador para el Web Service de Facturacion Electronica de AFIP}
|
14
14
|
s.email = %q{leanucci@vurbia.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"lib/bravo/constants.rb",
|
35
35
|
"lib/bravo/core_ext/float.rb",
|
36
36
|
"lib/bravo/core_ext/hash.rb",
|
37
|
+
"lib/bravo/core_ext/string.rb",
|
37
38
|
"lib/bravo/version.rb",
|
38
39
|
"spec/bravo/auth_data_spec.rb",
|
39
40
|
"spec/bravo/authorizer_spec.rb",
|
data/lib/bravo.rb
CHANGED
data/lib/bravo/bill.rb
CHANGED
@@ -2,14 +2,14 @@ module Bravo
|
|
2
2
|
class Bill
|
3
3
|
attr_reader :client, :base_imp, :total
|
4
4
|
attr_accessor :net, :doc_num, :iva_cond, :documento, :concepto, :moneda,
|
5
|
-
:due_date, :
|
5
|
+
:due_date, :aliciva_id, :fch_serv_desde, :fch_serv_hasta,
|
6
6
|
:body, :response
|
7
7
|
|
8
8
|
def initialize(attrs = {})
|
9
9
|
Bravo::AuthData.fetch
|
10
|
-
@client
|
11
|
-
@body
|
12
|
-
@net
|
10
|
+
@client = Savon::Client.new(Bravo.service_url)
|
11
|
+
@body = {"Auth" => Bravo.auth_hash}
|
12
|
+
@net = attrs[:net] || 0
|
13
13
|
self.documento = attrs[:documento] || Bravo.default_documento
|
14
14
|
self.moneda = attrs[:moneda] || Bravo.default_moneda
|
15
15
|
self.iva_cond = attrs[:iva_cond]
|
@@ -110,20 +110,32 @@ module Bravo
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def setup_response(response)
|
113
|
-
|
114
|
-
detail_response = response[:fecae_solicitar_response][:fecae_solicitar_result][:fe_det_resp][:fecae_det_response].symbolize_keys
|
113
|
+
# TODO: turn this into an all-purpose Response class
|
115
114
|
|
116
|
-
|
115
|
+
result = response[:fecae_solicitar_response][:fecae_solicitar_result]
|
117
116
|
|
118
|
-
|
117
|
+
response_header = result[:fe_cab_resp]
|
118
|
+
response_detail = result[:fe_det_resp][:fecae_det_response]
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
120
|
+
request_header = body["FeCAEReq"]["FeCabReq"].underscore_keys.symbolize_keys
|
121
|
+
request_detail = body["FeCAEReq"]["FeDetReq"]["FECAEDetRequest"].underscore_keys.symbolize_keys
|
122
|
+
|
123
|
+
iva = request_detail.delete(:iva)["AlicIva"].underscore_keys.symbolize_keys
|
124
|
+
|
125
|
+
request_detail.merge!(iva)
|
126
|
+
|
127
|
+
response_hash = {:header_result => response_header.delete(:resultado),
|
128
|
+
:authorized_on => response_header.delete(:fch_proceso),
|
129
|
+
:detail_result => response_detail.delete(:resultado),
|
130
|
+
:cae_due_date => response_detail.delete(:cae_fch_vto),
|
131
|
+
:cae => response_detail.delete(:cae),
|
132
|
+
:iva_id => request_detail.delete(:id),
|
133
|
+
:iva_importe => request_detail.delete(:importe),
|
134
|
+
:moneda => request_detail.delete(:mon_id),
|
135
|
+
:cotizacion => request_detail.delete(:mon_cotiz),
|
136
|
+
:iva_base_imp => request_detail.delete(:base_imp),
|
137
|
+
:doc_num => request_detail.delete(:doc_nro)
|
138
|
+
}.merge!(request_header).merge!(request_detail)
|
127
139
|
|
128
140
|
keys, values = response_hash.to_a.transpose
|
129
141
|
self.response = Struct.new("Response", *keys).new(*values)
|
data/lib/bravo/core_ext/hash.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Stolen from activesupport/lib/active_support/inflector/methods.rb, line 48
|
2
|
+
class String
|
3
|
+
def underscore
|
4
|
+
word = self.to_s.dup
|
5
|
+
word.gsub!(/::/, '/')
|
6
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
7
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
8
|
+
word.tr!("-", "_")
|
9
|
+
word.downcase!
|
10
|
+
word
|
11
|
+
end
|
12
|
+
end
|
data/lib/bravo/version.rb
CHANGED
data/spec/bravo/bill_spec.rb
CHANGED
@@ -91,20 +91,14 @@ describe "Bill" do
|
|
91
91
|
@bill.iva_cond = :responsable_inscripto
|
92
92
|
@bill.concepto = "Servicios"
|
93
93
|
|
94
|
-
@bill.authorized?.should
|
95
|
-
|
96
|
-
@bill.
|
97
|
-
|
98
|
-
@bill.authorized?.should == true
|
94
|
+
@bill.authorized?.should == false
|
95
|
+
@bill.authorize.should == true
|
96
|
+
@bill.authorized?.should == true
|
99
97
|
|
100
98
|
response = @bill.response
|
101
99
|
|
100
|
+
response.length.should == 28
|
102
101
|
response.cae.length.should == 14
|
103
|
-
|
104
|
-
pp response
|
105
|
-
|
106
|
-
response.length.should == 19
|
107
|
-
|
108
102
|
end
|
109
103
|
end
|
110
104
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bravo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Leandro Marcucci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-07 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/bravo/constants.rb
|
170
170
|
- lib/bravo/core_ext/float.rb
|
171
171
|
- lib/bravo/core_ext/hash.rb
|
172
|
+
- lib/bravo/core_ext/string.rb
|
172
173
|
- lib/bravo/version.rb
|
173
174
|
- spec/bravo/auth_data_spec.rb
|
174
175
|
- spec/bravo/authorizer_spec.rb
|