solidus_bling 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/accounts_controller.rb +15 -4
- data/app/models/solidus_bling/account.rb +4 -4
- data/app/models/solidus_bling/order.rb +35 -25
- data/app/models/solidus_bling/payment_method.rb +2 -0
- data/app/models/solidus_bling/seller.rb +3 -0
- data/app/models/solidus_bling/shipping_method.rb +2 -0
- data/app/views/spree/admin/accounts/_form.html.erb +4 -0
- data/app/views/spree/admin/accounts/edit.html.erb +3 -1
- data/db/migrate/20231018141940_add_company_to_solidus_bling_shipping_methods.rb +5 -0
- data/lib/solidus_bling/version.rb +1 -1
- metadata +4 -3
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
|
@@ -18,8 +18,14 @@ module Spree
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def create
|
21
|
-
bling_account = SolidusBling::Account.
|
22
|
-
|
21
|
+
bling_account = SolidusBling::Account.new account_params.merge(name: "Bling")
|
22
|
+
if bling_account.save
|
23
|
+
flash[:success] = "Conta criada com sucesso"
|
24
|
+
redirect_to admin_accounts_path
|
25
|
+
else
|
26
|
+
flash[:error] = bling_account.errors.full_messages.join("\n")
|
27
|
+
redirect_to new_admin_account_path
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def edit
|
@@ -27,7 +33,7 @@ module Spree
|
|
27
33
|
@payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
|
28
34
|
@shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
|
29
35
|
@products_count = @bling_account.products.count
|
30
|
-
@last_update = SolidusBling::Event.where(method: "products_updated").max.created_at
|
36
|
+
@last_update = SolidusBling::Event.where(method: "products_updated").max.try(:created_at)
|
31
37
|
end
|
32
38
|
|
33
39
|
def update
|
@@ -49,7 +55,12 @@ module Spree
|
|
49
55
|
end
|
50
56
|
|
51
57
|
def account_params
|
52
|
-
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
|
+
)
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module SolidusBling
|
2
2
|
class Account < ApplicationRecord
|
3
|
-
has_many :payment_methods
|
4
|
-
has_many :shipping_methods
|
5
|
-
has_many :products
|
6
|
-
has_many :sellers
|
3
|
+
has_many :payment_methods, dependent: :destroy
|
4
|
+
has_many :shipping_methods, dependent: :destroy
|
5
|
+
has_many :products, dependent: :destroy
|
6
|
+
has_many :sellers, dependent: :destroy
|
7
7
|
accepts_nested_attributes_for :payment_methods, :shipping_methods, :sellers
|
8
8
|
end
|
9
9
|
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>
|
@@ -3,7 +3,9 @@
|
|
3
3
|
{confirm: "Deseja baixar os produtos?" } %>
|
4
4
|
<span>Produtos baixados: <%= @products_count %></span>
|
5
5
|
<br>
|
6
|
-
|
6
|
+
<% if @last_update.present? %>
|
7
|
+
<span>Ultima atualização: <%= @last_update.strftime("%d/%m/%Y %H:%M") %> </span>
|
8
|
+
<% end %>
|
7
9
|
</div>
|
8
10
|
|
9
11
|
<%= render "form", bling_account: @bling_account, form_url: admin_account_path(@bling_account.id) %>
|
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
|
@@ -199,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
200
|
- !ruby/object:Gem::Version
|
200
201
|
version: '0'
|
201
202
|
requirements: []
|
202
|
-
rubygems_version: 3.4.
|
203
|
+
rubygems_version: 3.4.19
|
203
204
|
signing_key:
|
204
205
|
specification_version: 4
|
205
206
|
summary: Solidus extension to integrate with the Bling
|