solidus_brazilian_adaptations 1.0.4 → 1.0.5
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/db/seeds.rb +18 -0
- data/db/spree_br/countries.rb +45 -0
- data/db/spree_br/payment.rb +4 -0
- data/db/spree_br/refund_reasons.rb +3 -0
- data/db/spree_br/return_reasons.rb +11 -0
- data/db/spree_br/roles.rb +3 -0
- data/db/spree_br/shipping.rb +17 -0
- data/db/spree_br/states.rb +22 -0
- data/db/spree_br/stock_locations.rb +4 -0
- data/db/spree_br/store_credit.rb +23 -0
- data/db/spree_br/stores.rb +10 -0
- data/lib/solidus_brazilian_adaptations/version.rb +1 -1
- metadata +13 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: abf9b101cad24f96d6b95af4b1c1587666d279a7ec9c38cd6eadf80588c2de3a
|
|
4
|
+
data.tar.gz: cea1c5c853b54b8b10dc962476b05fe04f2f9819155e14cf3e3c5931919c055e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df1c8d4801d1a4c440c86ecdf94954145053cbbfd42ca61b365b4f93c22b6c38f0868645b73a0456bd9d0a07abc7b9c3bfb9038ed9998e1502e4a76e8dff15a2
|
|
7
|
+
data.tar.gz: 48da079873137eddebd6b0e1fdaf62605cd11446abaacff3641493429943395b3f187c2337382dad2f9be5c3921e7c0011a365ceefe6319283eab60732e0e5dc
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
shell = Thor::Base.shell.new
|
|
3
|
+
|
|
4
|
+
%w[
|
|
5
|
+
stores
|
|
6
|
+
store_credit
|
|
7
|
+
countries
|
|
8
|
+
return_reasons
|
|
9
|
+
states
|
|
10
|
+
stock_locations
|
|
11
|
+
refund_reasons
|
|
12
|
+
roles
|
|
13
|
+
shipping
|
|
14
|
+
payment
|
|
15
|
+
].each do |seed|
|
|
16
|
+
shell.say_status :seed, seed
|
|
17
|
+
require_relative "spree_br/#{seed}"
|
|
18
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'carmen'
|
|
4
|
+
|
|
5
|
+
# Insert Countries into the spree_countries table, checking to ensure that no
|
|
6
|
+
# duplicates are created, using as few SQL statements as possible (2)
|
|
7
|
+
|
|
8
|
+
connection = Spree::Base.connection
|
|
9
|
+
|
|
10
|
+
country_mapper = ->(country) do
|
|
11
|
+
name = connection.quote country.name
|
|
12
|
+
iso3 = connection.quote country.alpha_3_code
|
|
13
|
+
iso = connection.quote country.alpha_2_code
|
|
14
|
+
iso_name = connection.quote country.name.upcase
|
|
15
|
+
numcode = connection.quote country.numeric_code
|
|
16
|
+
states_required = connection.quote country.subregions?
|
|
17
|
+
|
|
18
|
+
[name, iso3, iso, iso_name, numcode, states_required].join(", ")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
country_values = -> do
|
|
22
|
+
carmen_countries = Carmen::Country.all
|
|
23
|
+
|
|
24
|
+
# find entires already in the database (so that we may ignore them)
|
|
25
|
+
existing_country_isos =
|
|
26
|
+
Spree::Country.where(iso: carmen_countries.map(&:alpha_2_code)).pluck(:iso)
|
|
27
|
+
|
|
28
|
+
# create VALUES statements for each country _not_ already in the database
|
|
29
|
+
carmen_countries
|
|
30
|
+
.reject { |c| existing_country_isos.include?(c.alpha_2_code) || c.alpha_2_code != 'BR' }
|
|
31
|
+
.map(&country_mapper)
|
|
32
|
+
.join("), (")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
country_columns = %w(name iso3 iso iso_name numcode states_required).join(', ')
|
|
36
|
+
country_vals = country_values.call
|
|
37
|
+
|
|
38
|
+
if country_vals.present?
|
|
39
|
+
# execute raw SQL (insted of ActiveRecord.create) to use a single
|
|
40
|
+
# INSERT statement, and to avoid any validations or callbacks
|
|
41
|
+
connection.execute <<-SQL
|
|
42
|
+
INSERT INTO spree_countries (#{country_columns})
|
|
43
|
+
VALUES (#{country_vals});
|
|
44
|
+
SQL
|
|
45
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Spree::ReturnReason.find_or_create_by(name: 'Better price available')
|
|
4
|
+
Spree::ReturnReason.find_or_create_by(name: 'Missed estimated delivery date')
|
|
5
|
+
Spree::ReturnReason.find_or_create_by(name: 'Missing parts or accessories')
|
|
6
|
+
Spree::ReturnReason.find_or_create_by(name: 'Damaged/Defective')
|
|
7
|
+
Spree::ReturnReason.find_or_create_by(name: 'Different from what was ordered')
|
|
8
|
+
Spree::ReturnReason.find_or_create_by(name: 'Different from description')
|
|
9
|
+
Spree::ReturnReason.find_or_create_by(name: 'No longer needed/wanted')
|
|
10
|
+
Spree::ReturnReason.find_or_create_by(name: 'Accidental order')
|
|
11
|
+
Spree::ReturnReason.find_or_create_by(name: 'Unauthorized purchase')
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
category = Spree::ShippingCategory.find_or_create_by(name: "Default")
|
|
4
|
+
todo_brasil = Spree::Zone.find_or_create_by!(name: "todo_brasil", description: "Todo Brasil")
|
|
5
|
+
todo_brasil.zone_members.find_or_create_by!(zoneable: Spree::Country.find_by!(iso: "BR"))
|
|
6
|
+
|
|
7
|
+
Spree::ShippingMethod.create!(
|
|
8
|
+
name: "Coruja",
|
|
9
|
+
available_to_all: true,
|
|
10
|
+
code: "CRJ",
|
|
11
|
+
shipping_categories: [category],
|
|
12
|
+
calculator: Spree::Calculator::Shipping::FlatRate.create!(
|
|
13
|
+
preferred_amount: 20.0,
|
|
14
|
+
preferred_currency: "BRL"
|
|
15
|
+
),
|
|
16
|
+
zones: [todo_brasil]
|
|
17
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
def create_states(subregions, country)
|
|
4
|
+
subregions.each do |subregion|
|
|
5
|
+
Spree::State.where(abbr: subregion.code, country: country).first_or_create!(
|
|
6
|
+
name: subregion.name
|
|
7
|
+
)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ActiveRecord::Base.transaction do
|
|
12
|
+
Spree::Country.all.find_each do |country|
|
|
13
|
+
carmen_country = Carmen::Country.coded(country.iso)
|
|
14
|
+
next unless carmen_country.subregions?
|
|
15
|
+
|
|
16
|
+
if Spree::Config[:countries_that_use_nested_subregions].include? country.iso
|
|
17
|
+
create_states(carmen_country.subregions.flat_map(&:subregions), country)
|
|
18
|
+
else
|
|
19
|
+
create_states(carmen_country.subregions, country)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Spree::PaymentMethod.create_with(
|
|
5
|
+
name: "Store Credit",
|
|
6
|
+
description: "Store credit",
|
|
7
|
+
active: true,
|
|
8
|
+
available_to_admin: false,
|
|
9
|
+
available_to_users: false
|
|
10
|
+
).find_or_create_by!(
|
|
11
|
+
type: "Spree::PaymentMethod::StoreCredit"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
Spree::StoreCreditType.create_with(priority: 1).find_or_create_by!(name: Spree::StoreCreditType::EXPIRING)
|
|
15
|
+
Spree::StoreCreditType.create_with(priority: 2).find_or_create_by!(name: Spree::StoreCreditType::NON_EXPIRING)
|
|
16
|
+
|
|
17
|
+
Spree::ReimbursementType.create_with(name: "Store Credit").find_or_create_by!(type: 'Spree::ReimbursementType::StoreCredit')
|
|
18
|
+
Spree::ReimbursementType.create_with(name: "Original").find_or_create_by!(type: 'Spree::ReimbursementType::OriginalPayment')
|
|
19
|
+
|
|
20
|
+
Spree::StoreCreditCategory.find_or_create_by!(name: Spree::StoreCreditCategory::GIFT_CARD)
|
|
21
|
+
Spree::StoreCreditCategory.find_or_create_by!(name: Spree::StoreCreditCategory::REIMBURSEMENT)
|
|
22
|
+
|
|
23
|
+
Spree::StoreCreditReason.find_or_create_by!(name: 'Credit Given In Error')
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solidus_brazilian_adaptations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.5
|
|
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-10-
|
|
11
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: solidus_core
|
|
@@ -102,6 +102,17 @@ files:
|
|
|
102
102
|
- config/routes.rb
|
|
103
103
|
- db/migrate/20230911133000_add_tax_id_to_spree_orders.rb
|
|
104
104
|
- db/migrate/20230911133157_add_number_district_to_addresses.rb
|
|
105
|
+
- db/seeds.rb
|
|
106
|
+
- db/spree_br/countries.rb
|
|
107
|
+
- db/spree_br/payment.rb
|
|
108
|
+
- db/spree_br/refund_reasons.rb
|
|
109
|
+
- db/spree_br/return_reasons.rb
|
|
110
|
+
- db/spree_br/roles.rb
|
|
111
|
+
- db/spree_br/shipping.rb
|
|
112
|
+
- db/spree_br/states.rb
|
|
113
|
+
- db/spree_br/stock_locations.rb
|
|
114
|
+
- db/spree_br/store_credit.rb
|
|
115
|
+
- db/spree_br/stores.rb
|
|
105
116
|
- lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
|
|
106
117
|
- lib/generators/solidus_brazilian_adaptations/install/templates/initializer.rb
|
|
107
118
|
- lib/solidus_brazilian_adaptations.rb
|