mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Compare commits
354 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9816332601 | ||
|
|
4810b02233 | ||
|
|
f8716f8005 | ||
|
|
5cf213f22a | ||
|
|
251a1acffc | ||
|
|
d5dec05ab1 | ||
|
|
7790259c27 | ||
|
|
6a99d2a3c8 | ||
|
|
e7a2b7ea48 | ||
|
|
bd0dcd99f3 | ||
|
|
bc23423521 | ||
|
|
a4ca56c7a5 | ||
|
|
9f7655852d | ||
|
|
ec106a8f83 | ||
|
|
2e7237197a | ||
|
|
25c579c478 | ||
|
|
66b820869c | ||
|
|
ffc819ea76 | ||
|
|
ed3f928783 | ||
|
|
63a9601812 | ||
|
|
3b068b7125 | ||
|
|
597c0590ed | ||
|
|
b9b91620ef | ||
|
|
c67d47a773 | ||
|
|
85e0da8aeb | ||
|
|
34c91613f7 | ||
|
|
219e3ca9c8 | ||
|
|
628810eb33 | ||
|
|
d95aac333b | ||
|
|
3e2e7f1799 | ||
|
|
ee13a3abaf | ||
|
|
d5bd8fa086 | ||
|
|
5e4cd4d51d | ||
|
|
c0823d24c2 | ||
|
|
41e4fd79a3 | ||
|
|
a60afd10e4 | ||
|
|
b42b10fcd1 | ||
|
|
c8dbf4c6f0 | ||
|
|
f5a3093e41 | ||
|
|
5a376c9106 | ||
|
|
152fd15bd0 | ||
|
|
5bdb6e6d69 | ||
|
|
cb6b1f2dd0 | ||
|
|
130401263a | ||
|
|
29a8a6641c | ||
|
|
7ab33d86f1 | ||
|
|
28241756aa | ||
|
|
fec5516fce | ||
|
|
6aa4bf7a33 | ||
|
|
c58a65a52b | ||
|
|
e21fadd124 | ||
|
|
1b468522e6 | ||
|
|
be7be9bbc6 | ||
|
|
6915836a14 | ||
|
|
e10fd0b020 | ||
|
|
45786780a8 | ||
|
|
7d400e9860 | ||
|
|
b50f299381 | ||
|
|
d706b3a6c2 | ||
|
|
153b94f18e | ||
|
|
71daccb49a | ||
|
|
bca5ee226d | ||
|
|
fe00d1f813 | ||
|
|
57a69f7fa3 | ||
|
|
f4d972fc5e | ||
|
|
6db3b44e92 | ||
|
|
f7f7a5738a | ||
|
|
da912f21b3 | ||
|
|
e2146eb1a3 | ||
|
|
8e19bfca3c | ||
|
|
255836b4d2 | ||
|
|
fcd7b457e6 | ||
|
|
eb1daf425a | ||
|
|
06bc6c276a | ||
|
|
6854a53bd1 | ||
|
|
57186a74a8 | ||
|
|
3575952d4b | ||
|
|
11203da5ca | ||
|
|
86091a5a79 | ||
|
|
f4328f1d18 | ||
|
|
2334a695a8 | ||
|
|
c9418c52e4 | ||
|
|
ce1e38f97b | ||
|
|
e16595eacb | ||
|
|
510fd4867b | ||
|
|
53d6886f20 | ||
|
|
dad9014a60 | ||
|
|
abe9032910 | ||
|
|
272cf9ae87 | ||
|
|
1d5bc14f2f | ||
|
|
0332049551 | ||
|
|
0ffd4dcc35 | ||
|
|
e899d1b7fd | ||
|
|
ed331dc104 | ||
|
|
1bec028a09 | ||
|
|
59547ba9e4 | ||
|
|
9fb8bb15e8 | ||
|
|
8aa89c0bf7 | ||
|
|
447d80c960 | ||
|
|
67853bb976 | ||
|
|
d57274fc4c | ||
|
|
f063e2e8c6 | ||
|
|
d3eb887664 | ||
|
|
efae11e2af | ||
|
|
1554459eb9 | ||
|
|
50265780cf | ||
|
|
7433f6d183 | ||
|
|
f1071575cd | ||
|
|
7a4beb8b22 | ||
|
|
9a48ee16cc | ||
|
|
50c0e8af7d | ||
|
|
1cf2928f9f | ||
|
|
6cacde837d | ||
|
|
1d2d661675 | ||
|
|
5029c03205 | ||
|
|
2b648f3f3c | ||
|
|
b2e847b551 | ||
|
|
4873fd3275 | ||
|
|
e0ad4363a9 | ||
|
|
46de21ea2b | ||
|
|
efdbf25f86 | ||
|
|
a069e4247f | ||
|
|
7010cda9f7 | ||
|
|
498ed5a3ec | ||
|
|
c7d4c6f3c4 | ||
|
|
70b2a6d999 | ||
|
|
36e3e16ba0 | ||
|
|
0f047e2c25 | ||
|
|
ef7bd083ed | ||
|
|
c13785f2e3 | ||
|
|
28dde86960 | ||
|
|
08691f81a1 | ||
|
|
0c0304b1c1 | ||
|
|
7922bf7b65 | ||
|
|
2d46676bb4 | ||
|
|
2808a41f0d | ||
|
|
18869979db | ||
|
|
708dbb2270 | ||
|
|
de52e21ee9 | ||
|
|
9488e9b459 | ||
|
|
503429960a | ||
|
|
83ec97e720 | ||
|
|
c0b6f26338 | ||
|
|
fd178ee80b | ||
|
|
e4db20f86e | ||
|
|
58520a0c4c | ||
|
|
0bc4b1c885 | ||
|
|
b7a1754879 | ||
|
|
560348722c | ||
|
|
6d17cf50fb | ||
|
|
7b715bf6c7 | ||
|
|
f6c426ef17 | ||
|
|
0a42f15c25 | ||
|
|
95412bd203 | ||
|
|
ab811b2c83 | ||
|
|
81aac877a5 | ||
|
|
2330c7cfc2 | ||
|
|
68c7d8f9f5 | ||
|
|
cf3175c16e | ||
|
|
85c903cb7f | ||
|
|
ebd7b0b24d | ||
|
|
78cf0434d6 | ||
|
|
74e7e9b17b | ||
|
|
2b32d53911 | ||
|
|
2cff5bc4df | ||
|
|
1dbcddf799 | ||
|
|
702db32595 | ||
|
|
d770049d2d | ||
|
|
424e25f83e | ||
|
|
ce12bc4dbc | ||
|
|
9d79119eb0 | ||
|
|
f2eec5685e | ||
|
|
8aac400c14 | ||
|
|
f31976a3a4 | ||
|
|
0bb2c867e0 | ||
|
|
cd68ddc34f | ||
|
|
2cfd386ad7 | ||
|
|
ce94b394b2 | ||
|
|
98775bfdb8 | ||
|
|
47ef21deb3 | ||
|
|
f80b484b12 | ||
|
|
b455755bfc | ||
|
|
1f7c08bbb0 | ||
|
|
fcb9439cd2 | ||
|
|
96c2b75a0a | ||
|
|
b6438992b9 | ||
|
|
69108df206 | ||
|
|
c66b9611b6 | ||
|
|
de873ae42c | ||
|
|
ed701b00dc | ||
|
|
52e2fb923e | ||
|
|
a2a9d32c5b | ||
|
|
619ecf9432 | ||
|
|
4f152a9151 | ||
|
|
8d7252f078 | ||
|
|
08399e753d | ||
|
|
8d721ccac8 | ||
|
|
b7a1b39c1a | ||
|
|
e276fb0386 | ||
|
|
e98244fe63 | ||
|
|
b348536d12 | ||
|
|
b528bb47a0 | ||
|
|
f86eb3fb82 | ||
|
|
0d46a3bc2e | ||
|
|
0418163ad7 | ||
|
|
2e67899bcc | ||
|
|
e2536ffe71 | ||
|
|
2c6b758f66 | ||
|
|
fb0f379c43 | ||
|
|
7a4aa9dcb1 | ||
|
|
4e8d37b0b5 | ||
|
|
616de3a9c0 | ||
|
|
16b3da66c2 | ||
|
|
691995eeaa | ||
|
|
045482e07d | ||
|
|
62f25d4d31 | ||
|
|
618c7028e2 | ||
|
|
13cec27f6b | ||
|
|
5b925517f0 | ||
|
|
167099badf | ||
|
|
40d8839bc4 | ||
|
|
da1e1a9859 | ||
|
|
43ad7654b6 | ||
|
|
1d4bbfa506 | ||
|
|
15d83724ea | ||
|
|
47652e9d25 | ||
|
|
4b689d00a4 | ||
|
|
b5315c2123 | ||
|
|
97ce4eaccd | ||
|
|
8814427677 | ||
|
|
4b69e192ec | ||
|
|
9c99f4868c | ||
|
|
39d59c3a5f | ||
|
|
ad9a12da0e | ||
|
|
9968776726 | ||
|
|
d99a88817d | ||
|
|
1b36cce816 | ||
|
|
4b157abd4d | ||
|
|
dc494bb0f9 | ||
|
|
b3e7b12b86 | ||
|
|
b69e6827cc | ||
|
|
340f459912 | ||
|
|
33a96d5a0f | ||
|
|
93d6db9d44 | ||
|
|
c1068af0ba | ||
|
|
482c2a4a6e | ||
|
|
2557a4de39 | ||
|
|
ab1f43f1ac | ||
|
|
f921524588 | ||
|
|
5cbd507c1e | ||
|
|
532bfaaa2d | ||
|
|
70b31a4212 | ||
|
|
9da3b0ea01 | ||
|
|
51df612c51 | ||
|
|
3be0cca230 | ||
|
|
283d13eb35 | ||
|
|
b21224d5ff | ||
|
|
4744d7b741 | ||
|
|
ac1dd74e23 | ||
|
|
970f486ec0 | ||
|
|
8c244e8b56 | ||
|
|
c3cc01c677 | ||
|
|
c63e60d782 | ||
|
|
11e8c9456d | ||
|
|
860a21f86f | ||
|
|
d24af18ff4 | ||
|
|
33b191f439 | ||
|
|
a690d39864 | ||
|
|
7c0586db7b | ||
|
|
461fd00ccd | ||
|
|
d33cabd6b2 | ||
|
|
7b21a9d30f | ||
|
|
c00e7eeecf | ||
|
|
afdb044386 | ||
|
|
b98552003c | ||
|
|
38f1754738 | ||
|
|
f872201fef | ||
|
|
ad23735384 | ||
|
|
6fd78d4647 | ||
|
|
cd3a80c502 | ||
|
|
f8c88ea8c7 | ||
|
|
4ba55c4067 | ||
|
|
813249bad7 | ||
|
|
162c58ac39 | ||
|
|
02d47d0a0d | ||
|
|
e86bf441ab | ||
|
|
f9617b8156 | ||
|
|
4650e30c09 | ||
|
|
2749965e73 | ||
|
|
e87965bda0 | ||
|
|
9f2c35d407 | ||
|
|
79af9efd29 | ||
|
|
9dcb3ec748 | ||
|
|
90c23d0245 | ||
|
|
99e238d92d | ||
|
|
b731f9b9e4 | ||
|
|
da90cdd9f6 | ||
|
|
f86c925209 | ||
|
|
0040e4d454 | ||
|
|
876d37d19a | ||
|
|
36d617bceb | ||
|
|
7c0528ad83 | ||
|
|
f25d51e772 | ||
|
|
8eb9709a04 | ||
|
|
5f31baa022 | ||
|
|
c115ab7a0d | ||
|
|
f3428494fc | ||
|
|
d748972fca | ||
|
|
b9c7925008 | ||
|
|
c11b93a4dc | ||
|
|
61e0688392 | ||
|
|
5971cdc6e2 | ||
|
|
b3a1d1269a | ||
|
|
a0011bd2e9 | ||
|
|
5e57325ce2 | ||
|
|
cd956dadda | ||
|
|
e6d556c809 | ||
|
|
f35b2be228 | ||
|
|
cc9cb966b5 | ||
|
|
34f9e08824 | ||
|
|
7d5db81017 | ||
|
|
1b03528aca | ||
|
|
9a90e46b78 | ||
|
|
5a9aa87831 | ||
|
|
8cfab08f9e | ||
|
|
b58834b11f | ||
|
|
d4811648f1 | ||
|
|
77fe1fa6f9 | ||
|
|
30804da259 | ||
|
|
1e2b8bad3f | ||
|
|
88a0737916 | ||
|
|
f5823bd618 | ||
|
|
d9453979b1 | ||
|
|
2cde74b91a | ||
|
|
3fd007fa3d | ||
|
|
e3431c7954 | ||
|
|
9fa715c709 | ||
|
|
03b7c07495 | ||
|
|
a3c08ceb7c | ||
|
|
e814fdd447 | ||
|
|
4d6231105f | ||
|
|
3a75c3446e | ||
|
|
29a76fd721 | ||
|
|
593bd89095 | ||
|
|
0079ed219b | ||
|
|
5957d99812 | ||
|
|
89453ec758 | ||
|
|
0de4f2f596 | ||
|
|
183cbecef6 | ||
|
|
ab6a49e568 | ||
|
|
52ddb29dc7 | ||
|
|
5ce7905a33 | ||
|
|
8748bd76e2 | ||
|
|
30f702ea96 |
9
.github/ISSUE_TEMPLATE/release.md
vendored
9
.github/ISSUE_TEMPLATE/release.md
vendored
@@ -27,7 +27,12 @@ assignees: ''
|
||||
- [ ] Move this issue to Test Ready.
|
||||
- [ ] Notify `@testers` in [#testing].
|
||||
- [ ] Test build: [Deploy to Staging] with release tag.
|
||||
- [ ] Notify a deployer to deploy it
|
||||
- [ ] Map is displayed correctly. Address changes are reflected in the map.
|
||||
- [ ] Stripe with no authentication card: `4242424242424242` as shopper and as Admin. Order confirmation displays order as "Paid".
|
||||
- [ ] Stripe with Authentication required card: `4000002760003184` as shopper and as Admin. As admin, check authorization through customer account `/account#/transactions` and email.
|
||||
- [ ] Pay with Paypal.
|
||||
- [ ] Order on mobile.
|
||||
- [ ] Notify a deployer to deploy it.
|
||||
|
||||
## 3. Deployment at beginning of week
|
||||
|
||||
@@ -57,4 +62,4 @@ The full process is described at https://github.com/openfoodfoundation/openfoodn
|
||||
[Create issue]: https://github.com/openfoodfoundation/openfoodnetwork/issues/new?assignees=&labels=&projects=&template=release.md&title=Release
|
||||
[#delivery-circle]: https://openfoodnetwork.slack.com/archives/C01T75H6G0Z
|
||||
[Transifex Client]: https://developers.transifex.com/docs/cli
|
||||
[minor or major breaking changes]: https://github.com/openfoodfoundation/openfoodnetwork/pulls?q=label%3A%22breaking+change%22%2C%22major+breaking+change%22
|
||||
[minor or major breaking changes]: https://github.com/openfoodfoundation/openfoodnetwork/pulls?q=label%3A%22breaking+change%22%2C%22major+breaking+change%22
|
||||
|
||||
4
.github/dependabot.yml
vendored
4
.github/dependabot.yml
vendored
@@ -31,6 +31,8 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
# Only specific requirements are specified in Gemfile, so don't touch it.
|
||||
versioning-strategy: lockfile-only
|
||||
@@ -39,6 +41,8 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
# Only specific requirements are specified in package.json, so don't touch it.
|
||||
versioning-strategy: lockfile-only
|
||||
|
||||
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -46,7 +46,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
uses: supercharge/redis-github-action@1.8.1
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
@@ -124,7 +124,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
uses: supercharge/redis-github-action@1.8.1
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
uses: supercharge/redis-github-action@1.8.1
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
@@ -290,7 +290,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
uses: supercharge/redis-github-action@1.8.1
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
|
||||
11
Gemfile
11
Gemfile
@@ -18,7 +18,7 @@ gem 'activemerchant'
|
||||
gem 'angular-rails-templates'
|
||||
gem 'ransack', '~> 4.1.0'
|
||||
gem 'responders'
|
||||
gem 'shakapacker', '7.2.3'
|
||||
gem 'shakapacker', '8.4.0'
|
||||
|
||||
# Indirect dependency but we access it directly in JS specs.
|
||||
# It turns out to be hard to upgrade but please do if you can.
|
||||
@@ -58,6 +58,7 @@ gem 'stringex', '~> 2.8.5', require: false
|
||||
|
||||
gem 'paypal-sdk-merchant', '1.117.2'
|
||||
gem 'stripe', '~> 15'
|
||||
gem "taler"
|
||||
|
||||
gem 'devise'
|
||||
gem 'devise-encryptable'
|
||||
@@ -111,7 +112,7 @@ gem "turbo_power"
|
||||
gem "turbo-rails"
|
||||
|
||||
gem 'combine_pdf'
|
||||
gem 'wicked_pdf'
|
||||
gem 'wicked_pdf', github: "openfoodfoundation/wicked_pdf", branch: "master"
|
||||
gem 'wkhtmltopdf-binary'
|
||||
|
||||
gem 'immigrant'
|
||||
@@ -126,9 +127,8 @@ gem 'angular_rails_csrf'
|
||||
|
||||
gem 'jquery-rails', '4.4.0'
|
||||
gem 'jquery-ui-rails', '~> 4.2'
|
||||
# TODO move away from sass-rails, master branch will get rid of dependency, so we can move to
|
||||
# https://github.com/sass/embedded-host-node
|
||||
gem "select2-rails", github: "openfoodfoundation/select2-rails", branch: "v349_with_thor_v1"
|
||||
gem "select2-rails", github: "openfoodfoundation/select2-rails",
|
||||
branch: "v349_with-relaxed-dependencies"
|
||||
|
||||
gem 'good_migrations'
|
||||
|
||||
@@ -203,6 +203,7 @@ group :development do
|
||||
gem 'spring'
|
||||
gem 'spring-commands-rspec'
|
||||
gem 'spring-commands-rubocop'
|
||||
gem 'spring-watcher-listen'
|
||||
gem 'web-console'
|
||||
|
||||
gem 'rack-mini-profiler', '< 3.0.0'
|
||||
|
||||
194
Gemfile.lock
194
Gemfile.lock
@@ -10,13 +10,21 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: https://github.com/openfoodfoundation/select2-rails.git
|
||||
revision: fc240e85fbdf1878ff3c39d972c0cd9a312f5ed4
|
||||
branch: v349_with_thor_v1
|
||||
revision: 9693e0cc5b04938da46692d3fa83aa8934791981
|
||||
branch: v349_with-relaxed-dependencies
|
||||
specs:
|
||||
select2-rails (3.4.9)
|
||||
sass-rails
|
||||
thor (>= 0.14)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/openfoodfoundation/wicked_pdf.git
|
||||
revision: bce498de547cdf00d037fdbec29fae844d69ee8e
|
||||
branch: master
|
||||
specs:
|
||||
wicked_pdf (2.8.1)
|
||||
activesupport
|
||||
ostruct
|
||||
|
||||
GIT
|
||||
remote: https://github.com/podia/stimulus_reflex_testing.git
|
||||
revision: abac2ee34de347c589795b4d1a8e83e0baafb201
|
||||
@@ -104,7 +112,7 @@ GEM
|
||||
rails-html-sanitizer (~> 1.6)
|
||||
active_model_serializers (0.8.4)
|
||||
activemodel (>= 3.0)
|
||||
active_storage_validations (3.0.2)
|
||||
active_storage_validations (3.0.3)
|
||||
activejob (>= 6.1.4)
|
||||
activemodel (>= 6.1.4)
|
||||
activestorage (>= 6.1.4)
|
||||
@@ -162,7 +170,7 @@ GEM
|
||||
addressable (2.8.8)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
aes_key_wrap (1.1.0)
|
||||
afm (0.2.2)
|
||||
afm (1.0.0)
|
||||
angular-rails-templates (1.4.0)
|
||||
railties (>= 5.0, < 8.2)
|
||||
sprockets (>= 3.0, < 5)
|
||||
@@ -202,12 +210,12 @@ GEM
|
||||
bigdecimal (3.3.1)
|
||||
bindata (2.5.1)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.19.0)
|
||||
bootsnap (1.22.0)
|
||||
msgpack (~> 1.2)
|
||||
bugsnag (6.28.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
builder (3.3.0)
|
||||
bullet (8.0.8)
|
||||
bullet (8.1.0)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
cable_ready (5.0.6)
|
||||
@@ -234,7 +242,7 @@ GEM
|
||||
marcel (~> 1.0)
|
||||
nokogiri (~> 1.10, >= 1.10.4)
|
||||
rubyzip (>= 1.3.0, < 3)
|
||||
cgi (0.5.0)
|
||||
cgi (0.5.1)
|
||||
childprocess (5.0.0)
|
||||
choice (0.2.0)
|
||||
chronic (0.10.2)
|
||||
@@ -249,7 +257,7 @@ GEM
|
||||
combine_pdf (1.0.31)
|
||||
matrix
|
||||
ruby-rc4 (>= 0.1.5)
|
||||
concurrent-ruby (1.3.5)
|
||||
concurrent-ruby (1.3.6)
|
||||
connection_pool (2.5.5)
|
||||
cookiejar (0.3.4)
|
||||
crack (1.0.1)
|
||||
@@ -259,9 +267,9 @@ GEM
|
||||
css_parser (1.21.1)
|
||||
addressable
|
||||
csv (3.3.5)
|
||||
cuprite (0.15)
|
||||
cuprite (0.17)
|
||||
capybara (~> 3.0)
|
||||
ferrum (~> 0.14.0)
|
||||
ferrum (~> 0.17.0)
|
||||
database_cleaner (2.1.0)
|
||||
database_cleaner-active_record (>= 2, < 3)
|
||||
database_cleaner-active_record (2.2.2)
|
||||
@@ -270,7 +278,7 @@ GEM
|
||||
database_cleaner-core (2.0.1)
|
||||
datafoodconsortium-connector (1.2.0)
|
||||
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
|
||||
date (3.5.0)
|
||||
date (3.5.1)
|
||||
debug (1.11.0)
|
||||
irb (~> 1.10)
|
||||
reline (>= 0.3.8)
|
||||
@@ -305,9 +313,9 @@ GEM
|
||||
eventmachine (>= 1.0.0.beta.1)
|
||||
email_validator (2.2.4)
|
||||
activemodel
|
||||
erb (6.0.0)
|
||||
erb (6.0.2)
|
||||
erubi (1.13.1)
|
||||
et-orbi (1.3.0)
|
||||
et-orbi (1.4.0)
|
||||
tzinfo
|
||||
eventmachine (1.2.7)
|
||||
eventmachine_httpserver (0.2.1)
|
||||
@@ -318,19 +326,22 @@ GEM
|
||||
factory_bot_rails (6.2.0)
|
||||
factory_bot (~> 6.2.0)
|
||||
railties (>= 5.0.0)
|
||||
faraday (2.9.0)
|
||||
faraday-net_http (>= 2.0, < 3.2)
|
||||
faraday (2.14.1)
|
||||
faraday-net_http (>= 2.0, < 3.5)
|
||||
json
|
||||
logger
|
||||
faraday-follow_redirects (0.4.0)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-net_http (3.1.1)
|
||||
net-http
|
||||
ferrum (0.14)
|
||||
faraday-net_http (3.4.2)
|
||||
net-http (~> 0.5)
|
||||
ferrum (0.17.1)
|
||||
addressable (~> 2.5)
|
||||
base64 (~> 0.2)
|
||||
concurrent-ruby (~> 1.1)
|
||||
webrick (~> 1.7)
|
||||
websocket-driver (>= 0.6, < 0.8)
|
||||
websocket-driver (~> 0.7)
|
||||
ffaker (2.25.0)
|
||||
ffi (1.17.2)
|
||||
ffi (1.17.3)
|
||||
flipper (1.3.6)
|
||||
concurrent-ruby (< 2)
|
||||
flipper-active_record (1.3.6)
|
||||
@@ -361,8 +372,8 @@ GEM
|
||||
foreman (0.90.0)
|
||||
thor (~> 1.4)
|
||||
formatador (0.2.5)
|
||||
fugit (1.11.1)
|
||||
et-orbi (~> 1, >= 1.2.11)
|
||||
fugit (1.12.1)
|
||||
et-orbi (~> 1.4)
|
||||
raabro (~> 1.4)
|
||||
fuubar (2.5.1)
|
||||
rspec-core (~> 3.0)
|
||||
@@ -388,12 +399,13 @@ GEM
|
||||
sysexits (~> 1.1)
|
||||
hashdiff (1.2.1)
|
||||
hashery (2.1.2)
|
||||
hashie (5.0.0)
|
||||
hashie (5.1.0)
|
||||
logger
|
||||
highline (3.1.2)
|
||||
reline
|
||||
htmlentities (4.4.2)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.14.7)
|
||||
i18n (1.14.8)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-js (3.9.2)
|
||||
i18n (>= 0.6.6)
|
||||
@@ -417,10 +429,11 @@ GEM
|
||||
activerecord (>= 3.0)
|
||||
invisible_captcha (2.3.0)
|
||||
rails (>= 5.2)
|
||||
io-console (0.8.1)
|
||||
io-console (0.8.2)
|
||||
ipaddress (0.8.3)
|
||||
irb (1.15.3)
|
||||
irb (1.17.0)
|
||||
pp (>= 0.6.0)
|
||||
prism (>= 1.3.0)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
jmespath (1.6.2)
|
||||
@@ -430,7 +443,7 @@ GEM
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (4.2.1)
|
||||
railties (>= 3.2.16)
|
||||
json (2.15.2)
|
||||
json (2.18.1)
|
||||
json-canonicalization (1.0.0)
|
||||
json-jwt (1.17.0)
|
||||
activesupport (>= 4.2)
|
||||
@@ -456,7 +469,7 @@ GEM
|
||||
activesupport (>= 4.2)
|
||||
jwt (2.10.2)
|
||||
base64
|
||||
knapsack_pro (8.4.0)
|
||||
knapsack_pro (9.2.2)
|
||||
rake
|
||||
language_server-protocol (3.17.0.5)
|
||||
launchy (3.0.0)
|
||||
@@ -466,11 +479,12 @@ GEM
|
||||
launchy (>= 2.2, < 4)
|
||||
link_header (0.0.8)
|
||||
lint_roller (1.1.0)
|
||||
listen (3.9.0)
|
||||
listen (3.10.0)
|
||||
logger
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
logger (1.7.0)
|
||||
loofah (2.24.1)
|
||||
loofah (2.25.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.12.0)
|
||||
mail (2.9.0)
|
||||
@@ -493,7 +507,9 @@ GEM
|
||||
logger
|
||||
mini_mime (1.1.5)
|
||||
mini_portile2 (2.8.6)
|
||||
minitest (5.26.2)
|
||||
minitest (6.0.2)
|
||||
drb (~> 2.0)
|
||||
prism (~> 1.5)
|
||||
monetize (1.13.0)
|
||||
money (~> 6.12)
|
||||
money (6.16.0)
|
||||
@@ -502,8 +518,8 @@ GEM
|
||||
multi_json (1.17.0)
|
||||
multi_xml (0.6.0)
|
||||
mutex_m (0.3.0)
|
||||
net-http (0.7.0)
|
||||
uri
|
||||
net-http (0.9.1)
|
||||
uri (>= 0.11.1)
|
||||
net-imap (0.5.12)
|
||||
date
|
||||
net-protocol
|
||||
@@ -515,7 +531,7 @@ GEM
|
||||
net-protocol
|
||||
newrelic_rpm (9.24.0)
|
||||
nio4r (2.7.5)
|
||||
nokogiri (1.18.10)
|
||||
nokogiri (1.19.1)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
nokogiri-html5-inference (0.3.0)
|
||||
@@ -532,7 +548,7 @@ GEM
|
||||
logger
|
||||
rack (>= 2.2.3)
|
||||
rack-protection
|
||||
omniauth-rails_csrf_protection (1.0.2)
|
||||
omniauth-rails_csrf_protection (2.0.1)
|
||||
actionpack (>= 4.2)
|
||||
omniauth (~> 2.0)
|
||||
omniauth_openid_connect (0.8.0)
|
||||
@@ -561,7 +577,7 @@ GEM
|
||||
parallel (1.27.0)
|
||||
paranoia (2.6.4)
|
||||
activerecord (>= 5.1, < 7.2)
|
||||
parser (3.3.10.0)
|
||||
parser (3.3.10.2)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
paypal-sdk-core (0.3.4)
|
||||
@@ -569,7 +585,7 @@ GEM
|
||||
xml-simple
|
||||
paypal-sdk-merchant (1.117.2)
|
||||
paypal-sdk-core (~> 0.3.0)
|
||||
pdf-reader (2.15.0)
|
||||
pdf-reader (2.15.1)
|
||||
Ascii85 (>= 1.0, < 3.0, != 2.0.0)
|
||||
afm (>= 0.2.1, < 2)
|
||||
hashery (~> 2.0)
|
||||
@@ -579,15 +595,16 @@ GEM
|
||||
pp (0.6.3)
|
||||
prettyprint
|
||||
prettyprint (0.2.0)
|
||||
prism (1.7.0)
|
||||
prism (1.9.0)
|
||||
private_address_check (0.5.0)
|
||||
pry (0.15.2)
|
||||
pry (0.16.0)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
psych (5.2.6)
|
||||
reline (>= 0.6.0)
|
||||
psych (5.3.1)
|
||||
date
|
||||
stringio
|
||||
public_suffix (7.0.0)
|
||||
public_suffix (7.0.2)
|
||||
puffing-billy (4.0.2)
|
||||
addressable (~> 2.5)
|
||||
em-http-request (~> 1.1, >= 1.1.0)
|
||||
@@ -603,7 +620,7 @@ GEM
|
||||
railties (>= 4.2)
|
||||
raabro (1.4.0)
|
||||
racc (1.8.1)
|
||||
rack (2.2.21)
|
||||
rack (2.2.22)
|
||||
rack-mini-profiler (2.3.4)
|
||||
rack (>= 1.2.0)
|
||||
rack-oauth2 (2.3.0)
|
||||
@@ -654,8 +671,8 @@ GEM
|
||||
activesupport (>= 4.2)
|
||||
choice (~> 0.2.0)
|
||||
ruby-graphviz (~> 1.2)
|
||||
rails-html-sanitizer (1.6.2)
|
||||
loofah (~> 2.21)
|
||||
rails-html-sanitizer (1.7.0)
|
||||
loofah (~> 2.25)
|
||||
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
||||
rails-i18n (7.0.10)
|
||||
i18n (>= 0.7, < 2)
|
||||
@@ -677,7 +694,7 @@ GEM
|
||||
activesupport (>= 6.1.5)
|
||||
i18n
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
rb-inotify (0.11.1)
|
||||
ffi (~> 1.0)
|
||||
rdf (3.3.4)
|
||||
bcp47_spec (~> 0.2)
|
||||
@@ -686,7 +703,7 @@ GEM
|
||||
logger (~> 1.5)
|
||||
ostruct (~> 0.6)
|
||||
readline (~> 0.0)
|
||||
rdoc (6.16.0)
|
||||
rdoc (7.2.0)
|
||||
erb
|
||||
psych (>= 4.0.0)
|
||||
tsort
|
||||
@@ -695,16 +712,16 @@ GEM
|
||||
redcarpet (3.6.1)
|
||||
redis (5.4.1)
|
||||
redis-client (>= 0.22.0)
|
||||
redis-client (0.26.1)
|
||||
redis-client (0.26.4)
|
||||
connection_pool
|
||||
regexp_parser (2.11.3)
|
||||
reline (0.6.3)
|
||||
io-console (~> 0.5)
|
||||
request_store (1.7.0)
|
||||
rack (>= 1.4)
|
||||
responders (3.1.1)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
responders (3.2.0)
|
||||
actionpack (>= 7.0)
|
||||
railties (>= 7.0)
|
||||
rexml (3.4.4)
|
||||
roadie (5.2.1)
|
||||
css_parser (~> 1.4)
|
||||
@@ -759,7 +776,7 @@ GEM
|
||||
rswag-ui (2.17.0)
|
||||
actionpack (>= 5.2, < 8.2)
|
||||
railties (>= 5.2, < 8.2)
|
||||
rubocop (1.81.7)
|
||||
rubocop (1.84.2)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
@@ -767,25 +784,25 @@ GEM
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 2.9.3, < 3.0)
|
||||
rubocop-ast (>= 1.47.1, < 2.0)
|
||||
rubocop-ast (>= 1.49.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 4.0)
|
||||
rubocop-ast (1.48.0)
|
||||
rubocop-ast (1.49.0)
|
||||
parser (>= 3.3.7.2)
|
||||
prism (~> 1.4)
|
||||
prism (~> 1.7)
|
||||
rubocop-capybara (2.22.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-factory_bot (2.28.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rails (2.34.2)
|
||||
rubocop-rails (2.34.3)
|
||||
activesupport (>= 4.2.0)
|
||||
lint_roller (~> 1.1)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.75.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
rubocop-rspec (3.8.0)
|
||||
rubocop-rspec (3.9.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.81)
|
||||
rubocop-rspec_rails (2.32.0)
|
||||
@@ -800,23 +817,16 @@ GEM
|
||||
ffi (~> 1.12)
|
||||
logger
|
||||
rubyzip (2.4.1)
|
||||
rufus-scheduler (3.8.2)
|
||||
fugit (~> 1.1, >= 1.1.6)
|
||||
rufus-scheduler (3.9.2)
|
||||
fugit (~> 1.1, >= 1.11.1)
|
||||
rugged (1.9.0)
|
||||
sanitize (7.0.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.16.8)
|
||||
sass (3.4.25)
|
||||
sass-rails (5.0.8)
|
||||
railties (>= 5.2.0)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
sd_notify (0.1.1)
|
||||
securerandom (0.4.1)
|
||||
semantic_range (3.1.0)
|
||||
shakapacker (7.2.3)
|
||||
shakapacker (8.4.0)
|
||||
activesupport (>= 5.2)
|
||||
package_json
|
||||
rack-proxy (>= 0.6.1)
|
||||
@@ -824,15 +834,15 @@ GEM
|
||||
semantic_range (>= 2.3.0)
|
||||
shoulda-matchers (7.0.1)
|
||||
activesupport (>= 7.1)
|
||||
sidekiq (7.2.4)
|
||||
concurrent-ruby (< 2)
|
||||
connection_pool (>= 2.3.0)
|
||||
rack (>= 2.2.4)
|
||||
redis-client (>= 0.19.0)
|
||||
sidekiq-scheduler (5.0.3)
|
||||
sidekiq (7.3.10)
|
||||
base64
|
||||
connection_pool (>= 2.3.0, < 3)
|
||||
logger
|
||||
rack (>= 2.2.4, < 3.3)
|
||||
redis-client (>= 0.23.0, < 1)
|
||||
sidekiq-scheduler (6.0.1)
|
||||
rufus-scheduler (~> 3.2)
|
||||
sidekiq (>= 6, < 8)
|
||||
tilt (>= 1.4.0)
|
||||
sidekiq (>= 7.3, < 9)
|
||||
simplecov (0.22.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
@@ -843,11 +853,14 @@ GEM
|
||||
caxlsx (<= 4.0)
|
||||
csv
|
||||
rodf
|
||||
spring (4.4.0)
|
||||
spring (4.4.2)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
spring-commands-rubocop (0.4.0)
|
||||
spring (>= 1.0)
|
||||
spring-watcher-listen (2.1.0)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 4)
|
||||
sprockets (3.7.5)
|
||||
base64
|
||||
concurrent-ruby (~> 1.0)
|
||||
@@ -876,7 +889,7 @@ GEM
|
||||
railties (>= 5.2)
|
||||
redis (>= 4.0, < 6.0)
|
||||
stringex (2.8.6)
|
||||
stringio (3.1.8)
|
||||
stringio (3.2.0)
|
||||
stripe (15.5.0)
|
||||
swd (2.0.3)
|
||||
activesupport (>= 3)
|
||||
@@ -884,17 +897,18 @@ GEM
|
||||
faraday (~> 2.0)
|
||||
faraday-follow_redirects
|
||||
sysexits (1.2.0)
|
||||
taler (0.2.0)
|
||||
temple (0.10.4)
|
||||
terminal-table (4.0.0)
|
||||
unicode-display_width (>= 1.1.1, < 4)
|
||||
thor (1.4.0)
|
||||
thor (1.5.0)
|
||||
thread-local (1.1.0)
|
||||
tilt (2.6.1)
|
||||
timeout (0.4.4)
|
||||
tilt (2.7.0)
|
||||
timeout (0.6.0)
|
||||
tsort (0.2.0)
|
||||
ttfunk (1.8.0)
|
||||
bigdecimal (~> 3.1)
|
||||
turbo-rails (2.0.20)
|
||||
turbo-rails (2.0.23)
|
||||
actionpack (>= 7.1.0)
|
||||
railties (>= 7.1.0)
|
||||
turbo_power (0.7.0)
|
||||
@@ -912,7 +926,7 @@ GEM
|
||||
unicode-display_width (3.2.0)
|
||||
unicode-emoji (~> 4.1)
|
||||
unicode-emoji (4.2.0)
|
||||
uniform_notifier (1.17.0)
|
||||
uniform_notifier (1.18.0)
|
||||
uri (1.1.1)
|
||||
valid_email2 (5.2.3)
|
||||
activemodel (>= 3.2)
|
||||
@@ -922,8 +936,7 @@ GEM
|
||||
public_suffix
|
||||
validates_lengths_from_database (0.8.0)
|
||||
activerecord (>= 4)
|
||||
vcr (6.3.1)
|
||||
base64
|
||||
vcr (6.4.0)
|
||||
view_component (4.1.1)
|
||||
actionview (>= 7.1.0, < 8.2)
|
||||
activesupport (>= 7.1.0, < 8.2)
|
||||
@@ -950,20 +963,17 @@ GEM
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
webrick (1.9.2)
|
||||
websocket-driver (0.7.7)
|
||||
websocket-driver (0.8.0)
|
||||
base64
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
whenever (1.1.0)
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (2.8.2)
|
||||
activesupport
|
||||
ostruct
|
||||
wkhtmltopdf-binary (0.12.6.10)
|
||||
xml-simple (1.1.8)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.7.3)
|
||||
zeitwerk (2.7.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -1085,7 +1095,7 @@ DEPENDENCIES
|
||||
rubocop-rspec_rails
|
||||
sd_notify
|
||||
select2-rails!
|
||||
shakapacker (= 7.2.3)
|
||||
shakapacker (= 8.4.0)
|
||||
shoulda-matchers
|
||||
sidekiq
|
||||
sidekiq-scheduler
|
||||
@@ -1094,12 +1104,14 @@ DEPENDENCIES
|
||||
spring
|
||||
spring-commands-rspec
|
||||
spring-commands-rubocop
|
||||
spring-watcher-listen
|
||||
sprockets (~> 3.7)
|
||||
state_machines-activerecord
|
||||
stimulus_reflex
|
||||
stimulus_reflex_testing!
|
||||
stringex (~> 2.8.5)
|
||||
stripe (~> 15)
|
||||
taler
|
||||
turbo-rails
|
||||
turbo_power
|
||||
undercover
|
||||
@@ -1112,7 +1124,7 @@ DEPENDENCIES
|
||||
web-console
|
||||
webmock
|
||||
whenever
|
||||
wicked_pdf
|
||||
wicked_pdf!
|
||||
wkhtmltopdf-binary
|
||||
|
||||
RUBY VERSION
|
||||
|
||||
2
Procfile
2
Procfile
@@ -1,5 +1,5 @@
|
||||
# Foreman Procfile. Start all dev server processes with: `foreman start`
|
||||
|
||||
rails: DEV_CACHING=true bundle exec rails s -p 3000
|
||||
webpack: ./bin/shakacker-dev-server
|
||||
webpack: ./bin/shakapacker-dev-server
|
||||
sidekiq: DEV_CACHING=true bundle exec sidekiq -q mailers -q default
|
||||
|
||||
@@ -4,16 +4,12 @@ angular.module("admin.enterprises")
|
||||
$scope.Enterprises = Enterprises
|
||||
$scope.navClear = NavigationCheck.clear
|
||||
$scope.menu = SideMenu
|
||||
$scope.newManager = { id: null, email: (t('add_manager')) }
|
||||
$scope.StatusMessage = StatusMessage
|
||||
$scope.RequestMonitor = RequestMonitor
|
||||
|
||||
$scope.$watch 'enterprise_form.$dirty', (newValue) ->
|
||||
StatusMessage.display 'notice', t('admin.unsaved_changes') if newValue
|
||||
|
||||
$scope.$watch 'newManager', (newValue) ->
|
||||
$scope.addManager($scope.newManager) if newValue
|
||||
|
||||
$scope.setFormDirty = ->
|
||||
$scope.$apply ->
|
||||
$scope.enterprise_form.$setDirty()
|
||||
@@ -35,26 +31,6 @@ angular.module("admin.enterprises")
|
||||
# Register the NavigationCheck callback
|
||||
NavigationCheck.register(enterpriseNavCallback)
|
||||
|
||||
$scope.removeManager = (manager) ->
|
||||
if manager.id?
|
||||
if manager.id == $scope.Enterprise.owner.id or manager.id == parseInt($scope.receivesNotifications)
|
||||
return
|
||||
for i, user of $scope.Enterprise.users when user.id == manager.id
|
||||
$scope.Enterprise.users.splice i, 1
|
||||
$scope.enterprise_form?.$setDirty()
|
||||
|
||||
$scope.addManager = (manager) ->
|
||||
if manager.id? and angular.isNumber(manager.id) and manager.email?
|
||||
manager =
|
||||
id: manager.id
|
||||
email: manager.email
|
||||
confirmed: manager.confirmed
|
||||
if (user for user in $scope.Enterprise.users when user.id == manager.id).length == 0
|
||||
$scope.Enterprise.users.unshift(manager)
|
||||
$scope.enterprise_form?.$setDirty()
|
||||
else
|
||||
alert ("#{manager.email}" + " " + t("is_already_manager"))
|
||||
|
||||
$scope.performEnterpriseAction = (enterpriseActionName, warning_message_key, success_message_key) ->
|
||||
return unless confirm($scope.translation(warning_message_key))
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
angular.module('Darkswarm').controller "HomeCtrl", ($scope) ->
|
||||
$scope.brandStoryExpanded = false
|
||||
|
||||
$scope.toggleBrandStory = ->
|
||||
$scope.brandStoryExpanded = !$scope.brandStoryExpanded
|
||||
@@ -1 +0,0 @@
|
||||
@import './mail/all.scss';
|
||||
@@ -1,3 +0,0 @@
|
||||
@import '../../../webpacker/css/admin/globals/palette.scss';
|
||||
@import 'email';
|
||||
@import 'payments_list';
|
||||
@@ -9,6 +9,11 @@
|
||||
padding: 1.2rem;
|
||||
}
|
||||
|
||||
&.big {
|
||||
max-height: 50em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SearchableDropdownComponent < ViewComponent::Base
|
||||
REMOVED_SEARCH_PLUGIN = { 'tom-select-options-value': '{ "plugins": [] }' }.freeze
|
||||
MINIMUM_OPTIONS_FOR_SEARCH_FIELD = 11 # at least 11 options are required for the search field
|
||||
|
||||
def initialize(
|
||||
form:,
|
||||
name:,
|
||||
options:,
|
||||
selected_option:,
|
||||
placeholder_value:,
|
||||
form: nil,
|
||||
placeholder_value: '',
|
||||
include_blank: false,
|
||||
aria_label: '',
|
||||
multiple: false,
|
||||
remote_url: nil,
|
||||
other_attrs: {}
|
||||
)
|
||||
@f = form
|
||||
@@ -21,13 +22,15 @@ class SearchableDropdownComponent < ViewComponent::Base
|
||||
@placeholder_value = placeholder_value
|
||||
@include_blank = include_blank
|
||||
@aria_label = aria_label
|
||||
@multiple = multiple
|
||||
@remote_url = remote_url
|
||||
@other_attrs = other_attrs
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :f, :name, :options, :selected_option, :placeholder_value, :include_blank,
|
||||
:aria_label, :other_attrs
|
||||
:aria_label, :multiple, :remote_url, :other_attrs
|
||||
|
||||
def classes
|
||||
"fullwidth #{'no-input' if remove_search_plugin?}"
|
||||
@@ -36,11 +39,33 @@ class SearchableDropdownComponent < ViewComponent::Base
|
||||
def data
|
||||
{
|
||||
controller: "tom-select",
|
||||
'tom-select-placeholder-value': placeholder_value
|
||||
}.merge(remove_search_plugin? ? REMOVED_SEARCH_PLUGIN : {})
|
||||
'tom-select-placeholder-value': placeholder_value,
|
||||
'tom-select-options-value': tom_select_options_value,
|
||||
'tom-select-remote-url-value': remote_url,
|
||||
}
|
||||
end
|
||||
|
||||
def tom_select_options_value
|
||||
plugins = []
|
||||
plugins << 'virtual_scroll' if @remote_url.present?
|
||||
plugins << 'dropdown_input' unless remove_search_plugin?
|
||||
plugins << 'remove_button' if multiple
|
||||
|
||||
{
|
||||
plugins:,
|
||||
maxItems: multiple ? nil : 1,
|
||||
}
|
||||
end
|
||||
|
||||
def uses_form_builder?
|
||||
f.present?
|
||||
end
|
||||
|
||||
def remove_search_plugin?
|
||||
@remove_search_plugin ||= options.count < MINIMUM_OPTIONS_FOR_SEARCH_FIELD
|
||||
# Remove the search plugin when:
|
||||
# - the select is multiple (it already includes a search field), or
|
||||
# - there is no remote URL and the options are below the search threshold
|
||||
@remove_search_plugin ||= multiple ||
|
||||
(@remote_url.nil? && options.count < MINIMUM_OPTIONS_FOR_SEARCH_FIELD)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
= f.select name, options_for_select(options, selected_option), { include_blank: }, class: classes, data:, 'aria-label': aria_label, **other_attrs
|
||||
- if uses_form_builder?
|
||||
= f.select name, options, { selected: selected_option, include_blank:, multiple: }, class: classes, data:, 'aria-label': aria_label, **other_attrs
|
||||
- else
|
||||
= select_tag name, options_for_select(options, selected_option), include_blank:, multiple:, class: classes, data:, 'aria-label': aria_label, **other_attrs
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class CustomerAccountTransactionController < Admin::ResourceController
|
||||
def index
|
||||
@available_credit = @collection.first&.balance || 0.00
|
||||
|
||||
respond_with do |format|
|
||||
format.turbo_stream {
|
||||
render :index
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# We are using an old version of CanCanCan so I could not get `accessible_by` to work properly,
|
||||
# so we are doing our own authorization before calling 'accessible_by'
|
||||
def collection
|
||||
allowed_customers = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.managed_enterprises.joins(:customers).select("customers.id").map(&:id)
|
||||
raise CanCan::AccessDenied unless allowed_customers.include?(params[:customer_id].to_i)
|
||||
|
||||
CustomerAccountTransaction.accessible_by(current_ability, action)
|
||||
.where(customer_id: params[:customer_id]).order(id: :desc)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,6 @@ module Admin
|
||||
def update
|
||||
tag_rules_attributes = params[object_name].delete :tag_rules_attributes
|
||||
update_tag_rules(tag_rules_attributes) if tag_rules_attributes.present?
|
||||
update_enterprise_notifications
|
||||
update_vouchers
|
||||
|
||||
delete_custom_tab if params[:custom_tab] == 'false'
|
||||
@@ -163,9 +162,11 @@ module Admin
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @object.destroy
|
||||
@object.transaction do
|
||||
@object.destroy!
|
||||
flash.now[:success] = flash_message_for(@object, :successfully_removed)
|
||||
else
|
||||
rescue StandardError
|
||||
Rails.logger.error @object.errors.full_messages.to_sentence
|
||||
flash.now[:error] = @object.errors.full_messages.to_sentence
|
||||
end
|
||||
|
||||
@@ -177,7 +178,7 @@ module Admin
|
||||
protected
|
||||
|
||||
def delete_custom_tab
|
||||
@object.custom_tab.destroy if @object.custom_tab.present?
|
||||
@object.custom_tab.presence&.destroy
|
||||
enterprise_params.delete(:custom_tab_attributes)
|
||||
end
|
||||
|
||||
@@ -240,9 +241,7 @@ module Admin
|
||||
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, @order_cycle)
|
||||
.visible_enterprises
|
||||
|
||||
if enterprises.present?
|
||||
enterprises.includes(supplied_products: [:variants, :image])
|
||||
end
|
||||
enterprises.presence&.includes(supplied_products: [:variants, :image])
|
||||
when :index
|
||||
if spree_current_user.admin?
|
||||
OpenFoodNetwork::Permissions.new(spree_current_user).
|
||||
@@ -314,14 +313,6 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def update_enterprise_notifications
|
||||
user_id = params[:receives_notifications].to_i
|
||||
|
||||
return unless user_id.positive? && @enterprise.user_ids.include?(user_id)
|
||||
|
||||
@enterprise.update_contact(user_id)
|
||||
end
|
||||
|
||||
def update_vouchers
|
||||
params_voucher_ids = params[:enterprise][:voucher_ids].to_a.map(&:to_i)
|
||||
voucher_ids = @enterprise.vouchers.map(&:id)
|
||||
|
||||
@@ -28,7 +28,7 @@ module Admin
|
||||
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 }]
|
||||
producer_id: @producer_id, category_id: @category_id, tags_name_in: @tags }]
|
||||
elsif product_set.errors.present?
|
||||
@error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count }
|
||||
|
||||
@@ -120,7 +120,7 @@ module Admin
|
||||
@search_term = params[:search_term] || params[:_search_term]
|
||||
@producer_id = params[:producer_id] || params[:_producer_id]
|
||||
@category_id = params[:category_id] || params[:_category_id]
|
||||
@tags = params[:tags_name_in] || params[:_tags_name_in]
|
||||
@tags = params[:tags_name_in] || []
|
||||
end
|
||||
|
||||
def init_pagination_params
|
||||
|
||||
@@ -4,6 +4,7 @@ module Admin
|
||||
class ReportsController < Spree::Admin::BaseController
|
||||
include ActiveStorage::SetCurrent
|
||||
include ReportsActions
|
||||
include Reports::AjaxSearch
|
||||
|
||||
helper ReportsHelper
|
||||
|
||||
|
||||
31
app/controllers/admin/user_invitations_controller.rb
Normal file
31
app/controllers/admin/user_invitations_controller.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class UserInvitationsController < ResourceController
|
||||
before_action :load_enterprise
|
||||
|
||||
def new; end
|
||||
|
||||
def create
|
||||
@user_invitation.attributes = permitted_resource_params
|
||||
if @user_invitation.save!
|
||||
flash[:success] = I18n.t(:user_invited, email: @user_invitation.email)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_enterprise
|
||||
@enterprise = OpenFoodNetwork::Permissions
|
||||
.new(spree_current_user)
|
||||
.editable_enterprises
|
||||
.find_by(permalink: params[:enterprise_id])
|
||||
end
|
||||
|
||||
def permitted_resource_params
|
||||
params.require(:user_invitation).permit(:email).merge(enterprise: @enterprise)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V1
|
||||
class CustomerAccountTransactionController < Api::V1::BaseController
|
||||
def create
|
||||
authorize! :create, CustomerAccountTransaction
|
||||
|
||||
default_params = {
|
||||
currency: CurrentConfig.get(:currency), created_by: current_api_user
|
||||
}
|
||||
parameters = default_params.merge(customer_account_transaction_params).merge(description: )
|
||||
transaction = CustomerAccountTransaction.new(parameters)
|
||||
|
||||
if transaction.save
|
||||
render json: Api::V1::CustomerAccountTransactionSerializer.new(transaction),
|
||||
status: :created
|
||||
else
|
||||
invalid_resource! transaction
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def customer_account_transaction_params
|
||||
params.require(:customer_account_transaction).permit(:customer_id, :amount, :description)
|
||||
end
|
||||
|
||||
def description
|
||||
I18n.t(".api_customer_credit", description: params[:description])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -31,6 +31,11 @@ class CheckoutController < BaseController
|
||||
check_step
|
||||
end
|
||||
|
||||
if payment_step? || summary_step?
|
||||
credit_payment_method = @order.distributor.payment_methods.customer_credit
|
||||
@paid_with_credit = @order.payments.find_by(payment_method: credit_payment_method)&.amount
|
||||
end
|
||||
|
||||
return if available_shipping_methods.any?
|
||||
|
||||
flash[:error] = I18n.t('checkout.errors.no_shipping_methods_available')
|
||||
@@ -121,7 +126,9 @@ class CheckoutController < BaseController
|
||||
shipping_method_updated = @order.shipping_method&.id != params[:shipping_method_id].to_i
|
||||
|
||||
@order.select_shipping_method(params[:shipping_method_id])
|
||||
|
||||
@order.update(order_params)
|
||||
|
||||
# We need to update voucher to take into account:
|
||||
# * when moving away from "details" step : potential change in shipping method fees
|
||||
# * when moving away from "payment" step : payment fees
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ManagerInvitations
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def create_new_manager(email, enterprise)
|
||||
password = SecureRandom.base58(64)
|
||||
new_user = Spree::User.create(email:, unconfirmed_email: email, password:)
|
||||
new_user.reset_password_token = Devise.friendly_token
|
||||
# Same time as used in Devise's lib/devise/models/recoverable.rb.
|
||||
new_user.reset_password_sent_at = Time.now.utc
|
||||
if new_user.save
|
||||
enterprise.users << new_user
|
||||
EnterpriseMailer.manager_invitation(enterprise, new_user).deliver_later
|
||||
end
|
||||
|
||||
new_user
|
||||
end
|
||||
end
|
||||
108
app/controllers/concerns/reports/ajax_search.rb
Normal file
108
app/controllers/concerns/reports/ajax_search.rb
Normal file
@@ -0,0 +1,108 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Reports
|
||||
module AjaxSearch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def search_enterprise_fees
|
||||
report = report_class.new(spree_current_user, params, render: false)
|
||||
fee_ids = enterprise_fee_ids(report.search.result)
|
||||
query = EnterpriseFee.where(id: fee_ids)
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
def search_enterprise_fee_owners
|
||||
report = report_class.new(spree_current_user, params, render: false)
|
||||
owner_ids = enterprise_fee_owner_ids(report.search.result)
|
||||
query = Enterprise.where(id: owner_ids)
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
def search_distributors
|
||||
query = frontend_data.distributors
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
def search_order_cycles
|
||||
query = frontend_data.order_cycles
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
def search_order_customers
|
||||
query = frontend_data.order_customers
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
def search_suppliers
|
||||
query = frontend_data.orders_suppliers
|
||||
|
||||
render json: build_search_response(query)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_search_response(query)
|
||||
page = (params[:page] || 1).to_i
|
||||
per_page = 30
|
||||
|
||||
filtered_query = apply_search_filter(query)
|
||||
total_count = filtered_query.size
|
||||
items = paginated_items(filtered_query, page, per_page)
|
||||
results = format_results(items)
|
||||
|
||||
{ results: results, pagination: { more: (page * per_page) < total_count } }
|
||||
end
|
||||
|
||||
def apply_search_filter(query)
|
||||
search_term = params[:q]
|
||||
return query if search_term.blank?
|
||||
|
||||
escaped_search_term = ActiveRecord::Base.sanitize_sql_like(search_term)
|
||||
pattern = "%#{escaped_search_term}%"
|
||||
|
||||
# Handle different model types
|
||||
if query.model == OrderCycle
|
||||
query.where("order_cycles.name ILIKE ?", pattern)
|
||||
elsif query.model == Customer
|
||||
query.where("customers.email ILIKE ?", pattern)
|
||||
else
|
||||
query.where("name ILIKE ?", pattern)
|
||||
end
|
||||
end
|
||||
|
||||
def paginated_items(query, page, per_page)
|
||||
if query.model == Customer
|
||||
query.order(:email).offset((page - 1) * per_page).limit(per_page).pluck(:email, :id)
|
||||
elsif query.model == OrderCycle
|
||||
query.order('order_cycles.orders_close_at DESC')
|
||||
.offset((page - 1) * per_page)
|
||||
.limit(per_page).pluck(
|
||||
:name, :id
|
||||
)
|
||||
else
|
||||
query.order(:name).offset((page - 1) * per_page).limit(per_page).pluck(:name, :id)
|
||||
end
|
||||
end
|
||||
|
||||
def format_results(items)
|
||||
items.map { |label, value| { value:, label: } }
|
||||
end
|
||||
|
||||
def frontend_data
|
||||
@frontend_data ||= Reporting::FrontendData.new(spree_current_user)
|
||||
end
|
||||
|
||||
def enterprise_fee_owner_ids(orders)
|
||||
EnterpriseFee.where(id: enterprise_fee_ids(orders)).select(:enterprise_id)
|
||||
end
|
||||
|
||||
def enterprise_fee_ids(orders)
|
||||
Spree::Adjustment.enterprise_fee.where(order_id: orders.select(:id)).select(:originator_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
16
app/controllers/payment_gateways/taler_controller.rb
Normal file
16
app/controllers/payment_gateways/taler_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PaymentGateways
|
||||
class TalerController < BaseController
|
||||
include OrderCompletion
|
||||
|
||||
# The Taler merchant backend has taken the payment.
|
||||
# Now we just need to confirm that and update our local database
|
||||
# before finalising the order.
|
||||
def confirm
|
||||
payment = Spree::Payment.find(params[:payment_id])
|
||||
@order = payment.order
|
||||
process_payment_completion!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -14,6 +14,8 @@ module Spree
|
||||
Spree::Gateway::PayPalExpress
|
||||
Spree::Gateway::StripeSCA
|
||||
Spree::PaymentMethod::Check
|
||||
Spree::PaymentMethod::Taler
|
||||
Spree::PaymentMethod::CustomerCredit
|
||||
}.freeze
|
||||
|
||||
def create
|
||||
@@ -137,7 +139,7 @@ module Spree
|
||||
|
||||
providers.delete("Spree::Gateway::StripeSCA") unless show_stripe?
|
||||
|
||||
providers.map(&:constantize)
|
||||
providers
|
||||
end
|
||||
|
||||
# Show Stripe as an option if enabled, or if the
|
||||
|
||||
@@ -5,7 +5,7 @@ module Spree
|
||||
class PaymentsController < Spree::Admin::BaseController
|
||||
before_action :load_order, except: [:show]
|
||||
before_action :load_payment, only: [:fire, :show]
|
||||
before_action :load_data
|
||||
before_action :load_data, except: [:credit_customer]
|
||||
before_action :can_transition_to_payment
|
||||
# We ensure that items are in stock before all screens if the order is in the Payment state.
|
||||
# This way, we don't allow someone to enter credit card details for an order only to be told
|
||||
@@ -92,11 +92,22 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def credit_customer
|
||||
response = ::Orders::CustomerCreditService.new(@order).refund
|
||||
|
||||
if response.success?
|
||||
flash[:success] = Spree.t(:customer_credit_successful, scope: "admin.payments")
|
||||
else
|
||||
flash[:error] = response.message
|
||||
end
|
||||
|
||||
redirect_to admin_order_payments_path(@order)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_payment_source
|
||||
if @payment.payment_method.is_a?(Spree::Gateway) &&
|
||||
@payment.payment_method.payment_profiles_supported? &&
|
||||
if @payment.payment_method.is_a?(Gateway::StripeSCA) &&
|
||||
params[:card].present? &&
|
||||
(params[:card] != 'new')
|
||||
@payment.source = CreditCard.find_by(id: params[:card])
|
||||
@@ -186,7 +197,7 @@ module Spree
|
||||
end
|
||||
|
||||
def allowed_events
|
||||
%w{capture void_transaction credit refund resend_authorization_email
|
||||
%w{capture void_transaction credit refund internal_void resend_authorization_email
|
||||
capture_and_complete_order}
|
||||
end
|
||||
|
||||
|
||||
@@ -29,7 +29,13 @@ module Spree
|
||||
hide_ofn_navigation(@order.distributor)
|
||||
end
|
||||
|
||||
def show; end
|
||||
def show
|
||||
credit_payment_method = @order.distributor.payment_methods.customer_credit
|
||||
credit_payment = @order.payments.find_by(payment_method: credit_payment_method)
|
||||
@paid_with_credit = credit_payment&.amount
|
||||
|
||||
@payment_total = @order.payment_total - @paid_with_credit.to_f
|
||||
end
|
||||
|
||||
def empty
|
||||
if @order = current_order
|
||||
|
||||
@@ -9,7 +9,6 @@ module Spree
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
include Spree::Core::ControllerHelpers::Common
|
||||
include Spree::Core::ControllerHelpers::Order
|
||||
include CablecarResponses
|
||||
|
||||
helper 'spree/base'
|
||||
|
||||
@@ -24,14 +23,12 @@ module Spree
|
||||
if spree_user_signed_in?
|
||||
flash[:success] = t('devise.success.logged_in_succesfully')
|
||||
|
||||
render cable_ready: cable_car.redirect_to(
|
||||
url: return_url_or_default(after_sign_in_path_for(spree_current_user))
|
||||
)
|
||||
redirect_to return_url_or_default(after_sign_in_path_for(spree_current_user))
|
||||
else
|
||||
render status: :unauthorized, cable_ready: cable_car.inner_html(
|
||||
"#login-feedback",
|
||||
partial("layouts/alert", locals: { type: "alert", message: t('devise.failure.invalid') })
|
||||
)
|
||||
message = t('devise.failure.invalid')
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'login-feedback', partial: 'layouts/alert', locals: { message:, type: 'alert' }
|
||||
), status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,11 +57,13 @@ module Spree
|
||||
end
|
||||
|
||||
def render_unconfirmed_response
|
||||
render status: :unprocessable_entity, cable_ready: cable_car.inner_html(
|
||||
"#login-feedback",
|
||||
partial("layouts/alert", locals: { type: "alert", message: t(:email_unconfirmed),
|
||||
unconfirmed: true, tab: "login" })
|
||||
)
|
||||
message = t(:email_unconfirmed)
|
||||
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'login-feedback',
|
||||
partial: 'layouts/alert', locals: { type: "alert", message:, unconfirmed: true,
|
||||
tab: "login", email: params.dig(:spree_user, :email) }
|
||||
), status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def ensure_valid_locale_persisted
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
module Spree
|
||||
class UsersController < ::BaseController
|
||||
include I18nHelper
|
||||
include CablecarResponses
|
||||
|
||||
layout 'darkswarm'
|
||||
|
||||
@@ -25,34 +24,17 @@ module Spree
|
||||
@unconfirmed_email = spree_current_user.unconfirmed_email
|
||||
end
|
||||
|
||||
# Endpoint for queries to check if a user is already registered
|
||||
def registered_email
|
||||
registered = Spree::User.find_by(email: params[:email]).present?
|
||||
|
||||
if registered
|
||||
render status: :ok, cable_ready: cable_car.
|
||||
inner_html(
|
||||
"#login-feedback",
|
||||
partial("layouts/alert",
|
||||
locals: { type: "alert", message: t('devise.failure.already_registered') })
|
||||
).
|
||||
dispatch_event(name: "login:modal:open")
|
||||
else
|
||||
head :not_found
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@user = Spree::User.new(user_params)
|
||||
|
||||
if @user.save
|
||||
flash[:success] = t('devise.user_registrations.spree_user.signed_up_but_unconfirmed')
|
||||
render cable_ready: cable_car.redirect_to(url: main_app.root_path)
|
||||
redirect_to main_app.root_path
|
||||
else
|
||||
render status: :unprocessable_entity, cable_ready: cable_car.morph(
|
||||
"#signup-tab",
|
||||
partial("layouts/signup_tab", locals: { signup_form_user: @user })
|
||||
)
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'signup-tab',
|
||||
partial: 'layouts/signup_tab', locals: { signup_form_user: @user }
|
||||
), status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,13 +79,10 @@ module Spree
|
||||
end
|
||||
|
||||
def render_alert_timestamp_error_message
|
||||
render cable_ready: cable_car.inner_html(
|
||||
"#signup-feedback",
|
||||
partial("layouts/alert",
|
||||
locals: {
|
||||
type: "alert",
|
||||
message: InvisibleCaptcha.timestamp_error_message
|
||||
})
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'signup-feedback',
|
||||
partial: 'layouts/alert',
|
||||
locals: { type: "alert", message: InvisibleCaptcha.timestamp_error_message }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
class UserConfirmationsController < DeviseController
|
||||
# Needed for access to current_ability, so we can authorize! actions
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
include CablecarResponses
|
||||
|
||||
# GET /resource/confirmation?confirmation_token=abcdef
|
||||
def show
|
||||
@@ -29,12 +28,12 @@ class UserConfirmationsController < DeviseController
|
||||
set_flash_message(:error, :confirmation_not_sent)
|
||||
end
|
||||
else
|
||||
render cable_ready: cable_car.inner_html(
|
||||
"##{params[:tab] || 'forgot'}-feedback",
|
||||
partial("layouts/alert",
|
||||
locals: { type: "success", message: t("devise.confirmations.send_instructions") })
|
||||
flash.now[:sucess] = t("devise.confirmations.send_instructions")
|
||||
|
||||
return render turbo_stream: turbo_stream.update(
|
||||
"#{params[:tab] || 'forgot'}-feedback",
|
||||
partial: 'shared/flashes', locals: { flashes: flash }
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
respond_with_navigational(resource){ redirect_to login_path }
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserPasswordsController < Spree::UserPasswordsController
|
||||
include CablecarResponses
|
||||
|
||||
layout 'darkswarm'
|
||||
|
||||
def create
|
||||
return render_unconfirmed_response if user_unconfirmed?
|
||||
|
||||
self.resource = resource_class.send_reset_password_instructions(raw_params[resource_name])
|
||||
status = :ok
|
||||
|
||||
if resource.errors.empty?
|
||||
render cable_ready: cable_car.inner_html(
|
||||
"#forgot-feedback",
|
||||
partial("layouts/alert", locals: { type: "success", message: t(:password_reset_sent) })
|
||||
)
|
||||
message, type = [t(:password_reset_sent), :success]
|
||||
else
|
||||
render status: :not_found, cable_ready: cable_car.inner_html(
|
||||
"#forgot-feedback",
|
||||
partial("layouts/alert", locals: { type: "alert", message: t(:email_not_found) })
|
||||
)
|
||||
message, type = [t(:email_not_found), :alert]
|
||||
status = :not_found
|
||||
end
|
||||
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'forgot-feedback',
|
||||
partial: 'layouts/alert',
|
||||
locals: { type:, message:, tab: 'forgot',
|
||||
unconfirmed: false, email: params.dig(:spree_user, :email) }
|
||||
), status:
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_unconfirmed_response
|
||||
render status: :unprocessable_entity, cable_ready: cable_car.inner_html(
|
||||
"#forgot-feedback",
|
||||
partial("layouts/alert",
|
||||
locals: { type: "alert", message: t(:email_unconfirmed),
|
||||
unconfirmed: true, tab: "forgot" })
|
||||
)
|
||||
message, type, unconfirmed, tab = [t(:email_unconfirmed), :alert, true, 'forgot']
|
||||
|
||||
render turbo_stream: turbo_stream.update(
|
||||
'forgot-feedback',
|
||||
partial: 'layouts/alert',
|
||||
locals: { type:, message:, tab:,
|
||||
unconfirmed:, email: params.dig(:spree_user, :email) }
|
||||
), status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def user_unconfirmed?
|
||||
|
||||
50
app/forms/user_invitation.rb
Normal file
50
app/forms/user_invitation.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserInvitation
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Attributes
|
||||
include ActiveModel::Validations::Callbacks
|
||||
|
||||
attribute :enterprise
|
||||
attribute :email
|
||||
|
||||
before_validation :normalize_email
|
||||
|
||||
validates :email, presence: true, 'valid_email_2/email': { mx: true }
|
||||
validates :enterprise, presence: true
|
||||
validate :not_existing_enterprise_user
|
||||
|
||||
def save!
|
||||
return unless valid?
|
||||
|
||||
user = find_or_create_user!
|
||||
enterprise.users << user
|
||||
|
||||
return unless user.previously_new_record?
|
||||
|
||||
EnterpriseMailer.manager_invitation(enterprise, user).deliver_later
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_or_create_user!
|
||||
Spree::User.find_or_create_by!(email: email) do |user|
|
||||
user.email = email
|
||||
user.password = SecureRandom.base58(64)
|
||||
user.unconfirmed_email = email
|
||||
user.reset_password_token = Devise.friendly_token
|
||||
# Same time as used in Devise's lib/devise/models/recoverable.rb.
|
||||
user.reset_password_sent_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_email
|
||||
self.email = email.strip if email.present?
|
||||
end
|
||||
|
||||
def not_existing_enterprise_user
|
||||
return unless email.present? && enterprise.users.where(email: email).exists?
|
||||
|
||||
errors.add(:email, :is_already_manager)
|
||||
end
|
||||
end
|
||||
@@ -74,6 +74,21 @@ module ApplicationHelper
|
||||
|
||||
# Update "v1" to invalidate existing cache key
|
||||
def cache_key_with_locale(key, locale)
|
||||
Array.wrap(key) + ["v2", locale.to_s, I18nDigests.for_locale(locale)]
|
||||
Array.wrap(key) + ["v3", locale.to_s, I18nDigests.for_locale(locale)]
|
||||
end
|
||||
|
||||
def pdf_stylesheet_pack_tag(source)
|
||||
# With shakapacker dev server running, the wicked_pdf_stylesheet_pack_tag will produce a
|
||||
# relative path, because we don't have `config.action_controller.asset_host`. Relative path
|
||||
# can't be resolved by `wkhtmltopdf`. So we pass the wepacker dev server host and port to
|
||||
# the shakapacker helper, so it generates the correct url.
|
||||
# For more info: https://stackoverflow.com/questions/58490299/how-to-include-css-stylesheet-into-wicked-pdf/60541688#60541688
|
||||
if running_in_development?
|
||||
options = { media: "all",
|
||||
host: "#{Shakapacker.dev_server.host}:#{Shakapacker.dev_server.port}" }
|
||||
stylesheet_pack_tag(source, **options)
|
||||
else
|
||||
wicked_pdf_stylesheet_pack_tag(source)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,31 +83,6 @@ module CheckoutHelper
|
||||
Spree::Money.new order.total - order.total_tax, currency: order.currency
|
||||
end
|
||||
|
||||
def validated_input(name, path, args = {})
|
||||
attributes = {
|
||||
:required => true,
|
||||
:type => :text,
|
||||
:name => path,
|
||||
:id => path,
|
||||
"ng-model" => path,
|
||||
"ng-class" => "{error: !fieldValid('#{path}')}"
|
||||
}.merge args
|
||||
|
||||
render "shared/validated_input", name:, path:, attributes:
|
||||
end
|
||||
|
||||
def validated_select(name, path, options, args = {})
|
||||
attributes = {
|
||||
:required => true,
|
||||
:id => path,
|
||||
"ng-model" => path,
|
||||
"ng-class" => "{error: !fieldValid('#{path}')}"
|
||||
}.merge args
|
||||
|
||||
render "shared/validated_select", name:, path:, options:,
|
||||
attributes:
|
||||
end
|
||||
|
||||
def payment_method_price(method, order)
|
||||
price = method.compute_amount(order)
|
||||
if price == 0
|
||||
@@ -139,7 +114,7 @@ module CheckoutHelper
|
||||
def stripe_card_options(cards)
|
||||
cards.map do |cc|
|
||||
[
|
||||
"#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:" \
|
||||
"#{cc.cc_type} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:" \
|
||||
"#{cc.month.to_s.rjust(2, '0')}/#{cc.year}", cc.id
|
||||
]
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ module ReportsHelper
|
||||
|
||||
next unless payment_method
|
||||
|
||||
[payment_method.name, payment_method.id]
|
||||
[payment_method.display_name, payment_method.id]
|
||||
end.compact.uniq
|
||||
end
|
||||
|
||||
@@ -34,29 +34,8 @@ module ReportsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def fee_name_options(orders)
|
||||
EnterpriseFee.where(id: enterprise_fee_ids(orders))
|
||||
.pluck(:name, :id)
|
||||
end
|
||||
|
||||
def fee_owner_options(orders)
|
||||
Enterprise.where(id: enterprise_fee_owner_ids(orders))
|
||||
.pluck(:name, :id)
|
||||
end
|
||||
|
||||
delegate :currency_symbol, to: :'Spree::Money'
|
||||
|
||||
def enterprise_fee_owner_ids(orders)
|
||||
EnterpriseFee.where(id: enterprise_fee_ids(orders))
|
||||
.pluck(:enterprise_id)
|
||||
end
|
||||
|
||||
def enterprise_fee_ids(orders)
|
||||
Spree::Adjustment.enterprise_fee
|
||||
.where(order_id: orders.map(&:id))
|
||||
.pluck(:originator_id)
|
||||
end
|
||||
|
||||
def datepicker_time(datetime)
|
||||
datetime = Time.zone.parse(datetime) if datetime.is_a? String
|
||||
datetime.strftime('%Y-%m-%d %H:%M')
|
||||
|
||||
18
app/helpers/spree/admin/payment_methods_helper.rb
Normal file
18
app/helpers/spree/admin/payment_methods_helper.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
module PaymentMethodsHelper
|
||||
def payment_method_type_name(class_name)
|
||||
scope = "spree.admin.payment_methods.providers"
|
||||
key = class_name.demodulize.downcase
|
||||
|
||||
I18n.t(key, scope:)
|
||||
end
|
||||
|
||||
def payment_method_type_options(providers)
|
||||
providers.map { |p| [payment_method_type_name(p), p] }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@ module Spree
|
||||
end
|
||||
|
||||
def payment_method_name(payment)
|
||||
payment_method(payment)&.name
|
||||
payment_method(payment)&.display_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
30
app/json_schemas/customer_account_transaction_schema.rb
Normal file
30
app/json_schemas/customer_account_transaction_schema.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CustomerAccountTransactionSchema < JsonApiSchema
|
||||
def self.object_name
|
||||
"customer_account_transaction"
|
||||
end
|
||||
|
||||
def self.attributes
|
||||
{
|
||||
id: { type: :integer, example: 1 },
|
||||
customer_id: { type: :integer, example: 10 },
|
||||
amount: { type: :decimal, example: 10.50 },
|
||||
currency: { type: :string, example: "AUD" },
|
||||
description: { type: :string, nullable: true, example: "Payment processed by POS" },
|
||||
balance: { type: :decimal, example: 10.50 },
|
||||
}
|
||||
end
|
||||
|
||||
def self.required_attributes
|
||||
[:customer_id, :amount]
|
||||
end
|
||||
|
||||
def self.writable_attributes
|
||||
attributes.except(:id, :balance, :currency)
|
||||
end
|
||||
|
||||
def self.relationships
|
||||
[:customer]
|
||||
end
|
||||
end
|
||||
@@ -6,11 +6,10 @@ class PaymentMailer < ApplicationMailer
|
||||
def authorize_payment(payment)
|
||||
@payment = payment
|
||||
@order = @payment.order
|
||||
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
|
||||
distributor: @order.distributor.name)
|
||||
@hide_ofn_navigation = @payment.order.distributor.hide_ofn_navigation
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
mail(to: @order.email,
|
||||
subject:,
|
||||
subject: default_i18n_subject(distributor: @order.distributor.name),
|
||||
reply_to: @order.distributor.contact.email)
|
||||
end
|
||||
end
|
||||
@@ -18,11 +17,20 @@ class PaymentMailer < ApplicationMailer
|
||||
def authorization_required(payment)
|
||||
@order = payment.order
|
||||
shop_owner = @order.distributor.owner
|
||||
subject = I18n.t('spree.payment_mailer.authorization_required.subject',
|
||||
order: @order)
|
||||
I18n.with_locale valid_locale(shop_owner) do
|
||||
mail(to: shop_owner.email,
|
||||
subject:,
|
||||
mail(to: shop_owner.email, reply_to: @order.email)
|
||||
end
|
||||
end
|
||||
|
||||
def refund_available(payment, taler_order_status_url)
|
||||
@order = payment.order
|
||||
@shop = @order.distributor.name
|
||||
@amount = payment.display_amount
|
||||
@taler_order_status_url = taler_order_status_url
|
||||
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
mail(to: @order.email,
|
||||
subject: default_i18n_subject(shop: @shop),
|
||||
reply_to: @order.email)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ module Spree
|
||||
|
||||
def cancel_email(order_or_order_id, resend = false)
|
||||
@order = find_order(order_or_order_id)
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
mail(to: @order.email,
|
||||
subject: mail_subject(t('spree.order_mailer.cancel_email.subject'), resend),
|
||||
@@ -51,6 +52,7 @@ module Spree
|
||||
|
||||
def invoice_email(order_or_order_id, options = {})
|
||||
@order = find_order(order_or_order_id)
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
current_user = if options[:current_user_id].present?
|
||||
find_user(options[:current_user_id])
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ module Spree
|
||||
class ShipmentMailer < ApplicationMailer
|
||||
def shipped_email(shipment, delivery:)
|
||||
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
|
||||
@hide_ofn_navigation = @shipment.order.distributor.hide_ofn_navigation
|
||||
@delivery = delivery
|
||||
@order = @shipment.order
|
||||
subject = base_subject
|
||||
|
||||
@@ -19,6 +19,7 @@ class SubscriptionMailer < ApplicationMailer
|
||||
@type = 'empty'
|
||||
@changes = changes
|
||||
@order = order
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
send_mail(order)
|
||||
end
|
||||
|
||||
@@ -26,11 +27,13 @@ class SubscriptionMailer < ApplicationMailer
|
||||
@type = 'placement'
|
||||
@changes = changes
|
||||
@order = order
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
send_mail(order)
|
||||
end
|
||||
|
||||
def failed_payment_email(order)
|
||||
@order = order
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
send_mail(order)
|
||||
end
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Customer < ApplicationRecord
|
||||
belongs_to :enterprise
|
||||
belongs_to :user, class_name: "Spree::User", optional: true
|
||||
has_many :orders, class_name: "Spree::Order", dependent: :nullify
|
||||
has_many :customer_account_transactions, dependent: :restrict_with_error
|
||||
before_validation :downcase_email
|
||||
before_validation :empty_code
|
||||
before_create :associate_user
|
||||
|
||||
38
app/models/customer_account_transaction.rb
Normal file
38
app/models/customer_account_transaction.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "spree/localized_number"
|
||||
|
||||
class CustomerAccountTransaction < ApplicationRecord
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
localize_number :amount
|
||||
|
||||
belongs_to :customer
|
||||
belongs_to :payment, class_name: "Spree::Payment", optional: true
|
||||
belongs_to :created_by, class_name: "Spree::User", optional: true
|
||||
|
||||
validates :amount, presence: true
|
||||
validates :currency, presence: true
|
||||
|
||||
before_create :update_balance
|
||||
|
||||
private
|
||||
|
||||
def readonly?
|
||||
!new_record?
|
||||
end
|
||||
|
||||
def update_balance
|
||||
# Locking the customer to prevent two transactions from behing created at the same time
|
||||
# resulting in a potentially wrong balance calculation.
|
||||
customer.with_lock(requires_new: true) do
|
||||
last_transaction = CustomerAccountTransaction.where(customer: customer).last
|
||||
|
||||
self.balance = if last_transaction.present?
|
||||
last_transaction.balance + amount
|
||||
else
|
||||
amount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -294,7 +294,13 @@ class Enterprise < ApplicationRecord
|
||||
contact || owner
|
||||
end
|
||||
|
||||
def update_contact(user_id)
|
||||
def contact_id
|
||||
contact&.id
|
||||
end
|
||||
|
||||
def contact_id=(user_id)
|
||||
return unless user_id.to_i.positive? && users.confirmed.exists?(user_id.to_i)
|
||||
|
||||
enterprise_roles.update_all(["receives_notifications=(user_id=?)", user_id])
|
||||
end
|
||||
|
||||
@@ -576,7 +582,7 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def set_default_contact
|
||||
update_contact owner_id
|
||||
self.contact_id = owner_id
|
||||
end
|
||||
|
||||
def relate_to_owners_enterprises
|
||||
|
||||
@@ -4,7 +4,7 @@ class Invoice < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
belongs_to :order, class_name: 'Spree::Order'
|
||||
serialize :data, Hash, coder: YAML
|
||||
serialize :data, type: Hash, coder: YAML
|
||||
before_validation :serialize_order
|
||||
after_create :cancel_previous_invoices
|
||||
default_scope { order(created_at: :desc) }
|
||||
|
||||
@@ -95,8 +95,8 @@ class Invoice
|
||||
def display_line_item_tax_rate(item)
|
||||
all_tax_adjustments.select { |a|
|
||||
a.adjustable.type == 'Spree::LineItem' && a.adjustable.id == item.id
|
||||
}.map(&:originator).map { |tr|
|
||||
number_to_percentage(tr.amount * 100, precision: 1)
|
||||
}.map(&:originator).map(&:amount).sort.map { |amount|
|
||||
number_to_percentage(amount * 100, precision: 1)
|
||||
}.join(", ")
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Invoice
|
||||
end
|
||||
|
||||
def payment_method_name
|
||||
payment_method&.name
|
||||
payment_method&.display_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
class Invoice
|
||||
class DataPresenter
|
||||
class PaymentMethod < Invoice::DataPresenter::Base
|
||||
attributes :id, :name, :description
|
||||
attributes :id, :display_name, :display_description
|
||||
invoice_generation_attributes :id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OrderBalance
|
||||
delegate :negative?, :positive?, :zero?, :abs, :to_s, :to_f, :to_d, :<, :>, to: :amount
|
||||
delegate :negative?, :positive?, :zero?, :abs, :to_s, :to_f, :to_d, :<, :>, :<=, :>=, to: :amount
|
||||
|
||||
def initialize(order)
|
||||
@order = order
|
||||
|
||||
@@ -76,6 +76,7 @@ class ProxyOrder < ApplicationRecord
|
||||
|
||||
def cart?
|
||||
order&.state == 'complete' &&
|
||||
order_cycle.orders_close_at.present? &&
|
||||
order_cycle.orders_close_at > Time.zone.now
|
||||
end
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ class ReportRenderingOptions < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
belongs_to :user, class_name: "Spree::User"
|
||||
serialize :options, Hash, coder: YAML
|
||||
serialize :options, type: Hash, coder: YAML
|
||||
end
|
||||
|
||||
@@ -6,6 +6,11 @@ module Spree
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
REPORTS_SEARCH_ACTIONS = [
|
||||
:search_enterprise_fees, :search_enterprise_fee_owners, :search_distributors,
|
||||
:search_suppliers, :search_order_cycles, :search_order_customers
|
||||
].freeze
|
||||
|
||||
def initialize(user)
|
||||
clear_aliased_actions
|
||||
|
||||
@@ -56,6 +61,7 @@ module Spree
|
||||
add_manage_line_items_abilities user
|
||||
end
|
||||
add_relationship_management_abilities user if can_manage_relationships? user
|
||||
add_customer_account_transaction_abilities user if can_manage_enterprises? user
|
||||
end
|
||||
|
||||
# New users have no enterprises.
|
||||
@@ -186,7 +192,7 @@ module Spree
|
||||
user.enterprises.include? stripe_account.enterprise
|
||||
end
|
||||
|
||||
can [:admin, :create], :manager_invitation
|
||||
can [:admin, :create], UserInvitation
|
||||
|
||||
can [:admin, :index, :destroy], :oidc_setting
|
||||
|
||||
@@ -260,7 +266,8 @@ module Spree
|
||||
can [:admin, :index, :import], ::Admin::DfcProductImportsController
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :show, :create], ::Admin::ReportsController
|
||||
can [:admin, :index, :show, :create, *REPORTS_SEARCH_ACTIONS],
|
||||
::Admin::ReportsController
|
||||
can [:admin, :show, :create, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management,
|
||||
:packing, :enterprise_fee_summary, :bulk_coop, :suppliers], :report
|
||||
@@ -392,7 +399,7 @@ module Spree
|
||||
end
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :show, :create], ::Admin::ReportsController
|
||||
can [:admin, :index, :show, :create, *REPORTS_SEARCH_ACTIONS], ::Admin::ReportsController
|
||||
can [:admin, :customers, :group_buys, :sales_tax, :payments,
|
||||
:orders_and_distributors, :orders_and_fulfillment, :products_and_inventory,
|
||||
:order_cycle_management, :xero_invoices, :enterprise_fee_summary, :bulk_coop], :report
|
||||
@@ -451,5 +458,9 @@ module Spree
|
||||
user.enterprises.include?(enterprise_relationship.child)
|
||||
end
|
||||
end
|
||||
|
||||
def add_customer_account_transaction_abilities(_user)
|
||||
can [:admin, :create, :index], CustomerAccountTransaction
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,9 +25,6 @@ module Spree
|
||||
|
||||
scope :with_payment_profile, -> { where.not(gateway_customer_profile_id: nil) }
|
||||
|
||||
# needed for some of the ActiveMerchant gateways (eg. SagePay)
|
||||
alias_attribute :brand, :cc_type
|
||||
|
||||
def expiry=(expiry)
|
||||
self[:month], self[:year] = expiry.split(" / ")
|
||||
self[:year] = "20#{self[:year]}"
|
||||
|
||||
@@ -5,7 +5,7 @@ module Spree
|
||||
acts_as_taggable
|
||||
include PaymentMethodDistributors
|
||||
|
||||
delegate :authorize, :purchase, :capture, :void, :credit, to: :provider
|
||||
delegate :authorize, :purchase, :capture, :void, :credit, :refund, to: :provider
|
||||
|
||||
validates :name, :type, presence: true
|
||||
|
||||
@@ -35,6 +35,10 @@ module Spree
|
||||
end
|
||||
|
||||
def method_missing(method, *)
|
||||
message = "Deprecated delegation of Gateway##{method}"
|
||||
Alert.raise(message)
|
||||
raise message if Rails.env.local?
|
||||
|
||||
if @provider.nil? || !@provider.respond_to?(method)
|
||||
super
|
||||
else
|
||||
@@ -42,19 +46,15 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def payment_profiles_supported?
|
||||
false
|
||||
end
|
||||
|
||||
def method_type
|
||||
'gateway'
|
||||
end
|
||||
|
||||
def supports?(source)
|
||||
return true unless provider_class.respond_to? :supports?
|
||||
return false unless source.brand
|
||||
return false unless source.cc_type
|
||||
|
||||
provider_class.supports?(source.brand)
|
||||
provider_class.supports?(source.cc_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,10 +35,6 @@ module Spree
|
||||
ActiveMerchant::Billing::StripePaymentIntentsGateway
|
||||
end
|
||||
|
||||
def payment_profiles_supported?
|
||||
true
|
||||
end
|
||||
|
||||
def stripe_account_id
|
||||
StripeAccount.find_by(enterprise_id: preferred_enterprise_id)&.stripe_user_id
|
||||
end
|
||||
@@ -84,7 +80,7 @@ module Spree
|
||||
end
|
||||
|
||||
# NOTE: this method is required by Spree::Payment::Processing
|
||||
def void(payment_intent_id, _creditcard, gateway_options)
|
||||
def void(payment_intent_id, gateway_options)
|
||||
payment_intent_response = Stripe::PaymentIntent.retrieve(
|
||||
payment_intent_id, stripe_account: stripe_account_id
|
||||
)
|
||||
@@ -101,7 +97,13 @@ module Spree
|
||||
end
|
||||
|
||||
# NOTE: this method is required by Spree::Payment::Processing
|
||||
def credit(money, _creditcard, payment_intent_id, gateway_options)
|
||||
def credit(money, payment_intent_id, gateway_options)
|
||||
gateway_options[:stripe_account] = stripe_account_id
|
||||
provider.refund(money, payment_intent_id, gateway_options)
|
||||
end
|
||||
|
||||
# NOTE: this method is required by Spree::Payment::Processing
|
||||
def refund(money, payment_intent_id, gateway_options)
|
||||
gateway_options[:stripe_account] = stripe_account_id
|
||||
provider.refund(money, payment_intent_id, gateway_options)
|
||||
end
|
||||
|
||||
@@ -24,6 +24,8 @@ module Spree
|
||||
before_validation :copy_price
|
||||
before_validation :copy_tax_category
|
||||
before_validation :copy_dimensions
|
||||
before_validation :copy_product_name, on: :create
|
||||
before_validation :copy_variant_name, on: :create
|
||||
|
||||
validates :quantity, numericality: {
|
||||
only_integer: true,
|
||||
@@ -250,6 +252,18 @@ module Spree
|
||||
adjustments.enterprise_fee
|
||||
end
|
||||
|
||||
def full_variant_name
|
||||
return variant_name if variant_name.present?
|
||||
|
||||
variant.full_name
|
||||
end
|
||||
|
||||
def full_product_name
|
||||
return product_name if product_name.present?
|
||||
|
||||
variant.product.name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def computed_weight_from_variant
|
||||
@@ -274,6 +288,18 @@ module Spree
|
||||
order.create_tax_charge!
|
||||
end
|
||||
|
||||
def copy_product_name
|
||||
return if variant.nil? || variant.product.nil?
|
||||
|
||||
self.product_name = variant.product.name
|
||||
end
|
||||
|
||||
def copy_variant_name
|
||||
return if variant.nil?
|
||||
|
||||
self.variant_name = variant.full_name
|
||||
end
|
||||
|
||||
def update_inventory_before_destroy
|
||||
# This is necessary before destroying the line item
|
||||
# so that update_inventory will restore stock to the variant
|
||||
|
||||
@@ -730,5 +730,9 @@ module Spree
|
||||
adjustment.update_adjustment!(force: true)
|
||||
update_totals_and_states
|
||||
end
|
||||
|
||||
def apply_customer_credit
|
||||
Orders::CustomerCreditService.new(self).apply
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,6 +78,8 @@ module Spree
|
||||
|
||||
before_transition to: :delivery, do: :create_proposed_shipments
|
||||
before_transition to: :delivery, do: :ensure_available_shipping_rates
|
||||
before_transition to: :payment, do: :apply_customer_credit
|
||||
|
||||
before_transition to: :confirmation, do: :validate_payment_method!
|
||||
|
||||
after_transition to: :payment do |order|
|
||||
|
||||
@@ -18,7 +18,7 @@ module Spree
|
||||
|
||||
belongs_to :order, class_name: 'Spree::Order'
|
||||
belongs_to :source, polymorphic: true
|
||||
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
|
||||
belongs_to :payment_method, class_name: "Spree::PaymentMethod", inverse_of: :payments
|
||||
|
||||
has_many :offsets, -> { where("source_type = 'Spree::Payment' AND amount < 0").completed },
|
||||
class_name: "Spree::Payment", foreign_key: :source_id,
|
||||
@@ -34,7 +34,7 @@ module Spree
|
||||
|
||||
# invalidate previously entered payments
|
||||
after_create :invalidate_old_payments
|
||||
after_save :create_payment_profile, if: :profiles_supported?
|
||||
after_save :create_payment_profile
|
||||
|
||||
# update the order totals, etc.
|
||||
after_save :ensure_correct_adjustment, :update_order
|
||||
@@ -115,12 +115,20 @@ module Spree
|
||||
Alert.raise(
|
||||
e,
|
||||
metadata: {
|
||||
event_tye: "ofn.payment_transition", payment_id: payment.id, event: transition.to
|
||||
event_type: "ofn.payment_transition", payment_id: payment.id, event: transition.to
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# Allows by passing the default scope on Spree::PaymentMethod. It's needed to link payment
|
||||
# to internal payment method.
|
||||
# Using ->{ unscoped } on the association doesn't work presumably because the default scope
|
||||
# is not a simple `where`.
|
||||
def payment_method
|
||||
Spree::PaymentMethod.unscoped { super }
|
||||
end
|
||||
|
||||
def money
|
||||
Spree::Money.new(amount, currency:)
|
||||
end
|
||||
@@ -217,18 +225,13 @@ module Spree
|
||||
errors.blank?
|
||||
end
|
||||
|
||||
def profiles_supported?
|
||||
payment_method.respond_to?(:payment_profiles_supported?) &&
|
||||
payment_method.payment_profiles_supported?
|
||||
end
|
||||
|
||||
def create_payment_profile
|
||||
return unless source.is_a?(CreditCard)
|
||||
return unless source.try(:save_requested_by_customer?)
|
||||
return unless source.number || source.gateway_payment_profile_id
|
||||
return unless source.gateway_customer_profile_id.nil?
|
||||
|
||||
payment_method.create_profile(self)
|
||||
payment_method.try(:create_profile, self)
|
||||
rescue ActiveMerchant::ConnectionError => e
|
||||
gateway_error e
|
||||
end
|
||||
|
||||
@@ -4,6 +4,8 @@ module Spree
|
||||
class Payment < ApplicationRecord
|
||||
module Processing
|
||||
def process!
|
||||
return internal_purchase! if payment_method.internal?
|
||||
|
||||
return unless validate!
|
||||
|
||||
purchase!
|
||||
@@ -20,6 +22,17 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def internal_purchase!
|
||||
started_processing!
|
||||
options = { customer_id: order.customer_id, payment_id: id, order_number: order.number }
|
||||
response = payment_method.purchase(
|
||||
(amount * 100).round,
|
||||
nil,
|
||||
options
|
||||
)
|
||||
handle_response(response, :complete, :failure)
|
||||
end
|
||||
|
||||
def authorize!(return_url = nil)
|
||||
started_processing!
|
||||
gateway_action(source, :authorize, :pend, return_url:)
|
||||
@@ -58,16 +71,7 @@ module Spree
|
||||
protect_from_connection_error do
|
||||
check_environment
|
||||
|
||||
response = if payment_method.payment_profiles_supported?
|
||||
# Gateways supporting payment profiles will need access to credit
|
||||
# card object because this stores the payment profile information
|
||||
# so supply the authorization itself as well as the credit card,
|
||||
# rather than just the authorization code
|
||||
payment_method.void(response_code, source, gateway_options)
|
||||
else
|
||||
# Standard ActiveMerchant void usage
|
||||
payment_method.void(response_code, gateway_options)
|
||||
end
|
||||
response = payment_method.void(response_code, gateway_options)
|
||||
|
||||
record_response(response)
|
||||
|
||||
@@ -86,20 +90,11 @@ module Spree
|
||||
|
||||
credit_amount = calculate_refund_amount(credit_amount)
|
||||
|
||||
response = if payment_method.payment_profiles_supported?
|
||||
payment_method.credit(
|
||||
(credit_amount * 100).round,
|
||||
source,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
else
|
||||
payment_method.credit(
|
||||
(credit_amount * 100).round,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
end
|
||||
response = payment_method.credit(
|
||||
(credit_amount * 100).round,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
|
||||
record_response(response)
|
||||
|
||||
@@ -125,20 +120,11 @@ module Spree
|
||||
|
||||
refund_amount = calculate_refund_amount(refund_amount)
|
||||
|
||||
response = if payment_method.payment_profiles_supported?
|
||||
payment_method.refund(
|
||||
(refund_amount * 100).round,
|
||||
source,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
else
|
||||
payment_method.refund(
|
||||
(refund_amount * 100).round,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
end
|
||||
response = payment_method.refund(
|
||||
(refund_amount * 100).round,
|
||||
response_code,
|
||||
gateway_options
|
||||
)
|
||||
|
||||
record_response(response)
|
||||
|
||||
@@ -158,6 +144,27 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def internal_void!
|
||||
return true if void?
|
||||
# We should only void complete payment, otherwise we will be refunding credit that was
|
||||
# not used in the first place.
|
||||
return gateway_error(Spree.t(:internal_payment_not_voidable)) if state != "completed"
|
||||
|
||||
options = { customer_id: order.customer_id, payment_id: id, order_number: order.number }
|
||||
response = payment_method.void(
|
||||
(amount * 100).round,
|
||||
nil,
|
||||
options
|
||||
)
|
||||
record_response(response)
|
||||
|
||||
if response.success?
|
||||
void
|
||||
else
|
||||
gateway_error(response)
|
||||
end
|
||||
end
|
||||
|
||||
def partial_credit(amount)
|
||||
return if amount > credit_allowed
|
||||
|
||||
@@ -183,6 +190,7 @@ module Spree
|
||||
|
||||
options.merge!({ billing_address: order.bill_address.try(:active_merchant_hash),
|
||||
shipping_address: order.ship_address.try(:active_merchant_hash) })
|
||||
options.merge!(payment: self)
|
||||
|
||||
options
|
||||
end
|
||||
@@ -274,6 +282,7 @@ module Spree
|
||||
end
|
||||
logger.error(Spree.t(:gateway_error))
|
||||
logger.error(" #{error.to_yaml}")
|
||||
# TODO why is this not captured ?
|
||||
raise Core::GatewayError, text
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class PaymentMethod < ApplicationRecord
|
||||
class PaymentMethod < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||
include CalculatedAdjustments
|
||||
include PaymentMethodDistributors
|
||||
|
||||
@@ -11,9 +11,11 @@ module Spree
|
||||
acts_as_paranoid
|
||||
|
||||
DISPLAY = [:both, :back_end].freeze
|
||||
default_scope -> { where(deleted_at: nil) }
|
||||
INTERNAL = Spree::PaymentMethod::CustomerCredit.to_s
|
||||
default_scope -> { where(deleted_at: nil).where.not(type: INTERNAL) }
|
||||
|
||||
has_many :credit_cards, class_name: "Spree::CreditCard", dependent: :destroy
|
||||
has_many :payments, class_name: "Spree::Payment", dependent: :restrict_with_error
|
||||
|
||||
validates :name, presence: true
|
||||
validate :distributor_validation
|
||||
@@ -52,6 +54,12 @@ module Spree
|
||||
.where(environment: [Rails.env, "", nil])
|
||||
}
|
||||
|
||||
# These method is used to get the internal payment method. It is accessible to all
|
||||
# enterprise, but the accessibility is managed by the code, as opposed to using the database.
|
||||
def self.customer_credit
|
||||
unscoped.find_by(type: "Spree::PaymentMethod::CustomerCredit", deleted_at: nil)
|
||||
end
|
||||
|
||||
def configured?
|
||||
!stripe? || stripe_configured?
|
||||
end
|
||||
@@ -93,10 +101,6 @@ module Spree
|
||||
unscoped { find(*) }
|
||||
end
|
||||
|
||||
def payment_profiles_supported?
|
||||
false
|
||||
end
|
||||
|
||||
def source_required?
|
||||
true
|
||||
end
|
||||
@@ -113,14 +117,23 @@ module Spree
|
||||
distributors.include?(distributor)
|
||||
end
|
||||
|
||||
def self.clean_name
|
||||
scope = "spree.admin.payment_methods.providers"
|
||||
I18n.t(name.demodulize.downcase, scope:)
|
||||
def display_name
|
||||
try_translating(name)
|
||||
end
|
||||
|
||||
def display_description
|
||||
try_translating(description)
|
||||
end
|
||||
|
||||
def internal?
|
||||
type == INTERNAL
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def distributor_validation
|
||||
return true if internal?
|
||||
|
||||
validates_with DistributorsValidator
|
||||
end
|
||||
|
||||
@@ -135,5 +148,11 @@ module Spree
|
||||
preferred_enterprise_id > 0 &&
|
||||
stripe_account_id.present?
|
||||
end
|
||||
|
||||
def try_translating(value)
|
||||
return value if value.blank?
|
||||
|
||||
I18n.t(value, default: value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
110
app/models/spree/payment_method/customer_credit.rb
Normal file
110
app/models/spree/payment_method/customer_credit.rb
Normal file
@@ -0,0 +1,110 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class PaymentMethod
|
||||
class CustomerCredit < Spree::PaymentMethod
|
||||
# Name and description are translatable string, to allow instances to customise them
|
||||
def name
|
||||
"credit_payment_method.name"
|
||||
end
|
||||
|
||||
def description
|
||||
"credit_payment_method.description"
|
||||
end
|
||||
|
||||
def actions
|
||||
%w{internal_void}
|
||||
end
|
||||
|
||||
# We should only void complete payment, otherwise we will be refunding credit that was
|
||||
# not used in the first place.
|
||||
def can_internal_void?(payment)
|
||||
payment.state == "completed"
|
||||
end
|
||||
|
||||
# Main method called by Spree::Payment::Processing during checkout
|
||||
# - amount is in cents
|
||||
# - options: {
|
||||
# customer_id:, payment_id:, order_number:
|
||||
# }
|
||||
def purchase(amount, _source, options)
|
||||
calculated_amount = amount / 100.00
|
||||
|
||||
customer = Customer.find_by(id: options[:customer_id])
|
||||
return error_response("customer_not_found") if customer.nil?
|
||||
return error_response("missing_payment") if options[:payment_id].nil?
|
||||
|
||||
available_credit = customer.customer_account_transactions.last&.balance
|
||||
return error_response("no_credit_available") if available_credit.nil?
|
||||
|
||||
return error_response("not_enough_credit_available") if calculated_amount > available_credit
|
||||
|
||||
customer.with_lock do
|
||||
description = I18n.t(
|
||||
"order_payment_description",
|
||||
scope: "credit_payment_method",
|
||||
order_number: options[:order_number]
|
||||
)
|
||||
customer.customer_account_transactions.create(
|
||||
amount: -calculated_amount,
|
||||
currency:,
|
||||
payment_id: options[:payment_id],
|
||||
description:
|
||||
)
|
||||
end
|
||||
message = I18n.t("success", scope: "credit_payment_method")
|
||||
ActiveMerchant::Billing::Response.new(true, message)
|
||||
end
|
||||
|
||||
# Main method called by Spree::Payment::Processing for void
|
||||
# - amount is in cents
|
||||
# - options: {
|
||||
# customer_id:, payment_id:, order_number:, user_id: (optional)
|
||||
# }
|
||||
def void(amount, _source, options)
|
||||
calculated_amount = amount / 100.00
|
||||
|
||||
customer = Customer.find_by(id: options[:customer_id])
|
||||
return error_response("customer_not_found") if customer.nil?
|
||||
return error_response("missing_payment") if options[:payment_id].nil?
|
||||
|
||||
customer.with_lock do
|
||||
description = I18n.t(
|
||||
"order_void_description",
|
||||
scope: "credit_payment_method",
|
||||
order_number: options[:order_number]
|
||||
)
|
||||
customer.customer_account_transactions.create(
|
||||
amount: calculated_amount,
|
||||
currency:,
|
||||
payment_id: options[:payment_id],
|
||||
description:,
|
||||
created_by_id: options[:user_id]
|
||||
)
|
||||
end
|
||||
|
||||
message = I18n.t("void_success", scope: "credit_payment_method")
|
||||
ActiveMerchant::Billing::Response.new(true, message)
|
||||
end
|
||||
|
||||
def method_type
|
||||
"check" # empty view
|
||||
end
|
||||
|
||||
def source_required?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def error_response(translation_key)
|
||||
message = I18n.t(translation_key, scope: "credit_payment_method.errors")
|
||||
ActiveMerchant::Billing::Response.new(false, message)
|
||||
end
|
||||
|
||||
def currency
|
||||
CurrentConfig.get(:currency)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
118
app/models/spree/payment_method/taler.rb
Normal file
118
app/models/spree/payment_method/taler.rb
Normal file
@@ -0,0 +1,118 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "taler"
|
||||
|
||||
module Spree
|
||||
class PaymentMethod
|
||||
# GNU Taler is a distributed, open source payment system.
|
||||
# You need a hosted Taler backend server to process payments.
|
||||
#
|
||||
# For testing, you can use the official demo backend:
|
||||
#
|
||||
# - Merchant UX: https://backend.demo.taler.net
|
||||
# - Username: sandbox
|
||||
# - Password: sandbox
|
||||
#
|
||||
# Configure this payment method for testing with:
|
||||
#
|
||||
# - backend_url: https://backend.demo.taler.net/instances/sandbox
|
||||
# - api_key: sandbox
|
||||
class Taler < PaymentMethod
|
||||
preference :backend_url, :string
|
||||
preference :api_key, :password
|
||||
|
||||
def actions
|
||||
%w{void}
|
||||
end
|
||||
|
||||
def can_void?(payment)
|
||||
payment.state == "completed"
|
||||
end
|
||||
|
||||
# Name of the view to display during checkout
|
||||
def method_type
|
||||
"check" # empty view
|
||||
end
|
||||
|
||||
def external_gateway?
|
||||
true
|
||||
end
|
||||
|
||||
# The backend provides this URL. It can look like this:
|
||||
# https://backend.demo.taler.net/instances/blog/orders/2026..?token=S8Y..&session_id=b0b..
|
||||
def external_payment_url(options)
|
||||
order = options.fetch(:order)
|
||||
payment = load_payment(order)
|
||||
|
||||
payment.source ||= self
|
||||
payment.response_code ||= create_taler_order(payment)
|
||||
payment.save! if payment.changed?
|
||||
|
||||
taler_order.status_url
|
||||
end
|
||||
|
||||
# Main method called by Spree::Payment::Processing during checkout
|
||||
# when the user is redirected back to the app.
|
||||
#
|
||||
# The payment has already been made and we need to verify the success.
|
||||
def purchase(_money, _source, gateway_options)
|
||||
payment = gateway_options[:payment]
|
||||
|
||||
return unless payment.response_code
|
||||
|
||||
taler_order = taler_order(id: payment.response_code)
|
||||
status = taler_order.fetch("order_status")
|
||||
success = (status == "paid")
|
||||
message = I18n.t(status, default: status, scope: "taler.order_status")
|
||||
|
||||
ActiveMerchant::Billing::Response.new(success, message)
|
||||
end
|
||||
|
||||
def void(response_code, gateway_options)
|
||||
payment = gateway_options[:payment]
|
||||
taler_order = taler_order(id: response_code)
|
||||
status = taler_order.fetch("order_status")
|
||||
|
||||
if status == "claimed"
|
||||
return ActiveMerchant::Billing::Response.new(true, "Already expired")
|
||||
end
|
||||
|
||||
raise "Unsupported action" if status != "paid"
|
||||
|
||||
amount = taler_order.fetch("contract_terms")["amount"]
|
||||
taler_order.refund(refund: amount, reason: "void")
|
||||
|
||||
PaymentMailer.refund_available(payment, taler_order.status_url).deliver_later
|
||||
|
||||
ActiveMerchant::Billing::Response.new(true, "Refund initiated")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_payment(order)
|
||||
order.payments.checkout.where(payment_method: self).last
|
||||
end
|
||||
|
||||
def create_taler_order(payment)
|
||||
# We are ignoring currency for now so that we can test with the
|
||||
# current demo backend only working with the KUDOS currency.
|
||||
taler_amount = "KUDOS:#{payment.amount}"
|
||||
urls = Rails.application.routes.url_helpers
|
||||
fulfillment_url = urls.payment_gateways_confirm_taler_url(payment_id: payment.id)
|
||||
taler_order.create(
|
||||
amount: taler_amount,
|
||||
summary: I18n.t("payment_method_taler.order_summary"),
|
||||
fulfillment_url:,
|
||||
)
|
||||
end
|
||||
|
||||
def taler_order(id: nil)
|
||||
@taler_order ||= ::Taler::Order.new(
|
||||
backend_url: preferred_backend_url,
|
||||
password: preferred_api_key,
|
||||
id:,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -251,7 +251,7 @@ module Spree
|
||||
transaction do
|
||||
ExchangeVariant.
|
||||
where(exchange_variants: { variant_id: variants.with_deleted.
|
||||
select(:id) }).destroy_all
|
||||
select(:id) }).destroy_all
|
||||
|
||||
yield
|
||||
end
|
||||
|
||||
@@ -35,8 +35,8 @@ module Spree
|
||||
taxons
|
||||
.pluck('spree_taxons.id, enterprises.id AS enterprise_id')
|
||||
.each_with_object({}) do |(taxon_id, enterprise_id), collection|
|
||||
collection[enterprise_id.to_i] ||= Set.new
|
||||
collection[enterprise_id.to_i] << taxon_id
|
||||
collection[enterprise_id.to_i] ||= Set.new
|
||||
collection[enterprise_id.to_i] << taxon_id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ module Spree
|
||||
before_destroy :check_completed_orders
|
||||
|
||||
scope :admin, -> { where(admin: true) }
|
||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||
|
||||
has_many :enterprise_roles, dependent: :destroy
|
||||
has_many :enterprises, through: :enterprise_roles
|
||||
|
||||
@@ -167,8 +167,8 @@ module Spree
|
||||
# In Rails 3, merging two scopes on the same column will consider only the last scope.
|
||||
def self.in_distributor(distributor)
|
||||
where(id: ExchangeVariant.select(:variant_id).
|
||||
joins(:exchange).
|
||||
where('exchanges.incoming = ? AND exchanges.receiver_id = ?', false, distributor))
|
||||
joins(:exchange).
|
||||
where('exchanges.incoming = ? AND exchanges.receiver_id = ?', false, distributor))
|
||||
end
|
||||
|
||||
def self.indexed
|
||||
@@ -179,11 +179,11 @@ module Spree
|
||||
# "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: joins(:prices).
|
||||
where(deleted_at: nil).
|
||||
where('spree_prices.currency' =>
|
||||
where(deleted_at: nil).
|
||||
where('spree_prices.currency' =>
|
||||
currency || CurrentConfig.get(:currency)).
|
||||
where.not(spree_prices: { amount: nil }).
|
||||
select("spree_variants.id") })
|
||||
where.not(spree_prices: { amount: nil }).
|
||||
select("spree_variants.id") })
|
||||
end
|
||||
|
||||
def self.linked_to(semantic_id)
|
||||
|
||||
@@ -12,7 +12,8 @@ class CustomersWithBalanceQuery
|
||||
joins(left_join_complete_orders).
|
||||
group("customers.id").
|
||||
select("customers.*").
|
||||
select("#{outstanding_balance_sum} AS balance_value")
|
||||
select("#{outstanding_balance_sum} AS balance_value").
|
||||
select("#{available_credit} AS credit_value")
|
||||
end
|
||||
|
||||
private
|
||||
@@ -34,4 +35,21 @@ class CustomersWithBalanceQuery
|
||||
def outstanding_balance_sum
|
||||
"SUM(#{OutstandingBalanceQuery.new.statement})::float"
|
||||
end
|
||||
|
||||
def available_credit
|
||||
<<~SQL.squish
|
||||
CASE WHEN EXISTS (#{available_credit_subquery}) THEN (#{available_credit_subquery})#{' '}
|
||||
ELSE 0.00 END
|
||||
SQL
|
||||
end
|
||||
|
||||
def available_credit_subquery
|
||||
<<~SQL.squish
|
||||
SELECT balance
|
||||
FROM customer_account_transactions
|
||||
WHERE customer_account_transactions.customer_id = customers.id
|
||||
ORDER BY id desc
|
||||
LIMIT 1
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,8 +60,8 @@ class ProductScopeQuery
|
||||
|
||||
def product_query_includes
|
||||
[
|
||||
image: { attachment_attachment: :blob },
|
||||
variants: [:default_price, :stock_items, :variant_overrides]
|
||||
{ image: { attachment_attachment: :blob },
|
||||
variants: [:default_price, :stock_items, :variant_overrides] }
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InviteManagerReflex < ApplicationReflex
|
||||
include ManagerInvitations
|
||||
|
||||
def invite
|
||||
email = params[:email]
|
||||
enterprise = Enterprise.find(params[:enterprise_id])
|
||||
|
||||
authorize! :edit, enterprise
|
||||
|
||||
existing_user = Spree::User.find_by(email:)
|
||||
|
||||
locals = { error: nil, success: nil, email:, enterprise: }
|
||||
|
||||
if existing_user
|
||||
locals[:error] = I18n.t('admin.enterprises.invite_manager.user_already_exists')
|
||||
|
||||
return_morph(locals)
|
||||
return
|
||||
end
|
||||
|
||||
new_user = create_new_manager(email, enterprise)
|
||||
|
||||
if new_user.errors.empty?
|
||||
locals[:success] = true
|
||||
else
|
||||
locals[:error] = new_user.errors.full_messages.to_sentence
|
||||
end
|
||||
|
||||
return_morph(locals)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def return_morph(locals)
|
||||
morph "#add_manager_modal",
|
||||
render(partial: "admin/enterprises/form/add_new_unregistered_manager", locals:)
|
||||
end
|
||||
end
|
||||
@@ -7,9 +7,9 @@ module Api
|
||||
# columns to instance methods. This way, the `balance_value` alias on that class ends up being
|
||||
# `object.balance_value` here.
|
||||
class CustomerWithBalanceSerializer < CustomerSerializer
|
||||
attributes :balance, :balance_status
|
||||
attributes :balance, :balance_status, :available_credit, :available_credit_url
|
||||
|
||||
delegate :balance_value, to: :object
|
||||
delegate :balance_value, :credit_value, to: :object
|
||||
|
||||
def balance
|
||||
Spree::Money.new(balance_value, currency: CurrentConfig.get(:currency)).to_s
|
||||
@@ -24,6 +24,14 @@ module Api
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def available_credit
|
||||
Spree::Money.new(object.credit_value).to_s
|
||||
end
|
||||
|
||||
def available_credit_url
|
||||
admin_customer_customer_account_transaction_index_path(object.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V1
|
||||
class CustomerAccountTransactionSerializer < Api::V1::BaseSerializer
|
||||
attributes :id, :customer_id, :amount, :currency, :description, :balance
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
class Invoice
|
||||
class PaymentMethodSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :description
|
||||
attributes :id, :display_name, :display_description
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ module Checkout
|
||||
def set_payment_amount
|
||||
return unless @order_params[:payments_attributes]
|
||||
|
||||
@order_params[:payments_attributes].first[:amount] = order.total
|
||||
@order_params[:payments_attributes].first[:amount] = order.outstanding_balance.amount
|
||||
end
|
||||
|
||||
def set_existing_card
|
||||
|
||||
@@ -28,6 +28,8 @@ module Checkout
|
||||
def validate_payment
|
||||
return true if params.dig(:order, :payments_attributes, 0, :payment_method_id).present?
|
||||
return true if order.zero_priced_order?
|
||||
# No payment required, it's usually due to the order being paid by customer credit
|
||||
return true if order.outstanding_balance <= 0.00
|
||||
|
||||
order.errors.add :payment_method, I18n.t('checkout.errors.select_a_payment_method')
|
||||
end
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
module CustomerAccountTransactions
|
||||
class DataLoaderService
|
||||
attr_reader :user, :enterprise
|
||||
|
||||
def initialize(user:, enterprise:)
|
||||
@user = user
|
||||
@enterprise = enterprise
|
||||
end
|
||||
|
||||
def customer_account_transactions
|
||||
return [] if user.customers.empty?
|
||||
|
||||
enterprise_customer = user.customers.find_by(enterprise: )
|
||||
return [] if enterprise_customer.nil?
|
||||
|
||||
enterprise_customer.customer_account_transactions.order(id: :desc)
|
||||
end
|
||||
|
||||
def available_credit
|
||||
return 0 if customer_account_transactions.empty?
|
||||
|
||||
# We are ordered by newest, so the lastest transaction is the first one
|
||||
customer_account_transactions.first.balance
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,10 +42,10 @@ class DfcCatalogImporter
|
||||
.includes(:semantic_links).references(:semantic_links)
|
||||
.where.not(semantic_links: { semantic_id: present_ids })
|
||||
.select do |variant|
|
||||
# Variants that were in the same catalog before:
|
||||
variant.semantic_links.map(&:semantic_id).any? do |semantic_id|
|
||||
FdcUrlBuilder.new(semantic_id).catalog_url == catalog_url
|
||||
end
|
||||
# Variants that were in the same catalog before:
|
||||
variant.semantic_links.map(&:semantic_id).any? do |semantic_id|
|
||||
FdcUrlBuilder.new(semantic_id).catalog_url == catalog_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,8 +51,8 @@ class LineItemSyncer
|
||||
def destroy_obsolete_items(order)
|
||||
order.line_items.
|
||||
where(variant_id: subscription_line_items.
|
||||
select(&:marked_for_destruction?).
|
||||
map(&:variant_id)).
|
||||
select(&:marked_for_destruction?).
|
||||
map(&:variant_id)).
|
||||
destroy_all
|
||||
end
|
||||
|
||||
@@ -77,7 +77,7 @@ class LineItemSyncer
|
||||
end
|
||||
|
||||
def add_order_update_issue(order, line_item)
|
||||
issue_description = "#{line_item.product.name} - #{line_item.variant.full_name}"
|
||||
issue_description = "#{line_item.product.name} - #{line_item.full_variant_name}"
|
||||
issue_description << " - #{stock_issue_description(line_item)}" if line_item.insufficient_stock?
|
||||
order_update_issues.add(order, issue_description)
|
||||
end
|
||||
|
||||
@@ -19,8 +19,9 @@ module Orders
|
||||
end
|
||||
|
||||
def reset_other!(current_user, current_customer)
|
||||
reset_user_and_customer(current_user)
|
||||
reset_user(current_user)
|
||||
reset_order_cycle(current_customer)
|
||||
order.customer = current_customer
|
||||
order.save!
|
||||
end
|
||||
|
||||
@@ -28,7 +29,7 @@ module Orders
|
||||
|
||||
attr_reader :order, :distributor, :current_user
|
||||
|
||||
def reset_user_and_customer(current_user)
|
||||
def reset_user(current_user)
|
||||
return unless current_user
|
||||
|
||||
order.associate_user!(current_user) if order.user.blank? || order.email.blank?
|
||||
|
||||
115
app/services/orders/customer_credit_service.rb
Normal file
115
app/services/orders/customer_credit_service.rb
Normal file
@@ -0,0 +1,115 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Orders
|
||||
class CustomerCreditService
|
||||
def initialize(order)
|
||||
@order = order
|
||||
end
|
||||
|
||||
def apply
|
||||
add_payment_with_credit if credit_available?
|
||||
end
|
||||
|
||||
def refund(user: nil) # rubocop:disable Metrics/AbcSize
|
||||
if order.payment_state != "credit_owed"
|
||||
return Response.new(
|
||||
success: false, message: I18n.t(:no_credit_owed, scope: translation_scope)
|
||||
)
|
||||
end
|
||||
|
||||
if credit_payment_method.nil?
|
||||
error_message = I18n.t(:credit_payment_method_missing, scope: translation_scope)
|
||||
log_error(error_message)
|
||||
return Response.new(success: false, message: error_message)
|
||||
end
|
||||
|
||||
amount = order.new_outstanding_balance
|
||||
order.customer.with_lock do
|
||||
payment = order.payments.create!( payment_method: credit_payment_method, amount: amount,
|
||||
state: "completed", skip_source_validation: true)
|
||||
|
||||
options = { customer_id: order.customer_id, payment_id: payment.id,
|
||||
order_number: order.number, user_id: user&.id }
|
||||
response = credit_payment_method.void((-1 * amount * 100).round, nil, options)
|
||||
|
||||
raise response.message if response.failure?
|
||||
|
||||
Response.new(success: true, message: I18n.t(:refund_sucessful, scope: translation_scope))
|
||||
end
|
||||
rescue StandardError => e
|
||||
# Even though the transaction rolled back, the order still have a payment in memory,
|
||||
# so we reload the payments so the payment doesn't get saved later on
|
||||
order.payments.reload
|
||||
log_error(e)
|
||||
Response.new(success: false, message: e.to_s)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :order
|
||||
|
||||
def add_payment_with_credit
|
||||
if credit_payment_method.nil?
|
||||
error_message = I18n.t(:credit_payment_method_missing, scope: translation_scope)
|
||||
log_error(error_message)
|
||||
return
|
||||
end
|
||||
|
||||
return if order.payments.where(payment_method: credit_payment_method).exists?
|
||||
|
||||
# we are already in a transaction because the order is locked, so we force creating a new one
|
||||
# to make sure the rollback works as expected :
|
||||
# https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html#module-ActiveRecord::Transactions::ClassMethods-label-Nested+transactions
|
||||
ActiveRecord::Base.transaction(requires_new: true) do
|
||||
amount = [available_credit, order.total].min
|
||||
payment = order.payments.create!(payment_method: credit_payment_method, amount:)
|
||||
payment.internal_purchase!
|
||||
end
|
||||
rescue StandardError => e
|
||||
# Even though the transaction rolled back, the order still have a payment in memory,
|
||||
# so we reload the payments so the payment doesn't get saved later on
|
||||
order.payments.reload
|
||||
log_error(e)
|
||||
end
|
||||
|
||||
def credit_available?
|
||||
return false if order.customer.nil?
|
||||
|
||||
available_credit > 0
|
||||
end
|
||||
|
||||
def available_credit
|
||||
@available_credit ||= order.customer.customer_account_transactions.last&.balance || 0.00
|
||||
end
|
||||
|
||||
def credit_payment_method
|
||||
Spree::PaymentMethod.customer_credit
|
||||
end
|
||||
|
||||
def log_error(error)
|
||||
Rails.logger.error("Orders::CustomerCreditService: #{error}")
|
||||
Alert.raise(error)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
"orders.customer_credit_service"
|
||||
end
|
||||
|
||||
class Response
|
||||
attr_reader :message
|
||||
|
||||
def initialize(success:, message:)
|
||||
@success = success
|
||||
@message = message
|
||||
end
|
||||
|
||||
def success?
|
||||
@success
|
||||
end
|
||||
|
||||
def failure?
|
||||
!success?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -130,12 +130,11 @@ module Orders
|
||||
|
||||
def order_cycle_fees
|
||||
return @order_cycle_fees if defined? @order_cycle_fees
|
||||
return [] unless order_cycle && distributor
|
||||
|
||||
@order_cycle_fees = begin
|
||||
fees = []
|
||||
|
||||
return fees unless order_cycle && distributor
|
||||
|
||||
order_cycle.exchanges.supplying_to(distributor).each do |exchange|
|
||||
exchange.enterprise_fees.per_item.each do |enterprise_fee|
|
||||
fee_value = FeeValue.new(fee: enterprise_fee, role: exchange.role)
|
||||
|
||||
@@ -14,12 +14,12 @@ module PermittedAttributes
|
||||
|
||||
def self.attributes
|
||||
basic_permitted_attributes + [
|
||||
group_ids: [], user_ids: [],
|
||||
shipping_method_ids: [], payment_method_ids: [],
|
||||
address_attributes: PermittedAttributes::Address.attributes,
|
||||
business_address_attributes: PermittedAttributes::BusinessAddress.attributes,
|
||||
producer_properties_attributes: [:id, :property_name, :value, :_destroy],
|
||||
custom_tab_attributes: PermittedAttributes::CustomTab.attributes,
|
||||
{ group_ids: [], user_ids: [],
|
||||
shipping_method_ids: [], payment_method_ids: [],
|
||||
address_attributes: PermittedAttributes::Address.attributes,
|
||||
business_address_attributes: PermittedAttributes::BusinessAddress.attributes,
|
||||
producer_properties_attributes: [:id, :property_name, :value, :_destroy],
|
||||
custom_tab_attributes: PermittedAttributes::CustomTab.attributes },
|
||||
]
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ module PermittedAttributes
|
||||
:hide_ofn_navigation, :white_label_logo, :white_label_logo_link,
|
||||
:hide_groups_tab, :external_billing_id,
|
||||
:enable_producers_to_edit_orders,
|
||||
:remove_logo, :remove_promo_image, :remove_white_label_logo
|
||||
:remove_logo, :remove_promo_image, :remove_white_label_logo, :contact_id
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +25,8 @@ module PermittedAttributes
|
||||
private
|
||||
|
||||
def attributes
|
||||
self.class.basic_attributes + [incoming_exchanges: permitted_exchange_attributes,
|
||||
outgoing_exchanges: permitted_exchange_attributes]
|
||||
self.class.basic_attributes + [{ incoming_exchanges: permitted_exchange_attributes,
|
||||
outgoing_exchanges: permitted_exchange_attributes }]
|
||||
end
|
||||
|
||||
def permitted_exchange_attributes
|
||||
|
||||
@@ -11,7 +11,7 @@ module PermittedAttributes
|
||||
[:name, :description, :type, :active,
|
||||
:environment, :display_on, :tag_list,
|
||||
:preferred_enterprise_id, :preferred_server, :preferred_login, :preferred_password,
|
||||
:calculator_type, :preferred_api_key,
|
||||
:calculator_type, :preferred_api_key, :preferred_backend_url,
|
||||
:preferred_signature, :preferred_solution, :preferred_landing_page, :preferred_logourl,
|
||||
:preferred_test_mode, :calculator_type, { distributor_ids: [] },
|
||||
{ calculator_attributes: PermittedAttributes::Calculator.attributes }]
|
||||
|
||||
@@ -26,11 +26,11 @@ module PermittedAttributes
|
||||
|
||||
def other_permitted_attributes
|
||||
[
|
||||
subscription_line_items_attributes: [
|
||||
:id, :quantity, :variant_id, :price_estimate, :_destroy
|
||||
],
|
||||
bill_address_attributes: PermittedAttributes::Address.attributes,
|
||||
ship_address_attributes: PermittedAttributes::Address.attributes
|
||||
{ subscription_line_items_attributes: [
|
||||
:id, :quantity, :variant_id, :price_estimate, :_destroy
|
||||
],
|
||||
bill_address_attributes: PermittedAttributes::Address.attributes,
|
||||
ship_address_attributes: PermittedAttributes::Address.attributes }
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
= turbo_stream.update "customer-account-transactions-modal-container" do
|
||||
= render ModalComponent.new(id: "customer-account-transactions-modal", instant: true, modal_class: "big") do
|
||||
%h3
|
||||
= t(".available_credit", available_credit: Spree::Money.new(@available_credit))
|
||||
%table.index
|
||||
%thead
|
||||
%tr
|
||||
%th.transaction-date
|
||||
= t(".transaction_date")
|
||||
%th.description
|
||||
= t(".description")
|
||||
%th.created-by
|
||||
= t(".created_by")
|
||||
%th.amount
|
||||
= t(".amount")
|
||||
%th.running-balance
|
||||
= t(".running_balance")
|
||||
|
||||
%tbody
|
||||
- @collection.each do |transaction|
|
||||
%tr.transaction
|
||||
%td.transaction-date
|
||||
= transaction.updated_at.strftime("%Y-%m-%d")
|
||||
%td.description
|
||||
= transaction.description
|
||||
%td.created-by
|
||||
= transaction.created_by&.email
|
||||
%td.amount
|
||||
= Spree::Money.new(transaction.amount)
|
||||
%td.running-balance
|
||||
= Spree::Money.new(transaction.balance)
|
||||
@@ -48,6 +48,7 @@
|
||||
%input.red{ type: "button", value: t(:save_changes), "ng-click": "submitAll(customers_form)", "ng-disabled": "!hasUnsavedChanges()" }
|
||||
|
||||
%table.index#customers{ 'ng-show' => '!RequestMonitor.loading && filteredCustomers.length > 0' }
|
||||
%col.id{ width: "5%", 'ng-show' => 'columns.id.visible' }
|
||||
%col.email{ width: "20%", 'ng-show' => 'columns.email.visible' }
|
||||
%col.first_name{ width: "20%", 'ng-show' => 'columns.first_name.visible' }
|
||||
%col.last_name{ width: "20%", 'ng-show' => 'columns.last_name.visible' }
|
||||
@@ -61,6 +62,7 @@
|
||||
%tr{ "ng-controller": "ColumnsCtrl" }
|
||||
-# %th.bulk
|
||||
-# %input{ :type => "checkbox", :name => 'toggle_bulk', 'ng-click' => 'toggleAllCheckboxes()', 'ng-checked' => "allBoxesChecked()" }
|
||||
%th.id{ 'ng-show' => 'columns.id.visible' }=t('admin.customers.index.id')
|
||||
%th.email{ 'ng-show' => 'columns.email.visible' }
|
||||
%a{ :href => '', 'ng-click' => "sorting.toggle('email')" }=t('admin.email')
|
||||
%th.first_name{ 'ng-show' => 'columns.first_name.visible' }
|
||||
@@ -73,10 +75,13 @@
|
||||
%th.bill_address{ 'ng-show' => 'columns.bill_address.visible' }=t('admin.customers.index.bill_address')
|
||||
%th.ship_address{ 'ng-show' => 'columns.ship_address.visible' }=t('admin.customers.index.ship_address')
|
||||
%th.balance{ 'ng-show' => 'columns.balance.visible' }=t('admin.customers.index.balance')
|
||||
%th.credit{ 'ng-show' => 'columns.credit.visible' }=t('admin.customers.index.credit')
|
||||
%tbody
|
||||
%tr.customer{ 'ng-repeat' => "customer in filteredCustomers = ( customers | filter:quickSearch | orderBy: sorting.predicate:sorting.reverse ) | limitTo:customerLimit track by customer.id", 'ng-class-even' => "'even'", 'ng-class-odd' => "'odd'", :id => "c_{{customer.id}}" }
|
||||
-# %td.bulk
|
||||
-# %input{ :type => "checkbox", :name => 'bulk', 'ng-model' => 'customer.checked' }
|
||||
%td.id{ 'ng-show' => 'columns.id.visible'}
|
||||
%span{ 'ng-bind' => '::customer.id' }
|
||||
%td.email{ 'ng-show' => 'columns.email.visible'}
|
||||
%span{ 'ng-bind' => '::customer.email' }
|
||||
%span.guest-label{ 'ng-show' => 'customer.user_id == null' }= t('.guest_label')
|
||||
@@ -98,9 +103,14 @@
|
||||
%td.balance.align-center{ 'ng-show' => 'columns.balance.visible'}
|
||||
%span.state.white-space-nowrap{ 'ng-class' => 'customer.balance_status', 'ng-bind' => 'displayBalanceStatus(customer)' }
|
||||
%span{ 'ng-bind' => '::customer.balance' }
|
||||
%td.balance.align-center{ 'ng-show' => 'columns.credit.visible', "data-turbo": true}
|
||||
%a{ "ng-href": "{{customer.available_credit_url}}", "data-turbo-stream": "" }
|
||||
%span{ 'ng-bind' => '::customer.available_credit' }
|
||||
%td.actions
|
||||
%a{ 'ng-click' => "deleteCustomer(customer)", :class => "delete-customer icon-trash no-text" }
|
||||
|
||||
.text-center{ "ng-show": "filteredCustomers.length > customerLimit" }
|
||||
%input{ type: 'button', value: t(:show_more), "ng-click": 'customerLimit = customerLimit + 20' }
|
||||
%input{ type: 'button', value: t(:show_all_with_more, num: '{{ filteredCustomers.length - customerLimit }}'), "ng-click": 'customerLimit = filteredCustomers.length' }
|
||||
|
||||
#customer-account-transactions-modal-container
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
%form#add_manager_modal{ 'data-reflex': 'submit->InviteManager#invite', 'data-reflex-serialize-form': true }
|
||||
.margin-bottom-30.text-center
|
||||
.text-big
|
||||
= t('js.admin.modals.invite_title')
|
||||
|
||||
- if success
|
||||
%p.alert-box.ok= t('user_invited', email: email)
|
||||
|
||||
- if error
|
||||
%p.alert-box.error= error
|
||||
|
||||
= text_field_tag :email, nil, class: 'fullwidth margin-bottom-20'
|
||||
= hidden_field_tag :enterprise_id, @enterprise&.id || enterprise.id
|
||||
|
||||
.modal-actions
|
||||
- if success
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.close'), "data-action": "click->help-modal#close" }
|
||||
- else
|
||||
%input{ class: "button icon-plus secondary", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->help-modal#close" }
|
||||
= submit_tag "#{t('js.admin.modals.invite')}"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
%tbody
|
||||
- @payment_methods.each do |payment_method|
|
||||
%tr
|
||||
%td= payment_method.name
|
||||
%td= payment_method.display_name
|
||||
%td= f.check_box :payment_method_ids, { multiple: true }, payment_method.id, nil
|
||||
%td= link_to t(:edit), edit_admin_payment_method_path(payment_method)
|
||||
%br
|
||||
|
||||
@@ -1,75 +1,54 @@
|
||||
- owner_email = @enterprise&.owner&.email || ""
|
||||
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise&.owner)
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
=f.label :owner_id, t('.owner')
|
||||
- if full_permissions
|
||||
%span.required *
|
||||
= render partial: 'admin/shared/whats_this_tooltip', locals: {tooltip_text: t('.owner_tip')}
|
||||
.eight.columns.omega
|
||||
- if full_permissions
|
||||
= f.hidden_field :owner_id, class: "select2 fullwidth", 'user-select' => 'Enterprise.owner', 'ng-model' => 'Enterprise.owner'
|
||||
- else
|
||||
= owner_email
|
||||
= t '.description'
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
=f.label :user_ids, t('.notifications')
|
||||
- if full_permissions
|
||||
%span.required *
|
||||
= render partial: 'admin/shared/whats_this_tooltip', locals: {tooltip_text: t('.contact_tip')}
|
||||
.eight.columns.omega
|
||||
- if full_permissions
|
||||
%select.select2.fullwidth{ id: 'receives_notifications_dropdown', name: 'receives_notifications', "ng-model": 'receivesNotifications', "ng-init": "receivesNotifications = '#{@enterprise.contact.id}'" }
|
||||
%option{ value: '{{user.id}}', "ng-repeat": 'user in Enterprise.users', "ng-selected": "user.id == #{@enterprise.contact.id}", "ng-hide": '!user.confirmed' }
|
||||
{{user.email}}
|
||||
- else
|
||||
= @enterprise.contact.email
|
||||
- if full_permissions && @enterprise.users.count > 0
|
||||
- enterprise_role_ids_by_user_id = @enterprise.enterprise_roles.pluck(:user_id, :id).to_h
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
=f.label :user_ids, t('.managers')
|
||||
- if full_permissions
|
||||
%span.required *
|
||||
= render partial: 'admin/shared/whats_this_tooltip', locals: {tooltip_text: t('.managers_tip')}
|
||||
.eight.columns.omega
|
||||
- if full_permissions
|
||||
%table.managers
|
||||
%tr
|
||||
%table.managers
|
||||
%thead
|
||||
%tr
|
||||
%th= t('.manager')
|
||||
%th.center
|
||||
= t('.owner')
|
||||
= render AdminTooltipComponent.new(text: t('.owner_tip'), link_text: %[<i class="fa fa-question-circle"></i>].html_safe, link: nil)
|
||||
%th.center
|
||||
= t('.contact')
|
||||
= render AdminTooltipComponent.new(text: t('.contact_tip'), link_text: %[<i class="fa fa-question-circle"></i>].html_safe, link: nil)
|
||||
%tbody
|
||||
- @enterprise.users.each do |user|
|
||||
- contact = user.id == @enterprise.contact&.id
|
||||
- owner = user.id == @enterprise.owner&.id
|
||||
%tr{ id: "manager-#{user.id}" }
|
||||
%td
|
||||
- # Ignore this input in the submit
|
||||
= hidden_field_tag :ignored, nil, class: "select2 fullwidth", 'user-select' => 'newManager', 'ng-model' => 'newManager'
|
||||
= user.email
|
||||
|
||||
- if user.confirmed?
|
||||
%i.confirmation.confirmed.fa.fa-check-circle{ "ofn-with-tip": t('.email_confirmed') }
|
||||
- else
|
||||
%i.confirmation.unconfirmed.fa.fa-exclamation-triangle{ "ofn-with-tip": t('.email_not_confirmed') }
|
||||
|
||||
%td.center
|
||||
- if user.confirmed?
|
||||
= f.label :owner_id, t(".set_as_owner", email: user.email), class: "sr-only", value: user.id
|
||||
= f.radio_button :owner_id, user.id
|
||||
%td.center
|
||||
- if user.confirmed?
|
||||
= f.label :owner_id, t(".set_as_contact", email: user.email), class: "sr-only", value: user.id
|
||||
= f.radio_button :contact_id, user.id
|
||||
%td.actions
|
||||
%tr.animate-repeat{ id: "manager-{{manager.id}}", "ng-repeat": 'manager in Enterprise.users' }
|
||||
%td
|
||||
= hidden_field_tag "enterprise[user_ids][]", nil, multiple: true, 'ng-value' => 'manager.id'
|
||||
{{ manager.email }}
|
||||
%i.confirmation.confirmed.fa.fa-check-circle{ "ofn-with-tip": t('.email_confirmed'), "ng-show": 'manager.confirmed' }
|
||||
%i.confirmation.unconfirmed.fa.fa-exclamation-triangle{ "ofn-with-tip": t('.email_not_confirmed'), "ng-show": '!manager.confirmed' }
|
||||
%i.role.contact.fa.fa-envelope-o{ "ofn-with-tip": t('.contact'), "ng-show": 'manager.id == receivesNotifications' }
|
||||
%i.role.owner.fa.fa-star{ "ofn-with-tip": t('.owner'), "ng-show": 'manager.id == Enterprise.owner.id' }
|
||||
%td.actions
|
||||
%a{ class: "icon-trash no-text", "ng-click": 'removeManager(manager)', "ng-class": "{disabled: manager.id == Enterprise.owner.id || manager.id == receivesNotifications}" }
|
||||
- if !owner && !contact
|
||||
= link_to_delete user, no_text: true, url: admin_enterprise_role_path(id: enterprise_role_ids_by_user_id[user.id])
|
||||
- else
|
||||
%a{ class: "icon-trash no-text disabled" }
|
||||
|
||||
- else
|
||||
- @enterprise.users.each do |manager|
|
||||
= manager.email
|
||||
%br
|
||||
%a.button{ href: "#{new_admin_enterprise_user_invitation_path(@enterprise)}", data: { turbo_stream: true, turbo: true } }
|
||||
%i.icon-plus
|
||||
= t('.invite_manager')
|
||||
%br
|
||||
|
||||
- if full_permissions
|
||||
%form
|
||||
.row
|
||||
.three.columns.alpha
|
||||
%label
|
||||
= t('.invite_manager')
|
||||
= render partial: 'admin/shared/whats_this_tooltip', locals: {tooltip_text: t('.invite_manager_tip')}
|
||||
.eight.columns.omega
|
||||
.row
|
||||
%a.button{ "data-controller": "help-modal-link", "data-action": "click->help-modal-link#open", "data-help-modal-link-target-value": "invite-manager-modal" }
|
||||
= t('.add_unregistered_user')
|
||||
|
||||
-# add to admin footer to avoid nesting invitation form inside enterprise form
|
||||
- content_for :admin_footer do
|
||||
= render HelpModalComponent.new(id: "invite-manager-modal", close_button: false) do
|
||||
= render partial: 'admin/enterprises/form/add_new_unregistered_manager', locals: { error: nil, success: nil }
|
||||
- else
|
||||
- @enterprise.users.each do |manager|
|
||||
= manager.email
|
||||
%br
|
||||
|
||||
@@ -68,11 +68,11 @@
|
||||
@order_cycle.distributor_payment_methods.include?(distributor_payment_method),
|
||||
id: "order_cycle_selected_distributor_payment_method_ids_#{distributor_payment_method.id}",
|
||||
data: ({ "checked-target" => "checkbox" } if distributor_payment_method.payment_method.frontend?)
|
||||
= distributor_payment_method.payment_method.name
|
||||
= distributor_payment_method.payment_method.display_name
|
||||
- distributor.payment_methods.inactive_or_backend.each do |payment_method|
|
||||
%label.disabled
|
||||
= check_box_tag nil, nil, false, disabled: true
|
||||
= payment_method.name
|
||||
= payment_method.display_name
|
||||
= "(#{t('.back_end')})"
|
||||
- if distributor.payment_methods.available.none?
|
||||
%p
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
%fieldset.no-border-top
|
||||
.add_producer_properties
|
||||
= image_pack_tag 'images/spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator'
|
||||
= image_pack_tag 'spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator'
|
||||
%table.index.sortable{"data-sortable-link" => main_app.update_positions_admin_enterprise_producer_properties_url(@enterprise)}
|
||||
%thead
|
||||
%tr
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
= hidden_field_tag :search_term, @search_term
|
||||
= hidden_field_tag :producer_id, @producer_id
|
||||
= hidden_field_tag :category_id, @category_id
|
||||
- @tags.each do |tag|
|
||||
= hidden_field_tag 'tags_name_in[]', tag
|
||||
|
||||
%table.products{ 'data-column-preferences-target': "table", class: (hide_producer_column?(producer_options) ? 'hide-producer' : '') }
|
||||
%colgroup
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
%td.col-sku.field.naked_inputs
|
||||
= f.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
|
||||
= error_message_on variant, :sku
|
||||
%td.col-unir_scale.field.naked_inputs{ 'data-controller': 'toggle-control', 'data-toggle-control-match-value': 'items' }
|
||||
%td.col-unit_scale.field.naked_inputs{ 'data-controller': 'toggle-control', 'data-toggle-control-match-value': 'items' }
|
||||
= f.hidden_field :variant_unit
|
||||
= f.hidden_field :variant_unit_scale
|
||||
= f.select :variant_unit_with_scale,
|
||||
|
||||
@@ -1,23 +1,50 @@
|
||||
- search_url_query = {report_type: :enterprise_fee_summary, report_subtype: :enterprise_fees_with_tax_report_by_order}
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
.omega.fourteen.columns
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :distributor_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :distributor_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_distributors_url))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :order_cycle_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :order_cycle_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_order_cycles_url))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:fee_name)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:enterprise_fee_id_in, fee_name_options(@report.search.result), {selected: params.dig(:q, :enterprise_fee_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :enterprise_fee_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :enterprise_fee_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_enterprise_fees_url(search_url_query)))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:fee_owner)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:enterprise_fee_owner_id_in, fee_owner_options(@report.search.result), {selected: params.dig(:q, :enterprise_fee_owner_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :enterprise_fee_owner_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :enterprise_fee_owner_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_enterprise_fee_owners_url(search_url_query)))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:customer_id_in, customer_email_options(@data.order_customers), {selected: params.dig(:q, :customer_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :customer_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :customer_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_order_customers_url))
|
||||
|
||||
@@ -1,27 +1,57 @@
|
||||
- search_url_query = {report_type: :enterprise_fee_summary, report_subtype: :enterprise_fees_with_tax_report_by_producer}
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.omega.fourteen.columns
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :distributor_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :distributor_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_distributors_url))
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@data.orders_suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
.omega.fourteen.columns
|
||||
= render(SearchableDropdownComponent.new(name: :supplier_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:supplier_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_suppliers_url))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :order_cycle_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :order_cycle_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_order_cycles_url))
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:fee_name)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:enterprise_fee_id_in, fee_name_options(@report.search.result), {selected: params.dig(:q, :enterprise_fee_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :enterprise_fee_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :enterprise_fee_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_enterprise_fees_url(search_url_query)))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:fee_owner)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:enterprise_fee_owner_id_in, fee_owner_options(@report.search.result), {selected: params.dig(:q, :enterprise_fee_owner_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :enterprise_fee_owner_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :enterprise_fee_owner_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_enterprise_fee_owners_url(search_url_query)))
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:customer_id_in, customer_email_options(@data.order_customers), {selected: params.dig(:q, :customer_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
= render(SearchableDropdownComponent.new(form: f,
|
||||
name: :customer_id_in,
|
||||
options: [],
|
||||
selected_option: params.dig(:q, :customer_id_in),
|
||||
multiple: true,
|
||||
remote_url: admin_reports_search_order_customers_url))
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
- link = pagy_anchor(pagy)
|
||||
|
||||
.pagination{ "data-controller": "search" }
|
||||
%nav.pagination{ "aria-label": t('.navigation'), "data-controller": "search" }
|
||||
- if pagy.prev
|
||||
%button.page.prev{ data: { action: 'click->search#changePage', page: pagy.prev } }
|
||||
%a.page.prev{ href: "#", rel: "prev", "aria-label": t('.previous'), data: { action: 'click->search#changePage', page: pagy.prev } }
|
||||
%i.icon-chevron-left{ data: { action: 'click->search#changePage', page: pagy.prev } }
|
||||
- else
|
||||
%button.page.disabled{disabled: "disabled"}!= pagy_t('pagy.prev')
|
||||
|
||||
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
||||
- if item.is_a?(Integer) # page link
|
||||
%button.page{ data: { action: 'click->search#changePage', page: item } }= item
|
||||
%ul.pagelist
|
||||
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
||||
- if item.is_a?(Integer) # page link
|
||||
%li
|
||||
%a.page{ href: "#", "aria-label": t('.page', number: item), data: { action: 'click->search#changePage', page: item } }= item
|
||||
|
||||
- elsif item.is_a?(String) # current page
|
||||
%button.page.current.active= item
|
||||
- elsif item.is_a?(String) # current page
|
||||
%li
|
||||
%a.page.current.active{ href: "#", "aria-label": t('.page', number: item), "aria-current": "page" }= item
|
||||
|
||||
- elsif item == :gap # page gap
|
||||
%span.page.gap.pagination-ellipsis!= pagy_t('pagy.gap')
|
||||
- elsif item == :gap # page gap
|
||||
%li
|
||||
%span.page.gap.pagination-ellipsis!= pagy_t('pagy.gap')
|
||||
|
||||
- if pagy.next
|
||||
%button.page.next{ data: { action: 'click->search#changePage', page: pagy.next } }
|
||||
%a.page.next{ href: "#", rel: "next", "aria-label": t('.next'), data: { action: 'click->search#changePage', page: pagy.next } }
|
||||
%i.icon-chevron-right{ data: { action: 'click->search#changePage', page: pagy.next } }
|
||||
- else
|
||||
%button.page.disabled.pagination-next{disabled: "disabled"}!= pagy_t('pagy.next')
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
= turbo_stream.update "remote_modal", ""
|
||||
= turbo_stream.update "users_panel" do
|
||||
= render partial: "admin/enterprises/form/users", locals: { f: ActionView::Helpers::FormBuilder.new(:enterprise, @enterprise, self, {}) }
|
||||
= turbo_stream.append "flashes" do
|
||||
= render partial: 'admin/shared/flashes', locals: { flashes: flash }
|
||||
17
app/views/admin/user_invitations/new.turbo_stream.haml
Normal file
17
app/views/admin/user_invitations/new.turbo_stream.haml
Normal file
@@ -0,0 +1,17 @@
|
||||
= turbo_stream.update "remote_modal" do
|
||||
= render ModalComponent.new id: "#modal_new_user_invitation", instant: true, close_button: false, modal_class: :fit do
|
||||
= form_with model: @user_invitation, url: admin_enterprise_user_invitations_path(@enterprise), html: { name: "user_invitation", data: { turbo: true } } do |f|
|
||||
%h2= t ".invite_new_user"
|
||||
|
||||
%p= t ".description"
|
||||
|
||||
%fieldset.no-border-top.no-border-bottom
|
||||
.row
|
||||
= f.label :email, t(:email)
|
||||
= f.email_field :email, placeholder: t('.eg_email_address'), data: { controller: "select-user" }, inputmode: "email", autocomplete: "off"
|
||||
= f.error_message_on :email
|
||||
|
||||
.modal-actions.justify-end.filter-actions
|
||||
%input{ class: "secondary relaxed", type: 'button', value: t('.back'), "data-action": "click->modal#close" }
|
||||
%button.button.primary.relaxed.icon-envelope{ type: "submit" }
|
||||
= t(".invite")
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user