solidus_india 0.0.1
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 +7 -0
- data/.circleci/config.yml +47 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +43 -0
- data/LICENSE +26 -0
- data/README.md +113 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/spree/backend/solidus_india.js +2 -0
- data/app/assets/javascripts/spree/frontend/solidus_india.js +2 -0
- data/app/assets/stylesheets/spree/backend/solidus_india.css +4 -0
- data/app/assets/stylesheets/spree/frontend/solidus_india.css +4 -0
- data/app/models/solidus_india/cgst_calculator.rb +26 -0
- data/app/models/solidus_india/igst_calculator.rb +26 -0
- data/app/models/solidus_india/sgst_calculator.rb +26 -0
- data/bin/console +17 -0
- data/bin/rails +7 -0
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +102 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +5 -0
- data/db/samples/prices_inr.rb +9 -0
- data/db/samples/shipping_categories_and_methods.rb +35 -0
- data/db/samples/tax_rates_and_zone.rb +77 -0
- data/db/samples/update_products_with_tax_category.rb +11 -0
- data/db/samples/variants_inr.rb +9 -0
- data/lib/generators/solidus_india/install/install_generator.rb +13 -0
- data/lib/generators/solidus_india/install/templates/initializer.rb +6 -0
- data/lib/solidus_india/configuration.rb +21 -0
- data/lib/solidus_india/engine.rb +19 -0
- data/lib/solidus_india/testing_support/factories.rb +4 -0
- data/lib/solidus_india/version.rb +5 -0
- data/lib/solidus_india.rb +5 -0
- data/lib/tasks/db/seed/solidus_india.rake +21 -0
- data/solidus_india.gemspec +36 -0
- data/spec/spec_helper.rb +31 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7c321699dbac8a8ad7d2b2145102b47a7c144ecd6ffdba129f5f8c348db7ff8
|
4
|
+
data.tar.gz: 15df061fb2ea694cccb17419939d4377ed460d72896ccb4fafea8417e4be5ef9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b24e404b6de319aec5144fcc77a2d435376abc759e96f4818ecb4464280c44145b31cd121545c5a2ee5bccc2e4da7f96f6fdbc2961b85d7d8418a27b0b40e2bd
|
7
|
+
data.tar.gz: 973f38bb63f623c840bb88e68fbad2afd0a8c115b79c9e4db67f015afb6ee376a6b70d865645766d1a1f2ed8104501408ed09b3c4d268eeb9a441ed46904874a
|
@@ -0,0 +1,47 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
# Required for feature specs.
|
5
|
+
browser-tools: circleci/browser-tools@1.1
|
6
|
+
|
7
|
+
# Always take the latest version of the orb, this allows us to
|
8
|
+
# run specs against Solidus supported versions only without the need
|
9
|
+
# to change this configuration every time a Solidus version is released
|
10
|
+
# or goes EOL.
|
11
|
+
solidusio_extensions: solidusio/extensions@volatile
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
run-specs-with-postgres:
|
15
|
+
executor: solidusio_extensions/postgres
|
16
|
+
steps:
|
17
|
+
- browser-tools/install-browser-tools
|
18
|
+
- solidusio_extensions/run-tests
|
19
|
+
run-specs-with-mysql:
|
20
|
+
executor: solidusio_extensions/mysql
|
21
|
+
steps:
|
22
|
+
- browser-tools/install-browser-tools
|
23
|
+
- solidusio_extensions/run-tests
|
24
|
+
lint-code:
|
25
|
+
executor: solidusio_extensions/sqlite-memory
|
26
|
+
steps:
|
27
|
+
- browser-tools/install-browser-tools
|
28
|
+
- solidusio_extensions/lint-code
|
29
|
+
|
30
|
+
workflows:
|
31
|
+
"Run specs on supported Solidus versions":
|
32
|
+
jobs:
|
33
|
+
- run-specs-with-postgres
|
34
|
+
- run-specs-with-mysql
|
35
|
+
- lint-code
|
36
|
+
|
37
|
+
"Weekly run specs against master":
|
38
|
+
triggers:
|
39
|
+
- schedule:
|
40
|
+
cron: "0 0 * * 4" # every Thursday
|
41
|
+
filters:
|
42
|
+
branches:
|
43
|
+
only:
|
44
|
+
- master
|
45
|
+
jobs:
|
46
|
+
- run-specs-with-postgres
|
47
|
+
- run-specs-with-mysql
|
data/.gem_release.yml
ADDED
data/.github/stale.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Number of days of inactivity before an issue becomes stale
|
2
|
+
daysUntilStale: 60
|
3
|
+
# Number of days of inactivity before a stale issue is closed
|
4
|
+
daysUntilClose: false
|
5
|
+
# Issues with these labels will never be considered stale
|
6
|
+
exemptLabels:
|
7
|
+
- pinned
|
8
|
+
- security
|
9
|
+
# Label to use when marking an issue as stale
|
10
|
+
staleLabel: stale
|
11
|
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
+
markComment: >
|
13
|
+
This issue has been automatically marked as stale because it has not had
|
14
|
+
recent activity. It might be closed if no further activity occurs. Thank you
|
15
|
+
for your contributions.
|
16
|
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
+
closeComment: false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Changelog
|
data/Gemfile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
8
|
+
|
9
|
+
# The solidus_frontend gem has been pulled out since v3.2
|
10
|
+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
|
11
|
+
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem
|
12
|
+
|
13
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
14
|
+
# otherwise it takes forever to resolve them.
|
15
|
+
# See https://github.com/bundler/bundler/issues/6677
|
16
|
+
gem 'rails', '>0.a'
|
17
|
+
|
18
|
+
# Provides basic authentication functionality for testing parts of your engine
|
19
|
+
gem 'solidus_auth_devise'
|
20
|
+
|
21
|
+
case ENV.fetch('DB', nil)
|
22
|
+
when 'mysql'
|
23
|
+
gem 'mysql2'
|
24
|
+
when 'postgresql'
|
25
|
+
gem 'pg'
|
26
|
+
else
|
27
|
+
gem 'sqlite3'
|
28
|
+
end
|
29
|
+
|
30
|
+
# While we still support Ruby < 3 we need to workaround a limitation in
|
31
|
+
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
|
32
|
+
# resolve gems based on the required ruby version.
|
33
|
+
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
|
34
|
+
|
35
|
+
gem 'pry'
|
36
|
+
gemspec
|
37
|
+
|
38
|
+
# Use a local Gemfile to include development dependencies that might not be
|
39
|
+
# relevant for the project or for other contributors, e.g. pry-byebug.
|
40
|
+
#
|
41
|
+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
42
|
+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
43
|
+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2022 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Solidus nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Solidus India
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/solidusio-contrib/solidus_india)
|
4
|
+
[](https://codecov.io/gh/solidusio-contrib/solidus_india)
|
5
|
+
|
6
|
+
<!-- Explain what your extension does. -->
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add solidus_india to your Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'solidus_india'
|
14
|
+
```
|
15
|
+
|
16
|
+
Bundle your dependencies and run the installation generator:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
bin/rails generate solidus_india:install
|
20
|
+
```
|
21
|
+
|
22
|
+
Go to `config/initializers/spree.rb` and change the following line
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
# Default currency for new sites
|
26
|
+
config.currency = "USD"
|
27
|
+
```
|
28
|
+
|
29
|
+
to
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# Default currency for new sites
|
33
|
+
config.currency = "INR"
|
34
|
+
```
|
35
|
+
|
36
|
+
This will allow you to use all the INR specific products, taxes and shipping methods added by the seeds.
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
This extension adds seeds and required functionality to modify the base Solidus Store into an ecommerce store in the indian context.
|
41
|
+
|
42
|
+
The base Solidus store is more USA and Europe friendly with products, prices, shipping and taxes based on those regions. For newcomers to Solidus from a region other than the USA and Europe, it becomes quite difficult to start a new project on Solidus.
|
43
|
+
|
44
|
+
As soon as you finish the installation, you can start the server and find that the base Solidus Store now works as an Indian ecommerce store with all the prices, taxes and shipping methods in INR and working for an indian context.
|
45
|
+
|
46
|
+
I would also recommend using the [solidus_razorpay](https://github.com/solidusio-contrib/solidus_razorpay) extension to allow your store to make UPI payments with the help of the Razorpay payment integration.
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
### Testing the extension
|
51
|
+
|
52
|
+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
53
|
+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
54
|
+
`bin/rake extension:test_app`.
|
55
|
+
|
56
|
+
```shell
|
57
|
+
bin/rake
|
58
|
+
```
|
59
|
+
|
60
|
+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
61
|
+
|
62
|
+
```shell
|
63
|
+
bundle exec rubocop
|
64
|
+
```
|
65
|
+
|
66
|
+
When testing your application's integration with this extension you may use its factories.
|
67
|
+
Simply add this require statement to your `spec/spec_helper.rb`:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'solidus_india/testing_support/factories'
|
71
|
+
```
|
72
|
+
|
73
|
+
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
|
74
|
+
factories along with this extension's factories using this statement:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusIndia::Engine)
|
78
|
+
```
|
79
|
+
|
80
|
+
### Running the sandbox
|
81
|
+
|
82
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
83
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
84
|
+
`sandbox/bin/rails`.
|
85
|
+
|
86
|
+
Here's an example:
|
87
|
+
|
88
|
+
```
|
89
|
+
$ bin/rails server
|
90
|
+
=> Booting Puma
|
91
|
+
=> Rails 6.0.2.1 application starting in development
|
92
|
+
* Listening on tcp://127.0.0.1:3000
|
93
|
+
Use Ctrl-C to stop
|
94
|
+
```
|
95
|
+
|
96
|
+
### Updating the changelog
|
97
|
+
|
98
|
+
Before and after releases the changelog should be updated to reflect the up-to-date status of
|
99
|
+
the project:
|
100
|
+
|
101
|
+
```shell
|
102
|
+
bin/rake changelog
|
103
|
+
git add CHANGELOG.md
|
104
|
+
git commit -m "Update the changelog"
|
105
|
+
```
|
106
|
+
|
107
|
+
### Releasing new versions
|
108
|
+
|
109
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
110
|
+
|
111
|
+
## License
|
112
|
+
|
113
|
+
Copyright (c) 2022 [name of extension author], released under the New BSD License.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'spree/calculator'
|
4
|
+
|
5
|
+
module SolidusIndia
|
6
|
+
class CgstCalculator < Spree::Calculator
|
7
|
+
def compute_line_item(line_item)
|
8
|
+
calculate_rates(line_item)
|
9
|
+
end
|
10
|
+
|
11
|
+
def compute_shipment(shipment)
|
12
|
+
calculate_rates(shipment)
|
13
|
+
end
|
14
|
+
|
15
|
+
def compute_shipping_rate(shipping)
|
16
|
+
calculate_rates(shipping)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def calculate_rates(item)
|
22
|
+
tax_rate = Spree::TaxRate.find_by(name: 'CGST')
|
23
|
+
item.amount * tax_rate.amount
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'spree/calculator'
|
4
|
+
|
5
|
+
module SolidusIndia
|
6
|
+
class IgstCalculator < Spree::Calculator
|
7
|
+
def compute_line_item(line_item)
|
8
|
+
calculate_rates(line_item)
|
9
|
+
end
|
10
|
+
|
11
|
+
def compute_shipment(shipment)
|
12
|
+
calculate_rates(shipment)
|
13
|
+
end
|
14
|
+
|
15
|
+
def compute_shipping_rate(shipping)
|
16
|
+
calculate_rates(shipping)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def calculate_rates(item)
|
22
|
+
tax_rate = Spree::TaxRate.find_by(name: 'IGST')
|
23
|
+
item.amount * tax_rate.amount
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'spree/calculator'
|
4
|
+
|
5
|
+
module SolidusIndia
|
6
|
+
class SgstCalculator < Spree::Calculator
|
7
|
+
def compute_line_item(line_item)
|
8
|
+
calculate_rates(line_item)
|
9
|
+
end
|
10
|
+
|
11
|
+
def compute_shipment(shipment)
|
12
|
+
calculate_rates(shipment)
|
13
|
+
end
|
14
|
+
|
15
|
+
def compute_shipping_rate(shipping)
|
16
|
+
calculate_rates(shipping)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def calculate_rates(item)
|
22
|
+
tax_rate = Spree::TaxRate.find_by(name: 'SGST')
|
23
|
+
item.amount * tax_rate.amount
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "solidus_india"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
# require "pry"
|
14
|
+
# Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
ADDED
data/bin/rails-engine
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/solidus_india/engine', __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'rails/all'
|
13
|
+
require 'rails/engine/commands'
|
data/bin/rails-sandbox
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
app_root = 'sandbox'
|
4
|
+
|
5
|
+
unless File.exist? "#{app_root}/bin/rails"
|
6
|
+
warn 'Creating the sandbox app...'
|
7
|
+
Dir.chdir "#{__dir__}/.." do
|
8
|
+
system "#{__dir__}/sandbox" or begin
|
9
|
+
warn 'Automatic creation of the sandbox app failed'
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir.chdir app_root
|
16
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
if [ ! -z $DEBUG ]
|
5
|
+
then
|
6
|
+
set -x
|
7
|
+
fi
|
8
|
+
|
9
|
+
case "$DB" in
|
10
|
+
postgres|postgresql)
|
11
|
+
RAILSDB="postgresql"
|
12
|
+
;;
|
13
|
+
mysql)
|
14
|
+
RAILSDB="mysql"
|
15
|
+
;;
|
16
|
+
sqlite3|sqlite)
|
17
|
+
RAILSDB="sqlite3"
|
18
|
+
;;
|
19
|
+
'')
|
20
|
+
echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
|
21
|
+
RAILSDB="sqlite3"
|
22
|
+
;;
|
23
|
+
*)
|
24
|
+
echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"."
|
25
|
+
echo "Please use 'postgres', 'mysql', or 'sqlite' instead."
|
26
|
+
exit 1
|
27
|
+
;;
|
28
|
+
esac
|
29
|
+
echo "~~> Using $RAILSDB as the database engine"
|
30
|
+
|
31
|
+
if [ -n $SOLIDUS_BRANCH ]
|
32
|
+
then
|
33
|
+
BRANCH=$SOLIDUS_BRANCH
|
34
|
+
else
|
35
|
+
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
|
36
|
+
BRANCH="master"
|
37
|
+
fi
|
38
|
+
echo "~~> Using branch $BRANCH of solidus"
|
39
|
+
|
40
|
+
if [ -z $SOLIDUS_FRONTEND ]
|
41
|
+
then
|
42
|
+
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
|
43
|
+
SOLIDUS_FRONTEND="solidus_frontend"
|
44
|
+
fi
|
45
|
+
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
|
46
|
+
|
47
|
+
extension_name="solidus_india"
|
48
|
+
|
49
|
+
# Stay away from the bundler env of the containing extension.
|
50
|
+
function unbundled {
|
51
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
52
|
+
}
|
53
|
+
|
54
|
+
rm -rf ./sandbox
|
55
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
56
|
+
--skip-bundle \
|
57
|
+
--skip-git \
|
58
|
+
--skip-keeps \
|
59
|
+
--skip-rc \
|
60
|
+
--skip-spring \
|
61
|
+
--skip-test \
|
62
|
+
--skip-javascript
|
63
|
+
|
64
|
+
if [ ! -d "sandbox" ]; then
|
65
|
+
echo 'sandbox rails application failed'
|
66
|
+
exit 1
|
67
|
+
fi
|
68
|
+
|
69
|
+
cd ./sandbox
|
70
|
+
cat <<RUBY >> Gemfile
|
71
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
72
|
+
gem 'rails-i18n'
|
73
|
+
gem 'solidus_i18n'
|
74
|
+
|
75
|
+
gem '$extension_name', path: '..'
|
76
|
+
|
77
|
+
group :test, :development do
|
78
|
+
platforms :mri do
|
79
|
+
gem 'pry-byebug'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
|
84
|
+
unbundled bundle install --gemfile Gemfile
|
85
|
+
|
86
|
+
unbundled bundle exec rake db:drop db:create
|
87
|
+
|
88
|
+
unbundled bundle exec rails generate solidus:install \
|
89
|
+
--auto-accept \
|
90
|
+
--user_class=Spree::User \
|
91
|
+
--enforce_available_locales=true \
|
92
|
+
--with-authentication=true \
|
93
|
+
--payment-method=none \
|
94
|
+
--frontend=${SOLIDUS_FRONTEND} \
|
95
|
+
$@
|
96
|
+
|
97
|
+
unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
|
98
|
+
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
|
99
|
+
|
100
|
+
echo
|
101
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
102
|
+
echo "🧪 This app is intended for test purposes."
|
data/bin/setup
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
india = Spree::Zone.find_by!(name: 'India')
|
4
|
+
tax_category = Spree::TaxCategory.find_by!(name: 'IGST')
|
5
|
+
shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'India')
|
6
|
+
|
7
|
+
Spree::ShippingMethod.create!([
|
8
|
+
{
|
9
|
+
name: 'Free Shipping (INR)',
|
10
|
+
zones: [india],
|
11
|
+
calculator: Spree::Calculator::Shipping::FlatRate.create!,
|
12
|
+
tax_category: tax_category,
|
13
|
+
shipping_categories: [shipping_category]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
name: 'Express Shipping (INR)',
|
17
|
+
zones: [india],
|
18
|
+
calculator: Spree::Calculator::Shipping::FlatRate.create!,
|
19
|
+
tax_category: tax_category,
|
20
|
+
shipping_categories: [shipping_category]
|
21
|
+
}
|
22
|
+
])
|
23
|
+
|
24
|
+
{
|
25
|
+
'Free Shipping (INR)' => [0, 'INR'],
|
26
|
+
'Express Shipping (INR)' => [100, 'INR']
|
27
|
+
}.each do |shipping_method_name, (price, currency)|
|
28
|
+
shipping_method = Spree::ShippingMethod.find_by!(name: shipping_method_name)
|
29
|
+
shipping_method.calculator.preferences = {
|
30
|
+
amount: price,
|
31
|
+
currency: currency
|
32
|
+
}
|
33
|
+
shipping_method.calculator.save!
|
34
|
+
shipping_method.save!
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
country = Spree::Country.find_by(iso: 'IN')
|
4
|
+
|
5
|
+
zone = Spree::Zone.find_or_create_by!(
|
6
|
+
name: 'India',
|
7
|
+
description: 'Taxes applied in the Indian Region',
|
8
|
+
)
|
9
|
+
|
10
|
+
Spree::ZoneMember.find_or_create_by!(
|
11
|
+
zoneable_type: 'Spree::Country',
|
12
|
+
zoneable_id: country.id,
|
13
|
+
zone_id: zone.id
|
14
|
+
)
|
15
|
+
|
16
|
+
tax_category_igst = Spree::TaxCategory.find_or_create_by!(
|
17
|
+
name: 'IGST',
|
18
|
+
description: 'Integrated Goods and Services Taxes',
|
19
|
+
tax_code: 'igst'
|
20
|
+
)
|
21
|
+
|
22
|
+
if tax_category_igst.tax_rates.pluck(:name).exclude?('IGST')
|
23
|
+
tax_rate_igst = Spree::TaxRate.find_or_create_by!(
|
24
|
+
name: 'IGST',
|
25
|
+
zone_id: zone.id,
|
26
|
+
amount: 0.18,
|
27
|
+
included_in_price: false,
|
28
|
+
show_rate_in_label: true,
|
29
|
+
level: 'item',
|
30
|
+
calculator: SolidusIndia::IgstCalculator.new
|
31
|
+
)
|
32
|
+
|
33
|
+
Spree::TaxRateTaxCategory.find_or_create_by!(
|
34
|
+
tax_rate_id: tax_rate_igst.id,
|
35
|
+
tax_category_id: tax_category_igst.id
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
tax_category_gst = Spree::TaxCategory.find_or_create_by!(
|
40
|
+
name: 'CGST + SGST',
|
41
|
+
description: 'Central and State Goods and Services Taxes',
|
42
|
+
tax_code: 'cgst-sgst'
|
43
|
+
)
|
44
|
+
|
45
|
+
if tax_category_gst.tax_rates.pluck(:name).exclude?('CGST')
|
46
|
+
tax_rate_cgst = Spree::TaxRate.find_or_create_by!(
|
47
|
+
name: 'CGST',
|
48
|
+
zone_id: zone.id,
|
49
|
+
amount: 0.09,
|
50
|
+
included_in_price: false,
|
51
|
+
show_rate_in_label: true,
|
52
|
+
level: "item",
|
53
|
+
calculator: SolidusIndia::CgstCalculator.new
|
54
|
+
)
|
55
|
+
|
56
|
+
Spree::TaxRateTaxCategory.find_or_create_by!(
|
57
|
+
tax_rate_id: tax_rate_cgst.id,
|
58
|
+
tax_category_id: tax_category_gst.id
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
if tax_category_gst.tax_rates.pluck(:name).exclude?('SGST')
|
63
|
+
tax_rate_sgst = Spree::TaxRate.find_or_create_by!(
|
64
|
+
name: 'SGST',
|
65
|
+
zone_id: zone.id,
|
66
|
+
amount: 0.09,
|
67
|
+
included_in_price: false,
|
68
|
+
show_rate_in_label: true,
|
69
|
+
level: "item",
|
70
|
+
calculator: SolidusIndia::SgstCalculator.new
|
71
|
+
)
|
72
|
+
|
73
|
+
Spree::TaxRateTaxCategory.find_or_create_by!(
|
74
|
+
tax_rate_id: tax_rate_sgst.id,
|
75
|
+
tax_category_id: tax_category_gst.id
|
76
|
+
)
|
77
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
tax_category = Spree::TaxCategory.find_by(name: 'IGST')
|
4
|
+
|
5
|
+
if tax_category.present?
|
6
|
+
Spree::Product.all.each do |product|
|
7
|
+
product.update(tax_category: tax_category)
|
8
|
+
end
|
9
|
+
else
|
10
|
+
Rails.logger 'IGST TaxCategory not found, update the products manually after ensuring the TaxCategory has been created'
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusIndia
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
def run_seeds
|
7
|
+
puts 'Starting to add seeds from Solidus India'
|
8
|
+
run 'bin/rails db:seed:solidus_india'
|
9
|
+
puts 'Finished seeding successfully'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusIndia
|
4
|
+
class Configuration
|
5
|
+
# Define here the settings for this extension, e.g.:
|
6
|
+
#
|
7
|
+
# attr_accessor :my_setting
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
alias config configuration
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield configuration
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solidus_core'
|
4
|
+
require 'solidus_support'
|
5
|
+
|
6
|
+
module SolidusIndia
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
include SolidusSupport::EngineExtensions
|
9
|
+
|
10
|
+
isolate_namespace ::Spree
|
11
|
+
|
12
|
+
engine_name 'solidus_india'
|
13
|
+
|
14
|
+
# use rspec for tests
|
15
|
+
config.generators do |g|
|
16
|
+
g.test_framework :rspec
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :db do
|
4
|
+
namespace :seed do
|
5
|
+
desc 'Loads solidus_india sample data'
|
6
|
+
task solidus_india: :environment do
|
7
|
+
samples_root = File.join(SolidusIndia::Engine.root, 'db', 'samples')
|
8
|
+
|
9
|
+
puts 'load prices_inr'
|
10
|
+
load File.join(samples_root, 'prices_inr.rb')
|
11
|
+
puts 'load variants_inr'
|
12
|
+
load File.join(samples_root, 'variants_inr.rb')
|
13
|
+
puts 'load tax_rates_and_zone'
|
14
|
+
load File.join(samples_root, 'tax_rates_and_zone.rb')
|
15
|
+
puts 'load shipping_categories_and_methods'
|
16
|
+
load File.join(samples_root, 'shipping_categories_and_methods.rb')
|
17
|
+
puts 'load update_products_with_tax_category'
|
18
|
+
load File.join(samples_root, 'update_products_with_tax_category.rb')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/solidus_india/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'solidus_india'
|
7
|
+
spec.version = SolidusIndia::VERSION
|
8
|
+
spec.authors = ['piyushswain']
|
9
|
+
spec.email = 'piyush.swain3@gmail.com'
|
10
|
+
|
11
|
+
spec.summary = 'Starter for Solidus projects to be made in an Indian context.'
|
12
|
+
spec.description = 'Starter for Solidus projects in an Indian context. Adds seeds and tax calculators for an Indian ecommerce store.'
|
13
|
+
spec.homepage = 'https://github.com/solidusio-contrib/solidus_india#readme'
|
14
|
+
spec.license = 'BSD-3-Clause'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_india'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_india/blob/master/CHANGELOG.md'
|
19
|
+
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7', '< 4')
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
|
+
|
26
|
+
spec.files = files.grep_v(%r{^(test|spec|features)/})
|
27
|
+
spec.test_files = files.grep(%r{^(test|spec|features)/})
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency 'solidus_core', ['>= 2.2', '< 4']
|
33
|
+
spec.add_dependency 'solidus_support', '~> 0.5'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'solidus_dev_support', '~> 2.5'
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Configure Rails Environment
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
|
6
|
+
# Run Coverage report
|
7
|
+
require 'solidus_dev_support/rspec/coverage'
|
8
|
+
|
9
|
+
# Create the dummy app if it's still missing.
|
10
|
+
dummy_env = "#{__dir__}/dummy/config/environment.rb"
|
11
|
+
system 'bin/rake extension:test_app' unless File.exist? dummy_env
|
12
|
+
require dummy_env
|
13
|
+
|
14
|
+
# Requires factories and other useful helpers defined in spree_core.
|
15
|
+
require 'solidus_dev_support/rspec/feature_helper'
|
16
|
+
|
17
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
|
+
# in spec/support/ and its subdirectories.
|
19
|
+
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
|
20
|
+
|
21
|
+
# Requires factories defined in lib/solidus_india/testing_support/factories.rb
|
22
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusIndia::Engine)
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.infer_spec_type_from_file_location!
|
26
|
+
config.use_transactional_fixtures = false
|
27
|
+
|
28
|
+
if Spree.solidus_gem_version < Gem::Version.new('2.11')
|
29
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solidus_india
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- piyushswain
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: solidus_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: solidus_support
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.5'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: solidus_dev_support
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.5'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.5'
|
61
|
+
description: Starter for Solidus projects in an Indian context. Adds seeds and tax
|
62
|
+
calculators for an Indian ecommerce store.
|
63
|
+
email: piyush.swain3@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".circleci/config.yml"
|
69
|
+
- ".gem_release.yml"
|
70
|
+
- ".github/stale.yml"
|
71
|
+
- ".github_changelog_generator"
|
72
|
+
- ".gitignore"
|
73
|
+
- ".rspec"
|
74
|
+
- ".rubocop.yml"
|
75
|
+
- CHANGELOG.md
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- app/assets/javascripts/spree/backend/solidus_india.js
|
81
|
+
- app/assets/javascripts/spree/frontend/solidus_india.js
|
82
|
+
- app/assets/stylesheets/spree/backend/solidus_india.css
|
83
|
+
- app/assets/stylesheets/spree/frontend/solidus_india.css
|
84
|
+
- app/models/solidus_india/cgst_calculator.rb
|
85
|
+
- app/models/solidus_india/igst_calculator.rb
|
86
|
+
- app/models/solidus_india/sgst_calculator.rb
|
87
|
+
- bin/console
|
88
|
+
- bin/rails
|
89
|
+
- bin/rails-engine
|
90
|
+
- bin/rails-sandbox
|
91
|
+
- bin/rake
|
92
|
+
- bin/sandbox
|
93
|
+
- bin/setup
|
94
|
+
- config/locales/en.yml
|
95
|
+
- config/routes.rb
|
96
|
+
- db/samples/prices_inr.rb
|
97
|
+
- db/samples/shipping_categories_and_methods.rb
|
98
|
+
- db/samples/tax_rates_and_zone.rb
|
99
|
+
- db/samples/update_products_with_tax_category.rb
|
100
|
+
- db/samples/variants_inr.rb
|
101
|
+
- lib/generators/solidus_india/install/install_generator.rb
|
102
|
+
- lib/generators/solidus_india/install/templates/initializer.rb
|
103
|
+
- lib/solidus_india.rb
|
104
|
+
- lib/solidus_india/configuration.rb
|
105
|
+
- lib/solidus_india/engine.rb
|
106
|
+
- lib/solidus_india/testing_support/factories.rb
|
107
|
+
- lib/solidus_india/version.rb
|
108
|
+
- lib/tasks/db/seed/solidus_india.rake
|
109
|
+
- solidus_india.gemspec
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
homepage: https://github.com/solidusio-contrib/solidus_india#readme
|
112
|
+
licenses:
|
113
|
+
- BSD-3-Clause
|
114
|
+
metadata:
|
115
|
+
homepage_uri: https://github.com/solidusio-contrib/solidus_india#readme
|
116
|
+
source_code_uri: https://github.com/solidusio-contrib/solidus_india
|
117
|
+
changelog_uri: https://github.com/solidusio-contrib/solidus_india/blob/master/CHANGELOG.md
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '2.7'
|
127
|
+
- - "<"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '4'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubygems_version: 3.4.10
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Starter for Solidus projects to be made in an Indian context.
|
140
|
+
test_files:
|
141
|
+
- spec/spec_helper.rb
|