mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Compare commits
432 Commits
7caaeffe80
...
v4.4.41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57f148564c | ||
|
|
e99b072442 | ||
|
|
f269584b8e | ||
|
|
4ff832693c | ||
|
|
09354dc80e | ||
|
|
b846d0f517 | ||
|
|
f083e851c0 | ||
|
|
85e3d5d858 | ||
|
|
0d03cdf815 | ||
|
|
434afb73cd | ||
|
|
c2cbe4f0bf | ||
|
|
645cb10864 | ||
|
|
4140257fa1 | ||
|
|
4f851bbe1f | ||
|
|
1ec453df4d | ||
|
|
5559816e12 | ||
|
|
574e8f0135 | ||
|
|
b5cdee3d65 | ||
|
|
d0f683d279 | ||
|
|
8d166ed3e1 | ||
|
|
9ae064a24f | ||
|
|
7aad4ad652 | ||
|
|
4a3f4136df | ||
|
|
8e7f4ff908 | ||
|
|
2090bc1b47 | ||
|
|
38a4bfe98b | ||
|
|
5b043574a2 | ||
|
|
e59237ef19 | ||
|
|
053a88d252 | ||
|
|
e7856d86f4 | ||
|
|
09ece4b35e | ||
|
|
9477725997 | ||
|
|
51d90e782b | ||
|
|
c4e92e7d8f | ||
|
|
142fe542c0 | ||
|
|
574297343f | ||
|
|
302cde6f4e | ||
|
|
5a2f791d58 | ||
|
|
456905e69f | ||
|
|
a2255e62d4 | ||
|
|
11541c9270 | ||
|
|
8f9d8b5fb8 | ||
|
|
91f0a80189 | ||
|
|
1d1169b478 | ||
|
|
06f67488a9 | ||
|
|
acc72514de | ||
|
|
1abb068a00 | ||
|
|
508ebab75b | ||
|
|
6c9a47854a | ||
|
|
9d6ef2f730 | ||
|
|
f17b0d176b | ||
|
|
72ce3a01a9 | ||
|
|
eb791bed27 | ||
|
|
b624965883 | ||
|
|
f5b6a14aba | ||
|
|
a27999f224 | ||
|
|
31c1eee593 | ||
|
|
ef3a41203d | ||
|
|
f6f0622e9b | ||
|
|
0c319bea2c | ||
|
|
5cd53e0b5e | ||
|
|
1fc4270613 | ||
|
|
7e2fcede61 | ||
|
|
a41019fbff | ||
|
|
d6f2a531aa | ||
|
|
9d09d5aff1 | ||
|
|
2adb69edb0 | ||
|
|
e33da30263 | ||
|
|
c30292890d | ||
|
|
77b9f506ab | ||
|
|
5371258125 | ||
|
|
91769574e3 | ||
|
|
bfd4b730f2 | ||
|
|
d2c2e20822 | ||
|
|
269811584b | ||
|
|
83c74bcc77 | ||
|
|
f08c1ca51d | ||
|
|
4a7cb601e6 | ||
|
|
579357dcfa | ||
|
|
08ccdf07c9 | ||
|
|
a2a951a18e | ||
|
|
8a9b728ac7 | ||
|
|
8f07ff49ac | ||
|
|
8ca019d00c | ||
|
|
eb82e30cf6 | ||
|
|
b1e10f3dd4 | ||
|
|
acc036b1d7 | ||
|
|
e182365006 | ||
|
|
9926b65bd9 | ||
|
|
8db716f047 | ||
|
|
3e27a34971 | ||
|
|
5420910907 | ||
|
|
bdbc9ae28b | ||
|
|
7fdf6f4607 | ||
|
|
81274bd075 | ||
|
|
4de1905e73 | ||
|
|
97eef4cfcd | ||
|
|
d9ec6e2ca3 | ||
|
|
e5323c8e82 | ||
|
|
cac9b515e0 | ||
|
|
9bb27aeac7 | ||
|
|
4109650509 | ||
|
|
03dffa5c96 | ||
|
|
bdd47f27b8 | ||
|
|
fd54a12bcb | ||
|
|
f4108e97c7 | ||
|
|
27a4202fa4 | ||
|
|
5ec1418eff | ||
|
|
38f97ffc8e | ||
|
|
1ae876ef96 | ||
|
|
4d94826516 | ||
|
|
dc7c5b6748 | ||
|
|
082b1f9411 | ||
|
|
5554eee0d1 | ||
|
|
34fc6283b8 | ||
|
|
2f3b8c8573 | ||
|
|
3318c2622d | ||
|
|
f6dbb78686 | ||
|
|
a94901fc99 | ||
|
|
0be720dcb1 | ||
|
|
1459c9ee94 | ||
|
|
18d91d166e | ||
|
|
32b33de707 | ||
|
|
917ca790af | ||
|
|
c2c7910357 | ||
|
|
b2172ef8d8 | ||
|
|
ec61cff387 | ||
|
|
693b9bd171 | ||
|
|
89033579bd | ||
|
|
b3dd51d6ac | ||
|
|
1425d524b9 | ||
|
|
e78ef120f4 | ||
|
|
129ceb01f0 | ||
|
|
97d13597b0 | ||
|
|
15790d3d8e | ||
|
|
54d0dfb141 | ||
|
|
c4b7b76e64 | ||
|
|
fd8be37a62 | ||
|
|
0fc3d39106 | ||
|
|
2c71f7f1ed | ||
|
|
8696e05e66 | ||
|
|
dadabcf8ad | ||
|
|
d904c2a494 | ||
|
|
e88335a923 | ||
|
|
6bcbbeadc4 | ||
|
|
9897c33a08 | ||
|
|
e5e8d62c6a | ||
|
|
b03bb30a8e | ||
|
|
3382a62eb5 | ||
|
|
48b447500f | ||
|
|
16c877f7cb | ||
|
|
1d8b942acd | ||
|
|
ade4e855dc | ||
|
|
d4da684f4a | ||
|
|
404fcf1f72 | ||
|
|
a40b9eb44e | ||
|
|
c0010319af | ||
|
|
c9c94fcaa5 | ||
|
|
103c6e7fc0 | ||
|
|
1509066b85 | ||
|
|
169df3fb8b | ||
|
|
061ff91786 | ||
|
|
0aea14832a | ||
|
|
939605cb7a | ||
|
|
b18fe8ce35 | ||
|
|
fc3d7f8496 | ||
|
|
3bd6c85f3b | ||
|
|
0726e4c1d0 | ||
|
|
cfca7816d5 | ||
|
|
f1309db0f0 | ||
|
|
d726a0e3cb | ||
|
|
5415fa2db8 | ||
|
|
2772dd2e78 | ||
|
|
f4cc5d5917 | ||
|
|
3634032948 | ||
|
|
8ad4f885a0 | ||
|
|
870e2b447c | ||
|
|
f57d44ba24 | ||
|
|
f618ef1201 | ||
|
|
644f0aaf75 | ||
|
|
2877c793f8 | ||
|
|
91803953fe | ||
|
|
e00156a8d4 | ||
|
|
fa03de33e1 | ||
|
|
16c20dbb6b | ||
|
|
403d855766 | ||
|
|
965ca5ca92 | ||
|
|
4e7fed9c4b | ||
|
|
0f3b502ca6 | ||
|
|
d6d16316dc | ||
|
|
84747ea064 | ||
|
|
94d08c6b91 | ||
|
|
cf9414a352 | ||
|
|
0887f0676f | ||
|
|
6cff5c81fe | ||
|
|
4db5aa593f | ||
|
|
0bae5d67c6 | ||
|
|
2007b2e1b0 | ||
|
|
0d0a9a467c | ||
|
|
a4cc4e28e7 | ||
|
|
12cf626202 | ||
|
|
af2e3ca703 | ||
|
|
52bc88bbd8 | ||
|
|
cadc2bf5d3 | ||
|
|
69a10f0137 | ||
|
|
eedbaaff6e | ||
|
|
5fde1cc7cd | ||
|
|
3e796da8ff | ||
|
|
8bee48df6d | ||
|
|
eaf32226a4 | ||
|
|
97c6c97499 | ||
|
|
484c037c38 | ||
|
|
100239c4e6 | ||
|
|
678fa37df9 | ||
|
|
8c05838080 | ||
|
|
6d1249e7f9 | ||
|
|
d3e62c4390 | ||
|
|
ac4ec36b3b | ||
|
|
8a364a5f48 | ||
|
|
d959ee2358 | ||
|
|
a55931c081 | ||
|
|
eac278ea1f | ||
|
|
2743a8183d | ||
|
|
3f2a5786bd | ||
|
|
02abe5cc06 | ||
|
|
fb09a7f1e6 | ||
|
|
78495d0ace | ||
|
|
6025491f94 | ||
|
|
c5ec7e361b | ||
|
|
d4dd3cc708 | ||
|
|
c0864405a1 | ||
|
|
6e7b97879b | ||
|
|
d281e9d1b5 | ||
|
|
d9899e8af6 | ||
|
|
b22c42613a | ||
|
|
269d3ced0c | ||
|
|
861f2aef01 | ||
|
|
6b3e33f607 | ||
|
|
cd601319f3 | ||
|
|
3b715875ad | ||
|
|
0dbbd5ed3b | ||
|
|
65731f6c52 | ||
|
|
3a38eeb248 | ||
|
|
2707c3137a | ||
|
|
b30944471d | ||
|
|
c805486f0a | ||
|
|
2ef266390d | ||
|
|
7b4b7c5f45 | ||
|
|
a3b646a500 | ||
|
|
01cbcf79fa | ||
|
|
c611754272 | ||
|
|
66b98bd477 | ||
|
|
18d1e00c47 | ||
|
|
05f373f541 | ||
|
|
4ba6afa665 | ||
|
|
ac1595e718 | ||
|
|
3bb44cfe6d | ||
|
|
19e3dc077e | ||
|
|
33889f1255 | ||
|
|
aab01e77e0 | ||
|
|
1b49606fca | ||
|
|
45ec3d759f | ||
|
|
d8641bf576 | ||
|
|
4498e91e90 | ||
|
|
116547d2d2 | ||
|
|
80db511fe5 | ||
|
|
3a2cb3e415 | ||
|
|
15c93a8e95 | ||
|
|
4a4135f261 | ||
|
|
0cd4682e36 | ||
|
|
1d6323c520 | ||
|
|
8b591b7d21 | ||
|
|
0b844bca8d | ||
|
|
1fd4c83cf1 | ||
|
|
266e94eba8 | ||
|
|
b9b2c876cc | ||
|
|
99121943a7 | ||
|
|
b2881bb169 | ||
|
|
11b8a01220 | ||
|
|
924701e161 | ||
|
|
1d8ed67b0b | ||
|
|
d238fc0cad | ||
|
|
4ddb2ff1e9 | ||
|
|
cf31d09ad8 | ||
|
|
49226ffdbc | ||
|
|
c98956bf5a | ||
|
|
28dab2fc2e | ||
|
|
9beaf0a0c2 | ||
|
|
6291cce5d1 | ||
|
|
e589605e3c | ||
|
|
e110cd1145 | ||
|
|
26723194d5 | ||
|
|
e94fddb0f8 | ||
|
|
4f7d50ca4b | ||
|
|
f13f2cfa2f | ||
|
|
4a776233db | ||
|
|
436f733213 | ||
|
|
a5741a1ca8 | ||
|
|
45b4e6c87c | ||
|
|
189cd88848 | ||
|
|
9b040d87f6 | ||
|
|
924bb2a003 | ||
|
|
9c06032077 | ||
|
|
50242d8821 | ||
|
|
c01bab5f27 | ||
|
|
7be06fc38c | ||
|
|
df50485b62 | ||
|
|
6240f37adf | ||
|
|
d1e492bb99 | ||
|
|
f8a7635463 | ||
|
|
9be929e572 | ||
|
|
7af1fcaabb | ||
|
|
8845161a8e | ||
|
|
ea584504bd | ||
|
|
3b2d8967ad | ||
|
|
52a36f33bc | ||
|
|
502d7c6d4a | ||
|
|
6b2c54a25e | ||
|
|
51404f4d66 | ||
|
|
fc1b686938 | ||
|
|
0ab3c3d875 | ||
|
|
03630f27af | ||
|
|
c0fd08d44e | ||
|
|
42520216aa | ||
|
|
ce24e6ecd6 | ||
|
|
4c1268b3ce | ||
|
|
3455ffd507 | ||
|
|
26f3b5603d | ||
|
|
54738fc552 | ||
|
|
50acf2f484 | ||
|
|
220e459da2 | ||
|
|
c6e88e70c3 | ||
|
|
4ada3edc4e | ||
|
|
579965c62c | ||
|
|
e85e606667 | ||
|
|
b4b8e99c7b | ||
|
|
2d8cd2b1a5 | ||
|
|
1e826e8308 | ||
|
|
d81fc44597 | ||
|
|
cb47624702 | ||
|
|
ccdd428b57 | ||
|
|
eb7e65a707 | ||
|
|
25e3f30f97 | ||
|
|
214f7ec23c | ||
|
|
b679a20f23 | ||
|
|
eb2213bd10 | ||
|
|
b07bf9989a | ||
|
|
13f387e0a4 | ||
|
|
fc24a830a5 | ||
|
|
dd86222391 | ||
|
|
794f92d9f5 | ||
|
|
e061dbb86b | ||
|
|
526069dbb3 | ||
|
|
acb53a6ddc | ||
|
|
b623ecab26 | ||
|
|
476825251d | ||
|
|
0d17230dd2 | ||
|
|
73eeaaabc2 | ||
|
|
cad1140b18 | ||
|
|
67a5aa6877 | ||
|
|
c4fa936f15 | ||
|
|
ad7d19a0be | ||
|
|
69df56ae76 | ||
|
|
63549b3dca | ||
|
|
8a84e0084f | ||
|
|
6dc0988933 | ||
|
|
e2a53b57d4 | ||
|
|
3c3f65c271 | ||
|
|
bdcb0856af | ||
|
|
778ed46d50 | ||
|
|
9d919938f3 | ||
|
|
8858ed86ac | ||
|
|
8efc215a14 | ||
|
|
d2d2db8489 | ||
|
|
3af7fa7521 | ||
|
|
b5c47b099e | ||
|
|
d47d3eba8f | ||
|
|
2e101c5fe6 | ||
|
|
1c09b5d16c | ||
|
|
d6da52929f | ||
|
|
30e8f9eb28 | ||
|
|
7abe455899 | ||
|
|
931ee2f9d2 | ||
|
|
477336c660 | ||
|
|
96ccea3691 | ||
|
|
c6a83588fe | ||
|
|
fcef8e8d7d | ||
|
|
696559200f | ||
|
|
c497b37452 | ||
|
|
acc52cc45f | ||
|
|
38b832cec2 | ||
|
|
261cb2d81b | ||
|
|
f59c43b8e9 | ||
|
|
29dad44f9f | ||
|
|
c4a8bf2490 | ||
|
|
82c444b8d8 | ||
|
|
d7fca66433 | ||
|
|
43d13253e7 | ||
|
|
84551068ee | ||
|
|
163c45d301 | ||
|
|
63a1931ce8 | ||
|
|
98457b2fff | ||
|
|
e072823071 | ||
|
|
d253effc29 | ||
|
|
331894017a | ||
|
|
1674d8ab5c | ||
|
|
85a47e61fd | ||
|
|
a4b7a8f95d | ||
|
|
462c763cd1 | ||
|
|
4f77ad40a3 | ||
|
|
a33eb80f56 | ||
|
|
fb8c86a9a7 | ||
|
|
b53be15fda | ||
|
|
f755aff23c | ||
|
|
ff52a66e75 | ||
|
|
2cac8471fc | ||
|
|
5653d542f6 | ||
|
|
7f3953882d | ||
|
|
f126b8b316 | ||
|
|
7849f30f46 | ||
|
|
b82496b8a1 | ||
|
|
bd6b0ddbf3 | ||
|
|
4a423e3275 | ||
|
|
1472749da8 | ||
|
|
27d1a9ee09 | ||
|
|
45f4a06263 | ||
|
|
ee1f60808e | ||
|
|
8370a5fed0 | ||
|
|
64b42b1284 | ||
|
|
f582bffbc5 | ||
|
|
b669b804c4 | ||
|
|
6e9089ad47 |
@@ -14,3 +14,4 @@ SITE_URL="test.host"
|
||||
|
||||
OPENID_APP_ID="test-provider"
|
||||
OPENID_APP_SECRET="12345"
|
||||
OPENID_REFRESH_TOKEN="dummy-refresh-token"
|
||||
|
||||
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@@ -1,3 +1,8 @@
|
||||
# Dependabot configuration
|
||||
#
|
||||
# The `directory` and `schedule.interval` options are mandatory.
|
||||
# Most of the configuration here is not used for security updates though.
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
|
||||
@@ -5,7 +10,7 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
# Only specific requirements are specified in Gemfile, so don't touch it.
|
||||
versioning-strategy: lockfile-only
|
||||
|
||||
@@ -13,5 +18,6 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
# All versions are specified in package.json, so please update them.
|
||||
versioning-strategy: increase
|
||||
|
||||
7
.github/workflows/linters.yml
vendored
7
.github/workflows/linters.yml
vendored
@@ -7,10 +7,11 @@ jobs:
|
||||
name: runner / rubocop
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||
|
||||
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
|
||||
|
||||
@@ -21,6 +22,8 @@ jobs:
|
||||
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
|
||||
reporter: github-pr-check
|
||||
level: error
|
||||
filter_mode: nofilter
|
||||
use_bundler: true
|
||||
fail_on_error: true
|
||||
prettier:
|
||||
name: runner / prettier
|
||||
|
||||
@@ -19,3 +19,6 @@ Capybara/NegationMatcher:
|
||||
RSpec/ExpectChange:
|
||||
Enabled: true
|
||||
EnforcedStyle: block
|
||||
|
||||
RSpec/NotToNot:
|
||||
Enabled: true
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# These are the rules we agreed upon and we work towards.
|
||||
AllCops:
|
||||
NewCops: enable
|
||||
SuggestExtensions: false
|
||||
Exclude:
|
||||
- bin/**/*
|
||||
- db/**/*
|
||||
@@ -125,6 +124,9 @@ Rails/SkipsModelValidations:
|
||||
- update_column
|
||||
- update_columns
|
||||
|
||||
Rails/WhereExists:
|
||||
EnforcedStyle: where # Cf. conversion https://github.com/openfoodfoundation/openfoodnetwork/pull/12363
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
|
||||
@@ -1,50 +1,17 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.60.2.
|
||||
# using RuboCop version 1.62.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 16
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: enums
|
||||
Lint/ConstantDefinitionInBlock:
|
||||
Exclude:
|
||||
- 'lib/tasks/import_product_images.rake'
|
||||
- 'lib/tasks/users.rake'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/helpers/serializer_helper_spec.rb'
|
||||
- 'spec/lib/reports/line_items_spec.rb'
|
||||
- 'spec/models/spree/ability_spec.rb'
|
||||
- 'spec/models/spree/gateway_spec.rb'
|
||||
- 'spec/models/spree/preferences/configuration_spec.rb'
|
||||
- 'spec/models/spree/preferences/preferable_spec.rb'
|
||||
- 'spec/validators/date_time_string_validator_spec.rb'
|
||||
- 'spec/validators/integer_array_validator_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
|
||||
Lint/DuplicateBranch:
|
||||
Exclude:
|
||||
- 'app/helpers/spree/admin/base_helper.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/calculator.rb'
|
||||
- 'app/models/spree/preference.rb'
|
||||
- 'app/models/spree/preferences/preferable.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Lint/DuplicateMethods:
|
||||
Exclude:
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/DuplicateRequire:
|
||||
Exclude:
|
||||
- 'spec/lib/open_food_network/scope_variants_to_search_spec.rb'
|
||||
|
||||
# Offense count: 18
|
||||
# Offense count: 16
|
||||
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
||||
Lint/EmptyBlock:
|
||||
Exclude:
|
||||
@@ -113,6 +80,7 @@ Lint/SelfAssignment:
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AutoCorrect.
|
||||
Lint/UselessMethodDefinition:
|
||||
Exclude:
|
||||
- 'app/models/spree/gateway.rb'
|
||||
@@ -141,7 +109,7 @@ Metrics/AbcSize:
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/spree/core/controller_helpers/order.rb'
|
||||
- 'lib/tasks/enterprises.rake'
|
||||
- 'spec/services/order_checkout_restart_spec.rb'
|
||||
- 'spec/services/orders/checkout_restart_service_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
||||
@@ -200,8 +168,8 @@ Metrics/ClassLength:
|
||||
- 'app/serializers/api/cached_enterprise_serializer.rb'
|
||||
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
|
||||
- 'app/services/cart_service.rb'
|
||||
- 'app/services/order_cycle_form.rb'
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'app/services/order_cycles/form_service.rb'
|
||||
- 'app/services/orders/sync_service.rb'
|
||||
- 'engines/order_management/app/services/order_management/order/updater.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
@@ -389,56 +357,213 @@ Naming/VariableNumber:
|
||||
- 'spec/models/spree/tax_rate_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# Offense count: 142
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
# AllowedMethods: order, limit, select, lock
|
||||
Rails/FindEach:
|
||||
# Configuration parameters: ResponseMethods.
|
||||
# ResponseMethods: response, last_response
|
||||
RSpecRails/HaveHttpStatus:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/order_cycles_controller.rb'
|
||||
- 'app/jobs/subscription_confirm_job.rb'
|
||||
- 'app/services/orders_bulk_cancel_service.rb'
|
||||
- 'app/services/products_renderer.rb'
|
||||
- 'lib/tasks/data.rake'
|
||||
- 'lib/tasks/subscriptions/debug.rake'
|
||||
- 'spec/system/admin/bulk_order_management_spec.rb'
|
||||
- 'spec/system/admin/enterprise_relationships_spec.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/HasManyOrHasOneDependent:
|
||||
Exclude:
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/address.rb'
|
||||
- 'app/models/spree/stock_item.rb'
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/helpers/**/*.rb
|
||||
Rails/HelperInstanceVariable:
|
||||
Exclude:
|
||||
- 'app/helpers/injection_helper.rb'
|
||||
- 'app/helpers/shared_helper.rb'
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
- 'app/helpers/spree/orders_helper.rb'
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/base_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/customers_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/logos_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/orders_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/products_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/promo_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/reports/packing_report_spec.rb'
|
||||
- 'spec/controllers/api/v0/reports_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/statuses_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/taxons_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/variants_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/callbacks_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/webhooks_controller_spec.rb'
|
||||
- 'spec/controllers/user_passwords_controller_spec.rb'
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/requests/admin/images_spec.rb'
|
||||
- 'spec/requests/api/routes_spec.rb'
|
||||
- 'spec/requests/checkout/failed_checkout_spec.rb'
|
||||
- 'spec/requests/checkout/stripe_sca_spec.rb'
|
||||
- 'spec/requests/home_controller_spec.rb'
|
||||
- 'spec/requests/omniauth_callbacks_controller_spec.rb'
|
||||
- 'spec/services/embedded_page_service_spec.rb'
|
||||
- 'spec/support/api_helper.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: Include.
|
||||
# Include: spec/**/*.rb, test/**/*.rb
|
||||
Rails/I18nLocaleAssignment:
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: numeric, symbolic, be_status
|
||||
RSpecRails/HttpStatus:
|
||||
Exclude:
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/helpers/i18n_helper_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.rb'
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Rails/I18nLocaleTexts:
|
||||
# Offense count: 146
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Inferences.
|
||||
RSpecRails/InferredSpecType:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/stripe_accounts_controller.rb'
|
||||
- 'engines/dfc_provider/spec/requests/addresses_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/catalog_items_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/enterprise_groups/affiliated_by_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/enterprise_groups_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/enterprises_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/offers_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/persons_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/social_medias_spec.rb'
|
||||
- 'engines/dfc_provider/spec/requests/supplied_products_spec.rb'
|
||||
- 'engines/web/spec/helpers/cookies_policy_helper_spec.rb'
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
|
||||
- 'spec/controllers/admin/customers_controller_spec.rb'
|
||||
- 'spec/controllers/admin/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/admin/inventory_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/invoice_settings_controller_spec.rb'
|
||||
- 'spec/controllers/admin/matomo_settings_controller_spec.rb'
|
||||
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/admin/product_import_controller_spec.rb'
|
||||
- 'spec/controllers/admin/proxy_orders_controller_spec.rb'
|
||||
- 'spec/controllers/admin/reports_controller_spec.rb'
|
||||
- 'spec/controllers/admin/schedules_controller_spec.rb'
|
||||
- 'spec/controllers/admin/stripe_accounts_controller_spec.rb'
|
||||
- 'spec/controllers/admin/stripe_connect_settings_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
|
||||
- 'spec/controllers/admin/terms_of_service_files_controller_spec.rb'
|
||||
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/customers_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/enterprise_fees_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/exchange_products_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/logos_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/orders_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/products_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/promo_images_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/reports/packing_report_spec.rb'
|
||||
- 'spec/controllers/api/v0/reports_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/shops_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/statuses_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
|
||||
- 'spec/controllers/api/v0/variants_controller_spec.rb'
|
||||
- 'spec/controllers/base_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/groups_controller_spec.rb'
|
||||
- 'spec/controllers/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/payment_gateways/paypal_controller_spec.rb'
|
||||
- 'spec/controllers/payment_gateways/stripe_controller_spec.rb'
|
||||
- 'spec/controllers/registration_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/shops_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/countries_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/general_settings_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/invoices_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/payments/payments_controller_refunds_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/overview_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/return_authorizations_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/search_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/shipping_categories_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/shipping_methods_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/tax_rates_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/tax_settings_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api_keys_controller_spec.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
|
||||
- 'spec/controllers/spree/users_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/callbacks_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/webhooks_controller_spec.rb'
|
||||
- 'spec/controllers/user_confirmations_controller_spec.rb'
|
||||
- 'spec/controllers/user_passwords_controller_spec.rb'
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/controllers/webhook_endpoints_controller_spec.rb'
|
||||
- 'spec/helpers/admin/enterprises_helper_spec.rb'
|
||||
- 'spec/helpers/admin/orders_helper_spec.rb'
|
||||
- 'spec/helpers/admin/reports_helper_spec.rb'
|
||||
- 'spec/helpers/admin/subscriptions_helper_spec.rb'
|
||||
- 'spec/helpers/application_helper_spec.rb'
|
||||
- 'spec/helpers/checkout_helper_spec.rb'
|
||||
- 'spec/helpers/i18n_helper_spec.rb'
|
||||
- 'spec/helpers/injection_helper_spec.rb'
|
||||
- 'spec/helpers/link_helper_spec.rb'
|
||||
- 'spec/helpers/navigation_helper_spec.rb'
|
||||
- 'spec/helpers/order_cycles_helper_spec.rb'
|
||||
- 'spec/helpers/serializer_helper_spec.rb'
|
||||
- 'spec/helpers/shared_helper_spec.rb'
|
||||
- 'spec/helpers/shop_helper_spec.rb'
|
||||
- 'spec/helpers/spree/admin/base_helper_spec.rb'
|
||||
- 'spec/helpers/spree/admin/general_settings_helper_spec.rb'
|
||||
- 'spec/helpers/spree/admin/orders_helper_spec.rb'
|
||||
- 'spec/helpers/spree/orders_helper_spec.rb'
|
||||
- 'spec/helpers/tax_helper_spec.rb'
|
||||
- 'spec/helpers/terms_and_conditions_helper_spec.rb'
|
||||
- 'spec/jobs/connect_app_job_spec.rb'
|
||||
- 'spec/mailers/producer_mailer_spec.rb'
|
||||
- 'spec/mailers/subscription_mailer_spec.rb'
|
||||
- 'spec/models/column_preference_spec.rb'
|
||||
- 'spec/models/connected_app_spec.rb'
|
||||
- 'spec/models/customer_spec.rb'
|
||||
- 'spec/models/invoice_spec.rb'
|
||||
- 'spec/models/oidc_account_spec.rb'
|
||||
- 'spec/models/proxy_order_spec.rb'
|
||||
- 'spec/models/report_blob_spec.rb'
|
||||
- 'spec/models/semantic_link_spec.rb'
|
||||
- 'spec/models/spree/gateway/stripe_sca_spec.rb'
|
||||
- 'spec/models/subscription_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_order_cycles_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_payment_methods_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_products_spec.rb'
|
||||
- 'spec/models/tag_rule/filter_shipping_methods_spec.rb'
|
||||
- 'spec/models/tag_rule_spec.rb'
|
||||
- 'spec/models/webhook_endpoint_spec.rb'
|
||||
- 'spec/requests/admin/images_spec.rb'
|
||||
- 'spec/requests/admin/product_import_spec.rb'
|
||||
- 'spec/requests/admin/vouchers_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
- 'spec/requests/api/routes_spec.rb'
|
||||
- 'spec/requests/api/v1/customers_spec.rb'
|
||||
- 'spec/requests/api_docs_spec.rb'
|
||||
- 'spec/requests/checkout/failed_checkout_spec.rb'
|
||||
- 'spec/requests/checkout/paypal_spec.rb'
|
||||
- 'spec/requests/checkout/routes_spec.rb'
|
||||
- 'spec/requests/checkout/stripe_sca_spec.rb'
|
||||
- 'spec/requests/errors_spec.rb'
|
||||
- 'spec/requests/home_controller_spec.rb'
|
||||
- 'spec/requests/large_request_spec.rb'
|
||||
- 'spec/requests/omniauth_callbacks_controller_spec.rb'
|
||||
- 'spec/requests/spree/admin/overview_spec.rb'
|
||||
- 'spec/requests/spree/admin/payments_spec.rb'
|
||||
- 'spec/requests/voucher_adjustments_spec.rb'
|
||||
- 'spec/routing/stripe_spec.rb'
|
||||
|
||||
# Offense count: 22
|
||||
# Configuration parameters: IgnoreScopes, Include.
|
||||
@@ -484,17 +609,6 @@ Rails/LexicallyScopedActionFilter:
|
||||
- 'app/controllers/spree/admin/zones_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/NegateInclude:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/resource_controller.rb'
|
||||
- 'app/models/calculator/weight.rb'
|
||||
- 'app/models/product_import/spreadsheet_entry.rb'
|
||||
- 'app/services/order_cart_reset.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 32
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/Pluck:
|
||||
@@ -535,15 +649,10 @@ Rails/RedundantActiveRecordAllMethod:
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'spec/system/admin/product_import_spec.rb'
|
||||
|
||||
# Offense count: 20
|
||||
# Offense count: 14
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/RedundantPresenceValidationOnBelongsTo:
|
||||
Exclude:
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/inventory_item.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/spree/address.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/product_property.rb'
|
||||
@@ -562,7 +671,7 @@ Rails/RelativeDateConstant:
|
||||
Exclude:
|
||||
- 'lib/tasks/data/remove_transient_data.rb'
|
||||
|
||||
# Offense count: 58
|
||||
# Offense count: 56
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Include.
|
||||
# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb
|
||||
@@ -602,14 +711,6 @@ Rails/SkipsModelValidations:
|
||||
- 'app/models/variant_override.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/SquishedSQLHeredocs:
|
||||
Exclude:
|
||||
- 'app/queries/customers_with_balance.rb'
|
||||
- 'app/queries/outstanding_balance.rb'
|
||||
- 'spec/queries/outstanding_balance_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
@@ -618,8 +719,8 @@ Rails/TimeZone:
|
||||
Exclude:
|
||||
- 'app/models/spree/gateway/pay_pal_express.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/services/customer_order_cancellation_spec.rb'
|
||||
- 'spec/services/order_cycle_webhook_service_spec.rb'
|
||||
- 'spec/services/order_cycles/webhook_service_spec.rb'
|
||||
- 'spec/services/orders/customer_cancellation_service_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: TransactionMethods.
|
||||
@@ -656,60 +757,12 @@ Rails/UnusedRenderContent:
|
||||
- 'app/controllers/api/v0/taxons_controller.rb'
|
||||
- 'app/controllers/api/v0/variants_controller.rb'
|
||||
|
||||
# Offense count: 55
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/WhereEquals:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/mailers/producer_mailer.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_fee.rb'
|
||||
- 'app/models/enterprise_group.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/exchange.rb'
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/product_import/entry_processor.rb'
|
||||
- 'app/models/proxy_order.rb'
|
||||
- 'app/models/schedule.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/payment_method.rb'
|
||||
- 'app/models/spree/product.rb'
|
||||
- 'app/models/spree/shipping_method.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/subscription.rb'
|
||||
- 'app/queries/payments_requiring_action.rb'
|
||||
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
|
||||
- 'app/serializers/api/order_serializer.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/reporting/reports/products_and_inventory/base.rb'
|
||||
- 'lib/tasks/data.rake'
|
||||
- 'lib/tasks/data/anonymize_data.rake'
|
||||
- 'lib/tasks/data/remove_transient_data.rb'
|
||||
- 'spec/services/product_tag_rules_filterer_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: exists, where
|
||||
Rails/WhereExists:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/overview_controller.rb'
|
||||
- 'app/controllers/spree/admin/tax_rates_controller.rb'
|
||||
- 'app/controllers/spree/user_sessions_controller.rb'
|
||||
- 'app/models/spree/preferences/store.rb'
|
||||
- 'lib/tasks/sample_data/customer_factory.rb'
|
||||
- 'lib/tasks/sample_data/group_factory.rb'
|
||||
- 'lib/tasks/sample_data/order_cycle_factory.rb'
|
||||
- 'lib/tasks/sample_data/taxon_factory.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Security/Open:
|
||||
Exclude:
|
||||
- 'app/services/image_importer.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/ArrayIntersect:
|
||||
Exclude:
|
||||
@@ -718,7 +771,6 @@ Style/ArrayIntersect:
|
||||
- 'app/models/tag_rule/filter_payment_methods.rb'
|
||||
- 'app/models/tag_rule/filter_products.rb'
|
||||
- 'app/models/tag_rule/filter_shipping_methods.rb'
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'lib/open_food_network/tag_rule_applicator.rb'
|
||||
- 'spec/support/matchers/select2_matchers.rb'
|
||||
|
||||
@@ -883,7 +935,7 @@ Style/PreferredHashMethods:
|
||||
Exclude:
|
||||
- 'app/controllers/api/v0/shipments_controller.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Methods.
|
||||
Style/RedundantArgument:
|
||||
@@ -898,7 +950,7 @@ Style/RedundantAssignment:
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowComments.
|
||||
# Configuration parameters: AutoCorrect, AllowComments.
|
||||
Style/RedundantInitialize:
|
||||
Exclude:
|
||||
- 'spec/models/spree/gateway_spec.rb'
|
||||
@@ -910,6 +962,12 @@ Style/RedundantInterpolation:
|
||||
- 'lib/tasks/karma.rake'
|
||||
- 'spec/base_spec_helper.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantLineContinuation:
|
||||
Exclude:
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
|
||||
# Offense count: 19
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
|
||||
@@ -6,28 +6,9 @@ This is a general guide to setting up an Open Food Network **development environ
|
||||
|
||||
Head to our wiki on [Learning Rails](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Learning-Rails) to find some good starting points.
|
||||
|
||||
### Requirements
|
||||
|
||||
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md).
|
||||
Otherwise, for a local setup you will need:
|
||||
* Ruby and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
|
||||
- To manage versions, it's recommended to use [rbenv](https://github.com/rbenv/rbenv) or [RVM](https://rvm.io/)
|
||||
* Node and yarn (check current Node version in [.node-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.node-version) file)
|
||||
- [nodevn](https://github.com/nodenv/nodenv) is recommended.
|
||||
* PostgreSQL database
|
||||
* Redis (for background jobs)
|
||||
* Chrome (for testing)
|
||||
|
||||
The following guides will provide OS-specific step-by-step instructions to get these requirements installed:
|
||||
- [Ubuntu Setup Guide][ubuntu]
|
||||
- [Debian Setup Guide][debian]
|
||||
- [OSX Setup Guide][osx]
|
||||
|
||||
For those new to Rails, the following tutorial will help get you up to speed with configuring a [Rails environment](http://guides.rubyonrails.org/getting_started.html).
|
||||
|
||||
### Get it
|
||||
|
||||
So you have set up your local environment according to the requirements listed above. If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), it is a good idea to begin by forking this repo using the `Fork` button in the top-right corner of this screen. You should then be able to use `git clone` to copy your fork onto your local machine:
|
||||
If you're planning on contributing code to the project (which we [LOVE](CONTRIBUTING.md)), it is a good idea to begin by forking this repo using the `Fork` button in the top-right corner of this screen. You should then be able to use `git clone` to copy your fork onto your local machine:
|
||||
|
||||
git clone git@github.com:YOUR_GITHUB_USERNAME_HERE/openfoodnetwork.git
|
||||
|
||||
@@ -43,6 +24,27 @@ Fetch the latest version of `master` from `upstream` (ie. the main repo):
|
||||
|
||||
git fetch upstream master
|
||||
|
||||
### Installation
|
||||
|
||||
This project needs specific ruby/bundler versions as well as node/yarn specific versions. For a local setup you will need:
|
||||
|
||||
* Install or change your Ruby version according to the one specified at [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file.
|
||||
- To manage versions, it's recommended to use [rbenv](https://github.com/rbenv/rbenv) or [RVM](https://rvm.io/).
|
||||
* Install [nodenv](https://github.com/nodenv/nodenv) to ensure the correct [.node-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.node-version) is used.
|
||||
- [nodevn](https://github.com/nodenv/nodenv) is recommended as a node version manager.
|
||||
* PostgreSQL database
|
||||
* Redis (for background jobs)
|
||||
* Chrome (for testing)
|
||||
|
||||
The following guides will provide OS-specific step-by-step instructions to get these requirements installed:
|
||||
- [Ubuntu Setup Guide][ubuntu]
|
||||
- [Debian Setup Guide][debian]
|
||||
- [OSX Setup Guide][osx]
|
||||
|
||||
For those new to Rails, the following tutorial will help get you up to speed with configuring a [Rails environment](http://guides.rubyonrails.org/getting_started.html).
|
||||
|
||||
Another way to make it work locally would be using Docker. See the [Docker setup guide](docker/README.md).
|
||||
|
||||
### Get it running
|
||||
|
||||
First, you need to create the database user the app will use by manually typing the following in your terminal:
|
||||
@@ -53,7 +55,8 @@ sudo --login --user=postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PA
|
||||
|
||||
This will create the "ofn" user as superuser and allowing it to create databases. If this command fails, check the [troubleshooting section](#creating-the-database) for an alternative.
|
||||
|
||||
Next, it is _strongly recommended_ to run the setup script.
|
||||
Next, it is _strongly recommended_ to run the setup script:
|
||||
|
||||
```sh
|
||||
./script/setup
|
||||
```
|
||||
|
||||
134
Gemfile.lock
134
Gemfile.lock
@@ -109,7 +109,7 @@ GEM
|
||||
activerecord (7.0.8)
|
||||
activemodel (= 7.0.8)
|
||||
activesupport (= 7.0.8)
|
||||
activerecord-import (1.5.1)
|
||||
activerecord-import (1.6.0)
|
||||
activerecord (>= 4.2)
|
||||
activerecord-postgresql-adapter (0.0.1)
|
||||
pg
|
||||
@@ -156,30 +156,30 @@ GEM
|
||||
awesome_nested_set (3.6.0)
|
||||
activerecord (>= 4.0.0, < 7.2)
|
||||
aws-eventstream (1.3.0)
|
||||
aws-partitions (1.883.0)
|
||||
aws-sdk-core (3.191.0)
|
||||
aws-partitions (1.914.0)
|
||||
aws-sdk-core (3.192.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.651.0)
|
||||
aws-sigv4 (~> 1.8)
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
aws-sdk-kms (1.77.0)
|
||||
aws-sdk-kms (1.79.0)
|
||||
aws-sdk-core (~> 3, >= 3.191.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.143.0)
|
||||
aws-sdk-core (~> 3, >= 3.191.0)
|
||||
aws-sdk-s3 (1.147.0)
|
||||
aws-sdk-core (~> 3, >= 3.192.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.8)
|
||||
aws-sigv4 (1.8.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
base64 (0.2.0)
|
||||
bcp47_spec (0.2.1)
|
||||
bcrypt (3.1.19)
|
||||
bcrypt (3.1.20)
|
||||
bigdecimal (3.0.2)
|
||||
bindata (2.5.0)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.18.3)
|
||||
msgpack (~> 1.2)
|
||||
bugsnag (6.26.3)
|
||||
bugsnag (6.26.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
builder (3.2.4)
|
||||
bullet (7.1.6)
|
||||
@@ -207,6 +207,7 @@ GEM
|
||||
nokogiri (~> 1.10, >= 1.10.4)
|
||||
rubyzip (>= 1.3.0, < 3)
|
||||
cgi (0.3.6)
|
||||
childprocess (5.0.0)
|
||||
choice (0.2.0)
|
||||
chronic (0.10.2)
|
||||
coderay (1.1.3)
|
||||
@@ -237,14 +238,14 @@ GEM
|
||||
activerecord (>= 5.a)
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
datafoodconsortium-connector (1.0.0.pre.alpha.10)
|
||||
datafoodconsortium-connector (1.0.0.pre.alpha.12)
|
||||
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
|
||||
date (3.3.4)
|
||||
debug (1.9.1)
|
||||
debug (1.9.2)
|
||||
irb (~> 1.10)
|
||||
reline (>= 0.3.8)
|
||||
debugger-linecache (1.2.0)
|
||||
devise (4.9.3)
|
||||
devise (4.9.4)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
@@ -256,7 +257,7 @@ GEM
|
||||
devise (>= 4.9.0)
|
||||
devise-token_authenticatable (1.1.0)
|
||||
devise (>= 4.0.0, < 5.0.0)
|
||||
diff-lcs (1.5.0)
|
||||
diff-lcs (1.5.1)
|
||||
digest (3.1.1)
|
||||
docile (1.4.0)
|
||||
dotenv (3.1.0)
|
||||
@@ -311,7 +312,7 @@ GEM
|
||||
fog-xml (0.1.3)
|
||||
fog-core
|
||||
nokogiri (>= 1.5.11, < 2.0.0)
|
||||
foreman (0.87.2)
|
||||
foreman (0.88.1)
|
||||
formatador (0.2.5)
|
||||
fugit (1.8.1)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
@@ -335,9 +336,8 @@ GEM
|
||||
hashie (5.0.0)
|
||||
highline (2.0.3)
|
||||
htmlentities (4.3.4)
|
||||
i18n (1.14.3)
|
||||
i18n (1.14.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
racc (~> 1.7)
|
||||
i18n-js (3.9.2)
|
||||
i18n (>= 0.6.6)
|
||||
image_processing (1.12.2)
|
||||
@@ -347,11 +347,11 @@ GEM
|
||||
activerecord (>= 3.0)
|
||||
invisible_captcha (2.2.0)
|
||||
rails (>= 5.2)
|
||||
io-console (0.7.1)
|
||||
io-console (0.7.2)
|
||||
ipaddress (0.8.3)
|
||||
irb (1.11.0)
|
||||
irb (1.12.0)
|
||||
rdoc
|
||||
reline (>= 0.3.8)
|
||||
reline (>= 0.4.2)
|
||||
jmespath (1.6.2)
|
||||
jquery-rails (4.4.0)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
@@ -359,7 +359,7 @@ GEM
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (4.2.1)
|
||||
railties (>= 3.2.16)
|
||||
json (2.7.1)
|
||||
json (2.7.2)
|
||||
json-canonicalization (1.0.0)
|
||||
json-jwt (1.16.6)
|
||||
activesupport (>= 4.2)
|
||||
@@ -387,10 +387,11 @@ GEM
|
||||
knapsack_pro (6.0.4)
|
||||
rake
|
||||
language_server-protocol (3.17.0.3)
|
||||
launchy (2.5.2)
|
||||
launchy (3.0.0)
|
||||
addressable (~> 2.8)
|
||||
letter_opener (1.9.0)
|
||||
launchy (>= 2.2, < 3)
|
||||
childprocess (~> 5.0)
|
||||
letter_opener (1.10.0)
|
||||
launchy (>= 2.2, < 4)
|
||||
link_header (0.0.8)
|
||||
listen (3.9.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
@@ -414,8 +415,8 @@ GEM
|
||||
rake
|
||||
mini_magick (4.11.0)
|
||||
mini_mime (1.1.5)
|
||||
mini_portile2 (2.8.5)
|
||||
minitest (5.22.2)
|
||||
mini_portile2 (2.8.6)
|
||||
minitest (5.22.3)
|
||||
monetize (1.13.0)
|
||||
money (~> 6.12)
|
||||
money (6.16.0)
|
||||
@@ -432,11 +433,11 @@ GEM
|
||||
net-protocol
|
||||
net-protocol (0.2.2)
|
||||
timeout
|
||||
net-smtp (0.4.0.1)
|
||||
net-smtp (0.5.0)
|
||||
net-protocol
|
||||
newrelic_rpm (9.7.1)
|
||||
newrelic_rpm (9.8.0)
|
||||
nio4r (2.7.0)
|
||||
nokogiri (1.16.2)
|
||||
nokogiri (1.16.4)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.11)
|
||||
@@ -506,7 +507,7 @@ GEM
|
||||
railties (>= 4.2)
|
||||
raabro (1.4.0)
|
||||
racc (1.7.3)
|
||||
rack (2.2.8.1)
|
||||
rack (2.2.9)
|
||||
rack-mini-profiler (2.3.4)
|
||||
rack (>= 1.2.0)
|
||||
rack-oauth2 (2.2.1)
|
||||
@@ -555,7 +556,7 @@ GEM
|
||||
rails-html-sanitizer (1.6.0)
|
||||
loofah (~> 2.21)
|
||||
nokogiri (~> 1.14)
|
||||
rails-i18n (7.0.8)
|
||||
rails-i18n (7.0.9)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 6.0.0, < 8)
|
||||
rails_safe_tasks (1.0.0)
|
||||
@@ -567,7 +568,7 @@ GEM
|
||||
thor (~> 1.0)
|
||||
zeitwerk (~> 2.5)
|
||||
rainbow (3.1.1)
|
||||
rake (13.1.0)
|
||||
rake (13.2.1)
|
||||
ransack (4.1.1)
|
||||
activerecord (>= 6.1.5)
|
||||
activesupport (>= 6.1.5)
|
||||
@@ -578,15 +579,15 @@ GEM
|
||||
rdf (3.3.1)
|
||||
bcp47_spec (~> 0.2)
|
||||
link_header (~> 0.0, >= 0.0.8)
|
||||
rdoc (6.6.2)
|
||||
rdoc (6.6.3.1)
|
||||
psych (>= 4.0.0)
|
||||
redcarpet (3.6.0)
|
||||
redis (5.1.0)
|
||||
redis-client (>= 0.17.0)
|
||||
redis-client (0.20.0)
|
||||
redis (5.2.0)
|
||||
redis-client (>= 0.22.0)
|
||||
redis-client (0.22.0)
|
||||
connection_pool
|
||||
regexp_parser (2.9.0)
|
||||
reline (0.4.1)
|
||||
reline (0.5.0)
|
||||
io-console (~> 0.5)
|
||||
request_store (1.5.1)
|
||||
rack (>= 1.4)
|
||||
@@ -606,32 +607,32 @@ GEM
|
||||
roo (2.10.1)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.3.0, < 3.0.0)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
rspec-mocks (~> 3.12.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
rspec (3.13.0)
|
||||
rspec-core (~> 3.13.0)
|
||||
rspec-expectations (~> 3.13.0)
|
||||
rspec-mocks (~> 3.13.0)
|
||||
rspec-core (3.13.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-expectations (3.13.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.6)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-mocks (3.13.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-rails (6.1.1)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-rails (6.1.2)
|
||||
actionpack (>= 6.1)
|
||||
activesupport (>= 6.1)
|
||||
railties (>= 6.1)
|
||||
rspec-core (~> 3.12)
|
||||
rspec-expectations (~> 3.12)
|
||||
rspec-mocks (~> 3.12)
|
||||
rspec-support (~> 3.12)
|
||||
rspec-core (~> 3.13)
|
||||
rspec-expectations (~> 3.13)
|
||||
rspec-mocks (~> 3.13)
|
||||
rspec-support (~> 3.13)
|
||||
rspec-retry (0.6.2)
|
||||
rspec-core (> 3.3)
|
||||
rspec-sql (0.0.1)
|
||||
rspec-sql (0.0.2)
|
||||
activesupport
|
||||
rspec
|
||||
rspec-support (3.12.1)
|
||||
rspec-support (3.13.1)
|
||||
rswag (2.13.0)
|
||||
rswag-api (= 2.13.0)
|
||||
rswag-specs (= 2.13.0)
|
||||
@@ -647,7 +648,7 @@ GEM
|
||||
rswag-ui (2.13.0)
|
||||
actionpack (>= 3.1, < 7.2)
|
||||
railties (>= 3.1, < 7.2)
|
||||
rubocop (1.60.2)
|
||||
rubocop (1.63.2)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
@@ -655,24 +656,27 @@ GEM
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.30.0, < 2.0)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.31.1)
|
||||
rubocop-ast (1.31.2)
|
||||
parser (>= 3.3.0.4)
|
||||
rubocop-capybara (2.20.0)
|
||||
rubocop (~> 1.41)
|
||||
rubocop-factory_bot (2.25.1)
|
||||
rubocop (~> 1.41)
|
||||
rubocop-rails (2.23.1)
|
||||
rubocop-rails (2.24.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.33.0, < 2.0)
|
||||
rubocop-ast (>= 1.30.0, < 2.0)
|
||||
rubocop-rspec (2.27.1)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
rubocop-rspec (2.29.1)
|
||||
rubocop (~> 1.40)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-factory_bot (~> 2.22)
|
||||
rubocop-rspec_rails (~> 2.28)
|
||||
rubocop-rspec_rails (2.28.2)
|
||||
rubocop (~> 1.40)
|
||||
ruby-graphviz (1.2.5)
|
||||
rexml
|
||||
ruby-progressbar (1.13.0)
|
||||
@@ -694,7 +698,7 @@ GEM
|
||||
tilt (>= 1.1, < 3)
|
||||
sd_notify (0.1.1)
|
||||
semantic_range (3.0.0)
|
||||
shoulda-matchers (6.1.0)
|
||||
shoulda-matchers (6.2.0)
|
||||
activesupport (>= 5.2.0)
|
||||
sidekiq (7.2.2)
|
||||
concurrent-ruby (< 2)
|
||||
@@ -714,7 +718,7 @@ GEM
|
||||
spreadsheet_architect (5.0.0)
|
||||
caxlsx (>= 3.3.0, < 4)
|
||||
rodf (>= 1.0.0, < 2)
|
||||
spring (4.1.3)
|
||||
spring (4.2.0)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
spring-commands-rubocop (0.4.0)
|
||||
@@ -747,14 +751,14 @@ GEM
|
||||
stimulus_reflex (>= 3.3.0)
|
||||
stringex (2.8.6)
|
||||
stringio (3.1.0)
|
||||
stripe (10.10.0)
|
||||
stripe (11.1.0)
|
||||
swd (2.0.3)
|
||||
activesupport (>= 3)
|
||||
attr_required (>= 0.0.5)
|
||||
faraday (~> 2.0)
|
||||
faraday-follow_redirects
|
||||
temple (0.8.2)
|
||||
thor (1.3.0)
|
||||
thor (1.3.1)
|
||||
thread-local (1.1.0)
|
||||
tilt (2.3.0)
|
||||
timecop (0.9.8)
|
||||
@@ -765,7 +769,7 @@ GEM
|
||||
unicode-display_width (2.5.0)
|
||||
uniform_notifier (1.16.0)
|
||||
uri (0.13.0)
|
||||
valid_email2 (5.2.1)
|
||||
valid_email2 (5.2.3)
|
||||
activemodel (>= 3.2)
|
||||
mail (~> 2.5)
|
||||
validate_url (1.0.15)
|
||||
@@ -774,7 +778,7 @@ GEM
|
||||
validates_lengths_from_database (0.8.0)
|
||||
activerecord (>= 4)
|
||||
vcr (6.2.0)
|
||||
view_component (3.11.0)
|
||||
view_component (3.12.0)
|
||||
activesupport (>= 5.2.0, < 8.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
method_source (~> 1.0)
|
||||
@@ -782,7 +786,7 @@ GEM
|
||||
rails (>= 5.2, < 8.0)
|
||||
stimulus_reflex (>= 3.5.0.pre2)
|
||||
view_component (>= 2.28.0)
|
||||
virtual_assembly-semantizer (1.0.5)
|
||||
virtual_assembly-semantizer (1.1.1)
|
||||
json-ld (~> 3.2, >= 3.2.3)
|
||||
warden (1.2.9)
|
||||
rack (>= 2.0.9)
|
||||
|
||||
@@ -48,7 +48,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
|
||||
params = {
|
||||
'q[name_cont]': $scope.q.query,
|
||||
'q[supplier_id_eq]': $scope.q.producerFilter,
|
||||
'q[primary_taxon_id_eq]': $scope.q.categoryFilter,
|
||||
'q[variants_primary_taxon_id_eq]': $scope.q.categoryFilter,
|
||||
'q[s]': $scope.sorting,
|
||||
import_date: $scope.q.importDateFilter,
|
||||
page: $scope.page,
|
||||
@@ -136,6 +136,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
|
||||
on_hand: null
|
||||
price: null
|
||||
tax_category_id: null
|
||||
category_id: null
|
||||
DisplayProperties.setShowVariants product.id, true
|
||||
|
||||
|
||||
@@ -217,7 +218,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
|
||||
filters:
|
||||
'q[name_cont]': $scope.q.query
|
||||
'q[supplier_id_eq]': $scope.q.producerFilter
|
||||
'q[primary_taxon_id_eq]': $scope.q.categoryFilter
|
||||
'q[variants_primary_taxon_id_eq]': $scope.q.categoryFilter
|
||||
'q[s]': $scope.sorting
|
||||
import_date: $scope.q.importDateFilter
|
||||
page: $scope.page
|
||||
@@ -332,9 +333,6 @@ filterSubmitProducts = (productsToFilter) ->
|
||||
if product.hasOwnProperty("on_demand") and filteredVariants.length == 0 #only update if no variants present
|
||||
filteredProduct.on_demand = product.on_demand
|
||||
hasUpdatableProperty = true
|
||||
if product.hasOwnProperty("category_id")
|
||||
filteredProduct.primary_taxon_id = product.category_id
|
||||
hasUpdatableProperty = true
|
||||
if product.hasOwnProperty("inherits_properties")
|
||||
filteredProduct.inherits_properties = product.inherits_properties
|
||||
hasUpdatableProperty = true
|
||||
@@ -375,6 +373,9 @@ filterSubmitVariant = (variant) ->
|
||||
if variant.hasOwnProperty("tax_category_id")
|
||||
filteredVariant.tax_category_id = variant.tax_category_id
|
||||
hasUpdatableProperty = true
|
||||
if variant.hasOwnProperty("category_id")
|
||||
filteredVariant.primary_taxon_id = variant.category_id
|
||||
hasUpdatableProperty = true
|
||||
if variant.hasOwnProperty("display_as")
|
||||
filteredVariant.display_as = variant.display_as
|
||||
hasUpdatableProperty = true
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# Controller for "New Products" form (spree/admin/products/new)
|
||||
angular.module("admin.products")
|
||||
.controller "unitsCtrl", ($scope, VariantUnitManager, OptionValueNamer, UnitPrices, PriceParser) ->
|
||||
$scope.product = { master: {} }
|
||||
@@ -12,13 +13,15 @@ angular.module("admin.products")
|
||||
|
||||
$scope.variant_unit_options = VariantUnitManager.variantUnitOptions()
|
||||
|
||||
# Extract variant_unit and variant_unit_scale from dropdown variant_unit_with_scale,
|
||||
# and update hidden product fields
|
||||
$scope.processVariantUnitWithScale = ->
|
||||
if $scope.product.variant_unit_with_scale
|
||||
match = $scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/)
|
||||
match = $scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/) # matches string like "weight_1000"
|
||||
if match
|
||||
$scope.product.variant_unit = match[1]
|
||||
$scope.product.variant_unit_scale = parseFloat(match[2])
|
||||
else
|
||||
else # "items"
|
||||
$scope.product.variant_unit = $scope.product.variant_unit_with_scale
|
||||
$scope.product.variant_unit_scale = null
|
||||
else if $scope.product.variant_unit
|
||||
@@ -32,6 +35,8 @@ angular.module("admin.products")
|
||||
else
|
||||
$scope.product.variant_unit = $scope.product.variant_unit_scale = null
|
||||
|
||||
# Extract unit_value and unit_description from text field unit_value_with_description,
|
||||
# and update hidden variant fields
|
||||
$scope.processUnitValueWithDescription = ->
|
||||
if $scope.product.master.hasOwnProperty("unit_value_with_description")
|
||||
match = $scope.product.master.unit_value_with_description.match(/^([\d\.,]+(?= *|$)|)( *)(.*)$/)
|
||||
@@ -45,6 +50,7 @@ angular.module("admin.products")
|
||||
value = window.bigDecimal.divide(value, $scope.product.variant_unit_scale, 2) if $scope.product.master.unit_value && $scope.product.variant_unit_scale
|
||||
$scope.product.master.unit_value_with_description = value + " " + $scope.product.master.unit_description
|
||||
|
||||
# Calculate unit price based on product price and variant_unit_scale
|
||||
$scope.processUnitPrice = ->
|
||||
price = $scope.product.price
|
||||
scale = $scope.product.variant_unit_scale
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
angular.module("admin.products").factory "OptionValueNamer", (VariantUnitManager) ->
|
||||
# Javascript clone of VariantUnits::OptionValueNamer, for bulk product editing.
|
||||
class OptionValueNamer
|
||||
constructor: (@variant) ->
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ angular.module('Darkswarm').controller "ProductsCtrl", ($scope, $sce, $filter, $
|
||||
per_page: $scope.per_page,
|
||||
'q[name_or_meta_keywords_or_variants_display_as_or_variants_display_name_or_supplier_name_cont]': $scope.query,
|
||||
'q[with_properties][]': $scope.activeProperties,
|
||||
'q[primary_taxon_id_in_any][]': $scope.activeTaxons
|
||||
'q[variants_primary_taxon_id_in_any][]': $scope.activeTaxons
|
||||
}
|
||||
|
||||
$scope.searchKeypress = (e)->
|
||||
|
||||
50
app/controllers/admin/dfc_product_imports_controller.rb
Normal file
50
app/controllers/admin/dfc_product_imports_controller.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "private_address_check"
|
||||
require "private_address_check/tcpsocket_ext"
|
||||
|
||||
module Admin
|
||||
class DfcProductImportsController < Spree::Admin::BaseController
|
||||
# Define model class for `can?` permissions:
|
||||
def model_class
|
||||
self.class
|
||||
end
|
||||
|
||||
def index
|
||||
# The plan:
|
||||
#
|
||||
# * Fetch DFC catalog as JSON from URL.
|
||||
enterprise = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.managed_product_enterprises.is_primary_producer
|
||||
.find(params.require(:enterprise_id))
|
||||
|
||||
catalog_url = params.require(:catalog_url)
|
||||
|
||||
json_catalog = DfcRequest.new(spree_current_user).get(catalog_url)
|
||||
graph = DfcIo.import(json_catalog)
|
||||
|
||||
# * First step: import all products for given enterprise.
|
||||
# * Second step: render table and let user decide which ones to import.
|
||||
imported = graph.map do |subject|
|
||||
import_product(subject, enterprise)
|
||||
end
|
||||
|
||||
@count = imported.compact.count
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Most of this code is the same as in the DfcProvider::SuppliedProductsController.
|
||||
def import_product(subject, enterprise)
|
||||
return unless subject.is_a? DataFoodConsortium::Connector::SuppliedProduct
|
||||
|
||||
variant = SuppliedProductBuilder.import_variant(subject, enterprise)
|
||||
product = variant.product
|
||||
|
||||
product.save! if product.new_record?
|
||||
variant.save! if variant.new_record?
|
||||
|
||||
variant
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -45,7 +45,8 @@ module Admin
|
||||
end
|
||||
|
||||
def create
|
||||
@order_cycle_form = OrderCycleForm.new(@order_cycle, order_cycle_params, spree_current_user)
|
||||
@order_cycle_form = OrderCycles::FormService.new(@order_cycle, order_cycle_params,
|
||||
spree_current_user)
|
||||
|
||||
if @order_cycle_form.save
|
||||
flash[:success] = t('.success')
|
||||
@@ -61,7 +62,8 @@ module Admin
|
||||
end
|
||||
|
||||
def update
|
||||
@order_cycle_form = OrderCycleForm.new(@order_cycle, order_cycle_params, spree_current_user)
|
||||
@order_cycle_form = OrderCycles::FormService.new(@order_cycle, order_cycle_params,
|
||||
spree_current_user)
|
||||
|
||||
if @order_cycle_form.save
|
||||
update_nil_subscription_line_items_price_estimate(@order_cycle)
|
||||
@@ -98,7 +100,7 @@ module Admin
|
||||
|
||||
def update_nil_subscription_line_items_price_estimate(order_cycle)
|
||||
order_cycle.schedules.each do |schedule|
|
||||
Subscription.where(schedule_id: schedule.id).each do |subscription|
|
||||
Subscription.where(schedule_id: schedule.id).find_each do |subscription|
|
||||
shop = Enterprise.managed_by(spree_current_user).find_by(id: subscription.shop_id)
|
||||
fee_calculator = OpenFoodNetwork::EnterpriseFeeCalculator.new(shop, order_cycle)
|
||||
subscription.subscription_line_items.nil_price_estimate.each do |line_item|
|
||||
|
||||
@@ -10,6 +10,8 @@ module Admin
|
||||
@product_categories = Spree::Taxon.order('name ASC').pluck(:name).uniq
|
||||
@tax_categories = Spree::TaxCategory.order('name ASC').pluck(:name)
|
||||
@shipping_categories = Spree::ShippingCategory.order('name ASC').pluck(:name)
|
||||
@producers = OpenFoodNetwork::Permissions.new(spree_current_user).
|
||||
managed_product_enterprises.is_primary_producer.by_name.to_a
|
||||
end
|
||||
|
||||
def import
|
||||
|
||||
@@ -2,6 +2,138 @@
|
||||
|
||||
module Admin
|
||||
class ProductsV3Controller < Spree::Admin::BaseController
|
||||
def index; end
|
||||
before_action :init_filters_params
|
||||
before_action :init_pagination_params
|
||||
|
||||
def index
|
||||
fetch_products
|
||||
render "index", locals: { producers:, categories:, flash: }
|
||||
end
|
||||
|
||||
def bulk_update
|
||||
product_set = product_set_from_params
|
||||
|
||||
product_set.collection.each { |p| authorize! :update, p }
|
||||
@products = product_set.collection # use instance variable mainly for testing
|
||||
|
||||
if product_set.save
|
||||
flash[:success] = I18n.t('admin.products_v3.bulk_update.success')
|
||||
redirect_to [:index,
|
||||
{ page: @page, per_page: @per_page, search_term: @search_term,
|
||||
producer_id: @producer_id, category_id: @category_id }]
|
||||
elsif product_set.errors.present?
|
||||
@error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count }
|
||||
|
||||
render "index", status: :unprocessable_entity, locals: { producers:, categories:, flash: }
|
||||
end
|
||||
end
|
||||
|
||||
def index_url(params)
|
||||
"/admin/products?#{params.to_query}" # todo: fix routing so this can be automaticly generated
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_filters_params
|
||||
# params comes from the form
|
||||
# _params comes from the url
|
||||
# priority is given to params from the form (if present) over url params
|
||||
@search_term = params[:search_term] || params[:_search_term]
|
||||
@producer_id = params[:producer_id] || params[:_producer_id]
|
||||
@category_id = params[:category_id] || params[:_category_id]
|
||||
end
|
||||
|
||||
def init_pagination_params
|
||||
# prority is given to element dataset (if present) over url params
|
||||
@page = params[:page].presence || 1
|
||||
@per_page = params[:per_page].presence || 15
|
||||
end
|
||||
|
||||
def producers
|
||||
producers = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.managed_product_enterprises.is_primary_producer.by_name
|
||||
producers.map { |p| [p.name, p.id] }
|
||||
end
|
||||
|
||||
def categories
|
||||
Spree::Taxon.order(:name).map { |c| [c.name, c.id] }
|
||||
end
|
||||
|
||||
def fetch_products
|
||||
product_query = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.editable_products.merge(product_scope).ransack(ransack_query).result
|
||||
@pagy, @products = pagy(product_query.order(:name), items: @per_page, page: @page,
|
||||
size: [1, 2, 2, 1])
|
||||
end
|
||||
|
||||
def product_scope
|
||||
user = spree_current_user
|
||||
scope = if user.has_spree_role?("admin") || user.enterprises.present?
|
||||
Spree::Product
|
||||
else
|
||||
Spree::Product.active
|
||||
end
|
||||
|
||||
scope.includes(product_query_includes).distinct
|
||||
end
|
||||
|
||||
def ransack_query
|
||||
query = {}
|
||||
query.merge!(supplier_id_in: @producer_id) if @producer_id.present?
|
||||
if @search_term.present?
|
||||
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)
|
||||
end
|
||||
query.merge!(variants_primary_taxon_id_in: @category_id) if @category_id.present?
|
||||
query
|
||||
end
|
||||
|
||||
# Optimise by pre-loading required columns
|
||||
def product_query_includes
|
||||
[
|
||||
:image,
|
||||
:supplier,
|
||||
{ variants: [
|
||||
:default_price,
|
||||
:primary_taxon,
|
||||
:product,
|
||||
:stock_items,
|
||||
:tax_category,
|
||||
] },
|
||||
]
|
||||
end
|
||||
|
||||
# Similar to spree/admin/products_controller
|
||||
def product_set_from_params
|
||||
# Form field names:
|
||||
# '[products][0][id]' (hidden field)
|
||||
# '[products][0][name]'
|
||||
# '[products][0][variants_attributes][0][id]' (hidden field)
|
||||
# '[products][0][variants_attributes][0][display_name]'
|
||||
#
|
||||
# Resulting in params:
|
||||
# "products" => {
|
||||
# "0" => {
|
||||
# "id" => "123"
|
||||
# "name" => "Pommes",
|
||||
# "variants_attributes" => {
|
||||
# "0" => {
|
||||
# "id" => "1234",
|
||||
# "display_name" => "Large box",
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
collection_hash = products_bulk_params[:products]
|
||||
.transform_values { |product|
|
||||
# Convert variants_attributes form hash to an array if present
|
||||
product[:variants_attributes] &&= product[:variants_attributes].values
|
||||
product
|
||||
}.with_indifferent_access
|
||||
Sets::ProductSet.new(collection_attributes: collection_hash)
|
||||
end
|
||||
|
||||
def products_bulk_params
|
||||
params.permit(products: ::PermittedAttributes::Product.attributes)
|
||||
.to_h.with_indifferent_access
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -229,7 +229,7 @@ module Admin
|
||||
end
|
||||
|
||||
def member_action?
|
||||
!collection_actions.include? action
|
||||
collection_actions.exclude? action
|
||||
end
|
||||
|
||||
def new_actions
|
||||
|
||||
@@ -16,14 +16,14 @@ module Admin
|
||||
authorize! :destroy, stripe_account
|
||||
|
||||
if stripe_account.deauthorize_and_destroy
|
||||
flash[:success] = "Stripe account disconnected."
|
||||
flash[:success] = I18n.t('stripe.success_code.disconnected')
|
||||
else
|
||||
flash[:error] = "Failed to disconnect Stripe."
|
||||
flash[:error] = I18n.t('stripe.error_code.disconnect_failure')
|
||||
end
|
||||
|
||||
redirect_to main_app.edit_admin_enterprise_path(stripe_account.enterprise)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash[:error] = "Failed to disconnect Stripe."
|
||||
flash[:error] = I18n.t('stripe.error_code.disconnect_failure')
|
||||
redirect_to spree.admin_dashboard_path
|
||||
end
|
||||
|
||||
|
||||
@@ -70,22 +70,7 @@ module Api
|
||||
end
|
||||
|
||||
def search_params
|
||||
permitted_search_params = params.slice :q, :page, :per_page
|
||||
|
||||
if permitted_search_params.key? :q
|
||||
permitted_search_params[:q].slice!(*permitted_ransack_params)
|
||||
end
|
||||
|
||||
permitted_search_params
|
||||
end
|
||||
|
||||
def permitted_ransack_params
|
||||
[
|
||||
"#{[:name, :meta_keywords, :variants_display_as,
|
||||
:variants_display_name, :supplier_name]
|
||||
.join('_or_')}_cont",
|
||||
:with_properties, :primary_taxon_id_in_any
|
||||
]
|
||||
params.slice :q, :page, :per_page
|
||||
end
|
||||
|
||||
def distributor
|
||||
@@ -101,7 +86,8 @@ module Api
|
||||
end
|
||||
|
||||
def distributed_products
|
||||
OrderCycleDistributedProducts.new(distributor, order_cycle, customer).products_relation
|
||||
OrderCycles::DistributedProductsService.new(distributor, order_cycle,
|
||||
customer).products_relation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ module Api
|
||||
def capture
|
||||
authorize! :admin, order
|
||||
|
||||
payment_capture = OrderCaptureService.new(order)
|
||||
payment_capture = Orders::CaptureService.new(order)
|
||||
|
||||
if payment_capture.call
|
||||
render json: order.reload, serializer: Api::Admin::OrderSerializer, status: :ok
|
||||
|
||||
@@ -21,7 +21,7 @@ module Api
|
||||
@shipment.refresh_rates
|
||||
@shipment.save!
|
||||
|
||||
OrderWorkflow.new(@order).advance_to_payment if @order.line_items.any?
|
||||
Orders::WorkflowService.new(@order).advance_to_payment if @order.line_items.any?
|
||||
|
||||
@order.recreate_all_fees!
|
||||
|
||||
@@ -85,6 +85,8 @@ module Api
|
||||
@order.contents.remove(variant, quantity, @shipment, restock_item)
|
||||
@shipment.reload if @shipment.persisted?
|
||||
|
||||
@order.recreate_all_fees!
|
||||
|
||||
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
|
||||
end
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class CheckoutController < BaseController
|
||||
def advance_order_state
|
||||
return if @order.complete?
|
||||
|
||||
OrderWorkflow.new(@order).advance_checkout(raw_params.slice(:shipping_method_id))
|
||||
Orders::WorkflowService.new(@order).advance_checkout(raw_params.slice(:shipping_method_id))
|
||||
end
|
||||
|
||||
def order_params
|
||||
|
||||
@@ -65,7 +65,7 @@ module CheckoutCallbacks
|
||||
|
||||
def valid_order_line_items?
|
||||
@order.insufficient_stock_lines.empty? &&
|
||||
OrderCycleDistributedVariants.new(@order.order_cycle, @order.distributor).
|
||||
OrderCycles::DistributedVariantsService.new(@order.order_cycle, @order.distributor).
|
||||
distributes_order_variants?(@order)
|
||||
end
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ module OrderCompletion
|
||||
return redirect_to order_failed_route(step: 'payment')
|
||||
end
|
||||
|
||||
if OrderWorkflow.new(@order).next && @order.complete?
|
||||
if Orders::WorkflowService.new(@order).next && @order.complete?
|
||||
processing_succeeded
|
||||
redirect_to order_completion_route
|
||||
else
|
||||
|
||||
@@ -6,7 +6,7 @@ module OrderStockCheck
|
||||
|
||||
def valid_order_line_items?
|
||||
@order.insufficient_stock_lines.empty? &&
|
||||
OrderCycleDistributedVariants.new(@order.order_cycle, @order.distributor).
|
||||
OrderCycles::DistributedVariantsService.new(@order.order_cycle, @order.distributor).
|
||||
distributes_order_variants?(@order)
|
||||
end
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class EnterprisesController < BaseController
|
||||
order = current_order(true)
|
||||
|
||||
# reset_distributor must be called before any call to current_customer or current_distributor
|
||||
order_cart_reset = OrderCartReset.new(order, params[:id])
|
||||
order_cart_reset = Orders::CartResetService.new(order, params[:id])
|
||||
order_cart_reset.reset_distributor
|
||||
order_cart_reset.reset_other!(spree_current_user, current_customer)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
||||
@@ -79,7 +79,7 @@ module PaymentGateways
|
||||
end
|
||||
|
||||
def last_payment
|
||||
@last_payment ||= OrderPaymentFinder.new(@order).last_payment
|
||||
@last_payment ||= Orders::FindPaymentService.new(@order).last_payment
|
||||
end
|
||||
|
||||
def cancel_incomplete_payments
|
||||
|
||||
@@ -26,7 +26,7 @@ module Spree
|
||||
def warn_invalid_order_cycles
|
||||
return if flash[:notice].present?
|
||||
|
||||
warning = OrderCycleWarning.new(spree_current_user).call
|
||||
warning = OrderCycles::WarningService.new(spree_current_user).call
|
||||
flash[:notice] = warning if warning.present?
|
||||
end
|
||||
|
||||
|
||||
@@ -19,8 +19,13 @@ module Spree
|
||||
|
||||
def generate
|
||||
@order = Order.find_by(number: params[:order_id])
|
||||
authorize! :invoice, @order
|
||||
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice
|
||||
if @order.distributor.can_invoice?
|
||||
authorize! :invoice, @order
|
||||
::Orders::GenerateInvoiceService.new(@order).generate_or_update_latest_invoice
|
||||
else
|
||||
flash[:error] = t(:must_have_valid_business_number,
|
||||
enterprise_name: @order.distributor.name)
|
||||
end
|
||||
redirect_back(fallback_location: spree.admin_dashboard_path)
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ module Spree
|
||||
end
|
||||
|
||||
refresh_shipment_rates
|
||||
OrderWorkflow.new(@order).advance_to_payment
|
||||
::Orders::WorkflowService.new(@order).advance_to_payment
|
||||
|
||||
flash[:success] = Spree.t('customer_details_updated')
|
||||
redirect_to spree.admin_order_customer_path(@order)
|
||||
|
||||
@@ -50,7 +50,7 @@ module Spree
|
||||
return redirect_to spree.edit_admin_order_path(@order)
|
||||
end
|
||||
|
||||
OrderWorkflow.new(@order).advance_to_payment
|
||||
::Orders::WorkflowService.new(@order).advance_to_payment
|
||||
|
||||
if @order.complete?
|
||||
redirect_to spree.edit_admin_order_path(@order)
|
||||
@@ -104,7 +104,7 @@ module Spree
|
||||
@order = if params[:invoice_id].present?
|
||||
@order.invoices.find(params[:invoice_id]).presenter
|
||||
else
|
||||
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice
|
||||
::Orders::GenerateInvoiceService.new(@order).generate_or_update_latest_invoice
|
||||
@order.invoices.first.presenter
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ module Spree
|
||||
return
|
||||
end
|
||||
|
||||
OrderWorkflow.new(@order).complete! unless @order.completed?
|
||||
::Orders::WorkflowService.new(@order).complete! unless @order.completed?
|
||||
|
||||
authorize_stripe_sca_payment
|
||||
@payment.process_offline!
|
||||
|
||||
@@ -175,7 +175,7 @@ module Spree
|
||||
Spree::Variant.
|
||||
select('DISTINCT spree_variants.import_date').
|
||||
joins(:product).
|
||||
where('spree_products.supplier_id IN (?)', editable_enterprises.collect(&:id)).
|
||||
where(spree_products: { supplier_id: editable_enterprises.collect(&:id) }).
|
||||
where.not(spree_variants: { import_date: nil }).
|
||||
where(spree_variants: { deleted_at: nil }).
|
||||
order('spree_variants.import_date DESC')
|
||||
|
||||
@@ -42,7 +42,7 @@ module Spree
|
||||
# Patching to redirect to shop if order is empty
|
||||
def edit
|
||||
@insufficient_stock_lines = @order.insufficient_stock_lines
|
||||
@unavailable_order_variants = OrderCycleDistributedVariants.
|
||||
@unavailable_order_variants = OrderCycles::DistributedVariantsService.
|
||||
new(current_order_cycle, current_distributor).unavailable_order_variants(@order)
|
||||
|
||||
if @order.line_items.empty?
|
||||
@@ -60,7 +60,7 @@ module Spree
|
||||
@insufficient_stock_lines = []
|
||||
@order = order_to_update
|
||||
unless @order
|
||||
flash[:error] = t(:order_not_found)
|
||||
flash[:error] = t(:order_not_updated)
|
||||
redirect_to(main_app.root_path) && return
|
||||
end
|
||||
|
||||
@@ -82,7 +82,7 @@ module Spree
|
||||
format.html do
|
||||
if params.key?(:checkout)
|
||||
@order.next_transition.run_callbacks if @order.cart?
|
||||
redirect_to main_app.checkout_step_path(@order.checkout_steps.first)
|
||||
redirect_to main_app.checkout_step_path("address")
|
||||
elsif @order.complete?
|
||||
redirect_to main_app.order_path(@order)
|
||||
else
|
||||
@@ -102,7 +102,7 @@ module Spree
|
||||
@order = Spree::Order.find_by!(number: params[:id])
|
||||
authorize! :cancel, @order
|
||||
|
||||
if CustomerOrderCancellation.new(@order).call
|
||||
if Orders::CustomerCancellationService.new(@order).call
|
||||
flash[:success] = I18n.t(:orders_your_order_has_been_cancelled)
|
||||
else
|
||||
flash[:error] = I18n.t(:orders_could_not_cancel)
|
||||
|
||||
@@ -162,7 +162,7 @@ module Admin
|
||||
def admin_inject_available_units
|
||||
admin_inject_json "admin.products",
|
||||
"availableUnits",
|
||||
Spree::Config.available_units
|
||||
CurrentConfig.get(:available_units)
|
||||
end
|
||||
|
||||
def admin_inject_json(ng_module, name, data)
|
||||
|
||||
@@ -59,7 +59,7 @@ module CheckoutHelper
|
||||
end
|
||||
|
||||
def display_checkout_taxes_hash(order)
|
||||
totals = OrderTaxAdjustmentsFetcher.new(order).totals
|
||||
totals = Orders::FetchTaxAdjustmentsService.new(order).totals
|
||||
|
||||
totals.map do |tax_rate, tax_amount|
|
||||
{
|
||||
|
||||
@@ -12,11 +12,11 @@ module EnterprisesHelper
|
||||
end
|
||||
|
||||
def available_shipping_methods
|
||||
OrderAvailableShippingMethods.new(current_order, current_customer).to_a
|
||||
Orders::AvailableShippingMethodsService.new(current_order, current_customer).to_a
|
||||
end
|
||||
|
||||
def available_payment_methods
|
||||
OrderAvailablePaymentMethods.new(current_order, current_customer).to_a
|
||||
Orders::AvailablePaymentMethodsService.new(current_order, current_customer).to_a
|
||||
end
|
||||
|
||||
def managed_enterprises
|
||||
|
||||
@@ -154,7 +154,6 @@ module InjectionHelper
|
||||
end
|
||||
|
||||
def enterprise_injection_data
|
||||
@enterprise_injection_data ||= OpenFoodNetwork::EnterpriseInjectionData.new
|
||||
{ data: @enterprise_injection_data }
|
||||
@enterprise_injection_data ||= { data: OpenFoodNetwork::EnterpriseInjectionData.new }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module OrderHelper
|
||||
def last_payment_method(order)
|
||||
OrderPaymentFinder.new(order).last_payment&.payment_method
|
||||
Orders::FindPaymentService.new(order).last_payment&.payment_method
|
||||
end
|
||||
|
||||
def outstanding_balance_label(order)
|
||||
@@ -16,6 +16,6 @@ module OrderHelper
|
||||
end
|
||||
|
||||
def order_comparator(order)
|
||||
OrderInvoiceComparator.new(order)
|
||||
Orders::CompareInvoiceService.new(order)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SharedHelper
|
||||
def distributor_link_class(distributor)
|
||||
cart = current_order(true)
|
||||
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
|
||||
|
||||
klass = "shop-distributor"
|
||||
klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor
|
||||
klass += @active_distributors.include?(distributor) ? ' active' : ' inactive'
|
||||
klass
|
||||
end
|
||||
|
||||
def enterprise_user?
|
||||
spree_current_user&.enterprises&.count.to_i > 0
|
||||
end
|
||||
|
||||
@@ -33,8 +33,6 @@ module Spree
|
||||
when :boolean
|
||||
hidden_field_tag(name, 0) +
|
||||
check_box_tag(name, 1, value, preference_field_options(options))
|
||||
when :string
|
||||
text_field_tag(name, value, preference_field_options(options))
|
||||
when :password
|
||||
password_field_tag(name, value, preference_field_options(options))
|
||||
when :text
|
||||
@@ -88,8 +86,6 @@ module Spree
|
||||
{ size: 10, class: 'input_integer', step: :any }
|
||||
when :boolean
|
||||
{}
|
||||
when :string
|
||||
{ size: 10, class: 'input_string fullwidth' }
|
||||
when :password
|
||||
{ size: 10, class: 'password_string fullwidth' }
|
||||
when :text
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
module Spree
|
||||
module Admin
|
||||
module OrdersHelper
|
||||
def event_links
|
||||
def event_links(order)
|
||||
links = []
|
||||
links << cancel_event_link if @order.can_cancel?
|
||||
links << resume_event_link if @order.can_resume?
|
||||
links << cancel_event_link(order) if order.can_cancel?
|
||||
links << resume_event_link(order) if order.can_resume?
|
||||
links.join(' ').html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def generate_invoice_button(order)
|
||||
if order.distributor.can_invoice?
|
||||
button_link_to t(:create_or_update_invoice), generate_admin_order_invoices_path(@order),
|
||||
button_link_to t(:create_or_update_invoice), generate_admin_order_invoices_path(order),
|
||||
data: { method: 'post' }, icon: 'icon-plus'
|
||||
else
|
||||
button_link_to t(:create_or_update_invoice), "#", data: {
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name)
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name)
|
||||
}, icon: 'icon-plus'
|
||||
end
|
||||
end
|
||||
@@ -26,82 +26,81 @@ module Spree
|
||||
end
|
||||
|
||||
def order_links(order)
|
||||
@order ||= order
|
||||
links = []
|
||||
links << edit_order_link unless action_name == "edit"
|
||||
links.concat(complete_order_links) if @order.complete? || @order.resumed?
|
||||
links << ship_order_link if @order.ready_to_ship?
|
||||
links << cancel_order_link if @order.can_cancel?
|
||||
links << edit_order_link(order) unless action_name == "edit"
|
||||
links.concat(complete_order_links(order)) if order.complete? || order.resumed?
|
||||
links << ship_order_link if order.ready_to_ship?
|
||||
links << cancel_order_link(order) if order.can_cancel?
|
||||
links
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def complete_order_links
|
||||
[resend_confirmation_link] + invoice_links
|
||||
def complete_order_links(order)
|
||||
[resend_confirmation_link(order)] + invoice_links(order)
|
||||
end
|
||||
|
||||
def invoice_links
|
||||
def invoice_links(order)
|
||||
return [] unless Spree::Config[:enable_invoices?]
|
||||
|
||||
[send_invoice_link, print_invoice_link]
|
||||
[send_invoice_link(order), print_invoice_link(order)]
|
||||
end
|
||||
|
||||
def send_invoice_link
|
||||
if @order.distributor.can_invoice?
|
||||
send_invoice_link_with_url
|
||||
def send_invoice_link(order)
|
||||
if order.distributor.can_invoice?
|
||||
send_invoice_link_with_url(order)
|
||||
else
|
||||
send_invoice_link_without_url
|
||||
send_invoice_link_without_url(order)
|
||||
end
|
||||
end
|
||||
|
||||
def print_invoice_link
|
||||
if @order.distributor.can_invoice?
|
||||
print_invoice_link_with_url
|
||||
def print_invoice_link(order)
|
||||
if order.distributor.can_invoice?
|
||||
print_invoice_link_with_url(order)
|
||||
else
|
||||
notify_about_required_enterprise_number
|
||||
notify_about_required_enterprise_number(order)
|
||||
end
|
||||
end
|
||||
|
||||
def edit_order_link
|
||||
def edit_order_link(order)
|
||||
{ name: t(:edit_order),
|
||||
url: spree.edit_admin_order_path(@order),
|
||||
url: spree.edit_admin_order_path(order),
|
||||
icon: 'icon-edit' }
|
||||
end
|
||||
|
||||
def resend_confirmation_link
|
||||
def resend_confirmation_link(order)
|
||||
{ name: t(:resend_confirmation),
|
||||
url: spree.resend_admin_order_path(@order),
|
||||
url: spree.resend_admin_order_path(order),
|
||||
icon: 'icon-email',
|
||||
confirm: t(:confirm_resend_order_confirmation) }
|
||||
end
|
||||
|
||||
def send_invoice_link_with_url
|
||||
def send_invoice_link_with_url(order)
|
||||
{ name: t(:send_invoice),
|
||||
url: invoice_admin_order_path(@order),
|
||||
url: invoice_admin_order_path(order),
|
||||
icon: 'icon-email',
|
||||
confirm: t(:confirm_send_invoice) }
|
||||
end
|
||||
|
||||
def send_invoice_link_without_url
|
||||
def send_invoice_link_without_url(order)
|
||||
{ name: t(:send_invoice),
|
||||
url: "#",
|
||||
icon: 'icon-email',
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name) }
|
||||
end
|
||||
|
||||
def print_invoice_link_with_url
|
||||
def print_invoice_link_with_url(order)
|
||||
{ name: t(:print_invoice),
|
||||
url: spree.print_admin_order_path(@order),
|
||||
url: spree.print_admin_order_path(order),
|
||||
icon: 'icon-print',
|
||||
target: "_blank" }
|
||||
end
|
||||
|
||||
def notify_about_required_enterprise_number
|
||||
def notify_about_required_enterprise_number(order)
|
||||
{ name: t(:print_invoice),
|
||||
url: "#",
|
||||
icon: 'icon-print',
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name) }
|
||||
end
|
||||
|
||||
def ship_order_link
|
||||
@@ -110,24 +109,24 @@ module Spree
|
||||
icon: 'icon-truck' }
|
||||
end
|
||||
|
||||
def cancel_order_link
|
||||
def cancel_order_link(order)
|
||||
{ name: t(:cancel_order),
|
||||
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
|
||||
url: spree.fire_admin_order_path(order.number, e: 'cancel'),
|
||||
icon: 'icon-trash' }
|
||||
end
|
||||
|
||||
def cancel_event_link
|
||||
def cancel_event_link(order)
|
||||
event_label = I18n.t("cancel", scope: "actions")
|
||||
button_link_to(event_label,
|
||||
fire_admin_order_url(@order, e: "cancel"),
|
||||
fire_admin_order_url(order, e: "cancel"),
|
||||
method: :put, icon: "icon-cancel", form_id: "cancel_order_form")
|
||||
end
|
||||
|
||||
def resume_event_link
|
||||
def resume_event_link(order)
|
||||
event_label = I18n.t("resume", scope: "actions")
|
||||
confirm_message = I18n.t("admin.orders.edit.order_sure_want_to", event: event_label)
|
||||
button_link_to(event_label,
|
||||
fire_admin_order_url(@order, e: "resume"),
|
||||
fire_admin_order_url(order, e: "resume"),
|
||||
method: :put, icon: "icon-resume",
|
||||
data: { confirm: confirm_message })
|
||||
end
|
||||
|
||||
@@ -17,17 +17,18 @@ module Spree
|
||||
|
||||
def changeable_orders
|
||||
# Only returns open order for the current user + shop + oc combo
|
||||
return @changeable_orders unless @changeable_orders.nil?
|
||||
return @changeable_orders = [] unless spree_current_user &&
|
||||
current_distributor && current_order_cycle
|
||||
return @changeable_orders = [] unless current_distributor.allow_order_changes?
|
||||
@changeable_orders ||= if spree_current_user &&
|
||||
current_order_cycle && current_distributor&.allow_order_changes?
|
||||
|
||||
@changeable_orders = Spree::Order.complete.where(
|
||||
state: 'complete',
|
||||
user_id: spree_current_user.id,
|
||||
distributor_id: current_distributor.id,
|
||||
order_cycle_id: current_order_cycle.id
|
||||
)
|
||||
Spree::Order.complete.where(
|
||||
state: 'complete',
|
||||
user_id: spree_current_user.id,
|
||||
distributor_id: current_distributor.id,
|
||||
order_cycle_id: current_order_cycle.id
|
||||
)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def changeable_orders_link_path
|
||||
|
||||
@@ -7,9 +7,10 @@ class BulkInvoiceJob < ApplicationJob
|
||||
|
||||
def perform(order_ids, filepath, options = {})
|
||||
@options = options
|
||||
orders = sorted_orders(order_ids)
|
||||
orders.filter!(&:invoiceable?) if OpenFoodNetwork::FeatureToggle.enabled?(:invoices,
|
||||
current_user)
|
||||
|
||||
# The `find` method returns records in the same order as the given ids.
|
||||
orders = Spree::Order.find(order_ids)
|
||||
|
||||
orders.each(&method(:generate_invoice))
|
||||
|
||||
ensure_directory_exists filepath
|
||||
@@ -21,19 +22,13 @@ class BulkInvoiceJob < ApplicationJob
|
||||
|
||||
private
|
||||
|
||||
# Ensures the records are returned in the same order the ids were originally given in
|
||||
def sorted_orders(order_ids)
|
||||
orders_by_id = Spree::Order.where(id: order_ids).to_a.index_by(&:id)
|
||||
order_ids.map { |id| orders_by_id[id.to_i] }
|
||||
end
|
||||
|
||||
def renderer
|
||||
@renderer ||= InvoiceRenderer.new
|
||||
end
|
||||
|
||||
def generate_invoice(order)
|
||||
renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices, current_user)
|
||||
OrderInvoiceGenerator.new(order).generate_or_update_latest_invoice
|
||||
Orders::GenerateInvoiceService.new(order).generate_or_update_latest_invoice
|
||||
order.invoices.first.presenter
|
||||
else
|
||||
order
|
||||
|
||||
@@ -4,7 +4,7 @@ class ConnectAppJob < ApplicationJob
|
||||
include CableReady::Broadcaster
|
||||
|
||||
def perform(app, token, channel: nil)
|
||||
url = "https://n8n.openfoodnetwork.org.uk/webhook/regen/connect-enterprise"
|
||||
url = I18n.t("connect_app.url")
|
||||
event = "connect-app"
|
||||
enterprise = app.enterprise
|
||||
payload = {
|
||||
|
||||
@@ -5,7 +5,7 @@ class OrderCycleOpenedJob < ApplicationJob
|
||||
def perform
|
||||
ActiveRecord::Base.transaction do
|
||||
recently_opened_order_cycles.find_each do |order_cycle|
|
||||
OrderCycleWebhookService.create_webhook_job(order_cycle, 'order_cycle.opened')
|
||||
OrderCycles::WebhookService.create_webhook_job(order_cycle, 'order_cycle.opened')
|
||||
end
|
||||
mark_as_opened(recently_opened_order_cycles)
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class SubscriptionConfirmJob < ApplicationJob
|
||||
unconfirmed_proxy_orders.update_all(confirmed_at: Time.zone.now)
|
||||
|
||||
# Confirm these proxy orders
|
||||
ProxyOrder.where(id: unconfirmed_proxy_orders_ids).each do |proxy_order|
|
||||
ProxyOrder.where(id: unconfirmed_proxy_orders_ids).find_each do |proxy_order|
|
||||
JobLogger.logger.info "Confirming Order for Proxy Order #{proxy_order.id}"
|
||||
confirm_order!(proxy_order.order)
|
||||
end
|
||||
|
||||
@@ -52,7 +52,7 @@ class ProducerMailer < ApplicationMailer
|
||||
def distributors_pickup_times_for(line_items)
|
||||
@order_cycle.distributors.
|
||||
joins(:distributed_orders).
|
||||
where("spree_orders.id IN (?)", line_items.map(&:order_id).uniq).
|
||||
where(spree_orders: { id: line_items.map(&:order_id).uniq }).
|
||||
map do |distributor|
|
||||
[distributor.name, @order_cycle.pickup_time_for(distributor)]
|
||||
end
|
||||
|
||||
@@ -52,7 +52,8 @@ module Spree
|
||||
find_user(options[:current_user_id])
|
||||
end
|
||||
renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices, current_user)
|
||||
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice
|
||||
::Orders::GenerateInvoiceService
|
||||
.new(@order).generate_or_update_latest_invoice
|
||||
@order.invoices.first.presenter
|
||||
else
|
||||
@order
|
||||
|
||||
@@ -10,7 +10,7 @@ module Calculator
|
||||
end
|
||||
|
||||
def set_preference(name, value)
|
||||
if name == :unit_from_list && !["kg", "lb"].include?(value)
|
||||
if name == :unit_from_list && ["kg", "lb"].exclude?(value)
|
||||
calculable.errors.add(:preferred_unit_from_list, I18n.t(:calculator_preferred_unit_error))
|
||||
else
|
||||
__send__ self.class.preference_setter_method(name), value
|
||||
|
||||
@@ -15,7 +15,7 @@ module OrderValidations
|
||||
|
||||
# Check that line_items in the current order are available from a newly selected distribution
|
||||
def products_available_from_new_distribution
|
||||
return if OrderCycleDistributedVariants.new(order_cycle, distributor)
|
||||
return if OrderCycles::DistributedVariantsService.new(order_cycle, distributor)
|
||||
.distributes_order_variants?(self)
|
||||
|
||||
errors.add(:base, I18n.t(:spree_order_availability_error))
|
||||
|
||||
19
app/models/current_config.rb
Normal file
19
app/models/current_config.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Wraps repeatedly-called configs in a CurrentAttributes object so they only get fetched once
|
||||
# per request at most, eg: CurrentConfig.get(:available_units) for Spree::Config[:available_units]
|
||||
|
||||
class CurrentConfig < ActiveSupport::CurrentAttributes
|
||||
attribute :display_currency, :hide_cents, :currency_decimal_mark,
|
||||
:currency_thousands_separator, :currency_symbol_position, :available_units
|
||||
|
||||
def get(config_key)
|
||||
return public_send(config_key) unless public_send(config_key).nil?
|
||||
|
||||
public_send("#{config_key}=", Spree::Config.public_send(config_key))
|
||||
end
|
||||
|
||||
def currency
|
||||
ENV.fetch("CURRENCY")
|
||||
end
|
||||
end
|
||||
@@ -43,25 +43,31 @@ class Enterprise < ApplicationRecord
|
||||
foreign_key: 'supplier_id',
|
||||
dependent: :destroy
|
||||
has_many :supplied_variants, through: :supplied_products, source: :variants
|
||||
has_many :distributed_orders, class_name: 'Spree::Order', foreign_key: 'distributor_id'
|
||||
has_many :distributed_orders, class_name: 'Spree::Order',
|
||||
foreign_key: 'distributor_id',
|
||||
dependent: :restrict_with_exception
|
||||
belongs_to :address, class_name: 'Spree::Address'
|
||||
belongs_to :business_address, optional: true, class_name: 'Spree::Address', dependent: :destroy
|
||||
has_many :enterprise_fees
|
||||
has_many :enterprise_fees, dependent: :restrict_with_exception
|
||||
has_many :enterprise_roles, dependent: :destroy
|
||||
has_many :users, through: :enterprise_roles
|
||||
belongs_to :owner, class_name: 'Spree::User',
|
||||
inverse_of: :owned_enterprises
|
||||
has_many :distributor_payment_methods,
|
||||
inverse_of: :distributor, foreign_key: :distributor_id
|
||||
inverse_of: :distributor,
|
||||
foreign_key: :distributor_id,
|
||||
dependent: :restrict_with_exception
|
||||
has_many :distributor_shipping_methods,
|
||||
inverse_of: :distributor, foreign_key: :distributor_id
|
||||
inverse_of: :distributor,
|
||||
foreign_key: :distributor_id,
|
||||
dependent: :restrict_with_exception
|
||||
has_many :payment_methods, through: :distributor_payment_methods
|
||||
has_many :shipping_methods, through: :distributor_shipping_methods
|
||||
has_many :customers, dependent: :destroy
|
||||
has_many :inventory_items, dependent: :destroy
|
||||
has_many :tag_rules, dependent: :destroy
|
||||
has_one :stripe_account, dependent: :destroy
|
||||
has_many :vouchers
|
||||
has_many :vouchers, dependent: :restrict_with_exception
|
||||
has_many :connected_apps, dependent: :destroy
|
||||
has_one :custom_tab, dependent: :destroy
|
||||
|
||||
@@ -128,6 +134,7 @@ class Enterprise < ApplicationRecord
|
||||
|
||||
after_create :set_default_contact
|
||||
after_create :relate_to_owners_enterprises
|
||||
|
||||
after_rollback :restore_permalink
|
||||
after_touch :touch_distributors
|
||||
after_create_commit :send_welcome_email
|
||||
@@ -161,7 +168,7 @@ class Enterprise < ApplicationRecord
|
||||
scope :is_hub, -> { where(sells: 'any') }
|
||||
scope :supplying_variant_in, lambda { |variants|
|
||||
joins(supplied_products: :variants).
|
||||
where('spree_variants.id IN (?)', variants).
|
||||
where(spree_variants: { id: variants }).
|
||||
select('DISTINCT enterprises.*')
|
||||
}
|
||||
|
||||
@@ -205,7 +212,7 @@ class Enterprise < ApplicationRecord
|
||||
").
|
||||
joins('INNER JOIN exchange_variants ON (exchange_variants.exchange_id = exchanges.id)').
|
||||
joins('INNER JOIN spree_variants ON (spree_variants.id = exchange_variants.variant_id)').
|
||||
where('spree_variants.product_id IN (?)', product_ids).select('DISTINCT enterprises.id')
|
||||
where(spree_variants: { product_id: product_ids }).select('DISTINCT enterprises.id')
|
||||
|
||||
where(id: exchanges)
|
||||
}
|
||||
@@ -214,7 +221,7 @@ class Enterprise < ApplicationRecord
|
||||
if user.has_spree_role?('admin')
|
||||
where(nil)
|
||||
else
|
||||
joins(:enterprise_roles).where('enterprise_roles.user_id = ?', user.id)
|
||||
joins(:enterprise_roles).where(enterprise_roles: { user_id: user.id })
|
||||
end
|
||||
}
|
||||
|
||||
@@ -369,10 +376,10 @@ class Enterprise < ApplicationRecord
|
||||
:producer_shop # Producer with shopfront and supplies other hubs.
|
||||
when "producer_sells_none"
|
||||
:producer # Producer only supplies through others.
|
||||
when "non_producer_sells_any"
|
||||
:hub # Hub selling others products in order cycles.
|
||||
when "non_producer_sells_own"
|
||||
:hub # Wholesaler selling through own shopfront? Does this need a separate name or even exist?
|
||||
when "non_producer_sells_any", "non_producer_sells_own"
|
||||
# Hub selling others products in order cycles
|
||||
# Or Wholesaler selling through own shopfront? Does this need a separate name or even exist?
|
||||
:hub
|
||||
when "non_producer_sells_none"
|
||||
:hub_profile # Hub selling outside the system.
|
||||
end
|
||||
@@ -382,7 +389,7 @@ class Enterprise < ApplicationRecord
|
||||
def distributed_taxons
|
||||
Spree::Taxon.
|
||||
joins(:products).
|
||||
where('spree_products.id IN (?)', Spree::Product.in_distributor(self).select(&:id)).
|
||||
where(spree_products: { id: Spree::Product.in_distributor(self).select(&:id) }).
|
||||
select('DISTINCT spree_taxons.*')
|
||||
end
|
||||
|
||||
@@ -398,7 +405,7 @@ class Enterprise < ApplicationRecord
|
||||
def supplied_taxons
|
||||
Spree::Taxon.
|
||||
joins(:products).
|
||||
where('spree_products.id IN (?)', Spree::Product.in_supplier(self).select(&:id)).
|
||||
where(spree_products: { id: Spree::Product.in_supplier(self).select(&:id) }).
|
||||
select('DISTINCT spree_taxons.*')
|
||||
end
|
||||
|
||||
@@ -472,7 +479,7 @@ class Enterprise < ApplicationRecord
|
||||
ExchangeVariant.joins(exchange: :order_cycle)
|
||||
.merge(Exchange.outgoing)
|
||||
.select("DISTINCT exchange_variants.variant_id, exchanges.receiver_id AS enterprise_id")
|
||||
.where("exchanges.receiver_id = ?", id)
|
||||
.where(exchanges: { receiver_id: id })
|
||||
.merge(OrderCycle.active.with_distributor(id))
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ class EnterpriseFee < ApplicationRecord
|
||||
|
||||
validates :fee_type, inclusion: { in: FEE_TYPES }
|
||||
validates :name, presence: true
|
||||
validates :enterprise_id, presence: true
|
||||
|
||||
before_save :ensure_valid_tax_category_settings
|
||||
|
||||
@@ -32,7 +31,7 @@ class EnterpriseFee < ApplicationRecord
|
||||
if user.has_spree_role?('admin')
|
||||
where(nil)
|
||||
else
|
||||
where('enterprise_id IN (?)', user.enterprises.select(&:id))
|
||||
where(enterprise_id: user.enterprises.select(&:id))
|
||||
end
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ class EnterpriseFee < ApplicationRecord
|
||||
joins(:calculator).where.not(spree_calculators: { type: PER_ORDER_CALCULATORS })
|
||||
}
|
||||
scope :per_order, lambda {
|
||||
joins(:calculator).where('spree_calculators.type IN (?)', PER_ORDER_CALCULATORS)
|
||||
joins(:calculator).where(spree_calculators: { type: PER_ORDER_CALCULATORS })
|
||||
}
|
||||
|
||||
def self.clear_all_adjustments(order)
|
||||
|
||||
@@ -41,7 +41,7 @@ class EnterpriseGroup < ApplicationRecord
|
||||
if user.has_spree_role?('admin')
|
||||
where(nil)
|
||||
else
|
||||
where('owner_id = ?', user.id)
|
||||
where(owner_id: user.id)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ class EnterpriseRelationship < ApplicationRecord
|
||||
where('parent_id IN (?) OR child_id IN (?)', enterprises.select(&:id), enterprises.select(&:id))
|
||||
}
|
||||
|
||||
scope :permitting, ->(enterprise_ids) { where('child_id IN (?)', enterprise_ids) }
|
||||
scope :permitted_by, ->(enterprise_ids) { where('parent_id IN (?)', enterprise_ids) }
|
||||
scope :permitting, ->(enterprise_ids) { where(child_id: enterprise_ids) }
|
||||
scope :permitted_by, ->(enterprise_ids) { where(parent_id: enterprise_ids) }
|
||||
|
||||
scope :with_permission, ->(permission) {
|
||||
joins(:permissions).
|
||||
where('enterprise_relationship_permissions.name = ?', permission)
|
||||
where(enterprise_relationship_permissions: { name: permission })
|
||||
}
|
||||
|
||||
scope :by_name, -> { with_enterprises.order('child_enterprises.name, parent_enterprises.name') }
|
||||
@@ -108,6 +108,6 @@ class EnterpriseRelationship < ApplicationRecord
|
||||
|
||||
def child_variant_overrides
|
||||
VariantOverride.unscoped.for_hubs(child)
|
||||
.joins(variant: :product).where("spree_products.supplier_id IN (?)", parent)
|
||||
.joins(variant: :product).where(spree_products: { supplier_id: parent })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
# shopfront (outgoing products). But the set of shown products can be smaller
|
||||
# than all incoming products.
|
||||
class Exchange < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
acts_as_taggable
|
||||
|
||||
belongs_to :order_cycle
|
||||
@@ -24,7 +22,6 @@ class Exchange < ApplicationRecord
|
||||
has_many :exchange_fees, dependent: :destroy
|
||||
has_many :enterprise_fees, through: :exchange_fees
|
||||
|
||||
validates :order_cycle, :sender, :receiver, presence: true
|
||||
validates :sender_id, uniqueness: { scope: [:order_cycle_id, :receiver_id, :incoming] }
|
||||
|
||||
before_destroy :delete_related_exchange_variants, prepend: true
|
||||
@@ -38,8 +35,8 @@ class Exchange < ApplicationRecord
|
||||
scope :outgoing, -> { where(incoming: false) }
|
||||
scope :from_enterprise, lambda { |enterprise| where(sender_id: enterprise) }
|
||||
scope :to_enterprise, lambda { |enterprise| where(receiver_id: enterprise) }
|
||||
scope :from_enterprises, lambda { |enterprises| where('exchanges.sender_id IN (?)', enterprises) }
|
||||
scope :to_enterprises, lambda { |enterprises| where('exchanges.receiver_id IN (?)', enterprises) }
|
||||
scope :from_enterprises, lambda { |enterprises| where(exchanges: { sender_id: enterprises }) }
|
||||
scope :to_enterprises, lambda { |enterprises| where(exchanges: { receiver_id: enterprises }) }
|
||||
scope :involving, lambda { |enterprises|
|
||||
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises).
|
||||
select('DISTINCT exchanges.*')
|
||||
@@ -48,7 +45,7 @@ class Exchange < ApplicationRecord
|
||||
where('exchanges.incoming OR exchanges.receiver_id = ?', distributor)
|
||||
}
|
||||
scope :with_variant, lambda { |variant|
|
||||
joins(:exchange_variants).where('exchange_variants.variant_id = ?', variant)
|
||||
joins(:exchange_variants).where(exchange_variants: { variant_id: variant })
|
||||
}
|
||||
scope :with_any_variant, lambda { |variant_ids|
|
||||
joins(:exchange_variants).
|
||||
@@ -57,7 +54,7 @@ class Exchange < ApplicationRecord
|
||||
}
|
||||
scope :with_product, lambda { |product|
|
||||
joins(:exchange_variants).
|
||||
where('exchange_variants.variant_id IN (?)', product.variants.select(&:id))
|
||||
where(exchange_variants: { variant_id: product.variants.select(&:id) })
|
||||
}
|
||||
scope :by_enterprise_name, -> {
|
||||
joins('INNER JOIN enterprises AS sender ON (sender.id = exchanges.sender_id)').
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InventoryItem < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
belongs_to :enterprise
|
||||
belongs_to :variant, class_name: "Spree::Variant"
|
||||
|
||||
validates :variant_id, uniqueness: { scope: :enterprise_id }
|
||||
validates :enterprise, presence: true
|
||||
validates :variant, presence: true
|
||||
validates :visible,
|
||||
inclusion: { in: [true, false], message: I18n.t(:inventory_item_visibility_error) }
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
require 'open_food_network/scope_variant_to_hub'
|
||||
|
||||
class OrderCycle < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
searchable_attributes :orders_open_at, :orders_close_at, :coordinator_id
|
||||
searchable_scopes :active, :inactive, :active_or_complete, :upcoming, :closed, :not_closed,
|
||||
:dated, :undated, :soonest_opening, :soonest_closing, :most_recently_closed
|
||||
@@ -44,7 +42,7 @@ class OrderCycle < ApplicationRecord
|
||||
before_update :reset_processed_at, if: :will_save_change_to_orders_close_at?
|
||||
after_save :sync_subscriptions, if: :opening?
|
||||
|
||||
validates :name, :coordinator_id, presence: true
|
||||
validates :name, presence: true
|
||||
validate :orders_close_at_after_orders_open_at?
|
||||
|
||||
preference :product_selection_from_coordinator_inventory_only, :boolean, default: false
|
||||
@@ -165,17 +163,17 @@ class OrderCycle < ApplicationRecord
|
||||
def attachable_distributor_payment_methods
|
||||
DistributorPaymentMethod.joins(:payment_method).
|
||||
merge(Spree::PaymentMethod.available).
|
||||
where("distributor_id IN (?)", distributor_ids)
|
||||
where(distributor_id: distributor_ids)
|
||||
end
|
||||
|
||||
def attachable_distributor_shipping_methods
|
||||
DistributorShippingMethod.joins(:shipping_method).
|
||||
merge(Spree::ShippingMethod.frontend).
|
||||
where("distributor_id IN (?)", distributor_ids)
|
||||
where(distributor_id: distributor_ids)
|
||||
end
|
||||
|
||||
def clone!
|
||||
OrderCycleClone.new(self).create
|
||||
OrderCycles::CloneService.new(self).create
|
||||
end
|
||||
|
||||
def variants
|
||||
|
||||
@@ -56,7 +56,7 @@ module ProductImport
|
||||
else
|
||||
Spree::Variant.
|
||||
joins(:product).
|
||||
where('spree_products.supplier_id IN (?)', enterprise_id).
|
||||
where(spree_products: { supplier_id: enterprise_id }).
|
||||
count
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ module ProductImport
|
||||
|
||||
def self.non_updatable_fields
|
||||
{
|
||||
category: :primary_taxon_id,
|
||||
description: :description,
|
||||
unit_type: :variant_unit_scale,
|
||||
variant_unit_name: :variant_unit_name,
|
||||
@@ -69,7 +68,7 @@ module ProductImport
|
||||
def mark_as_new_variant(entry, product_id)
|
||||
variant_attributes = entry.assignable_attributes.except(
|
||||
'id', 'product_id', 'on_hand', 'on_demand', 'variant_unit', 'variant_unit_name',
|
||||
'variant_unit_scale', 'primary_taxon_id'
|
||||
'variant_unit_scale'
|
||||
)
|
||||
# Variant needs a product. Product needs to be assigned first in order for
|
||||
# delegate to work. name= will fail otherwise.
|
||||
@@ -398,7 +397,7 @@ module ProductImport
|
||||
def mark_as_existing_variant(entry, existing_variant)
|
||||
existing_variant.assign_attributes(
|
||||
entry.assignable_attributes.except('id', 'product_id', 'variant_unit', 'variant_unit_name',
|
||||
'variant_unit_scale', 'primary_taxon_id')
|
||||
'variant_unit_scale')
|
||||
)
|
||||
check_on_hand_nil(entry, existing_variant)
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ module ProductImport
|
||||
units = UnitConverter.new(attrs)
|
||||
|
||||
units.converted_attributes.each do |attr, value|
|
||||
if respond_to?("#{attr}=") && !NON_PRODUCT_ATTRIBUTES.include?(attr)
|
||||
if respond_to?("#{attr}=") && NON_PRODUCT_ATTRIBUTES.exclude?(attr)
|
||||
public_send("#{attr}=", value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ class ProxyOrder < ApplicationRecord
|
||||
scope :closed, -> { joins(:order_cycle).merge(OrderCycle.closed) }
|
||||
scope :not_closed, -> { joins(:order_cycle).merge(OrderCycle.not_closed) }
|
||||
scope :canceled, -> { where.not(proxy_orders: { canceled_at: nil }) }
|
||||
scope :not_canceled, -> { where('proxy_orders.canceled_at IS NULL') }
|
||||
scope :not_canceled, -> { where(proxy_orders: { canceled_at: nil }) }
|
||||
scope :placed_and_open, -> {
|
||||
joins(:order).not_closed
|
||||
.where(spree_orders: { state: ['complete', 'resumed'] })
|
||||
@@ -58,7 +58,7 @@ class ProxyOrder < ApplicationRecord
|
||||
def initialise_order!
|
||||
return order if order.present?
|
||||
|
||||
factory = OrderFactory.new(order_attrs, skip_stock_check: true)
|
||||
factory = Orders::FactoryService.new(order_attrs, skip_stock_check: true)
|
||||
self.order = factory.create
|
||||
save!
|
||||
order
|
||||
|
||||
@@ -8,7 +8,8 @@ class Schedule < ApplicationRecord
|
||||
has_many :coordinators, -> { distinct }, through: :order_cycles
|
||||
|
||||
scope :with_coordinator, lambda { |enterprise|
|
||||
joins(:order_cycles).where('coordinator_id = ?', enterprise.id)
|
||||
joins(:order_cycles)
|
||||
.where(order_cycles: { coordinator_id: enterprise.id })
|
||||
.select('DISTINCT schedules.*')
|
||||
}
|
||||
|
||||
|
||||
8
app/models/semantic_link.rb
Normal file
8
app/models/semantic_link.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Link a Spree::Variant to an external DFC SuppliedProduct.
|
||||
class SemanticLink < ApplicationRecord
|
||||
belongs_to :variant, class_name: "Spree::Variant"
|
||||
|
||||
validates :semantic_id, presence: true
|
||||
end
|
||||
@@ -192,7 +192,7 @@ module Spree
|
||||
OpenFoodNetwork::Permissions.new(user).managed_product_enterprises.include? product.supplier
|
||||
end
|
||||
|
||||
can [:admin, :index], :products_v3
|
||||
can [:admin, :index, :bulk_update], :products_v3
|
||||
|
||||
can [:create], Spree::Variant
|
||||
can [:admin, :index, :read, :edit,
|
||||
@@ -239,6 +239,8 @@ module Spree
|
||||
can [:admin, :index, :guide, :import, :save, :save_data,
|
||||
:validate_data, :reset_absent_products], ProductImport::ProductImporter
|
||||
|
||||
can [:admin, :index], ::Admin::DfcProductImportsController
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :show], ::Admin::ReportsController
|
||||
can [:admin, :show, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
|
||||
@@ -4,19 +4,17 @@ module Spree
|
||||
class Address < ApplicationRecord
|
||||
include AddressDisplay
|
||||
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
searchable_attributes :firstname, :lastname, :phone, :full_name, :full_name_reversed,
|
||||
:full_name_with_comma, :full_name_with_comma_reversed
|
||||
searchable_associations :country, :state
|
||||
|
||||
belongs_to :country, class_name: "Spree::Country"
|
||||
belongs_to :state, class_name: "Spree::State"
|
||||
belongs_to :state, class_name: "Spree::State", optional: true
|
||||
|
||||
has_one :enterprise, dependent: :restrict_with_exception
|
||||
has_many :shipments
|
||||
has_many :shipments, dependent: :restrict_with_exception
|
||||
|
||||
validates :address1, :city, :country, :phone, presence: true
|
||||
validates :address1, :city, :phone, presence: true
|
||||
validates :company, presence: true, unless: -> { first_name.blank? || last_name.blank? }
|
||||
validates :firstname, :lastname, presence: true, if: -> do
|
||||
company.blank? || company == 'unused'
|
||||
|
||||
@@ -120,7 +120,7 @@ module Spree
|
||||
end
|
||||
|
||||
def currency
|
||||
adjustable ? adjustable.currency : Spree::Config[:currency]
|
||||
adjustable ? adjustable.currency : CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
def display_amount
|
||||
|
||||
@@ -44,9 +44,9 @@ module Spree
|
||||
# Given an object which might be an Order or a LineItem (amongst
|
||||
# others), return a collection of line items.
|
||||
def line_items_for(object)
|
||||
if object.is_a?(Spree::LineItem)
|
||||
[object]
|
||||
elsif object.respond_to? :line_items
|
||||
return [object] if object.is_a?(Spree::LineItem)
|
||||
|
||||
if object.respond_to? :line_items
|
||||
object.line_items
|
||||
elsif object.respond_to?(:order) && object.order.present?
|
||||
object.order.line_items
|
||||
|
||||
@@ -152,7 +152,7 @@ module Spree
|
||||
end
|
||||
|
||||
def default_missing?
|
||||
!user.credit_cards.exists?(is_default: true)
|
||||
!user.credit_cards.where(is_default: true).exists?
|
||||
end
|
||||
|
||||
def default_card_needs_updating?
|
||||
|
||||
@@ -85,7 +85,7 @@ module Spree
|
||||
|
||||
scope :from_order_cycle, lambda { |order_cycle|
|
||||
joins(order: :order_cycle).
|
||||
where('order_cycles.id = ?', order_cycle)
|
||||
where(order_cycles: { id: order_cycle })
|
||||
}
|
||||
|
||||
# Here we are simply joining the line item to its variant and product
|
||||
@@ -94,12 +94,12 @@ module Spree
|
||||
scope :supplied_by_any, lambda { |enterprises|
|
||||
product_ids = Spree::Product.unscoped.where(supplier_id: enterprises).select(:id)
|
||||
variant_ids = Spree::Variant.unscoped.where(product_id: product_ids).select(:id)
|
||||
where("spree_line_items.variant_id IN (?)", variant_ids)
|
||||
where(spree_line_items: { variant_id: variant_ids })
|
||||
}
|
||||
|
||||
scope :with_tax, -> {
|
||||
joins(:adjustments).
|
||||
where('spree_adjustments.originator_type = ?', 'Spree::TaxRate').
|
||||
where(spree_adjustments: { originator_type: 'Spree::TaxRate' }).
|
||||
select('DISTINCT spree_line_items.*')
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ module Spree
|
||||
ON (spree_adjustments.adjustable_id=spree_line_items.id
|
||||
AND spree_adjustments.adjustable_type = 'Spree::LineItem'
|
||||
AND spree_adjustments.originator_type='Spree::TaxRate')").
|
||||
where('spree_adjustments.id IS NULL')
|
||||
where(spree_adjustments: { id: nil })
|
||||
}
|
||||
|
||||
def copy_price
|
||||
|
||||
@@ -141,7 +141,7 @@ module Spree
|
||||
if user.has_spree_role?('admin')
|
||||
where(nil)
|
||||
else
|
||||
where('spree_orders.distributor_id IN (?)', user.enterprises.select(&:id))
|
||||
where(spree_orders: { distributor_id: user.enterprises.select(&:id) })
|
||||
end
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ module Spree
|
||||
scope :finalized, -> { where(state: FINALIZED_STATES) }
|
||||
scope :complete, -> { where.not(completed_at: nil) }
|
||||
scope :incomplete, -> { where(completed_at: nil) }
|
||||
scope :invoiceable, -> { where(state: [:complete, :resumed]) }
|
||||
scope :by_state, lambda { |state| where(state:) }
|
||||
scope :not_state, lambda { |state| where.not(state:) }
|
||||
|
||||
@@ -186,7 +187,7 @@ module Spree
|
||||
end
|
||||
|
||||
def currency
|
||||
self[:currency] || Spree::Config[:currency]
|
||||
self[:currency] || CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
def display_item_total
|
||||
@@ -213,10 +214,6 @@ module Spree
|
||||
completed_at.present?
|
||||
end
|
||||
|
||||
def invoiceable?
|
||||
complete? || resumed?
|
||||
end
|
||||
|
||||
# Indicates whether or not the user is allowed to proceed to checkout.
|
||||
# Currently this is implemented as a check for whether or not there is at
|
||||
# least one LineItem in the Order. Feel free to override this logic in your
|
||||
@@ -652,7 +649,7 @@ module Spree
|
||||
end
|
||||
|
||||
def fee_handler
|
||||
@fee_handler ||= OrderFeesHandler.new(self)
|
||||
@fee_handler ||= Orders::HandleFeesService.new(self)
|
||||
end
|
||||
|
||||
def clear_legacy_taxes!
|
||||
@@ -689,7 +686,7 @@ module Spree
|
||||
end
|
||||
|
||||
def set_currency
|
||||
self.currency = Spree::Config[:currency] if self[:currency].nil?
|
||||
self.currency = CurrentConfig.get(:currency) if self[:currency].nil?
|
||||
end
|
||||
|
||||
def using_guest_checkout?
|
||||
@@ -697,11 +694,11 @@ module Spree
|
||||
end
|
||||
|
||||
def registered_email?
|
||||
Spree::User.exists?(email:)
|
||||
Spree::User.where(email:).exists?
|
||||
end
|
||||
|
||||
def adjustments_fetcher
|
||||
@adjustments_fetcher ||= OrderAdjustmentsFetcher.new(self)
|
||||
@adjustments_fetcher ||= Orders::FetchAdjustmentsService.new(self)
|
||||
end
|
||||
|
||||
def skip_payment_for_subscription?
|
||||
|
||||
@@ -8,7 +8,6 @@ module Spree
|
||||
class_attribute :next_event_transitions
|
||||
class_attribute :previous_states
|
||||
class_attribute :checkout_flow
|
||||
class_attribute :checkout_steps
|
||||
|
||||
def self.checkout_flow(&block)
|
||||
if block_given?
|
||||
@@ -20,7 +19,6 @@ module Spree
|
||||
end
|
||||
|
||||
def self.define_state_machine!
|
||||
self.checkout_steps = {}
|
||||
self.next_event_transitions = []
|
||||
self.previous_states = [:cart]
|
||||
|
||||
@@ -97,7 +95,6 @@ module Spree
|
||||
end
|
||||
|
||||
def self.go_to_state(name, options = {})
|
||||
checkout_steps[name] = options
|
||||
previous_states.each do |state|
|
||||
add_transition({ from: state, to: name }.merge(options))
|
||||
end
|
||||
@@ -112,30 +109,14 @@ module Spree
|
||||
@next_event_transitions ||= []
|
||||
end
|
||||
|
||||
def self.checkout_steps
|
||||
@checkout_steps ||= {}
|
||||
end
|
||||
|
||||
def self.add_transition(options)
|
||||
next_event_transitions << { options.delete(:from) => options.delete(:to) }.
|
||||
merge(options)
|
||||
end
|
||||
|
||||
def checkout_steps
|
||||
steps = self.class.checkout_steps.
|
||||
each_with_object([]) { |(step, options), checkout_steps|
|
||||
next if options.include?(:if) && !options[:if].call(self)
|
||||
|
||||
checkout_steps << step
|
||||
}.map(&:to_s)
|
||||
# Ensure there is always a complete step
|
||||
steps << "complete" unless steps.include?("complete")
|
||||
steps
|
||||
end
|
||||
|
||||
def restart_checkout_flow
|
||||
update_columns(
|
||||
state: checkout_steps.first,
|
||||
state: "address",
|
||||
updated_at: Time.zone.now,
|
||||
)
|
||||
end
|
||||
|
||||
@@ -246,7 +246,7 @@ module Spree
|
||||
# and this is it. Related to #1998.
|
||||
# See https://github.com/spree/spree/issues/1998#issuecomment-12869105
|
||||
def set_unique_identifier
|
||||
self.identifier = generate_identifier while self.class.exists?(identifier:)
|
||||
self.identifier = generate_identifier while self.class.where(identifier:).exists?
|
||||
end
|
||||
|
||||
def generate_identifier
|
||||
|
||||
@@ -48,7 +48,7 @@ module Spree
|
||||
end
|
||||
|
||||
def capture_and_complete_order!
|
||||
OrderWorkflow.new(order).complete!
|
||||
Orders::WorkflowService.new(order).complete!
|
||||
capture!
|
||||
end
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ module Spree
|
||||
return where(nil) if user.admin?
|
||||
|
||||
joins(:distributors).
|
||||
where('distributors_payment_methods.distributor_id IN (?)',
|
||||
user.enterprises.select(&:id)).
|
||||
where(distributors_payment_methods: { distributor_id: user.enterprises.select(&:id) }).
|
||||
select('DISTINCT spree_payment_methods.*')
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ module Spree
|
||||
}
|
||||
|
||||
scope :for_distributor, ->(distributor) {
|
||||
joins(:distributors).where('enterprises.id = ?', distributor)
|
||||
joins(:distributors).where(enterprises: { id: distributor })
|
||||
}
|
||||
|
||||
scope :for_subscriptions, -> { where(type: Subscription::ALLOWED_PAYMENT_METHOD_TYPES) }
|
||||
|
||||
@@ -16,9 +16,7 @@ module Spree
|
||||
def value
|
||||
if self[:value_type].present?
|
||||
case self[:value_type].to_sym
|
||||
when :string, :text
|
||||
self[:value].to_s
|
||||
when :password
|
||||
when :string, :text, :password
|
||||
self[:value].to_s
|
||||
when :decimal
|
||||
BigDecimal(self[:value].to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) ||
|
||||
|
||||
@@ -111,9 +111,7 @@ module Spree
|
||||
|
||||
def convert_preference_value(value, type)
|
||||
case type
|
||||
when :string, :text
|
||||
value.to_s
|
||||
when :password
|
||||
when :string, :text, :password
|
||||
value.to_s
|
||||
when :decimal
|
||||
value = 0 if value.blank?
|
||||
|
||||
@@ -37,7 +37,7 @@ module Spree
|
||||
def check_price
|
||||
return unless currency.nil?
|
||||
|
||||
self.currency = Spree::Config[:currency]
|
||||
self.currency = CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
# strips all non-price-like characters from the price, taking into account locale settings
|
||||
|
||||
@@ -28,16 +28,11 @@ module Spree
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
after_create :ensure_standard_variant
|
||||
around_destroy :destruction
|
||||
after_save :update_units
|
||||
|
||||
searchable_attributes :supplier_id, :primary_taxon_id, :meta_keywords, :sku
|
||||
searchable_associations :supplier, :properties, :primary_taxon, :variants
|
||||
searchable_attributes :supplier_id, :meta_keywords, :sku
|
||||
searchable_associations :supplier, :properties, :variants
|
||||
searchable_scopes :active, :with_properties
|
||||
|
||||
belongs_to :supplier, class_name: 'Enterprise', optional: false, touch: true
|
||||
belongs_to :primary_taxon, class_name: 'Spree::Taxon', optional: false, touch: true
|
||||
|
||||
has_one :image, class_name: "Spree::Image", as: :viewable, dependent: :destroy
|
||||
|
||||
@@ -77,7 +72,11 @@ module Spree
|
||||
# Transient attributes used temporarily when creating a new product,
|
||||
# these values are persisted on the product's variant
|
||||
attr_accessor :price, :display_as, :unit_value, :unit_description, :tax_category_id,
|
||||
:shipping_category_id
|
||||
:shipping_category_id, :primary_taxon_id
|
||||
|
||||
after_create :ensure_standard_variant
|
||||
around_destroy :destruction
|
||||
after_save :update_units
|
||||
|
||||
scope :with_properties, ->(*property_ids) {
|
||||
left_outer_joins(:product_properties).
|
||||
@@ -160,7 +159,7 @@ module Spree
|
||||
scope :in_order_cycle, lambda { |order_cycle|
|
||||
with_order_cycles_inner.
|
||||
merge(Exchange.outgoing).
|
||||
where('order_cycles.id = ?', order_cycle)
|
||||
where(order_cycles: { id: order_cycle })
|
||||
}
|
||||
|
||||
scope :in_an_active_order_cycle, lambda {
|
||||
@@ -177,7 +176,7 @@ module Spree
|
||||
if user.has_spree_role?('admin')
|
||||
where(nil)
|
||||
else
|
||||
where('supplier_id IN (?)', user.enterprises.select("enterprises.id"))
|
||||
where(supplier_id: user.enterprises.select("enterprises.id"))
|
||||
end
|
||||
}
|
||||
|
||||
@@ -188,10 +187,10 @@ module Spree
|
||||
.with_permission(:add_to_order_cycle)
|
||||
.where(enterprises: { is_primary_producer: true })
|
||||
.pluck(:parent_id)
|
||||
where('spree_products.supplier_id IN (?)', [enterprise.id] | permitted_producer_ids)
|
||||
where(spree_products: { supplier_id: [enterprise.id] | permitted_producer_ids })
|
||||
}
|
||||
|
||||
scope :active, lambda { where("spree_products.deleted_at IS NULL") }
|
||||
scope :active, lambda { where(spree_products: { deleted_at: nil }) }
|
||||
|
||||
def self.group_by_products_id
|
||||
group(column_names.map { |col_name| "#{table_name}.#{col_name}" })
|
||||
@@ -266,8 +265,8 @@ module Spree
|
||||
touch_distributors
|
||||
|
||||
ExchangeVariant.
|
||||
where('exchange_variants.variant_id IN (?)', variants.with_deleted.
|
||||
select(:id)).destroy_all
|
||||
where(exchange_variants: { variant_id: variants.with_deleted.
|
||||
select(:id) }).destroy_all
|
||||
|
||||
yield
|
||||
end
|
||||
@@ -284,6 +283,7 @@ module Spree
|
||||
variant.unit_description = unit_description
|
||||
variant.tax_category_id = tax_category_id
|
||||
variant.shipping_category_id = shipping_category_id
|
||||
variant.primary_taxon_id = primary_taxon_id
|
||||
variants << variant
|
||||
end
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ module Spree
|
||||
end
|
||||
|
||||
def currency
|
||||
order.nil? ? Spree::Config[:currency] : order.currency
|
||||
order.nil? ? CurrentConfig.get(:currency) : order.currency
|
||||
end
|
||||
|
||||
def display_amount
|
||||
|
||||
@@ -163,7 +163,7 @@ module Spree
|
||||
end
|
||||
|
||||
def currency
|
||||
order ? order.currency : Spree::Config[:currency]
|
||||
order ? order.currency : CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
def display_cost
|
||||
|
||||
@@ -41,8 +41,7 @@ module Spree
|
||||
where(nil)
|
||||
else
|
||||
joins(:distributors).
|
||||
where('distributors_shipping_methods.distributor_id IN (?)',
|
||||
user.enterprises.select(&:id)).
|
||||
where(distributors_shipping_methods: { distributor_id: user.enterprises.select(&:id) }).
|
||||
select('DISTINCT spree_shipping_methods.*')
|
||||
end
|
||||
}
|
||||
@@ -53,7 +52,7 @@ module Spree
|
||||
}
|
||||
scope :for_distributor, lambda { |distributor|
|
||||
joins(:distributors).
|
||||
where('enterprises.id = ?', distributor)
|
||||
where(enterprises: { id: distributor })
|
||||
}
|
||||
|
||||
scope :by_name, -> { order('spree_shipping_methods.name ASC') }
|
||||
|
||||
@@ -8,7 +8,7 @@ module Spree
|
||||
|
||||
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :stock_items
|
||||
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
|
||||
has_many :stock_movements
|
||||
has_many :stock_movements, dependent: :destroy
|
||||
|
||||
validates :stock_location, :variant, presence: true
|
||||
validates :variant_id, uniqueness: { scope: [:stock_location_id, :deleted_at] }
|
||||
|
||||
@@ -14,10 +14,6 @@ module Spree
|
||||
|
||||
scope :recent, -> { order('created_at DESC') }
|
||||
|
||||
def readonly?
|
||||
!new_record?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_stock_item_quantity
|
||||
|
||||
@@ -21,7 +21,7 @@ module Spree
|
||||
|
||||
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
|
||||
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
|
||||
has_many :adjustments, as: :originator
|
||||
has_many :adjustments, as: :originator, dependent: nil
|
||||
|
||||
validates :amount, presence: true, numericality: true
|
||||
validates :tax_category, presence: true
|
||||
|
||||
@@ -7,9 +7,12 @@ module Spree
|
||||
acts_as_nested_set dependent: :destroy
|
||||
|
||||
belongs_to :taxonomy, class_name: 'Spree::Taxonomy', touch: true
|
||||
has_many :products, class_name: "Spree::Product", foreign_key: "primary_taxon_id",
|
||||
|
||||
has_many :variants, class_name: "Spree::Variant", foreign_key: "primary_taxon_id",
|
||||
inverse_of: :primary_taxon, dependent: :restrict_with_error
|
||||
|
||||
has_many :products, through: :variants, dependent: nil
|
||||
|
||||
before_create :set_permalink
|
||||
|
||||
validates :name, presence: true
|
||||
@@ -77,7 +80,7 @@ module Spree
|
||||
|
||||
taxons = Spree::Taxon
|
||||
.select("DISTINCT spree_taxons.id, ents_and_vars.enterprise_id")
|
||||
.joins(products: :variants)
|
||||
.joins(:variants)
|
||||
.joins("
|
||||
INNER JOIN (#{ents_and_vars.to_sql}) AS ents_and_vars
|
||||
ON spree_variants.id = ents_and_vars.variant_id")
|
||||
|
||||
@@ -13,8 +13,8 @@ module Spree
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
searchable_attributes :sku, :display_as, :display_name
|
||||
searchable_associations :product, :default_price
|
||||
searchable_attributes :sku, :display_as, :display_name, :primary_taxon_id
|
||||
searchable_associations :product, :default_price, :primary_taxon
|
||||
searchable_scopes :active, :deleted
|
||||
|
||||
NAME_FIELDS = ["display_name", "display_as", "weight", "unit_value", "unit_description"].freeze
|
||||
@@ -28,11 +28,12 @@ module Spree
|
||||
belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product'
|
||||
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
|
||||
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', optional: false
|
||||
belongs_to :primary_taxon, class_name: 'Spree::Taxon', touch: true, optional: false
|
||||
|
||||
delegate :name, :name=, :description, :description=, :meta_keywords, to: :product
|
||||
|
||||
has_many :inventory_units, inverse_of: :variant
|
||||
has_many :line_items, inverse_of: :variant
|
||||
has_many :inventory_units, inverse_of: :variant, dependent: nil
|
||||
has_many :line_items, inverse_of: :variant, dependent: nil
|
||||
|
||||
has_many :stock_items, dependent: :destroy, inverse_of: :variant
|
||||
has_many :stock_locations, through: :stock_items
|
||||
@@ -42,7 +43,7 @@ module Spree
|
||||
accepts_nested_attributes_for :images
|
||||
|
||||
has_one :default_price,
|
||||
-> { with_deleted.where(currency: Spree::Config[:currency]) },
|
||||
-> { with_deleted.where(currency: CurrentConfig.get(:currency)) },
|
||||
class_name: 'Spree::Price',
|
||||
dependent: :destroy
|
||||
has_many :prices,
|
||||
@@ -52,10 +53,11 @@ module Spree
|
||||
:currency, :currency=,
|
||||
to: :find_or_build_default_price
|
||||
|
||||
has_many :exchange_variants
|
||||
has_many :exchange_variants, dependent: nil
|
||||
has_many :exchanges, through: :exchange_variants
|
||||
has_many :variant_overrides, dependent: :destroy
|
||||
has_many :inventory_items, dependent: :destroy
|
||||
has_many :semantic_links, dependent: :delete_all
|
||||
|
||||
localize_number :price, :weight
|
||||
|
||||
@@ -81,6 +83,7 @@ module Spree
|
||||
before_validation :ensure_unit_value
|
||||
before_validation :update_weight_from_unit_value, if: ->(v) { v.product.present? }
|
||||
before_validation :convert_variant_weight_to_decimal
|
||||
before_validation :assign_related_taxon, if: ->(v) { v.primary_taxon.blank? }
|
||||
|
||||
before_save :assign_units, if: ->(variant) {
|
||||
variant.new_record? || variant.changed_attributes.keys.intersection(NAME_FIELDS).any?
|
||||
@@ -98,7 +101,7 @@ module Spree
|
||||
scope :in_order_cycle, lambda { |order_cycle|
|
||||
with_order_cycles_inner.
|
||||
merge(Exchange.outgoing).
|
||||
where('order_cycles.id = ?', order_cycle).
|
||||
where(order_cycles: { id: order_cycle }).
|
||||
select('DISTINCT spree_variants.*')
|
||||
}
|
||||
|
||||
@@ -110,8 +113,8 @@ module Spree
|
||||
}
|
||||
|
||||
scope :for_distribution, lambda { |order_cycle, distributor|
|
||||
where('spree_variants.id IN (?)', order_cycle.variants_distributed_by(distributor).
|
||||
select(&:id))
|
||||
where(spree_variants: { id: order_cycle.variants_distributed_by(distributor).
|
||||
select(&:id) })
|
||||
}
|
||||
|
||||
scope :visible_for, lambda { |enterprise|
|
||||
@@ -158,12 +161,12 @@ module Spree
|
||||
def self.active(currency = nil)
|
||||
# "where(id:" is necessary so that the returned relation has no includes
|
||||
# The relation without includes will not be readonly and allow updates on it
|
||||
where("spree_variants.id in (?)", joins(:prices).
|
||||
where(spree_variants: { id: joins(:prices).
|
||||
where(deleted_at: nil).
|
||||
where('spree_prices.currency' =>
|
||||
currency || Spree::Config[:currency]).
|
||||
currency || CurrentConfig.get(:currency)).
|
||||
where.not(spree_prices: { amount: nil }).
|
||||
select("spree_variants.id"))
|
||||
select("spree_variants.id") })
|
||||
end
|
||||
|
||||
def tax_category
|
||||
@@ -207,10 +210,14 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def assign_related_taxon
|
||||
self.primary_taxon ||= product.variants.last&.primary_taxon
|
||||
end
|
||||
|
||||
def check_currency
|
||||
return unless currency.nil?
|
||||
|
||||
self.currency = Spree::Config[:currency]
|
||||
self.currency = CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
def save_default_price
|
||||
@@ -222,7 +229,7 @@ module Spree
|
||||
end
|
||||
|
||||
def set_cost_currency
|
||||
self.cost_currency = Spree::Config[:currency] if cost_currency.blank?
|
||||
self.cost_currency = CurrentConfig.get(:currency) if cost_currency.blank?
|
||||
end
|
||||
|
||||
def create_stock_items
|
||||
|
||||
@@ -34,8 +34,8 @@ class Subscription < ApplicationRecord
|
||||
where('subscriptions.ends_at > (?) OR subscriptions.ends_at IS NULL',
|
||||
Time.zone.now)
|
||||
}
|
||||
scope :not_canceled, -> { where('subscriptions.canceled_at IS NULL') }
|
||||
scope :not_paused, -> { where('subscriptions.paused_at IS NULL') }
|
||||
scope :not_canceled, -> { where(subscriptions: { canceled_at: nil }) }
|
||||
scope :not_paused, -> { where(subscriptions: { paused_at: nil }) }
|
||||
scope :active, -> {
|
||||
not_canceled.not_ended.not_paused.where('subscriptions.begins_at <= (?)',
|
||||
Time.zone.now)
|
||||
|
||||
@@ -20,7 +20,7 @@ class ProductScopeQuery
|
||||
|
||||
product_query.
|
||||
ransack(query_params_with_defaults).
|
||||
result
|
||||
result(distinct: true)
|
||||
end
|
||||
|
||||
def find_product
|
||||
|
||||
@@ -5,7 +5,7 @@ module Admin
|
||||
before_reflex :authorize_order, only: [:capture, :ship]
|
||||
|
||||
def capture
|
||||
payment_capture = OrderCaptureService.new(@order)
|
||||
payment_capture = Orders::CaptureService.new(@order)
|
||||
|
||||
if payment_capture.call
|
||||
cable_ready.replace(selector: dom_id(@order),
|
||||
@@ -32,13 +32,32 @@ module Admin
|
||||
end
|
||||
|
||||
def bulk_invoice(params)
|
||||
visible_orders = editable_orders.invoiceable.where(id: params[:bulk_ids])
|
||||
|
||||
if Spree::Config.enterprise_number_required_on_invoices?
|
||||
distributors_without_abn = Enterprise.where(
|
||||
id: visible_orders.select(:distributor_id),
|
||||
abn: nil,
|
||||
)
|
||||
|
||||
if distributors_without_abn.exists?
|
||||
render_business_number_required_error(distributors_without_abn)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
cable_ready.append(
|
||||
selector: "#orders-index",
|
||||
html: render(partial: "spree/admin/orders/bulk/invoice_modal")
|
||||
).broadcast
|
||||
|
||||
# Preserve order of bulk_ids.
|
||||
# The ids are supplied in the sequence of the orders screen and may be
|
||||
# sorted, for example by last name of the customer.
|
||||
visible_order_ids = params[:bulk_ids].map(&:to_i) & visible_orders.pluck(:id)
|
||||
|
||||
BulkInvoiceJob.perform_later(
|
||||
params[:bulk_ids],
|
||||
visible_order_ids,
|
||||
"tmp/invoices/#{Time.zone.now.to_i}-#{SecureRandom.hex(2)}.pdf",
|
||||
channel: SessionChannel.for_request(request),
|
||||
current_user_id: current_user.id
|
||||
@@ -48,7 +67,7 @@ module Admin
|
||||
end
|
||||
|
||||
def cancel_orders(params)
|
||||
cancelled_orders = OrdersBulkCancelService.new(params, current_user).call
|
||||
cancelled_orders = Orders::BulkCancelService.new(params, current_user).call
|
||||
|
||||
cable_ready.dispatch_event(name: "modal:close")
|
||||
|
||||
@@ -75,8 +94,8 @@ module Admin
|
||||
|
||||
def send_invoices(params)
|
||||
count = 0
|
||||
editable_orders.where(id: params[:bulk_ids]).find_each do |o|
|
||||
next unless o.distributor.can_invoice? && o.invoiceable?
|
||||
editable_orders.invoiceable.where(id: params[:bulk_ids]).find_each do |o|
|
||||
next unless o.distributor.can_invoice?
|
||||
|
||||
Spree::OrderMailer.invoice_email(o.id, current_user_id: current_user.id).deliver_later
|
||||
count += 1
|
||||
@@ -106,5 +125,13 @@ module Admin
|
||||
def set_param_for_controller
|
||||
params[:id] = @order.number
|
||||
end
|
||||
|
||||
def render_business_number_required_error(distributors)
|
||||
distributor_names = distributors.pluck(:name)
|
||||
|
||||
flash[:error] = I18n.t(:must_have_valid_business_number,
|
||||
enterprise_name: distributor_names.join(", "))
|
||||
morph_admin_flashes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,10 +5,6 @@ class ProductsReflex < ApplicationReflex
|
||||
|
||||
before_reflex :init_filters_params, :init_pagination_params
|
||||
|
||||
def fetch
|
||||
fetch_and_render_products_with_flash
|
||||
end
|
||||
|
||||
def change_per_page
|
||||
@per_page = element.value.to_i
|
||||
@page = 1
|
||||
@@ -16,12 +12,6 @@ class ProductsReflex < ApplicationReflex
|
||||
fetch_and_render_products_with_flash
|
||||
end
|
||||
|
||||
def filter
|
||||
@page = 1
|
||||
|
||||
fetch_and_render_products_with_flash
|
||||
end
|
||||
|
||||
def clear_search
|
||||
@search_term = nil
|
||||
@producer_id = nil
|
||||
@@ -31,21 +21,6 @@ class ProductsReflex < ApplicationReflex
|
||||
fetch_and_render_products_with_flash
|
||||
end
|
||||
|
||||
def bulk_update
|
||||
product_set = product_set_from_params
|
||||
|
||||
product_set.collection.each { |p| authorize! :update, p }
|
||||
@products = product_set.collection # use instance variable mainly for testing
|
||||
|
||||
if product_set.save
|
||||
flash[:success] = I18n.t('admin.products_v3.bulk_update.success')
|
||||
elsif product_set.errors.present?
|
||||
@error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count }
|
||||
end
|
||||
|
||||
render_products_form_with_flash
|
||||
end
|
||||
|
||||
def delete_product
|
||||
id = current_id_from_element(element)
|
||||
product = product_finder(id).find_product
|
||||
@@ -116,11 +91,11 @@ class ProductsReflex < ApplicationReflex
|
||||
producer_options: producers, producer_id: @producer_id,
|
||||
category_options: categories, category_id: @category_id,
|
||||
flashes: flash })
|
||||
).broadcast
|
||||
)
|
||||
|
||||
cable_ready.replace_state(
|
||||
url: current_url,
|
||||
).broadcast_later
|
||||
)
|
||||
|
||||
morph :nothing
|
||||
end
|
||||
@@ -133,12 +108,11 @@ class ProductsReflex < ApplicationReflex
|
||||
cable_ready.replace(
|
||||
selector: "#products-form",
|
||||
html: render(partial: "admin/products_v3/table", locals:)
|
||||
).broadcast
|
||||
)
|
||||
morph :nothing
|
||||
|
||||
# dunno why this doesn't work.
|
||||
# morph "#products-form", render(partial: "admin/products_v3/table",
|
||||
# locals: { products: products })
|
||||
# dunno why this doesn't work. The HTML stops after the first `<col>` element, wtf?!
|
||||
# morph "#products-form", render(partial: "admin/products_v3/table", locals:)
|
||||
end
|
||||
|
||||
def producers
|
||||
@@ -153,7 +127,7 @@ class ProductsReflex < ApplicationReflex
|
||||
|
||||
def fetch_products
|
||||
product_query = OpenFoodNetwork::Permissions.new(current_user)
|
||||
.editable_products.merge(product_scope).ransack(ransack_query).result
|
||||
.editable_products.merge(product_scope).ransack(ransack_query).result(distinct: true)
|
||||
@pagy, @products = pagy(product_query.order(:name), items: @per_page, page: @page,
|
||||
size: [1, 2, 2, 1])
|
||||
end
|
||||
@@ -174,7 +148,7 @@ class ProductsReflex < ApplicationReflex
|
||||
if @search_term.present?
|
||||
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)
|
||||
end
|
||||
query.merge!(primary_taxon_id_in: @category_id) if @category_id.present?
|
||||
query.merge!(variants_primary_taxon_id_in: @category_id) if @category_id.present?
|
||||
query
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ module Api
|
||||
delegate :balance_value, to: :object
|
||||
|
||||
def balance
|
||||
Spree::Money.new(balance_value, currency: Spree::Config[:currency]).to_s
|
||||
Spree::Money.new(balance_value, currency: CurrentConfig.get(:currency)).to_s
|
||||
end
|
||||
|
||||
def balance_status
|
||||
|
||||
@@ -8,7 +8,6 @@ module Api
|
||||
:thumb_url, :variants
|
||||
|
||||
has_one :supplier, key: :producer_id, embed: :id
|
||||
has_one :primary_taxon, key: :category_id, embed: :id
|
||||
|
||||
def variants
|
||||
ActiveModel::ArraySerializer.new(
|
||||
|
||||
@@ -8,6 +8,8 @@ module Api
|
||||
:display_as, :display_name, :name_to_display, :variant_overrides_count,
|
||||
:price, :on_demand, :on_hand, :in_stock, :stock_location_id, :stock_location_name
|
||||
|
||||
has_one :primary_taxon, key: :category_id, embed: :id
|
||||
|
||||
def name
|
||||
if object.full_name.present?
|
||||
"#{object.name} - #{object.full_name}"
|
||||
|
||||
@@ -4,22 +4,22 @@ class Api::CurrencyConfigSerializer < ActiveModel::Serializer
|
||||
attributes :currency, :display_currency, :symbol, :symbol_position, :hide_cents
|
||||
|
||||
def currency
|
||||
Spree::Config[:currency]
|
||||
CurrentConfig.get(:currency)
|
||||
end
|
||||
|
||||
def display_currency
|
||||
Spree::Config[:display_currency]
|
||||
CurrentConfig.get(:display_currency)
|
||||
end
|
||||
|
||||
def symbol
|
||||
::Money.new(1, Spree::Config[:currency]).symbol
|
||||
::Money.new(1, CurrentConfig.get(:currency)).symbol
|
||||
end
|
||||
|
||||
def symbol_position
|
||||
Spree::Config[:currency_symbol_position]
|
||||
CurrentConfig.get(:currency_symbol_position)
|
||||
end
|
||||
|
||||
def hide_cents
|
||||
Spree::Config[:hide_cents]
|
||||
CurrentConfig.get(:hide_cents)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -145,7 +145,7 @@ module Api
|
||||
require_shipping = type == :delivery ? 't' : 'f'
|
||||
Spree::ShippingMethod.
|
||||
joins(:distributor_shipping_methods).
|
||||
where('distributors_shipping_methods.distributor_id = ?', enterprise.id).
|
||||
where(distributors_shipping_methods: { distributor_id: enterprise.id }).
|
||||
where("spree_shipping_methods.require_ship_address = '#{require_shipping}'").exists?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ module Api
|
||||
end
|
||||
|
||||
def payments
|
||||
object.payments.joins(:payment_method).where('state IN (?)', %w(completed pending))
|
||||
object.payments.joins(:payment_method).where(state: %w(completed pending))
|
||||
end
|
||||
|
||||
def shop_id
|
||||
|
||||
@@ -9,8 +9,6 @@ class Api::ProductSerializer < ActiveModel::Serializer
|
||||
|
||||
has_many :variants, serializer: Api::VariantSerializer
|
||||
|
||||
has_one :primary_taxon, serializer: Api::TaxonSerializer
|
||||
|
||||
has_one :image, serializer: Api::ImageSerializer
|
||||
has_one :supplier, serializer: Api::IdSerializer
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class CapQuantity
|
||||
end
|
||||
|
||||
def available_variants_for
|
||||
OrderCycleDistributedVariants.new(order.order_cycle, order.distributor).available_variants
|
||||
OrderCycles::DistributedVariantsService.new(order.order_cycle,
|
||||
order.distributor).available_variants
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user