myfinance-rails 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/myfinance/categoria.rb +4 -2
- data/lib/myfinance/centro_receita_custo.rb +26 -5
- data/lib/myfinance/conta_a_receber.rb +4 -0
- data/lib/myfinance/entidade.rb +4 -3
- data/lib/myfinance/version.rb +1 -1
- data/spec/features/categoria_spec.rb +5 -1
- data/spec/features/centro_receita_custo_spec.rb +90 -0
- data/spec/features/contas_a_receber_spec.rb +5 -3
- data/spec/features/entidades_spec.rb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 456f4ce9dd6880ae41a26f481ce0a052020e6711
|
4
|
+
data.tar.gz: 24c8da38786e3bffd15019e3f94a765f251e6635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86f379ebdc9a02b97c21d44068a73047c038d379bce3b4038089dbb0c70fbdc51ce0993784d2bcd2adc5484e897a8d4d8911ad467ad48de44a16a9f8af1729f
|
7
|
+
data.tar.gz: baab5c1fd42a3ae97d2e2d843884dfc61defebc3ee2cde9145f6a85dc68628661a0164ccc0d60ad7f5e9b7d7ce3b4a9b4c6ca8b3cdad72bbda19031ced623a54
|
data/lib/myfinance/categoria.rb
CHANGED
@@ -2,8 +2,7 @@ module Myfinance
|
|
2
2
|
|
3
3
|
def self.categoria_id(nome)
|
4
4
|
mid = nil
|
5
|
-
|
6
|
-
response.each do | item |
|
5
|
+
categorias.each do | item |
|
7
6
|
category = item['category']
|
8
7
|
if category['full_name'] == nome
|
9
8
|
mid = category['id']
|
@@ -13,5 +12,8 @@ module Myfinance
|
|
13
12
|
mid
|
14
13
|
end
|
15
14
|
|
15
|
+
def self.categorias
|
16
|
+
lget '/categories.json'
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
@@ -10,18 +10,39 @@ module Myfinance
|
|
10
10
|
|
11
11
|
def self.centro_id(nome, custo = nil)
|
12
12
|
mid = nil
|
13
|
-
|
14
|
-
response.each do | item |
|
13
|
+
centros(custo).each do | item |
|
15
14
|
cc = item['classification_center']
|
16
15
|
if cc['name'] == nome
|
17
|
-
|
18
|
-
mid = cc['id']
|
19
|
-
end
|
16
|
+
mid = cc['id']
|
20
17
|
break
|
21
18
|
end
|
22
19
|
end
|
23
20
|
mid
|
24
21
|
end
|
25
22
|
|
23
|
+
def self.centros(custo = nil)
|
24
|
+
items = Array.new
|
25
|
+
classification_centers.each do | item |
|
26
|
+
cc = item['classification_center']
|
27
|
+
if custo.nil?
|
28
|
+
items.push(item)
|
29
|
+
else
|
30
|
+
if custo
|
31
|
+
if cc['cost_center']
|
32
|
+
items.push(item)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
if cc['revenue_center']
|
36
|
+
items.push(item)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
items
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.classification_centers
|
45
|
+
lget '/classification_centers.json'
|
46
|
+
end
|
26
47
|
end
|
27
48
|
|
data/lib/myfinance/entidade.rb
CHANGED
@@ -2,8 +2,7 @@ module Myfinance
|
|
2
2
|
|
3
3
|
def self.entidade_id(nome)
|
4
4
|
mid = nil
|
5
|
-
|
6
|
-
response.each do | ent |
|
5
|
+
entidades.each do | ent |
|
7
6
|
cliente = ent['entity']
|
8
7
|
if cliente['name'] == nome or cliente['federation_subscription_number'] == nome
|
9
8
|
mid = cliente['id']
|
@@ -19,6 +18,8 @@ module Myfinance
|
|
19
18
|
response['entity']
|
20
19
|
end
|
21
20
|
|
22
|
-
|
21
|
+
def self.entidades
|
22
|
+
lget '/entities.json'
|
23
|
+
end
|
23
24
|
end
|
24
25
|
|
data/lib/myfinance/version.rb
CHANGED
@@ -16,5 +16,9 @@ describe 'Manipulando Pessoas', type: :feature do
|
|
16
16
|
expect(centro_de_receita_id).to be_nil
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it '#categorias' do
|
20
|
+
double categorias_double = double('categorias_double')
|
21
|
+
expect(Myfinance).to receive(:lget).once.with('/categories.json').and_return categorias_double
|
22
|
+
expect(Myfinance.categorias).to eql(categorias_double)
|
23
|
+
end
|
20
24
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
describe "Manipulando Centros de Receita e Custo", type: :feature do
|
2
|
+
|
3
|
+
require "myfinance"
|
4
|
+
|
5
|
+
let(:centers) {
|
6
|
+
[
|
7
|
+
{"classification_center" => {"cost_center" => true, "created_at" => "2013-05-21T17:05:14-03:00", "entity_id" => 14618, "excel_import_id" => nil, "guid" => nil, "id" => 94150, "imported_from_sync" => false, "modified_by_sync" => false, "name" => "Despesas Marketing", "revenue_center" => false, "updated_at" => "2013-05-21T17:05:14-03:00", "use_count" => 0}},
|
8
|
+
{"classification_center" => {"cost_center" => true, "created_at" => "2013-05-21T17:07:04-03:00", "entity_id" => 14618, "excel_import_id" => nil, "guid" => nil, "id" => 94152, "imported_from_sync" => false, "modified_by_sync" => false, "name" => "Despesas Producao TI", "revenue_center" => false, "updated_at" => "2013-05-21T17:07:04-03:00", "use_count" => 2}},
|
9
|
+
{"classification_center" => {"cost_center" => false, "created_at" => "2013-07-25T17:06:28-03:00", "entity_id" => 14618, "excel_import_id" => nil, "guid" => nil, "id" => 108858, "imported_from_sync" => false, "modified_by_sync" => false, "name" => "Receita de Marketing", "revenue_center" => true, "updated_at" => "2013-07-25T17:06:28-03:00", "use_count" => 23}},
|
10
|
+
{"classification_center" => {"cost_center" => false, "created_at" => "2014-11-05T11:10:42-02:00", "entity_id" => 20341, "excel_import_id" => nil, "guid" => nil, "id" => 173848, "imported_from_sync" => false, "modified_by_sync" => false, "name" => "Receita Total", "revenue_center" => true, "updated_at" => "2014-11-05T11:10:42-02:00", "use_count" => 1}}
|
11
|
+
]
|
12
|
+
}
|
13
|
+
|
14
|
+
describe "#centros" do
|
15
|
+
it "sem filtro" do
|
16
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
17
|
+
centros = Myfinance.centros
|
18
|
+
expect(centros.size).to eql(4)
|
19
|
+
expect(centros[0]["classification_center"]["id"]).to eql(94150)
|
20
|
+
expect(centros[1]["classification_center"]["id"]).to eql(94152)
|
21
|
+
expect(centros[2]["classification_center"]["id"]).to eql(108858)
|
22
|
+
expect(centros[3]["classification_center"]["id"]).to eql(173848)
|
23
|
+
end
|
24
|
+
it "somente custo" do
|
25
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
26
|
+
centros = Myfinance.centros(true)
|
27
|
+
expect(centros.size).to eql(2)
|
28
|
+
expect(centros[0]["classification_center"]["id"]).to eql(94150)
|
29
|
+
expect(centros[1]["classification_center"]["id"]).to eql(94152)
|
30
|
+
end
|
31
|
+
it "somente receita" do
|
32
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
33
|
+
centros = Myfinance.centros(false)
|
34
|
+
expect(centros.size).to eql(2)
|
35
|
+
expect(centros[0]["classification_center"]["id"]).to eql(108858)
|
36
|
+
expect(centros[1]["classification_center"]["id"]).to eql(173848)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#centro_id" do
|
41
|
+
describe "sem filtro" do
|
42
|
+
it "encontrado" do
|
43
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
44
|
+
expect(Myfinance.centro_id("Despesas Producao TI")).to eql(94152)
|
45
|
+
end
|
46
|
+
it "nao encontrado" do
|
47
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
48
|
+
expect(Myfinance.centro_id("XYZ")).to be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe "somente custo" do
|
52
|
+
it "encontrado" do
|
53
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
54
|
+
expect(Myfinance.centro_id("Despesas Producao TI", true)).to eql(94152)
|
55
|
+
end
|
56
|
+
it "nao encontrado" do
|
57
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
58
|
+
expect(Myfinance.centro_id("Receita de Marketing", true)).to be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
describe "somente receita" do
|
62
|
+
it "encontrado" do
|
63
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
64
|
+
expect(Myfinance.centro_id("Despesas Producao TI", false)).to be_nil
|
65
|
+
end
|
66
|
+
it "nao encontrado" do
|
67
|
+
expect(Myfinance).to receive(:classification_centers).once.and_return(centers)
|
68
|
+
expect(Myfinance.centro_id("Receita de Marketing", false)).to eql(108858)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "#centro_de_receita_id" do
|
74
|
+
double id_double = double("id_double")
|
75
|
+
expect(Myfinance).to receive(:centro_id).once.with("nome", false).and_return id_double
|
76
|
+
expect(Myfinance.centro_de_receita_id("nome")).to eql(id_double)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "#centro_de_custo_id" do
|
80
|
+
double id_double = double("id_double")
|
81
|
+
expect(Myfinance).to receive(:centro_id).once.with("nome", true).and_return id_double
|
82
|
+
expect(Myfinance.centro_de_custo_id("nome")).to eql(id_double)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "#classification_centers" do
|
86
|
+
double classification_centers_double = double("classification_centers_double")
|
87
|
+
expect(Myfinance).to receive(:lget).once.with("/classification_centers.json").and_return classification_centers_double
|
88
|
+
expect(Myfinance.classification_centers).to eql(classification_centers_double)
|
89
|
+
end
|
90
|
+
end
|
@@ -63,7 +63,9 @@ describe 'Manipulando Contas a Receber', type: :feature do
|
|
63
63
|
expect(conta_a_receber['receivable_account']).to_not be_nil
|
64
64
|
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
it '#conta_a_receber' do
|
67
|
+
double conta_a_receber_double = double('conta_a_receber_double')
|
68
|
+
expect(Myfinance).to receive(:lget).once.with("/entities/2/receivable_accounts/1.json").and_return conta_a_receber_double
|
69
|
+
expect(Myfinance.conta_a_receber(1,2)).to eql(conta_a_receber_double)
|
70
|
+
end
|
69
71
|
end
|
@@ -17,4 +17,9 @@ describe 'Manipulando Entidades', type: :feature do
|
|
17
17
|
expect(entidade['deleted_at']).to be_nil
|
18
18
|
end
|
19
19
|
|
20
|
+
it '#entidades' do
|
21
|
+
double entidades_double = double('entidades_double')
|
22
|
+
expect(Myfinance).to receive(:lget).once.with('/entities.json').and_return entidades_double
|
23
|
+
expect(Myfinance.entidades).to eql(entidades_double)
|
24
|
+
end
|
20
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myfinance-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Lopes Neto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/myfinance/version.rb
|
92
92
|
- myfinance-rails.gemspec
|
93
93
|
- spec/features/categoria_spec.rb
|
94
|
+
- spec/features/centro_receita_custo_spec.rb
|
94
95
|
- spec/features/contas_a_receber_spec.rb
|
95
96
|
- spec/features/entidades_spec.rb
|
96
97
|
- spec/features/imposto_spec.rb
|
@@ -122,6 +123,7 @@ specification_version: 4
|
|
122
123
|
summary: GEM para facilitar a uso da API do Myfinance em Aplicativos Rails
|
123
124
|
test_files:
|
124
125
|
- spec/features/categoria_spec.rb
|
126
|
+
- spec/features/centro_receita_custo_spec.rb
|
125
127
|
- spec/features/contas_a_receber_spec.rb
|
126
128
|
- spec/features/entidades_spec.rb
|
127
129
|
- spec/features/imposto_spec.rb
|