bravo 0.3.0 → 0.3.5

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 CHANGED
@@ -1,3 +1,11 @@
1
+ *Bravo 0.4.0 (March 11, 2011)*
2
+
3
+ * Errors will be raised if CERT or PKEY are not present [miloops]
4
+ * Removed various hardcoded options [leanucci]
5
+ * Added support for more iva conditions [miloops]
6
+ * Log verbosity switch [leanucci]
7
+ * Better spec coverage
8
+
1
9
  *Bravo 0.3.0 (March 07, 2011)*
2
10
 
3
11
  * Bill#response returns the full list of parameters passed and returned by FECAESolicitar [leanucci]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.5
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.3.0"
8
+ s.version = "0.3.5"
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-07}
12
+ s.date = %q{2011-03-11}
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 = [
@@ -3,9 +3,16 @@ module Bravo
3
3
 
4
4
  class << self
5
5
  def fetch
6
+ unless File.exists?(Bravo.pkey)
7
+ raise "Archivo de llave privada no encontrado en #{Bravo.pkey}"
8
+ end
9
+
10
+ unless File.exists?(Bravo.cert)
11
+ raise "Archivo certificado no encontrado en #{Bravo.cert}"
12
+ end
13
+
6
14
  todays_datafile = "/tmp/bravo_#{Time.new.strftime('%d_%m_%Y')}.yml"
7
15
  opts = "-u https://wsaahomo.afip.gov.ar/ws/services/LoginCms"
8
- keys_root = "/Users/leanucci/Xephstratus/afip/claves/"
9
16
  opts += " -k #{Bravo.pkey}"
10
17
  opts += " -c #{Bravo.cert}"
11
18
 
data/lib/bravo/bill.rb CHANGED
@@ -91,7 +91,7 @@ module Bravo
91
91
  def next_bill_number
92
92
  resp = client.fe_comp_ultimo_autorizado do |s|
93
93
  s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
94
- s.body = {"Auth" => Bravo.auth_hash, "PtoVta" => Bravo.sale_point, "CbteTipo" => "1"}
94
+ s.body = {"Auth" => Bravo.auth_hash, "PtoVta" => Bravo.sale_point, "CbteTipo" => cbte_type}
95
95
  end
96
96
 
97
97
  resp.to_hash[:fe_comp_ultimo_autorizado_response][:fe_comp_ultimo_autorizado_result][:cbte_nro].to_i + 1
@@ -105,7 +105,7 @@ module Bravo
105
105
 
106
106
  class << self
107
107
  def header(cbte_type)#todo sacado de la factura
108
- {"CantReg" => "1", "CbteTipo" => cbte_type, "PtoVta" => "2"}
108
+ {"CantReg" => "1", "CbteTipo" => cbte_type, "PtoVta" => Bravo.sale_point}
109
109
  end
110
110
  end
111
111
 
@@ -138,7 +138,7 @@ module Bravo
138
138
  }.merge!(request_header).merge!(request_detail)
139
139
 
140
140
  keys, values = response_hash.to_a.transpose
141
- self.response = Struct.new("Response", *keys).new(*values)
141
+ self.response = (defined?(Struct::Response) ? Struct::Response : Struct.new("Response", *keys)).new(*values)
142
142
  end
143
143
  end
144
144
  end
@@ -33,10 +33,7 @@ module Bravo
33
33
  :oro => {:codigo => "049", :nombre =>"Gramos de Oro Fino"}
34
34
  }
35
35
 
36
- ALIC_IVA = [["03", 0],
37
- ["04", 0.105],
38
- ["05", 0.21],
39
- ["06", 0.27]]
36
+ ALIC_IVA = [["03", 0], ["04", 0.105], ["05", 0.21], ["06", 0.27]]
40
37
 
41
- BILL_TYPE = {:responsable_inscripto => {:responsable_inscripto => "01", :consumidor_final => "06"}}
38
+ BILL_TYPE = {:responsable_inscripto => {:responsable_inscripto => "01", :consumidor_final => "06", :exento => "06", :responsable_monotributo => "06"}}
42
39
  end
data/lib/bravo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bravo
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/bravo.rb CHANGED
@@ -17,9 +17,11 @@ module Bravo
17
17
 
18
18
  extend self
19
19
  attr_accessor :cuit, :sale_point, :service_url, :default_documento, :pkey, :cert,
20
- :default_concepto, :default_moneda, :own_iva_cond
20
+ :default_concepto, :default_moneda, :own_iva_cond, :verbose
21
21
 
22
22
  def auth_hash
23
23
  {"Token" => Bravo::TOKEN, "Sign" => Bravo::SIGN, "Cuit" => Bravo.cuit}
24
24
  end
25
+
26
+ Savon::Request.log = false unless (Bravo.verbose == "true") || (ENV["VERBOSE"] == true)
25
27
  end
@@ -84,21 +84,23 @@ describe "Bill" do
84
84
  detail["FchVtoPago"].should == "20111210"
85
85
  end
86
86
 
87
- it "should authorize a valid bill" do
88
- @bill.net = 1000000
89
- @bill.aliciva_id = 2
90
- @bill.doc_num = "30710151543"
91
- @bill.iva_cond = :responsable_inscripto
92
- @bill.concepto = "Servicios"
93
-
94
- @bill.authorized?.should == false
95
- @bill.authorize.should == true
96
- @bill.authorized?.should == true
97
-
98
- response = @bill.response
99
-
100
- response.length.should == 28
101
- response.cae.length.should == 14
87
+ Bravo::BILL_TYPE[Bravo.own_iva_cond].keys.each do |target_iva_cond|
88
+ it "should authorize a valid bill for #{target_iva_cond.to_s}" do
89
+ @bill.net = 1000000
90
+ @bill.aliciva_id = 2
91
+ @bill.doc_num = "30710151543"
92
+ @bill.iva_cond = target_iva_cond
93
+ @bill.concepto = "Servicios"
94
+
95
+ @bill.authorized?.should == false
96
+ @bill.authorize.should == true
97
+ @bill.authorized?.should == true
98
+
99
+ response = @bill.response
100
+
101
+ response.length.should == 28
102
+ response.cae.length.should == 14
103
+ end
102
104
  end
103
105
  end
104
106
  end
data/spec/spec_helper.rb CHANGED
@@ -11,8 +11,6 @@ end
11
11
  # in ./support/ and its subdirectories.
12
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
13
13
 
14
- Savon::Request.log = false unless ENV["VERBOSE"] == "true"
15
-
16
14
  Bravo.pkey = "spec/fixtures/pkey"
17
15
  Bravo.cert = "spec/fixtures/cert.crt"
18
16
  Bravo.cuit = ENV["CUIT"] || raise(Bravo::NullOrInvalidAttribute.new, "Please set CUIT env variable.")
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: 19
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 5
10
+ version: 0.3.5
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-07 00:00:00 -03:00
18
+ date: 2011-03-11 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency