solidus_bling 3.4.4 → 3.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39972f690b188582eb90995659ea1f965d304b6739cfd1ed758f40fc667c0191
4
- data.tar.gz: 199818222481a6e2a8dc44c4eeae4e2fb7ee0fd38515d6bc1d9db9713b6519fc
3
+ metadata.gz: 96ae26320b68f766dc44bb621d62ea6588edca4942dd652e27f9db773b3746a7
4
+ data.tar.gz: 3cc77c798db3a3e13fae2af0825d3ab9f1c11b9cec025873d7858a47bbb8ad75
5
5
  SHA512:
6
- metadata.gz: adca05171481ba6bd6f08aff36f050ef95ac0f30aa2233f5c660cbae4079212ed27e452a9360714b41cf4067459766885c33b47c1fb242a3ae6c017ac77e64f8
7
- data.tar.gz: 390625e14a64fb80333a4de9f9d0d9470bd528f2bd43beba00117732209b610a94b837b56f04df13e9e2fcc1dde088b659b5580d8d4672888372e3ccf5dff896
6
+ metadata.gz: e84e85d97a04a3515d3dda9d97e46f8fe947bf15590d315f4fef2a4972d3804c903244e074e041e270d635015db561a1c72a62514ad7de8d25ca5ffeef3bce2e
7
+ data.tar.gz: 4cf11ba85c9efe1315a498ef9bde72528ee84de38c4768ee416d2bc222adf9897ebb50def3d382e5cd21728441cbaa41f361af7d8c25df31a7ae362b69053d50
@@ -38,9 +38,11 @@ module Spree
38
38
  def edit
39
39
  @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
40
40
  @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
41
+ @sellers = @bling_account.sellers.actives.order(:name).pluck(:name, :id)
41
42
  end
42
43
 
43
44
  def update
45
+ @bling_account.sellers.find_by_id(params[:account]["default_seller"]).update(default: true)
44
46
  @bling_account.update account_params
45
47
  redirect_to edit_admin_solidus_bling_account_path(@bling_account.id)
46
48
  end
@@ -74,8 +76,8 @@ module Spree
74
76
 
75
77
  def account_params
76
78
  params.require(:account).permit(
77
- :client_id, :client_secret, :refresh_token, :redirect_url, :state, :access_token, :api_key, :external_store_id, :incoming_category_id,
78
- payment_methods_attributes: [:id, :spree_payment_method_id, :external_id],
79
+ :client_id, :client_secret, :refresh_token, :redirect_url, :state, :access_token, :api_key, :external_store_id,
80
+ payment_methods_attributes: [:id, :spree_payment_method_id, :external_id, :incoming_category_id],
79
81
  shipping_methods_attributes: [:id, :spree_shipping_method_id, :alias, :company],
80
82
  sellers_attributes: [:id, :name, :external_id]
81
83
  )
@@ -15,6 +15,7 @@ module SolidusBling
15
15
  observacoes_internas = internal_observations
16
16
  transporte = shipment
17
17
  id_vendedor = seller_external_id
18
+ id_categoria_receita = @account.payment_methods.find_by(spree_payment_method_id: @order.payments.last.payment_method_id).incoming_category_id
18
19
 
19
20
  bling_order = BlingApi::Order.new(
20
21
  id_contato: contato.id,
@@ -30,7 +31,7 @@ module SolidusBling
30
31
  observacoes: "Número do pedido loja: #{@order.number}",
31
32
  observacoes_internas: observacoes_internas,
32
33
  valor_desconto: @order.adjustment_total.abs,
33
- id_categoria: @account.incoming_category_id,
34
+ id_categoria: id_categoria_receita,
34
35
  transporte: transporte,
35
36
  id_vendedor: id_vendedor
36
37
  ).create
@@ -2,8 +2,8 @@ module SolidusBling
2
2
  class Seller < ApplicationRecord
3
3
  validates :name, presence: true
4
4
  validates :external_id, presence: true
5
-
6
5
  belongs_to :account
6
+ after_save :falsify_all_others
7
7
 
8
8
  def self.upsert_sellers account
9
9
  account.check_token
@@ -30,5 +30,9 @@ module SolidusBling
30
30
  sellers_inactive = where(external_id: ids_sellers_inactive)
31
31
  sellers_inactive.update_all(active: false)
32
32
  end
33
+
34
+ def falsify_all_others
35
+ self.class.where("id != ?", id).update(default: false) if default
36
+ end
33
37
  end
34
38
  end
@@ -25,13 +25,6 @@
25
25
  <%= form.text_field :external_store_id, required: true, class: 'fullwidth' %>
26
26
  <%= form.error_message_on :external_store_id %>
27
27
  <% end %>
28
-
29
- <%= form.field_container :incoming_category_id do %>
30
- <%= form.label :incoming_category_id, "ID Categoria Receita", class: 'required' %>
31
- <%= form.text_field :incoming_category_id, required: true, class: 'fullwidth' %>
32
- <%= form.error_message_on :incoming_category_id %>
33
- <% end %>
34
-
35
28
  </div>
36
29
 
37
30
  <div class="col-12 col-md-6">
@@ -76,18 +69,24 @@
76
69
  </legend>
77
70
  <%= form.fields_for :payment_methods do |payment_form| %>
78
71
  <div class="row">
79
- <div class="col-12 col-md-6">
72
+ <div class="col-12 col-md-4">
80
73
  <div class="field">
81
74
  <%= payment_form.label :spree_payment_method_id, "Método de Pagamento", class: 'required' %>
82
75
  <%= payment_form.select :spree_payment_method_id, @payment_methods, {}, { class: "custom-select fullwidth" } %>
83
76
  </div>
84
77
  </div>
85
- <div class="col-12 col-md-6">
78
+ <div class="col-12 col-md-4">
86
79
  <div class="field">
87
80
  <%= payment_form.label :external_id, "ID Forma de Pagamento", class: 'required' %>
88
81
  <%= payment_form.text_field :external_id, required: true, class:"fullwidth" %>
89
82
  </div>
90
83
  </div>
84
+ <div class="col-12 col-md-4">
85
+ <div class="field">
86
+ <%= payment_form.label :incoming_category_id, "ID Categoria Receita", class: 'required' %>
87
+ <%= payment_form.text_field :incoming_category_id, required: true, class:"fullwidth" %>
88
+ </div>
89
+ </div>
91
90
  </div>
92
91
  <% end %>
93
92
  </fieldset>
@@ -120,16 +119,20 @@
120
119
  <% end %>
121
120
  </fieldset>
122
121
 
123
- <fieldset class="no-border-top text-center">
124
- <legend>
125
- Vendedor padrão
126
- </legend>
127
- <% if bling_account.sellers.default %>
128
- <span><%= bling_account.sellers.default.name %></span>
129
- <% else %>
130
- <span>Vendedor padrão não selecionado</span>
131
- <% end %>
132
- </fieldset>
122
+ <% if @sellers %>
123
+ <fieldset class="no-border-top text-center">
124
+ <legend>
125
+ Vendedor padrão
126
+ </legend>
127
+ <div class="col-12 col-md-6 mx-auto">
128
+ <div class="field">
129
+ <%= form.select "default_seller", @sellers, {selected: ::SolidusBling::Seller.default&.id, include_blank: true }, { class: "custom-select fullwidth" } %>
130
+ </div>
131
+ </div>
132
+
133
+ </fieldset>
134
+ <% end %>
135
+
133
136
 
134
137
 
135
138
  <div class="form-buttons filter-actions actions" data-hook="buttons">
@@ -0,0 +1,5 @@
1
+ class AddIncomingCategoryIdOnPaymentMethod < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :solidus_bling_payment_methods, :incoming_category_id, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveIncomingCategoryIdFromAccount < ActiveRecord::Migration[7.1]
2
+ def change
3
+ remove_column :solidus_bling_accounts, :incoming_category_id, :string
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = "3.4.4"
4
+ VERSION = "3.4.6"
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.4.4
4
+ version: 3.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todas Essas Coisas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -151,6 +151,8 @@ files:
151
151
  - db/migrate/20240318171147_add_solidus_bling_seller_id_to_orders.rb
152
152
  - db/migrate/20240318180555_add_deafult_column_to_sellers.rb
153
153
  - db/migrate/20240424112257_add_active_column_to_sellers.rb
154
+ - db/migrate/20240830124253_add_incoming_category_id_on_payment_method.rb
155
+ - db/migrate/20240830124611_remove_incoming_category_id_from_account.rb
154
156
  - lib/generators/solidus_bling/install/install_generator.rb
155
157
  - lib/generators/solidus_bling/install/templates/initializer.rb
156
158
  - lib/solidus_bling.rb