spree_zaez_tnt_mercurio 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +7 -0
- data/Guardfile +90 -0
- data/LICENSE +22 -0
- data/README.md +89 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/spree_zaez_tnt_mercurio.js +2 -0
- data/app/assets/javascripts/spree/frontend/spree_zaez_tnt_mercurio.js +2 -0
- data/app/assets/stylesheets/spree/backend/spree_zaez_tnt_mercurio.css +3 -0
- data/app/assets/stylesheets/spree/frontend/spree_zaez_tnt_mercurio.css +4 -0
- data/app/controllers/spree/admin/tnt_mercurio_settings_controller.rb +20 -0
- data/app/models/spree/calculator/shipping/tnt_mercurio_anc.rb +13 -0
- data/app/models/spree/calculator/shipping/tnt_mercurio_base_calculator.rb +42 -0
- data/app/models/spree/calculator/shipping/tnt_mercurio_rnc.rb +13 -0
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_tnt_mercurio_settings_tab.html.erb.deface +2 -0
- data/app/views/spree/admin/tnt_mercurio_settings/edit.html.erb +76 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +41 -0
- data/config/locales/pt-br.yml +41 -0
- data/config/routes.rb +5 -0
- data/lib/generators/spree_zaez_tnt_mercurio/install/install_generator.rb +31 -0
- data/lib/spree/tnt_mercurio_configuration.rb +18 -0
- data/lib/spree_zaez_tnt_mercurio/engine.rb +32 -0
- data/lib/spree_zaez_tnt_mercurio/factories.rb +9 -0
- data/lib/spree_zaez_tnt_mercurio.rb +3 -0
- data/spec/features/admin/tnt_settings_spec.rb +121 -0
- data/spec/fixtures/calcula_frete/error_response.xml +28 -0
- data/spec/fixtures/calcula_frete/invalid_credentials.xml +32 -0
- data/spec/fixtures/calcula_frete/success_response.xml +155 -0
- data/spec/models/spree/calculator/shipping/tnt_mercurio_anc_spec.rb +19 -0
- data/spec/models/spree/calculator/shipping/tnt_mercurio_rnc_spec.rb +18 -0
- data/spec/models/spree/tnt_mercurio_configuration_spec.rb +14 -0
- data/spec/shared_examples/tnt_calculator.rb +159 -0
- data/spec/spec_helper.rb +89 -0
- data/spec/support/capybara_login.rb +6 -0
- data/spec/support/verify_tnt_input_field.rb +16 -0
- data/spree_zaez_tnt_mercurio.gemspec +38 -0
- metadata +53 -3
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'TNT Settings', type: :feature do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@admin = Spree.user_class.create(email: 'admin@admin.com', password: 'password', password_confirmation: 'password')
|
7
|
+
@role = Spree::Role.create(name: 'admin')
|
8
|
+
@role.users << @admin
|
9
|
+
sign_in_admin! @admin
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'visit TNT settings' do
|
13
|
+
it 'should be a link to tnt settings' do
|
14
|
+
within('.sidebar') { page.find_link('TNT Mercurio Settings')['/admin/tnt_mercurio_settings/edit'] }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'show TNT settings', js: true do
|
19
|
+
it 'should be present all tnt settings' do
|
20
|
+
visit spree.edit_admin_tnt_mercurio_settings_path
|
21
|
+
|
22
|
+
expect(page).to have_selector '#email'
|
23
|
+
expect(page).to have_selector '#password'
|
24
|
+
expect(page).to have_selector '#division'
|
25
|
+
expect(page).to have_selector '#cgc'
|
26
|
+
expect(page).to have_selector '#state_registry'
|
27
|
+
expect(page).to have_selector '[name=type_cgc]'
|
28
|
+
expect(page).to have_selector '[name=billet_type]'
|
29
|
+
expect(page).to have_selector '[name=tax_situation]'
|
30
|
+
expect(page).to have_selector '#additional_days'
|
31
|
+
expect(page).to have_selector '#additional_value'
|
32
|
+
expect(page).to have_selector '#customer_field'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'edit TNT settings' do
|
37
|
+
before { visit spree.edit_admin_tnt_mercurio_settings_path }
|
38
|
+
|
39
|
+
it 'can edit the email', js: true do
|
40
|
+
fill_in 'Email', with: 'some@email.com'
|
41
|
+
click_button 'Update'
|
42
|
+
|
43
|
+
verify_tnt_input_value 'email', Spree::TntMercurioConfig, 'some@email.com', ''
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'can edit the password', js: true do
|
47
|
+
fill_in 'Password', with: '123'
|
48
|
+
click_button 'Update'
|
49
|
+
verify_tnt_input_value 'password', Spree::TntMercurioConfig, '123', ''
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can edit the division', js: true do
|
53
|
+
fill_in 'Division', with: '1'
|
54
|
+
click_button 'Update'
|
55
|
+
verify_tnt_input_value 'division', Spree::TntMercurioConfig, 1, 0
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'can edit the CGC', js: true do
|
59
|
+
fill_in 'CGC', with: '12345'
|
60
|
+
click_button 'Update'
|
61
|
+
verify_tnt_input_value 'cgc', Spree::TntMercurioConfig, '12345', ''
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can edit the state registry', js: true do
|
65
|
+
fill_in 'State Registry', with: '123'
|
66
|
+
click_button 'Update'
|
67
|
+
verify_tnt_input_value 'state_registry', Spree::TntMercurioConfig, '123', ''
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'can edit the CGC type', js: true do
|
71
|
+
find(:css, '#type_cgc_F').set true
|
72
|
+
click_button 'Update'
|
73
|
+
|
74
|
+
expect(Spree::TntMercurioConfig.type_cgc).to eq 'F'
|
75
|
+
expect(find_field('type_cgc_F')).to be_checked
|
76
|
+
|
77
|
+
# set default
|
78
|
+
Spree::TntMercurioConfig.type_cgc = 'J'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can edit the billet type', js: true do
|
82
|
+
find(:css, '#billet_type_F').set true
|
83
|
+
click_button 'Update'
|
84
|
+
|
85
|
+
expect(Spree::TntMercurioConfig.billet_type).to eq 'F'
|
86
|
+
expect(find_field('billet_type_F')).to be_checked
|
87
|
+
|
88
|
+
# set default
|
89
|
+
Spree::TntMercurioConfig.billet_type = 'C'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'can edit the tax situation', js: true do
|
93
|
+
find(:css, '#tax_situation_ME').set true
|
94
|
+
click_button 'Update'
|
95
|
+
|
96
|
+
expect(Spree::TntMercurioConfig.tax_situation).to eq 'ME'
|
97
|
+
expect(find_field('tax_situation_ME')).to be_checked
|
98
|
+
|
99
|
+
# set default
|
100
|
+
Spree::TntMercurioConfig.tax_situation = 'CO'
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'can edit the additional days', js: true do
|
104
|
+
fill_in 'Additional Days', with: '3'
|
105
|
+
click_button 'Update'
|
106
|
+
verify_tnt_input_value 'additional_days', Spree::TntMercurioConfig, 3, 0
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'can edit the additional value', js: true do
|
110
|
+
fill_in 'Additional Value', with: '10'
|
111
|
+
click_button 'Update'
|
112
|
+
verify_tnt_input_value 'additional_value', Spree::TntMercurioConfig, 10, 0
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'can edit the customer field', js: true do
|
116
|
+
select('Email', :from => 'Customer Field')
|
117
|
+
click_button 'Update'
|
118
|
+
verify_tnt_input_value 'customer_field', Spree::TntMercurioConfig, 'email', ''
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
2
|
+
<soap:Body>
|
3
|
+
<ns1:calculaFreteResponse xmlns:ns1="http://service.calculoFrete.mercurio.com">
|
4
|
+
<ns1:out>
|
5
|
+
<errorList xmlns="http://model.expedicao.lms.mercurio.com\">
|
6
|
+
<ns1:string>Peso da mercadoria est\xC3\xA1 fora dos limites.</ns1:string>
|
7
|
+
</errorList>
|
8
|
+
<nmDestinatario xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
9
|
+
<nmMunicipioDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
10
|
+
<nmMunicipioOrigem xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
11
|
+
<nmRemetente xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
12
|
+
<nrDDDFilialDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
13
|
+
<nrDDDFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
14
|
+
<nrTelefoneFilialDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
15
|
+
<nrTelefoneFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
16
|
+
<parcelas xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
17
|
+
<prazoEntrega xmlns="http://model.expedicao.lms.mercurio.com">0</prazoEntrega>
|
18
|
+
<servicosAdicionais xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
19
|
+
<vlDesconto xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
20
|
+
<vlICMSubstituicaoTributaria xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
21
|
+
<vlImposto xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
22
|
+
<vlTotalCtrc xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
23
|
+
<vlTotalFrete xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
24
|
+
<vlTotalServico xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
25
|
+
</ns1:out>
|
26
|
+
</ns1:calculaFreteResponse>
|
27
|
+
</soap:Body>
|
28
|
+
</soap:Envelope>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
2
|
+
<soap:Body>
|
3
|
+
<ns1:calculaFreteResponse xmlns:ns1="http://service.calculoFrete.mercurio.com">
|
4
|
+
<ns1:out>
|
5
|
+
<errorList xmlns="http://model.expedicao.lms.mercurio.com">
|
6
|
+
<ns1:string>Login \xC3\xA9 obrigat\xC3\xB3rio.</ns1:string>
|
7
|
+
<ns1:string>Identifica\xC3\xA7\xC3\xA3o do cliente remetente \xC3\xA9 obrigat\xC3\xB3ria.</ns1:string>
|
8
|
+
<ns1:string>Identifica\xC3\xA7\xC3\xA3o do cliente destinat\xC3\xA1rio \xC3\xA9 obrigat\xC3\xB3ria.</ns1:string>
|
9
|
+
<ns1:string>Inscri\xC3\xA7\xC3\xA3o estadual do remetente \xC3\xA9 obrigat\xC3\xB3ria quando o frete \xC3\xA9 CIF.</ns1:string>
|
10
|
+
<ns1:string>Usu\xC3\xA1rio n\xC3\xA3o possui permiss\xC3\xA3o para realizar cota\xC3\xA7\xC3\xA3o de frete para o CNPJ </ns1:string>
|
11
|
+
</errorList>
|
12
|
+
<nmDestinatario xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
13
|
+
<nmMunicipioDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
14
|
+
<nmMunicipioOrigem xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
15
|
+
<nmRemetente xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
16
|
+
<nrDDDFilialDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
17
|
+
<nrDDDFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
18
|
+
<nrTelefoneFilialDestino xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
19
|
+
<nrTelefoneFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com\" xsi:nil="true" />
|
20
|
+
<parcelas xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
21
|
+
<prazoEntrega xmlns="http://model.expedicao.lms.mercurio.com">0</prazoEntrega>
|
22
|
+
<servicosAdicionais xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
23
|
+
<vlDesconto xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
24
|
+
<vlICMSubstituicaoTributaria xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
25
|
+
<vlImposto xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
26
|
+
<vlTotalCtrc xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
27
|
+
<vlTotalFrete xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
28
|
+
<vlTotalServico xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
29
|
+
</ns1:out>
|
30
|
+
</ns1:calculaFreteResponse>
|
31
|
+
</soap:Body>
|
32
|
+
</soap:Envelope>
|
@@ -0,0 +1,155 @@
|
|
1
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
2
|
+
<soap:Body>
|
3
|
+
<ns1:calculaFreteResponse xmlns:ns1="http://service.calculoFrete.mercurio.com">
|
4
|
+
<ns1:out>
|
5
|
+
<errorList xmlns="http://model.expedicao.lms.mercurio.com" />
|
6
|
+
<nmDestinatario xmlns="http://model.expedicao.lms.mercurio.com" xsi:nil="true" />
|
7
|
+
<nmMunicipioDestino xmlns="http://model.expedicao.lms.mercurio.com">Ja\xC3\xBA</nmMunicipioDestino>
|
8
|
+
<nmMunicipioOrigem xmlns="http://model.expedicao.lms.mercurio.com">S\xC3\xA3o Paulo</nmMunicipioOrigem>
|
9
|
+
<nmRemetente xmlns="http://model.expedicao.lms.mercurio.com">RAZAO SOCIAL EMPRESA</nmRemetente>
|
10
|
+
<nrDDDFilialDestino xmlns="http://model.expedicao.lms.mercurio.com\">14</nrDDDFilialDestino>
|
11
|
+
<nrDDDFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com\">11</nrDDDFilialOrigem>
|
12
|
+
<nrTelefoneFilialDestino xmlns="http://model.expedicao.lms.mercurio.com\">40095000</nrTelefoneFilialDestino>
|
13
|
+
<nrTelefoneFilialOrigem xmlns="http://model.expedicao.lms.mercurio.com\">4009-5000</nrTelefoneFilialOrigem>
|
14
|
+
<parcelas xmlns="http://model.expedicao.lms.mercurio.com">
|
15
|
+
<ParcelasFreteWebService>
|
16
|
+
<dsParcela>Frete peso</dsParcela>
|
17
|
+
<vlParcela>32.07</vlParcela>
|
18
|
+
</ParcelasFreteWebService>
|
19
|
+
<ParcelasFreteWebService>
|
20
|
+
<dsParcela>Frete Valor</dsParcela>
|
21
|
+
<vlParcela>0.28</vlParcela>
|
22
|
+
</ParcelasFreteWebService>
|
23
|
+
<ParcelasFreteWebService>
|
24
|
+
<dsParcela>GRIS</dsParcela>
|
25
|
+
<vlParcela>5.19</vlParcela>
|
26
|
+
</ParcelasFreteWebService>
|
27
|
+
<ParcelasFreteWebService>
|
28
|
+
<dsParcela>Ped\xC3\xA1gio</dsParcela>
|
29
|
+
<vlParcela>5.53</vlParcela>
|
30
|
+
</ParcelasFreteWebService>
|
31
|
+
<ParcelasFreteWebService>
|
32
|
+
<dsParcela>Despacho</dsParcela>
|
33
|
+
<vlParcela>26.22</vlParcela>
|
34
|
+
</ParcelasFreteWebService>
|
35
|
+
</parcelas>
|
36
|
+
<prazoEntrega xmlns="http://model.expedicao.lms.mercurio.com">3</prazoEntrega>
|
37
|
+
<servicosAdicionais xmlns="http://model.expedicao.lms.mercurio.com">
|
38
|
+
<ServicoAdicionalWebService>
|
39
|
+
<dsComplemento>15,86% sobre o valor do frete com m\xC3\xADnimo de R$ 11,69.</dsComplemento>
|
40
|
+
<nmServico>Agendamento de entrega</nmServico>
|
41
|
+
<sgMoeda>R$</sgMoeda>
|
42
|
+
<vlServico>15.86</vlServico>
|
43
|
+
</ServicoAdicionalWebService>
|
44
|
+
<ServicoAdicionalWebService>
|
45
|
+
<dsComplemento>Custo + Impostos + 27,19%.</dsComplemento>
|
46
|
+
<nmServico>Capatazia</nmServico>
|
47
|
+
<sgMoeda>R$</sgMoeda>
|
48
|
+
<vlServico>27.19</vlServico>
|
49
|
+
</ServicoAdicionalWebService>
|
50
|
+
<ServicoAdicionalWebService>
|
51
|
+
<dsComplemento>R$ 7,22 - 2 seguran\xC3\xA7as - unidirecional - por km rodado.</dsComplemento>
|
52
|
+
<nmServico>Escolta</nmServico>
|
53
|
+
<sgMoeda>R$</sgMoeda>
|
54
|
+
<vlServico>7.22</vlServico>
|
55
|
+
</ServicoAdicionalWebService>
|
56
|
+
<ServicoAdicionalWebService>
|
57
|
+
<dsComplemento>R$ 1.087,58 por per\xC3\xADodo.</dsComplemento>
|
58
|
+
<nmServico>Estadia de veiculo conjunto</nmServico>
|
59
|
+
<sgMoeda>R$</sgMoeda>
|
60
|
+
<vlServico>1087.58</vlServico>
|
61
|
+
</ServicoAdicionalWebService>
|
62
|
+
<ServicoAdicionalWebService>
|
63
|
+
<dsComplemento>R$ 1.010,04 por per\xC3\xADodo.</dsComplemento>
|
64
|
+
<nmServico>Estadia de ve\xC3\xADculo 3/4</nmServico>
|
65
|
+
<sgMoeda>R$</sgMoeda>
|
66
|
+
<vlServico>1010.04</vlServico>
|
67
|
+
</ServicoAdicionalWebService>
|
68
|
+
<ServicoAdicionalWebService>
|
69
|
+
<dsComplemento>R$ 884,38 por per\xC3\xADodo.</dsComplemento>
|
70
|
+
<nmServico>Estadia de ve\xC3\xADculo carreta</nmServico>
|
71
|
+
<sgMoeda>R$</sgMoeda>
|
72
|
+
<vlServico>884.38</vlServico>
|
73
|
+
</ServicoAdicionalWebService>
|
74
|
+
<ServicoAdicionalWebService>
|
75
|
+
<dsComplemento>R$ 707,59 por per\xC3\xADodo.</dsComplemento>
|
76
|
+
<nmServico>Estadia de ve\xC3\xADculo toco</nmServico>
|
77
|
+
<sgMoeda>R$</sgMoeda>
|
78
|
+
<vlServico>707.59</vlServico>
|
79
|
+
</ServicoAdicionalWebService>
|
80
|
+
<ServicoAdicionalWebService>
|
81
|
+
<dsComplemento>R$ 707,59 por per\xC3\xADodo.</dsComplemento>
|
82
|
+
<nmServico>Estadia de ve\xC3\xADculo truck</nmServico>
|
83
|
+
<sgMoeda>R$</sgMoeda>
|
84
|
+
<vlServico>707.59</vlServico>
|
85
|
+
</ServicoAdicionalWebService>
|
86
|
+
<ServicoAdicionalWebService>
|
87
|
+
<dsComplemento>R$ 25,99 por pallet padr\xC3\xA3o PBR.</dsComplemento>
|
88
|
+
<nmServico>Paletiza\xC3\xA7\xC3\xA3o</nmServico>
|
89
|
+
<sgMoeda>R$</sgMoeda>
|
90
|
+
<vlServico>25.99</vlServico>
|
91
|
+
</ServicoAdicionalWebService>
|
92
|
+
<ServicoAdicionalWebService>
|
93
|
+
<dsComplemento>0,18% sobre o valor da mercadoria por per\xC3\xADodo.</dsComplemento>
|
94
|
+
<nmServico>Seguro da carga em perman\xC3\xAAncia</nmServico>
|
95
|
+
<sgMoeda>R$</sgMoeda>
|
96
|
+
<vlServico>0.18</vlServico>
|
97
|
+
</ServicoAdicionalWebService>
|
98
|
+
<ServicoAdicionalWebService>
|
99
|
+
<dsComplemento>R$ 0,19 por kg/dia com m\xC3\xADnimo de R$ 20,06 com car\xC3\xAAncia de 3 dias e decurso de prazo de 15 dias.</dsComplemento>
|
100
|
+
<nmServico>Taxa de fiel deposit\xC3\xA1rio</nmServico>
|
101
|
+
<sgMoeda>R$</sgMoeda>
|
102
|
+
<vlServico>0.19</vlServico>
|
103
|
+
</ServicoAdicionalWebService>
|
104
|
+
<ServicoAdicionalWebService>
|
105
|
+
<dsComplemento>R$ 0,28 por kg/dia com m\xC3\xADnimo de R$ 28,66 com car\xC3\xAAncia de 15 dias e decurso de prazo de 15 dias.</dsComplemento>
|
106
|
+
<nmServico>Taxa de perman\xC3\xAAncia de carga</nmServico>
|
107
|
+
<sgMoeda>R$</sgMoeda>
|
108
|
+
<vlServico>0.28</vlServico>
|
109
|
+
</ServicoAdicionalWebService>
|
110
|
+
<ServicoAdicionalWebService>
|
111
|
+
<dsComplemento xsi:nil="true" />
|
112
|
+
<nmServico>Valor por km ve\xC3\xADculo dedicado 3/4 ou van</nmServico>
|
113
|
+
<sgMoeda>R$</sgMoeda>
|
114
|
+
<vlServico>1.63</vlServico>
|
115
|
+
</ServicoAdicionalWebService>
|
116
|
+
<ServicoAdicionalWebService>
|
117
|
+
<dsComplemento xsi:nil="true" />
|
118
|
+
<nmServico>Valor por km ve\xC3\xADculo dedicado carreta</nmServico>
|
119
|
+
<sgMoeda>R$</sgMoeda>
|
120
|
+
<vlServico>2.27</vlServico>
|
121
|
+
</ServicoAdicionalWebService>
|
122
|
+
<ServicoAdicionalWebService>
|
123
|
+
<dsComplemento>1,99% sobre o valor do frete com m\xC3\xADnimo de R$ 0,00.</dsComplemento>
|
124
|
+
<nmServico>Valor por km ve\xC3\xADculo dedicado toco ou truck</nmServico>
|
125
|
+
<sgMoeda>R$</sgMoeda>
|
126
|
+
<vlServico>1.99</vlServico>
|
127
|
+
</ServicoAdicionalWebService>
|
128
|
+
<ServicoAdicionalWebService>
|
129
|
+
<dsComplemento>R$ 506,72 por entrega - R$ 1,63 por km excedente (100 km).</dsComplemento>
|
130
|
+
<nmServico>Ve\xC3\xADculo dedicado 3/4 ou van</nmServico>
|
131
|
+
<sgMoeda>R$</sgMoeda>
|
132
|
+
<vlServico>506.72</vlServico>
|
133
|
+
</ServicoAdicionalWebService>
|
134
|
+
<ServicoAdicionalWebService>
|
135
|
+
<dsComplemento>R$ 928,58 por entrega - R$ 2,27 por km excedente (100 km).</dsComplemento>
|
136
|
+
<nmServico>Ve\xC3\xADculo dedicado carreta</nmServico>
|
137
|
+
<sgMoeda>R$</sgMoeda>
|
138
|
+
<vlServico>928.58</vlServico>
|
139
|
+
</ServicoAdicionalWebService>
|
140
|
+
<ServicoAdicionalWebService>
|
141
|
+
<dsComplemento>R$ 545,63 por entrega - R$ 1,99 por km excedente (100 km).</dsComplemento>
|
142
|
+
<nmServico>Ve\xC3\xADculo dedicado toco ou truck</nmServico>
|
143
|
+
<sgMoeda>R$</sgMoeda><vlServico>545.63</vlServico>
|
144
|
+
</ServicoAdicionalWebService>
|
145
|
+
</servicosAdicionais>
|
146
|
+
<vlDesconto xmlns="http://model.expedicao.lms.mercurio.com">0.00</vlDesconto>
|
147
|
+
<vlICMSubstituicaoTributaria xmlns="http://model.expedicao.lms.mercurio.com">0</vlICMSubstituicaoTributaria>
|
148
|
+
<vlImposto xmlns="http://model.expedicao.lms.mercurio.com">8.31</vlImposto>
|
149
|
+
<vlTotalCtrc xmlns="http://model.expedicao.lms.mercurio.com">69.29</vlTotalCtrc>
|
150
|
+
<vlTotalFrete xmlns="http://model.expedicao.lms.mercurio.com">69.29</vlTotalFrete>
|
151
|
+
<vlTotalServico xmlns="http://model.expedicao.lms.mercurio.com">0.00</vlTotalServico>
|
152
|
+
</ns1:out>
|
153
|
+
</ns1:calculaFreteResponse>
|
154
|
+
</soap:Body>
|
155
|
+
</soap:Envelope>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared_examples/tnt_calculator'
|
3
|
+
|
4
|
+
describe Spree::Calculator::Shipping::TntMercurioANC do
|
5
|
+
before do
|
6
|
+
@anc = Spree::Calculator::Shipping::TntMercurioANC.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like 'tnt calculator'
|
10
|
+
|
11
|
+
it 'should have a description' do
|
12
|
+
expect(@anc.description).to eq('TNT Mercúrio - Aéreo Nacional')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a shipping method' do
|
16
|
+
expect(@anc.shipping_method).to eq('ANC')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Calculator::Shipping::TntMercurioRNC do
|
4
|
+
before do
|
5
|
+
@rnc = Spree::Calculator::Shipping::TntMercurioRNC.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it_behaves_like 'tnt calculator'
|
9
|
+
|
10
|
+
it 'should have a description' do
|
11
|
+
expect(@rnc.description).to eq('TNT Mercúrio - Rodoviário Nacional')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have a shipping method' do
|
15
|
+
expect(@rnc.shipping_method).to eq('RNC')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::TntMercurioConfiguration do
|
4
|
+
before do
|
5
|
+
@object = Spree::TntMercurioConfiguration.new
|
6
|
+
end
|
7
|
+
|
8
|
+
[:email, :password, :division, :cgc, :type_cgc, :state_registry, :tax_situation,
|
9
|
+
:billet_type, :additional_days, :additional_value, :customer_field].each do |preference|
|
10
|
+
it "should has #{preference} preference" do
|
11
|
+
expect(@object.has_preference?(preference)).to be true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# require the helper module
|
2
|
+
require 'savon'
|
3
|
+
require 'savon/mock/spec_helper'
|
4
|
+
|
5
|
+
shared_examples_for 'tnt calculator' do
|
6
|
+
|
7
|
+
let(:calculator) { subject.class.new }
|
8
|
+
|
9
|
+
# include the helper module
|
10
|
+
include Savon::SpecHelper
|
11
|
+
|
12
|
+
# set Savon in and out of mock mode
|
13
|
+
before(:all) { savon.mock! }
|
14
|
+
after(:all) { savon.unmock! }
|
15
|
+
|
16
|
+
before do
|
17
|
+
address = FactoryGirl.build(:address, zipcode: '17209420')
|
18
|
+
# use authentication token for save the customer's CGC
|
19
|
+
user = FactoryGirl.build(:user)
|
20
|
+
user.authentication_token = '12345678900'
|
21
|
+
@variant = FactoryGirl.build(:variant, weight: 1, height: 5, width: 15, depth: 20)
|
22
|
+
@order = FactoryGirl.build(:order_with_shipments, ship_address: address, user: user)
|
23
|
+
|
24
|
+
line_item = FactoryGirl.build(:line_item, variant: @variant, price: 100, order: @order)
|
25
|
+
@order.line_items << line_item
|
26
|
+
|
27
|
+
# stock location
|
28
|
+
@stock_location = FactoryGirl.build(:stock_location, zipcode: '08465312')
|
29
|
+
|
30
|
+
# shipment
|
31
|
+
@shipment = FactoryGirl.build(:shipment, order: @order, stock_location: @stock_location)
|
32
|
+
@shipment.inventory_units << FactoryGirl.build(:inventory_unit, variant: @variant, order: @order,
|
33
|
+
line_item: line_item, shipment: @shipment)
|
34
|
+
|
35
|
+
# package
|
36
|
+
@package = @shipment.to_package
|
37
|
+
@package.add @shipment.inventory_units.first
|
38
|
+
|
39
|
+
@params = {in0: {login: 'teste@email.com',
|
40
|
+
senha: 'password',
|
41
|
+
nr_identif_cliente_rem: '1234678900000',
|
42
|
+
nr_inscricao_estadual_remetente: '344028650118',
|
43
|
+
nr_identif_cliente_dest: '12345678900',
|
44
|
+
tp_situacao_tributaria_remetente: 'CO',
|
45
|
+
tp_pessoa_remetente: 'J',
|
46
|
+
tp_pessoa_destinatario: 'F',
|
47
|
+
tp_situacao_tributaria_destinatario: 'NC',
|
48
|
+
cep_origem: '08465312',
|
49
|
+
cep_destino: '17209420',
|
50
|
+
vl_mercadoria: '100.0',
|
51
|
+
ps_real: '1.0',
|
52
|
+
tp_servico: calculator.shipping_method,
|
53
|
+
tp_frete: 'C',
|
54
|
+
cd_divisao_cliente: 1}}
|
55
|
+
|
56
|
+
# set the value of tnt config
|
57
|
+
Spree::TntMercurioConfig.email = @params[:in0][:login]
|
58
|
+
Spree::TntMercurioConfig.password = @params[:in0][:senha]
|
59
|
+
Spree::TntMercurioConfig.division = 1
|
60
|
+
Spree::TntMercurioConfig.cgc = @params[:in0][:nr_identif_cliente_rem]
|
61
|
+
Spree::TntMercurioConfig.state_registry = @params[:in0][:nr_inscricao_estadual_remetente]
|
62
|
+
Spree::TntMercurioConfig.customer_field = 'authentication_token'
|
63
|
+
end
|
64
|
+
|
65
|
+
after do
|
66
|
+
# set default for preferences
|
67
|
+
Spree::TntMercurioConfig.email = nil
|
68
|
+
Spree::TntMercurioConfig.password = nil
|
69
|
+
Spree::TntMercurioConfig.division = nil
|
70
|
+
Spree::TntMercurioConfig.cgc = nil
|
71
|
+
Spree::TntMercurioConfig.state_registry = nil
|
72
|
+
Spree::TntMercurioConfig.type_cgc = 'J'
|
73
|
+
Spree::TntMercurioConfig.tax_situation = 'CO'
|
74
|
+
Spree::TntMercurioConfig.billet_type = 'C'
|
75
|
+
Spree::TntMercurioConfig.additional_value = 0
|
76
|
+
Spree::TntMercurioConfig.additional_days = 0
|
77
|
+
Spree::TntMercurioConfig.customer_field = ''
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'compute_package' do
|
81
|
+
|
82
|
+
it 'should calculate the price and delivery time' do
|
83
|
+
|
84
|
+
fixture = File.read('spec/fixtures/calcula_frete/success_response.xml')
|
85
|
+
|
86
|
+
savon.expects(:calcula_frete).with(message: @params).returns(fixture)
|
87
|
+
response = calculator.compute_package(@package)
|
88
|
+
|
89
|
+
expect(response).to eq(69.29)
|
90
|
+
expect(calculator.delivery_time).to eq(3)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should possible add days to delivery time' do
|
95
|
+
Spree::TntMercurioConfig.additional_days = 5
|
96
|
+
|
97
|
+
fixture = File.read('spec/fixtures/calcula_frete/success_response.xml')
|
98
|
+
|
99
|
+
savon.expects(:calcula_frete).with(message: @params).returns(fixture)
|
100
|
+
calculator.compute_package(@package)
|
101
|
+
|
102
|
+
expect(calculator.delivery_time).to eq(8)
|
103
|
+
|
104
|
+
# set value default after test
|
105
|
+
Spree::TntMercurioConfig.additional_days = 0
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should possible add some value to price' do
|
109
|
+
Spree::TntMercurioConfig.additional_value = 10.0
|
110
|
+
|
111
|
+
fixture = File.read('spec/fixtures/calcula_frete/success_response.xml')
|
112
|
+
|
113
|
+
savon.expects(:calcula_frete).with(message: @params).returns(fixture)
|
114
|
+
response = calculator.compute_package(@package)
|
115
|
+
|
116
|
+
expect(response).to eq(79.29)
|
117
|
+
|
118
|
+
# set value default after test
|
119
|
+
Spree::TntMercurioConfig.additional_value = 0
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'invalid data' do
|
125
|
+
|
126
|
+
it 'should return false when the variant has nil/zero weight' do
|
127
|
+
# set 0 to variant weight
|
128
|
+
@variant.weight = 0
|
129
|
+
|
130
|
+
fixture = File.read('spec/fixtures/calcula_frete/error_response.xml')
|
131
|
+
|
132
|
+
savon.expects(:calcula_frete).with(message: @params).returns(fixture)
|
133
|
+
response = calculator.compute_package(@package)
|
134
|
+
|
135
|
+
expect(response).to be false
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should return false if the credentials are invalid' do
|
139
|
+
@params[:in0][:login] = ''
|
140
|
+
@params[:in0][:senha] = ''
|
141
|
+
@params[:in0][:nr_identif_cliente_rem] = ''
|
142
|
+
@params[:in0][:nr_inscricao_estadual_remetente] = ''
|
143
|
+
|
144
|
+
Spree::TntMercurioConfig.email = ''
|
145
|
+
Spree::TntMercurioConfig.password = ''
|
146
|
+
Spree::TntMercurioConfig.cgc = ''
|
147
|
+
Spree::TntMercurioConfig.state_registry = ''
|
148
|
+
|
149
|
+
fixture = File.read('spec/fixtures/calcula_frete/invalid_credentials.xml')
|
150
|
+
|
151
|
+
savon.expects(:calcula_frete).with(message: @params).returns(fixture)
|
152
|
+
|
153
|
+
response = calculator.compute_package(@package)
|
154
|
+
|
155
|
+
expect(response).to be false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec/dummy'
|
5
|
+
add_group 'Controllers', 'app/controllers'
|
6
|
+
add_group 'Helpers', 'app/helpers'
|
7
|
+
add_group 'Mailers', 'app/mailers'
|
8
|
+
add_group 'Models', 'app/models'
|
9
|
+
add_group 'Views', 'app/views'
|
10
|
+
add_group 'Libraries', 'lib'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Configure Rails Environment
|
14
|
+
ENV['RAILS_ENV'] = 'test'
|
15
|
+
|
16
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
17
|
+
|
18
|
+
require 'rspec/rails'
|
19
|
+
require 'database_cleaner'
|
20
|
+
require 'ffaker'
|
21
|
+
require 'capybara/poltergeist'
|
22
|
+
Capybara.javascript_driver = :poltergeist
|
23
|
+
|
24
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
25
|
+
# in spec/support/ and its subdirectories.
|
26
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
27
|
+
|
28
|
+
# Requires factories and other useful helpers defined in spree_core.
|
29
|
+
require 'spree/testing_support/authorization_helpers'
|
30
|
+
require 'spree/testing_support/capybara_ext'
|
31
|
+
require 'spree/testing_support/controller_requests'
|
32
|
+
require 'spree/testing_support/factories'
|
33
|
+
require 'spree/testing_support/url_helpers'
|
34
|
+
|
35
|
+
# Requires factories defined in lib/spree_zaez_tnt_mercurio/factories.rb
|
36
|
+
require 'spree_zaez_tnt_mercurio/factories'
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.include FactoryGirl::Syntax::Methods
|
40
|
+
|
41
|
+
# Infer an example group's spec type from the file location.
|
42
|
+
config.infer_spec_type_from_file_location!
|
43
|
+
|
44
|
+
# == URL Helpers
|
45
|
+
#
|
46
|
+
# Allows access to Spree's routes in specs:
|
47
|
+
#
|
48
|
+
# visit spree.admin_path
|
49
|
+
# current_path.should eql(spree.products_path)
|
50
|
+
config.include Spree::TestingSupport::UrlHelpers
|
51
|
+
|
52
|
+
# == Mock Framework
|
53
|
+
#
|
54
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
55
|
+
#
|
56
|
+
# config.mock_with :mocha
|
57
|
+
# config.mock_with :flexmock
|
58
|
+
# config.mock_with :rr
|
59
|
+
config.mock_with :rspec
|
60
|
+
config.color = true
|
61
|
+
|
62
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
63
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
64
|
+
|
65
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
66
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
67
|
+
# to setup a test will be unavailable to the browser, which runs under a separate server instance.
|
68
|
+
config.use_transactional_fixtures = false
|
69
|
+
|
70
|
+
# Ensure Suite is set to use transactions for speed.
|
71
|
+
config.before :suite do
|
72
|
+
DatabaseCleaner.strategy = :transaction
|
73
|
+
DatabaseCleaner.clean_with :truncation
|
74
|
+
end
|
75
|
+
|
76
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
77
|
+
config.before :each do
|
78
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
79
|
+
DatabaseCleaner.start
|
80
|
+
end
|
81
|
+
|
82
|
+
# After each spec clean the database.
|
83
|
+
config.after :each do
|
84
|
+
DatabaseCleaner.clean
|
85
|
+
end
|
86
|
+
|
87
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
88
|
+
config.order = "random"
|
89
|
+
end
|