solidus_bling 3.3.2 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61d895a0dd8ca48a5d19ddba3f958296fc3dbd3379e36174f100b649a9bc4993
4
- data.tar.gz: 9e8d61d8aaa13c93a392ea1289000b9e1e68af33197d87f16944192471bc7638
3
+ metadata.gz: 7681d43d1cd2da7a170365fcf1e2728d33db77e0d1d10253562d3a3f40bf2cf5
4
+ data.tar.gz: a736c5689d9ba27426074d8333e4a397721994de8a5760c45e09b27b1da0d333
5
5
  SHA512:
6
- metadata.gz: ddd57ad2c8a9999e3485fbb8a726421326d861f461e2ca64b38997cdae7c18f5fb4b10827784fde1e28b027f81ba37906f881a9dfbda1271ea7c2ebc0423a97a
7
- data.tar.gz: 366ce7688962f92b5549ec5818563547092a576434f3ff21cc4438d37de776a68235724d591cf074aa2b0cc9b0b9c8abb5700414edd6730e5f3998a577d4f59c
6
+ metadata.gz: f185a198007eef59805be874c7f77d5fd7236a5cfa3f66c6202aa2eb045ff3e2b48ef62140d245dc3560735a5ae19016647495bfeb3d78a7d62756a6fe2e3eb6
7
+ data.tar.gz: 0a09fd5f816d4d3a2cf9344bf7cc035dbbd9e1d71947fd35098cab325926442f26bb1f32923445c0247275da3866a71bc89c7ce452036dabb3c8cd77c53f5e1a
@@ -5,7 +5,7 @@ module Spree
5
5
  before_action :set_order, only: [:edit, :update]
6
6
 
7
7
  def edit
8
- @sellers = ::SolidusBling::Seller.all.order(:name)
8
+ @sellers = ::SolidusBling::Seller.actives.order(:name)
9
9
  end
10
10
 
11
11
  def update
@@ -13,7 +13,7 @@ module Spree
13
13
  flash[:success] = "Vendedor atualizado com sucesso."
14
14
  else
15
15
  flash[:error] = "Erro ao atualizar vendedor."
16
- end
16
+ end
17
17
  redirect_to admin_orders_seller_path(@order)
18
18
  end
19
19
 
@@ -22,7 +22,7 @@ module Spree
22
22
  end
23
23
 
24
24
  private
25
-
25
+
26
26
  def order_params
27
27
  params.require(:order).permit(:seller_id)
28
28
  end
@@ -9,7 +9,7 @@ module SolidusBling
9
9
  @account.check_token
10
10
  BlingApi.configure { |config| config.access_token = @account.access_token }
11
11
 
12
- contato = costumer
12
+ contato = customer
13
13
  items = products
14
14
  parcelas = installments
15
15
  observacoes_internas = internal_observations
@@ -40,13 +40,20 @@ module SolidusBling
40
40
  end
41
41
  end
42
42
 
43
- def costumer
43
+ def customer
44
44
  contato = BlingApi::Customer.find_by_tax_id(@order.tax_id)
45
45
  if contato
46
46
  contato.update(
47
47
  pessoa_juridica: @order.tax_id.length > 14,
48
48
  numero_documento: @order.tax_id,
49
49
  situacao: "A",
50
+ codigo: contato.codigo,
51
+ vendedor: contato.vendedor,
52
+ dados_adicionais: contato.dados_adicionais,
53
+ financeiro: contato.financeiro,
54
+ pais: contato.pais,
55
+ tipos_contato: contato.tipos_contato,
56
+ pessoa_contato: contato.pessoa_contato,
50
57
  **build_customer
51
58
  )
52
59
  else
@@ -10,12 +10,25 @@ module SolidusBling
10
10
  BlingApi.configure { |config| config.access_token = account.access_token }
11
11
 
12
12
  sellers = BlingApi::Seller.get_sellers
13
- upsert_sellers = sellers.map { |seller| { name: seller[:nome], external_id: seller[:id], account_id: account.id } }
13
+ upsert_sellers = sellers.map { |seller| { name: seller[:nome], external_id: seller[:id], account_id: account.id, active: true } }
14
14
  SolidusBling::Seller.upsert_all(upsert_sellers, unique_by: :external_id)
15
+ inactivate_sellers(sellers)
15
16
  end
16
17
 
17
18
  def self.default
18
19
  find_by(default: true)
19
20
  end
21
+
22
+ def self.actives
23
+ where(active: true)
24
+ end
25
+
26
+ def self.inactivate_sellers sellers_bling
27
+ ids_sellers_bling = sellers_bling.pluck(:id)
28
+ ids_sellers_store = pluck(:external_id).map(&:to_i)
29
+ ids_sellers_inactive = ids_sellers_store - ids_sellers_bling
30
+ sellers_inactive = where(external_id: ids_sellers_inactive)
31
+ sellers_inactive.update_all(active: false)
32
+ end
20
33
  end
21
34
  end
@@ -0,0 +1,5 @@
1
+ class AddActiveColumnToSellers < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_bling_sellers, :active, :boolean, default: true
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = "3.3.2"
4
+ VERSION = "3.3.4"
5
5
  end
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: 3.3.2
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamilton Tumenas Borges
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-22 00:00:00.000000000 Z
11
+ date: 2024-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -148,6 +148,7 @@ files:
148
148
  - db/migrate/20231110113221_create_solidus_bling_shipping_methods.rb
149
149
  - db/migrate/20240318171147_add_solidus_bling_seller_id_to_orders.rb
150
150
  - db/migrate/20240318180555_add_deafult_column_to_sellers.rb
151
+ - db/migrate/20240424112257_add_active_column_to_sellers.rb
151
152
  - lib/generators/solidus_bling/install/install_generator.rb
152
153
  - lib/generators/solidus_bling/install/templates/initializer.rb
153
154
  - lib/solidus_bling.rb