solidus_bling 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/accounts_controller.rb +6 -1
- data/app/models/solidus_bling/order.rb +35 -25
- data/app/views/spree/admin/accounts/_form.html.erb +4 -0
- data/db/migrate/20231018141940_add_company_to_solidus_bling_shipping_methods.rb +5 -0
- data/lib/solidus_bling/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3b2416612bb0c496adcbe4dadb851decd26a74c378ea362f5ab47a2cac9c50
|
4
|
+
data.tar.gz: 8b918c41a1a377631d470407b6d711f7dd57d4183d558e24ab99627f433b3394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e33cf15f8c38519af2688ce3834aca4777c16995f83ddf394de8689d274459896357b910ccb23dc0e03aa5dbdf54a267ef5068fd799eb79ba24ea1061411d8
|
7
|
+
data.tar.gz: 246a8b67a86852e725584de7a7d413f293ac3c31984fa889baba8d188132d17e1325b800cb0b76cc9be5ce8d7c3ccc40637a385140b387429f1084206b6c3d96
|
@@ -55,7 +55,12 @@ module Spree
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def account_params
|
58
|
-
params.require(:account).permit(
|
58
|
+
params.require(:account).permit(
|
59
|
+
:app_name, :client_id, :client_secret, :refresh_token, :api_base_url, :external_store_id, :incoming_category_id,
|
60
|
+
payment_methods_attributes: [:id, :spree_payment_method_id, :external_id],
|
61
|
+
shipping_methods_attributes: [:id, :spree_shipping_method_id, :alias, :company],
|
62
|
+
sellers_attributes: [:id, :name, :external_id]
|
63
|
+
)
|
59
64
|
end
|
60
65
|
end
|
61
66
|
end
|
@@ -5,7 +5,7 @@ module SolidusBling
|
|
5
5
|
super(SolidusBling::Account.first)
|
6
6
|
@order = order
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def send
|
10
10
|
if @order.present?
|
11
11
|
contato = SolidusBling::Contact.new(@order, @account)
|
@@ -34,31 +34,35 @@ module SolidusBling
|
|
34
34
|
"numeroLoja": order.number,
|
35
35
|
"data": order.completed_at.strftime("%Y-%m-%d"),
|
36
36
|
"loja": {
|
37
|
-
|
37
|
+
"id": @account.external_store_id
|
38
38
|
},
|
39
39
|
"contato": {
|
40
|
-
|
40
|
+
"id": contato["id"]
|
41
41
|
},
|
42
42
|
"itens": build_array_items(order.line_items),
|
43
43
|
"vendedor": {
|
44
|
-
|
44
|
+
"id": @account.sellers.first.external_id
|
45
45
|
},
|
46
46
|
"transporte": build_hash_transporte(order),
|
47
47
|
"parcelas": build_array_parcelas(order),
|
48
48
|
"desconto": {
|
49
|
-
|
50
|
-
|
49
|
+
"valor": order.promo_total&.to_f.abs || 0,
|
50
|
+
"unidade": "REAL"
|
51
51
|
},
|
52
52
|
"totalProdutos": order.item_total.to_f,
|
53
53
|
"total": order.total.to_f,
|
54
54
|
"observacoes": " Nº Pedido Loja: #{order.number}",
|
55
|
-
"observacoesInternas": "Pagamento: #{@parcelas}x R$ #{(order.total.to_f / @parcelas).round(2)}\nForma de envio: #{order.shipments.last.selected_shipping_rate.name}\n#{build_cupons(order.promotions)}",
|
55
|
+
"observacoesInternas": "Pagamento: #{@parcelas}x R$ #{(order.total.to_f / @parcelas).round(2)}\nForma de envio: #{order.shipments.last.selected_shipping_rate.name}\n#{build_cupons(order.promotions)}#{build_order_url(order)}",
|
56
56
|
"categoria": {
|
57
|
-
|
57
|
+
"id": @account.incoming_category_id
|
58
58
|
}
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
62
|
+
def build_order_url order
|
63
|
+
"Link para o pedido: #{order.store.url}/orders/#{order.number}/token/#{order.guest_token}"
|
64
|
+
end
|
65
|
+
|
62
66
|
def build_array_items items
|
63
67
|
items.map do |item|
|
64
68
|
bling_product = SolidusBling::Product.find_by(sku: item.sku)
|
@@ -67,8 +71,8 @@ module SolidusBling
|
|
67
71
|
"quantidade": item.quantity,
|
68
72
|
"valor": item.price.to_f,
|
69
73
|
"produto": {
|
70
|
-
|
71
|
-
|
74
|
+
"id": bling_product.external_id
|
75
|
+
}
|
72
76
|
}
|
73
77
|
end
|
74
78
|
end
|
@@ -81,34 +85,40 @@ module SolidusBling
|
|
81
85
|
valor_parcela = order.total.to_f / @parcelas
|
82
86
|
1.upto(@parcelas).map do |parcela|
|
83
87
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
"dataVencimento": (order.completed_at + parcela.months).strftime("%Y-%m-%d"),
|
89
|
+
"valor": valor_parcela,
|
90
|
+
"formaPagamento": {
|
91
|
+
"id": @account.payment_methods.find_by(spree_payment_method_id: order.payments.last.payment_method_id).external_id
|
92
|
+
}
|
89
93
|
}
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
93
97
|
def build_hash_transporte order
|
98
|
+
shipping_method = @account.shipping_methods.find_by(spree_shipping_method_id: order.shipments.last.shipping_method.id)
|
99
|
+
servico = shipping_method.nil? ? "" : shipping_method.alias
|
100
|
+
transportadora = shipping_method.nil? ? "" : shipping_method.company
|
94
101
|
{
|
95
102
|
"fretePorConta": 1,
|
96
103
|
"frete": order.shipment_total.to_f,
|
97
104
|
"quantidadeVolumes": 1,
|
105
|
+
"contato": {
|
106
|
+
"nome": transportadora,
|
107
|
+
},
|
98
108
|
"etiqueta": {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
109
|
+
"nome": order.ship_address.name,
|
110
|
+
"endereco": order.ship_address.address1,
|
111
|
+
"numero": order.ship_address.number,
|
112
|
+
"complemento": order.ship_address.address2,
|
113
|
+
"municipio": order.ship_address.city,
|
114
|
+
"uf": order.ship_address.state.abbr,
|
115
|
+
"bairro": order.ship_address.district,
|
116
|
+
"cep": order.ship_address.zipcode,
|
117
|
+
"nomePais": "Brasil"
|
108
118
|
},
|
109
119
|
"volumes": [
|
110
120
|
{
|
111
|
-
"servico":
|
121
|
+
"servico": servico,
|
112
122
|
"codigoRastreamento": ""
|
113
123
|
}
|
114
124
|
]
|
@@ -40,6 +40,7 @@
|
|
40
40
|
<%= form.fields_for :payment_methods do |payment_form| %>
|
41
41
|
<div>
|
42
42
|
<%= payment_form.select :spree_payment_method_id, @payment_methods %>
|
43
|
+
<%= payment_form.label :external_id, "ID Forma de Pagamento: " %>
|
43
44
|
<%= payment_form.text_field :external_id %>
|
44
45
|
</div>
|
45
46
|
<% end %>
|
@@ -50,7 +51,10 @@
|
|
50
51
|
<%= form.fields_for :shipping_methods do |shipping_form| %>
|
51
52
|
<div>
|
52
53
|
<%= shipping_form.select :spree_shipping_method_id, @shipping_methods %>
|
54
|
+
<%= shipping_form.label :alias, "Alias: " %>
|
53
55
|
<%= shipping_form.text_field :alias %>
|
56
|
+
<%= shipping_form.label :company, "Nome Transportadora: " %>
|
57
|
+
<%= shipping_form.text_field :company %>
|
54
58
|
</div>
|
55
59
|
<% end %>
|
56
60
|
</div>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_bling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ulysses-bull
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- db/migrate/20230918142742_create_solidus_bling_payment_methods.rb
|
152
152
|
- db/migrate/20230918142953_create_solidus_bling_sellers.rb
|
153
153
|
- db/migrate/20230918143057_create_solidus_bling_shipping_methods.rb
|
154
|
+
- db/migrate/20231018141940_add_company_to_solidus_bling_shipping_methods.rb
|
154
155
|
- lib/generators/solidus_bling/install/install_generator.rb
|
155
156
|
- lib/generators/solidus_bling/install/templates/initializer.rb
|
156
157
|
- lib/solidus_bling.rb
|