Skip to content

Commit

Permalink
Version Bump to 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
leanucci committed Mar 1, 2011
1 parent c54d693 commit b3a2c3e
Show file tree
Hide file tree
Showing 16 changed files with 439 additions and 11 deletions.
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
gem "savon"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "rspec", "~> 2.1.0"
gem "rspec", "~> 2.4.0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.5.1"
gem "rcov", ">= 0"
Expand Down
41 changes: 41 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
GEM
remote: http://rubygems.org/
specs:
builder (3.0.0)
crack (0.1.8)
diff-lcs (1.1.2)
git (1.2.5)
gyoku (0.1.1)
builder (>= 2.1.2)
httpi (0.7.7)
rack
jeweler (1.5.2)
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
rack (1.2.1)
rake (0.8.7)
rcov (0.9.9)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
savon (0.8.2)
builder (>= 2.1.2)
crack (~> 0.1.8)
gyoku (>= 0.1.1)
httpi (>= 0.7.5)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.0.0)
jeweler (~> 1.5.1)
rcov
rspec (~> 2.4.0)
savon
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Jeweler::Tasks.new do |gem|
gem.name = "bravo"
gem.homepage = "http://github.com/leanucci/bravo"
gem.license = "MIT"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.email = "leanucci@gmail.com"
gem.summary = "Adaptador AFIP wsfe."
gem.description = "Adaptador para el Web Service de Facturacion Electronica de AFIP"
gem.email = "leanucci@vurbia.com"
gem.authors = ["Leandro Marcucci"]
# Include your dependencies below. Runtime dependencies are required when using your gem,
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0
0.0.1
1 change: 1 addition & 0 deletions autotest/discover.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Autotest.add_discovery { "rspec2" } #added according to rspec2 book
67 changes: 67 additions & 0 deletions bravo.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{bravo}
s.version = "0.0.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Leandro Marcucci"]
s.date = %q{2011-01-07}
s.description = %q{Adaptador para el Web Service de Facturacion Electronica de AFIP}
s.email = %q{leanucci@vurbia.com}
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
s.files = [
".document",
".rspec",
"Gemfile",
"LICENSE.txt",
"README.rdoc",
"Rakefile",
"VERSION",
"lib/bravo.rb",
"spec/spec_helper.rb"
]
s.homepage = %q{http://github.com/leanucci/bravo}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Adaptador AFIP wsfe.}
s.test_files = [
"spec/bravo/auth_data_spec.rb",
"spec/bravo/authorizer_spec.rb",
"spec/bravo/biller_spec.rb",
"spec/spec_helper.rb"
]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<savon>, [">= 0"])
s.add_development_dependency(%q<rspec>, ["~> 2.4.0"])
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
s.add_development_dependency(%q<rcov>, [">= 0"])
else
s.add_dependency(%q<savon>, [">= 0"])
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
s.add_dependency(%q<rcov>, [">= 0"])
end
else
s.add_dependency(%q<savon>, [">= 0"])
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
s.add_dependency(%q<rcov>, [">= 0"])
end
end

24 changes: 24 additions & 0 deletions lib/bravo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Bravo
autoload :Version, "bravo/version"
autoload :Authorizer, "bravo/authorizer"
autoload :AuthData, "bravo/auth_data"
autoload :Biller, "bravo/biller"

extend self
attr_reader :pkey, :cert, :cuit
def pkey=(relative_path)
@pkey = File.read(relative_path)
end

def cert=(relative_path)
@cert = File.read(relative_path)
end

def cuit=()
@cuit = "30711034389"
end

def auth_hash
{"Token" => Bravo::TOKEN, "Sign" => Bravo::SIGN, "Cuit" => Bravo.cuit}
end
end
21 changes: 21 additions & 0 deletions lib/bravo/auth_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'yaml'
module Bravo
class AuthData

def read
get_authdata
end

def get_authdata
# setear endpoint, key, cert, cuit, filename ✔
# crear filename del dia ✔

todays_datafile = "/tmp/bravo_#{Time.new.strftime('%d_%m_%Y')}.yml"
%x("./wsaa-client.sh") unless File.exists?(todays_datafile)

@data = YAML.load_file(todays_datafile).each do |k, v|
Bravo.const_set(k.to_s.upcase, v)
end
end
end
end
10 changes: 10 additions & 0 deletions lib/bravo/authorizer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Bravo
class Authorizer
attr_reader :pkey, :cert

def initialize
@pkey = Bravo.pkey
@cert = Bravo.cert
end
end
end
80 changes: 80 additions & 0 deletions lib/bravo/biller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
module Bravo
class Biller
def initialize
Bravo::AuthData.read
end

def dummy
client = Savon::Client.new "http://wswhomo.afip.gov.ar/wsfev1/service.asmx?WSDL"
# client.fecaea_solicitar do |s|
# s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
# s.body = {"Auth" => {"Token" => TOKEN, "Sign" => SIGN, "Cuit" => CUIT.to_i},
# "Periodo" => "201101", "Orden" => "2"}
# end

# client.fecae_solicitar do |s|
# s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
# s.body = {"Auth" => {"Token" => TOKEN, "Sign" => SIGN, "Cuit" => CUIT.to_i},
# "FeCAEReq" => {"FeCabReq" => {"CantReg" => "", "CbteTipo" => "", "PtoVta" => ""},
# "FeCAEDetReq" => {"Concepto" => "",
# "DocTipo" => "",
# "DocNro" => "",
# "CbteDesde" => "",
# "CbteHasta" => "",
# "CbteFch" => "",
# "ImpTotal" => "",
# "ImpTotConc" => "",
# "ImpNeto" => "",
# "ImpOpEx" => "",
# "ImpIVA" => "",
# "ImpTrib" => "",
# "MonId" => "",
# "MonCotiz" => "",
# }}}
# end

# client.fe_param_get_tipos_iva do |s|
# s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
# s.body = {"Auth" => {"Token" => TOKEN, "Sign" => SIGN, "Cuit" => CUIT.to_i}}
# end

resp = client.fe_comp_ultimo_autorizado do |s|
s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
s.body = {"Auth" => Bravo.auth_hash,
"PtoVta" => "2", "CbteTipo" => "1"}
end

@nro = resp.to_hash[:fe_comp_ultimo_autorizado_response][:fe_comp_ultimo_autorizado_result][:cbte_nro]

client.fecae_solicitar do |s|
s.namespaces["xmlns"] = "http://ar.gov.afip.dif.FEV1/"
s.body = {"Auth" => Bravo.auth_hash,
"FeCAEReq" => {"FeCabReq" => {"CantReg" => "1", #todo sacado de la factura
"CbteTipo" => "1",
"PtoVta" => "2"},
"FeDetReq" => {"FECAEDetRequest" => { "Concepto" => "1", #productos
"DocTipo" => "80",
"DocNro" => "30710151543",
"CbteDesde" => @nro.to_i+1,
"CbteHasta" => @nro.to_i+1,
"CbteFch" => "20110105",
"ImpTotal" => "121.00",
"ImpTotConc" => "0.00",
"ImpNeto" => "100.00",
"ImpOpEx" => "0.00",
"ImpIVA" => "21.00",
"ImpTrib" => "0.00",
"MonId" => "PES",
"MonCotiz" => "1.00",
"Iva" => { "AlicIva" => { "Id" => "5",
"BaseImp" => "100",
"Importe" => "21"}
}
}
}
}
}
end
end
end
end
3 changes: 3 additions & 0 deletions lib/bravo/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Bravo
VERSION = "0.0.1"
end
9 changes: 9 additions & 0 deletions spec/bravo/auth_data_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "AuthData" do
it "should read todays data" do
Bravo::AuthData.new.read
end
it "should get sign and key for the day"
it "should get todays data and store it to file"
end
12 changes: 12 additions & 0 deletions spec/bravo/authorizer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Authorizer" do
it "should read credentials on initialize" do
authorizer = Bravo::Authorizer.new
authorizer.pkey.should == File.read('spec/fixtures/pkey')
authorizer.cert.should == File.read('spec/fixtures/cert.crt')
end

it "should store sign and key for the day"
it "should return sign and key for the day"
end
5 changes: 5 additions & 0 deletions spec/bravo/biller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Biller" do
it "should get basic CAE"
end
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|

end
Bravo.pkey = 'spec/fixtures/pkey'
Bravo.cert = 'spec/fixtures/cert.crt'
Loading

0 comments on commit b3a2c3e

Please sign in to comment.