forked from vurbia/bravo
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
439 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.0 | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Autotest.add_discovery { "rspec2" } #added according to rspec2 book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Bravo | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.