Compare commits

...

159 Commits

Author SHA1 Message Date
Pau Perez
198d4be18f Update all locales with the latest Transifex translations 2021-06-18 18:05:03 +02:00
Pau Pérez Fabregat
42e26f3328 Merge pull request #7708 from andrewpbrett/payment-states
Add `requires_authorization` Payment state
2021-06-18 17:04:03 +02:00
Pau Perez
cb23cda9e9 Update all locales with the latest Transifex translations 2021-06-18 15:05:26 +02:00
Pau Pérez Fabregat
4ecbf51b33 Merge pull request #7802 from Matt-Yorkley/confirmation-mails
Add a delay on sending order confirmation emails
2021-06-18 12:27:24 +02:00
Pau Pérez Fabregat
837e65d72a Merge pull request #7792 from openfoodfoundation/dependabot/npm_and_yarn/postcss-7.0.36
Bump postcss from 7.0.35 to 7.0.36
2021-06-18 12:24:33 +02:00
Pau Pérez Fabregat
aa9a85159e Merge pull request #7806 from mkllnk/feature-toggles
Remove custom feature toggles
2021-06-18 12:23:21 +02:00
Pau Pérez Fabregat
db993652c4 Merge branch 'master' into payment-states 2021-06-18 12:20:26 +02:00
Pau Pérez Fabregat
b500486f6b Merge pull request #7211 from jibees/4207-add-query-params-in-url
Orders list : save filters params
2021-06-18 11:19:26 +02:00
Pau Pérez Fabregat
11a7316b9d Merge pull request #7759 from apricot12/fix_duplicate_refund
Disable credit button on click
2021-06-18 09:27:45 +02:00
Pau Pérez Fabregat
75ed148490 Merge pull request #7803 from openfoodfoundation/transifex
Transifex
2021-06-18 09:26:47 +02:00
Transifex-Openfoodnetwork
2f82afcb07 Updating translations for config/locales/en_FR.yml 2021-06-18 16:58:14 +10:00
Transifex-Openfoodnetwork
fcf6f1929b Updating translations for config/locales/fr.yml 2021-06-18 16:58:00 +10:00
Pau Pérez Fabregat
6f90a7b07f Merge pull request #7720 from luisramos0/rubocop_auto_correct
Executed rubocop autocorrect (-a for safe corrections plus adding frozen_string_literal comment to all files)
2021-06-18 08:48:03 +02:00
Transifex-Openfoodnetwork
36fa34a39e Updating translations for config/locales/es.yml 2021-06-18 16:44:01 +10:00
Transifex-Openfoodnetwork
d516b1d885 Updating translations for config/locales/ca.yml 2021-06-18 16:43:55 +10:00
Andy Brett
d9aa1b054a update payments to be in requires_authorization state in specs 2021-06-17 18:10:41 -07:00
Maikel Linke
a8eecf963d Remove unused custom FeatureToggle implementation
Flipper is now our only source of truth regarding feature toggles.
2021-06-18 10:46:51 +10:00
Maikel Linke
bba85e5e79 Remove feature toggling via ENV vars
We don't use ENV vars for feature toggles any more. Flipper is much
easier to manage.
2021-06-18 10:46:51 +10:00
Maikel Linke
a712f254e0 Remove Australian custom homepage content
This was activated with a feature toggle. But when we re-implemented the
feature toggles, we accidentally broke this one and it hasn't been
active for two months. Nobody complained and it doesn't seem to be
needed while developers are keen to remove instance-specific
customisations anyway.
2021-06-18 10:46:50 +10:00
Luis Ramos
5a05a21dad Revert to false so strings can be mutated in this class 2021-06-17 23:07:54 +01:00
Luis Ramos
f95b0e3c54 Revert frozen string literal comment in codecov config 2021-06-17 23:07:41 +01:00
Luis Ramos
755222a35d Revert to false so strings can be mutated in this class 2021-06-17 23:07:35 +01:00
Luis Ramos
e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00
Luis Ramos
4fe9a936f0 Regenerate rubocop_todo 2021-06-17 22:32:59 +01:00
Luis Ramos
a253228b96 Add some rubocop disable commands in the code to avoid future wrong rubocop auto corrections 2021-06-17 22:26:54 +01:00
Andy Brett
b41302d5d8 update state transitions for new requires_authorization state 2021-06-17 14:23:59 -07:00
Andy Brett
dd0375aed4 clear authorization url after failing the payment 2021-06-17 14:23:59 -07:00
Andy Brett
d3cca04703 update spec 2021-06-17 14:23:59 -07:00
Andy Brett
3e32abe64f add colors and translations for requires_authorization state 2021-06-17 14:23:59 -07:00
Andy Brett
dc1a24339c update can_resend_auth_email 2021-06-17 14:23:59 -07:00
Andy Brett
95f123d137 update success response in payment spec 2021-06-17 14:23:59 -07:00
Andy Brett
b016337d4f add requires_authorization as a possible payment_state on Orders 2021-06-17 14:23:59 -07:00
Andy Brett
24a60cd108 add translation key 2021-06-17 14:23:59 -07:00
Andy Brett
2699e17b63 update specs to create payment in requires_authorization state 2021-06-17 14:23:59 -07:00
Andy Brett
527f4e2cb3 move payment to requires_authorization if cvv_result is present 2021-06-17 14:23:59 -07:00
Andy Brett
a6cec20056 update success_response in payment_spec 2021-06-17 14:23:59 -07:00
Andy Brett
31738ceb49 rename and consolidate authorization? methods 2021-06-17 14:23:59 -07:00
Andy Brett
674ca3026b change states after failure/requiring auth 2021-06-17 14:23:58 -07:00
Andy Brett
a3d9f1f3cc create requires_authorization payment state and migration 2021-06-17 14:23:58 -07:00
Andy Brett
4d2235c9cc Merge pull request #7794 from openfoodfoundation/dependabot/bundler/bigdecimal-3.0.2
Bump bigdecimal from 1.4.2 to 3.0.2
2021-06-17 14:21:55 -07:00
Luis Ramos
de76a1d41e Manually fix rubocop issue (unsafe auto correct would be wrong) 2021-06-17 22:20:28 +01:00
Luis Ramos
23627c5453 Run rubocop -a (safe corrections) removing all exceptions so all possible fixes are applied
9290 issues fixed
2021-06-17 22:19:26 +01:00
Andy Brett
5a25de1c82 Merge pull request #7760 from apricot12/remove_unused_partial_paypal
Remove unused partial paypal
2021-06-17 13:21:33 -07:00
Andy Brett
355b5ab56f Merge pull request #7788 from jibees/5735-flaky-spec-on-variant-override
Uncomment flaky (?) spec
2021-06-17 12:55:16 -07:00
Andy Brett
bcd0173ed0 Merge pull request #7305 from cillian/add-distributor-to-shipment-email
Add enterprise name to subject and body of shipment shipped email
2021-06-17 12:53:09 -07:00
Andy Brett
7c694e3cf3 Merge pull request #7771 from openfoodfoundation/dependabot/bundler/activemerchant-1.121.0
Bump activemerchant from 1.120.0 to 1.121.0
2021-06-17 12:52:21 -07:00
Jean-Baptiste Bellet
89ea9913e6 Checkbox is correctly handled with null value (and not false)
- It's better to read the comment juste below the line... 😠 (https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498)
 - Add appropriate spec so it is now correctly tested!
2021-06-17 21:40:25 +02:00
Matt-Yorkley
c821380ff1 Merge pull request #7749 from apricot12/remove_paypal_refund_button
Remove refund button from paypal completed order tab
2021-06-17 21:37:51 +02:00
Matt-Yorkley
e4e84b0a86 Remove old warning on BigDecimal gem 2021-06-17 16:05:12 +01:00
Matt-Yorkley
a7d873356d Fix shady use of BigDecimal 2021-06-17 15:51:06 +01:00
Transifex-Openfoodnetwork
ba7b53051a Updating translations for config/locales/es.yml 2021-06-17 20:30:36 +10:00
Transifex-Openfoodnetwork
5803c0fe50 Updating translations for config/locales/fr.yml 2021-06-17 20:27:31 +10:00
Transifex-Openfoodnetwork
2e701656d2 Updating translations for config/locales/en_US.yml 2021-06-17 20:27:29 +10:00
Pau Pérez Fabregat
a8efbffca6 Merge pull request #7429 from Matt-Yorkley/adjustments-taxrate
[Adjustments] TaxRate changes
2021-06-17 11:51:01 +02:00
Pau Pérez Fabregat
ef724d2de8 Merge pull request #7758 from jibees/7710-manage-comma-as-decimal-separator-in-unit-value-field
[UnitPrice] Manage comma as decimal separator in unit value field
2021-06-17 11:46:22 +02:00
Matt-Yorkley
bb848811e6 Add a delay on sending order confirmation emails
There's a race condition here that means the order's address is not always present when the email is first sent, but it *is* present shortly after. The fix in this commit is a temporary solution.
2021-06-17 09:35:25 +01:00
Matt-Yorkley
6ebc6bcd6f Merge pull request #7797 from luisramos0/bundler
Upgrade to bundler 2
2021-06-17 09:18:13 +02:00
dependabot[bot]
9653b0a965 Bump activemerchant from 1.120.0 to 1.121.0
Bumps [activemerchant](https://github.com/activemerchant/active_merchant) from 1.120.0 to 1.121.0.
- [Release notes](https://github.com/activemerchant/active_merchant/releases)
- [Changelog](https://github.com/activemerchant/active_merchant/blob/master/CHANGELOG)
- [Commits](https://github.com/activemerchant/active_merchant/compare/v1.120.0...v1.121.0)

---
updated-dependencies:
- dependency-name: activemerchant
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 00:26:49 +00:00
Andy Brett
aca3a76854 Merge pull request #7793 from openfoodfoundation/dependabot/bundler/ransack-2.4.2
Bump ransack from 2.4.1 to 2.4.2
2021-06-16 17:12:17 -07:00
Andy Brett
d38cf1da1f Merge pull request #7795 from openfoodfoundation/dependabot/bundler/rubocop-1.17.0
Bump rubocop from 1.16.1 to 1.17.0
2021-06-16 17:10:48 -07:00
Luis Ramos
a226aedaec Upgrade to bundler 2 2021-06-16 21:50:01 +01:00
dependabot[bot]
b39ed424f6 Bump rubocop from 1.16.1 to 1.17.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.16.1 to 1.17.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.16.1...v1.17.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-16 05:20:57 +00:00
dependabot[bot]
e4cf6421bd Bump bigdecimal from 1.4.2 to 3.0.2
Bumps [bigdecimal](https://github.com/ruby/bigdecimal) from 1.4.2 to 3.0.2.
- [Release notes](https://github.com/ruby/bigdecimal/releases)
- [Changelog](https://github.com/ruby/bigdecimal/blob/v3.0.2/CHANGES.md)
- [Commits](https://github.com/ruby/bigdecimal/compare/v1.4.2...v3.0.2)

---
updated-dependencies:
- dependency-name: bigdecimal
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-16 05:18:50 +00:00
dependabot[bot]
0776fcf5cc Bump ransack from 2.4.1 to 2.4.2
Bumps [ransack](https://github.com/activerecord-hackery/ransack) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/activerecord-hackery/ransack/releases)
- [Changelog](https://github.com/activerecord-hackery/ransack/blob/master/CHANGELOG.md)
- [Commits](https://github.com/activerecord-hackery/ransack/compare/2.4.1...v2.4.2)

---
updated-dependencies:
- dependency-name: ransack
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-16 05:17:11 +00:00
Andy Brett
59358443b4 Merge pull request #7786 from andrewpbrett/add-web-console
Add web-console gem for debugging in development
2021-06-15 13:10:25 -07:00
Andy Brett
c4911b1947 add web console for debugging in development 2021-06-15 13:00:22 -07:00
dependabot[bot]
6c24d4bc1a Bump postcss from 7.0.35 to 7.0.36
Bumps [postcss](https://github.com/postcss/postcss) from 7.0.35 to 7.0.36.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/7.0.35...7.0.36)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-15 19:08:24 +00:00
Matt-Yorkley
8753076dcd Merge pull request #7737 from luisramos0/ruby273
Upgrade to ruby 2.7.3
2021-06-15 21:07:38 +02:00
Jean-Baptiste Bellet
7f5e58bcc3 Uncomment flaky (?) spec 2021-06-15 13:51:40 +02:00
Maikel
d839313cf5 Merge pull request #7782 from openfoodfoundation/dependabot/bundler/redis-4.3.1
Bump redis from 4.2.5 to 4.3.1
2021-06-15 17:17:59 +10:00
Pau Pérez Fabregat
f51f304818 Merge pull request #7778 from openfoodfoundation/transifex
Transifex
2021-06-15 09:12:11 +02:00
Transifex-Openfoodnetwork
7f09fd4c19 Updating translations for config/locales/en_US.yml 2021-06-15 10:23:53 +10:00
Andy Brett
b8617e0a5a Merge pull request #7783 from openfoodfoundation/dependabot/npm_and_yarn/karma-6.3.4
Bump karma from 6.3.3 to 6.3.4
2021-06-14 09:18:55 -07:00
Transifex-Openfoodnetwork
6701afcdce Updating translations for config/locales/en_GB.yml 2021-06-14 18:10:03 +10:00
dependabot[bot]
fbf0e48a07 Bump karma from 6.3.3 to 6.3.4
Bumps [karma](https://github.com/karma-runner/karma) from 6.3.3 to 6.3.4.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v6.3.3...v6.3.4)

---
updated-dependencies:
- dependency-name: karma
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 06:57:07 +00:00
dependabot[bot]
e4087e9c65 Bump redis from 4.2.5 to 4.3.1
Bumps [redis](https://github.com/redis/redis-rb) from 4.2.5 to 4.3.1.
- [Release notes](https://github.com/redis/redis-rb/releases)
- [Changelog](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/redis/redis-rb/compare/v4.2.5...v4.3.1)

---
updated-dependencies:
- dependency-name: redis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 06:05:07 +00:00
Andy Brett
0eea932778 Merge pull request #7757 from openfoodfoundation/dependabot/bundler/acts-as-taggable-on-8.0.0
Bump acts-as-taggable-on from 7.0.0 to 8.0.0
2021-06-11 07:39:57 -07:00
Jean-Baptiste Bellet
db8f8a2675 Create internal methods with regexp test
- Make it more easily readable and add unit tests
2021-06-11 10:40:02 +02:00
Transifex-Openfoodnetwork
3ef5953db2 Updating translations for config/locales/en_FR.yml 2021-06-11 18:38:36 +10:00
Transifex-Openfoodnetwork
586c97b22c Updating translations for config/locales/fr.yml 2021-06-11 18:37:04 +10:00
Transifex-Openfoodnetwork
d54cb9182f Updating translations for config/locales/ca.yml 2021-06-11 18:19:44 +10:00
Transifex-Openfoodnetwork
3257f16667 Updating translations for config/locales/es.yml 2021-06-11 18:17:41 +10:00
Jean-Baptiste Bellet
178c0a441b Move unlocalize_currency filter to a PriceParser service
- It's no longer a filter but more a service: it's therefore more logic.
2021-06-11 10:01:19 +02:00
Matt-Yorkley
937cede9b8 Fix tax adjustment label
:amount is actually a property on the TaxRate object itself that refers to the rate (eg 10% expressed as 0.10), and is not the same as the adjustment amount being passed in to this method (eg: $4.28)
2021-06-10 17:16:45 +01:00
Nihal Mohammed
3b4baab01a Remove unused _paypal_complete partial 2021-06-08 16:31:26 +05:30
Nihal Mohammed
4476d7f69e Disable credit button on click 2021-06-08 14:41:25 +05:30
Jean-Baptiste Bellet
6cf0c73453 Use our unlocalizeCurrencyFilter to parse unit value field
- More tolerant (can handle `,` or `.` as decimal separator, remove thousands separator) to return a `number`
2021-06-08 10:55:43 +02:00
Jean-Baptiste Bellet
d3c2158121 Handle comma as decimal separator in the unit value field
- Add comma as a decimal separator in the regexp
 - Do not use parseFloat but our `unlocalizeCurrencyFilter` which is more tolerant
2021-06-08 09:51:30 +02:00
Jean-Baptiste Bellet
0cb2739139 Handle case when price is not a number
And return a `null` if so.
2021-06-08 09:46:24 +02:00
dependabot[bot]
0cca01345c Bump acts-as-taggable-on from 7.0.0 to 8.0.0
Bumps [acts-as-taggable-on](https://github.com/mbleigh/acts-as-taggable-on) from 7.0.0 to 8.0.0.
- [Release notes](https://github.com/mbleigh/acts-as-taggable-on/releases)
- [Changelog](https://github.com/mbleigh/acts-as-taggable-on/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mbleigh/acts-as-taggable-on/compare/v7.0.0...v8.0.0)

---
updated-dependencies:
- dependency-name: acts-as-taggable-on
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-08 05:12:23 +00:00
Jean-Baptiste Bellet
3ebba9502a Handle more cases with decimal/thousands separator
- ',' or '.' can be used as decimal separator (defined in the application configuration)
 - Remove thousands separator if it's detected as so (use regexp to match)
2021-06-07 16:53:20 +02:00
Nihal Mohammed
a5190ec5d7 Remove refund button from paypal completed order tab 2021-06-07 16:07:31 +05:30
Matt-Yorkley
5bfe079262 Update Xero Invoices test setup
Uses the new format of enterprise fee taxes
2021-06-06 20:20:41 +01:00
Matt-Yorkley
7b641ace23 Update Xero Invoices scopes for taxable fees
Taxable enterprise fee adjustments now have a tax_category
2021-06-06 20:20:41 +01:00
Matt-Yorkley
7bcb0bcaa8 Eager-load the adjustment's adjustable
Reduces the total migration time by ~15%. Requires including some more models, as order objects are now being eager-loaded as part of the polymorphic associations.
2021-06-06 20:20:41 +01:00
Matt-Yorkley
7ecd67a3fe Skip orphaned adjustments
There are a handful of enterprise fee adjustments on line items in production data where the line item has actually been deleted and no longer exists, but the fee adjustment is still in the database.
2021-06-06 20:20:41 +01:00
Matt-Yorkley
d9f459d94a Update db/migrate/20210406161242_migrate_enterprise_fee_tax_amounts.rb
Co-authored-by: Maikel <maikel@email.org.au>
2021-06-06 20:20:41 +01:00
Matt-Yorkley
76756923ba Use non-legacy-tax example in paypal items spec 2021-06-06 20:20:41 +01:00
Matt-Yorkley
401dd99225 Update stubbing of default country id in TaxRate tests 2021-06-06 20:20:41 +01:00
Matt-Yorkley
e21ef3f182 Add test coverage to #create_tax_charge! with legacy taxes 2021-06-06 20:20:41 +01:00
Matt-Yorkley
9e1d8ab369 Introduce legacy tax handing in Order::Updater whenever order totals change
This will remove legacy tax adjustments, recalculate any relevant taxes for items in the order and re-apply them in non-legacy tax adjustments
2021-06-06 20:20:41 +01:00
Matt-Yorkley
00988dc1e7 Use :order_with_totals factory in payments controller spec
This factory makes an order that actually has a line item 👍
2021-06-06 20:20:41 +01:00
Matt-Yorkley
7007de752d Update BulkLineItemsController spec now that taxes on enterprise fees are updated correctly
Tax on fees previously stayed the same unless the fees were deleted recreated from scratch, instead of updating when the fee amounts changed
2021-06-06 20:20:41 +01:00
Matt-Yorkley
832fbb7d5d Update data migration model definitions
The good_migrations gem was not working with polymorphic associations.
2021-06-06 20:18:05 +01:00
Matt-Yorkley
dc7c674a0e Switch to ApplicationRecord in migation spec
Fixes:

An error occurred while loading ./spec/migrations/migrate_enterprise_fee_tax_amounts_spec.rb.
Failure/Error: require_relative '../../db/migrate/20210406161242_migrate_enterprise_fee_tax_amounts'

TypeError:
  superclass mismatch for class Adjustment
# ./db/migrate/20210406161242_migrate_enterprise_fee_tax_amounts.rb:2:in `<class:MigrateEnterpriseFeeTaxAmounts>'
# ./db/migrate/20210406161242_migrate_enterprise_fee_tax_amounts.rb:1:in `<top (required)>'
# ./spec/migrations/migrate_enterprise_fee_tax_amounts_spec.rb:4:in `require_relative'
# ./spec/migrations/migrate_enterprise_fee_tax_amounts_spec.rb:4:in `<top (required)>'
# -e:1:in `<main>'
2021-06-06 20:18:05 +01:00
Matt-Yorkley
bfea47802e Move fee tax call outside of lock and simplify order updating 2021-06-06 20:18:05 +01:00
Matt-Yorkley
28ebb303af Simplify order interface 2021-06-06 20:17:03 +01:00
Matt-Yorkley
f20cf509d3 Add missing Spree translation 2021-06-06 20:17:03 +01:00
Matt-Yorkley
3f9a3b41da Refactor and improve EnterpriseFeeApplicator spec 2021-06-06 20:17:03 +01:00
Matt-Yorkley
38811b5a28 Add Bugsnag message if legacy taxes are used 2021-06-06 20:17:03 +01:00
Matt-Yorkley
f791f6fa20 Add test coverage to recalculating fees and taxes on completed orders 2021-06-06 20:17:03 +01:00
Matt-Yorkley
c84f9e56fb Tax enterprise fee adjustments when calling #recreate_all_fees! 2021-06-06 20:17:03 +01:00
Matt-Yorkley
355837547e Add test coverage for legacy additional taxes in OrderTaxAdjustmentsFetcher
OrderTaxAdjustmentsFetcher is used in various places to display the taxes on an order. This test validates that legacy taxes are still returned and displayed as normal.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
0f5c39317a Re-apply taxes in Admin::OrdersController#update
Ensures taxes are updated properly when hitting the "Update and Recalculate Fees" button on the order edit page.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
43877f4e34 Add unit tests for data migration 2021-06-06 20:16:03 +01:00
Matt-Yorkley
b427fd6876 Add data migration for enterprise fee tax amounts 2021-06-06 20:16:03 +01:00
Matt-Yorkley
a31487a86d Clear any legacy taxes when applying tax to an order
#create_tax_charge! adds tax (adjustments) to all taxable items on an order. If an order order has legacy taxes (lump-sum tax adjustments on the order object), we remove them here before re-applying taxes (using the new setup).
2021-06-06 20:16:03 +01:00
Matt-Yorkley
84a40e6ae0 Improve Order#enterpise_fee_tax 2021-06-06 20:16:03 +01:00
Matt-Yorkley
19f32b7825 Update checkout tax display test setup 2021-06-06 20:16:03 +01:00
Matt-Yorkley
93e422ec59 Update order fee tax test setup 2021-06-06 20:16:03 +01:00
Matt-Yorkley
6e9ae0b0db Update tax totals calculation in Order::Updater
Line items, shipments, and fees now all have taxes recorded in a uniform way, so we can drop more complexity here (and the number of queries).
2021-06-06 20:16:03 +01:00
Matt-Yorkley
a1438bdb3d Update enterprise fee tax adjustment specs 2021-06-06 20:16:03 +01:00
Matt-Yorkley
510f74f654 Update OrderTaxAdjustmentsFetcher
Taxes on Enterprise Fees are now recorded in proper tax adjustments, so they don't need special treatment.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
52452f7939 Update default tax calculator
Line items, shipments and fees can now all be calculated in the same way when applying tax.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
b3240f859a Add tax category id to adjustments 2021-06-06 20:16:03 +01:00
Matt-Yorkley
2de442f44d Move taxing of enterprise fees to TaxRate 2021-06-06 20:16:03 +01:00
Matt-Yorkley
c2211c501d Improve test setup in Xero Invoices spec 2021-06-06 20:16:03 +01:00
Matt-Yorkley
6c340f8ed4 Update SalesTax test setup 2021-06-06 20:16:03 +01:00
Matt-Yorkley
a22cc96ea5 Simplify DefaultTax calculator
This logic is handled in TaxRate and doesn't need to be duplicated here.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
8c9733d8da Remove included tax check from CalculatedAdjustments
This is handled in TaxRate now.
2021-06-06 20:16:03 +01:00
Matt-Yorkley
ff9ad96b74 Update TaxRate specs 2021-06-06 20:16:03 +01:00
Matt-Yorkley
8479d4ff7c Update outdated calls to TaxRate#adjust in specs 2021-06-06 20:16:03 +01:00
Matt-Yorkley
d450aff607 Update Order#create_tax_charge!
TaxRate#adjust now handles individual items instead of the whole order 🎉 We can use this elsewhere too, for example to re-apply taxes on a single line item, we can do: Spree::TaxRate.adjust(order, [line_item])
2021-06-06 20:16:03 +01:00
Matt-Yorkley
1c28b9783f Bring in Spree::TaxRate test coverage 2021-06-06 20:16:03 +01:00
Matt-Yorkley
f92c082df8 Refactor tax adjustment create_label method 2021-06-06 20:16:03 +01:00
Matt-Yorkley
d69f714032 Bring in changes to TaxRate#adjust 2021-06-06 20:16:03 +01:00
Matt-Yorkley
50d0952dd5 Bring in TaxRate#potentially_applicable method and add eager-loading 2021-06-06 20:16:03 +01:00
Luis Ramos
5453a1c0fa Adapt importer error to new ruby version 2.7 2021-06-04 22:42:27 +01:00
Luis Ramos
18231cd950 Adding bigdecimal to avoid errors with BigDecimal
v1.4.2 is the version that works for us, see here for more details: https://github.com/ruby/bigdecimal/issues/127
2021-06-04 22:42:27 +01:00
Luis Ramos
5629dfbe09 Fix warning: deprecated Object#=~ is called 2021-06-04 22:42:27 +01:00
Luis Ramos
21b80db0ee Fix json v1.8.6 common.rb warning
Using this patch https://github.com/flori/json/issues/399#issuecomment-734863279

We can upgrade to json v2 but to do that we need to switch from aws-sdk-v1 to aws-sdk-s3 first
2021-06-04 22:42:27 +01:00
Luis Ramos
c22799bda1 Replace gsub! with gsub so that strings are not modified 2021-06-04 22:42:22 +01:00
Luis Ramos
2b187c0547 Upgrade to ruby 2.7.3 2021-06-04 22:29:49 +01:00
Jean-Baptiste Bellet
f73e5c74fb Handle null/undefined cases for price 2021-06-01 11:40:02 +02:00
Jean-Baptiste Bellet
7008b5ec7b Make a more generic solution: KeyValueMapStore
- As QueryPersistence, stored in the localStorage too but it is now more generic and has nothing to do with Query
 - Add some js unit testing
2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
f167b09397 Add distributor and order cycle selectors in the test 2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
54c645e33a Add tests for clearing all filters feature
- and check each filter is well reinitialized
2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
385446807d Add a clear filters button
- This button clear all stored filters and then update results
2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
ea2cb4e6c0 Update flatpickr input value if ng-model change 2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
303bf5420e Add select2WatchNgModel directive
- Select2 components cannot handle ng-model correctly: they do not update if the ng-model change. Add a directive to watch the ng-model and update the component value
2021-05-31 10:44:21 +02:00
Jean-Baptiste Bellet
58a96c6500 Add missing ] char to be consistant 2021-05-31 10:44:12 +02:00
Jean-Baptiste Bellet
4f50afc188 Change shipping_method_id storage: in the query 2021-05-31 10:44:12 +02:00
Jean-Baptiste Bellet
e388238a25 Add tests for saving filter params in Orders list 2021-05-31 10:44:12 +02:00
Jean-Baptiste Bellet
1674c6a252 Improve HTML to improve tests readability
- Specify `for` attribute to `<label />` element
- Initialize component with its default value

So, it's linked to its `<input />`
2021-05-31 10:44:12 +02:00
Matt-Yorkley
93ebfb6a4f Improve checking for presence of saved filters 2021-05-31 10:44:12 +02:00
Matt-Yorkley
47404b1dc8 Improve handling of nils 2021-05-31 10:44:12 +02:00
Matt-Yorkley
c24ceac063 Extract default-setting to comment method 2021-05-31 10:44:12 +02:00
Jean-Baptiste Bellet
c5a2d183d8 Save filter params to sessionStorage for orders list
- Use sessionStorage to save the filters params each time a filter is modified
2021-05-31 10:44:12 +02:00
Cillian O'Ruanaidh
413896af5d Add enterprise name to subject and body of shipment shipped email
Fixes #7052
2021-04-02 11:44:40 +01:00
692 changed files with 7712 additions and 3765 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
2.5.9
2.7.3

0
.simplecov Normal file → Executable file
View File

16
Gemfile
View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
source 'https://rubygems.org'
ruby "2.5.9"
ruby "2.7.3"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'rails', '~> 6.0.3.7'
@@ -9,7 +9,7 @@ gem 'rails', '~> 6.0.3.7'
gem 'activemerchant', '>= 1.78.0'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '2.4.1'
gem 'ransack', '2.4.2'
gem 'responders'
gem 'sass', '~> 3.4.0' # this restriction originates from foundation-rails's version
gem 'sass-rails', '< 5.1.0' # this restriction originates from the compass-rails's version
@@ -64,8 +64,9 @@ gem 'actionpack-action_caching'
# AMS is deprecated, we will introduce an alternative at some point
gem "active_model_serializers", "0.8.4"
gem 'activerecord-session_store'
gem 'acts-as-taggable-on', '~> 7.0'
gem 'acts-as-taggable-on', '~> 8.0'
gem 'angularjs-file-upload-rails', '~> 2.4.1'
gem 'bigdecimal', '3.0.2'
gem 'bootsnap', require: false
gem 'custom_error_message', github: 'jeremydurham/custom-err-msg'
gem 'dalli'
@@ -73,14 +74,14 @@ gem 'figaro'
gem 'geocoder'
gem 'gmaps4rails'
gem 'mimemagic', '> 0.3.5'
gem 'paper_trail', '~> 10.3.1'
gem 'paperclip', '~> 3.4.1'
gem 'paper_trail', '~> 10.3.1'
gem 'rack-rewrite'
gem 'rack-ssl', require: 'rack/ssl'
gem 'roadie-rails'
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'hiredis'
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'sidekiq'
gem 'sidekiq-scheduler'
@@ -151,11 +152,11 @@ end
group :test do
gem 'byebug'
gem 'codecov', require: false
gem 'pdf-reader'
gem 'rails-controller-testing'
gem 'simplecov', require: false
gem 'test-prof'
gem 'webmock'
gem 'rails-controller-testing'
gem 'pdf-reader'
# See spec/spec_helper.rb for instructions
# gem 'perftools.rb'
end
@@ -168,6 +169,7 @@ group :development do
gem 'rubocop-rails'
gem 'spring'
gem 'spring-commands-rspec'
gem 'web-console'
gem "view_component_storybook", require: "view_component/storybook/engine"

View File

@@ -100,7 +100,7 @@ GEM
activejob (6.0.3.7)
activesupport (= 6.0.3.7)
globalid (>= 0.3.6)
activemerchant (1.120.0)
activemerchant (1.121.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
@@ -131,7 +131,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
acts-as-taggable-on (7.0.0)
acts-as-taggable-on (8.0.0)
activerecord (>= 5.0, < 6.2)
acts_as_list (1.0.4)
activerecord (>= 4.2)
@@ -157,6 +157,8 @@ GEM
json (~> 1.4)
nokogiri (~> 1)
bcrypt (3.1.16)
bigdecimal (3.0.2)
bindex (0.8.1)
bootsnap (1.7.5)
msgpack (~> 1.0)
bugsnag (6.20.0)
@@ -477,7 +479,7 @@ GEM
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
ransack (2.4.1)
ransack (2.4.2)
activerecord (>= 5.2.4)
activesupport (>= 5.2.4)
i18n
@@ -485,7 +487,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
redis (4.2.5)
redis (4.3.1)
regexp_parser (2.1.1)
request_store (1.5.0)
rack (>= 1.4)
@@ -538,7 +540,7 @@ GEM
rswag-ui (2.4.0)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (1.16.1)
rubocop (1.17.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
@@ -639,6 +641,11 @@ GEM
view_component (>= 2.2)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.6.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
@@ -670,7 +677,7 @@ DEPENDENCIES
activerecord-import
activerecord-postgresql-adapter
activerecord-session_store
acts-as-taggable-on (~> 7.0)
acts-as-taggable-on (~> 8.0)
acts_as_list (= 1.0.4)
andand
angular-rails-templates (>= 0.3.0)
@@ -680,6 +687,7 @@ DEPENDENCIES
awesome_nested_set
awesome_print
aws-sdk (= 1.67.0)
bigdecimal (= 3.0.2)
bootsnap
bugsnag
bullet
@@ -750,7 +758,7 @@ DEPENDENCIES
rails-controller-testing
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (= 2.4.1)
ransack (= 2.4.2)
redcarpet
redis (>= 4.0)
responders
@@ -783,6 +791,7 @@ DEPENDENCIES
view_component
view_component_storybook
web!
web-console
webdrivers
webmock
whenever
@@ -790,7 +799,7 @@ DEPENDENCIES
wkhtmltopdf-binary
RUBY VERSION
ruby 2.5.9p229
ruby 2.7.3p183
BUNDLED WITH
1.17.3
2.1.4

View File

@@ -8,6 +8,6 @@ require_relative 'config/application'
Openfoodnetwork::Application.load_tasks
unless ENV['DISABLE_KNAPSACK']
Knapsack.load_tasks if defined?(Knapsack)
if !ENV['DISABLE_KNAPSACK'] && defined?(Knapsack)
Knapsack.load_tasks
end

View File

@@ -8,6 +8,7 @@ angular.module("ofn.admin", [
"admin.dropdown",
"admin.products",
"admin.taxons",
"infinite-scroll"
"infinite-scroll",
"admin.orders"
]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"

View File

@@ -110,5 +110,8 @@
// foundation
//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
// LocalStorage
//= require ../shared/angular-local-storage.js
// requires the rest of the JS code in this folder
//= require_tree .

View File

@@ -0,0 +1,8 @@
angular.module("ofn.admin").directive "select2WatchNgModel", () ->
restrict: 'E'
scope: true
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
ngModel.$render = () ->
newValue = ngModel.$viewValue;
element.children(".select2").select2("val", newValue)

View File

@@ -1,4 +1,4 @@
angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, RequestMonitor, Orders, SortOptions, $window, $filter) ->
angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, RequestMonitor, Orders, SortOptions, $window, $filter, $location, KeyValueMapStore) ->
$scope.RequestMonitor = RequestMonitor
$scope.pagination = Orders.pagination
$scope.orders = Orders.all
@@ -15,39 +15,54 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, Reque
$scope.poll = 0
$scope.rowStatus = {}
KeyValueMapStore.localStorageKey = 'ordersFilters'
KeyValueMapStore.storableKeys = ["q", "sorting", "page", "per_page"]
$scope.initialise = ->
unless KeyValueMapStore.restoreValues($scope)
$scope.setDefaults()
$scope.fetchResults()
$scope.setDefaults = ->
$scope.per_page = 15
$scope.q = {
completed_at_not_null: true
}
$scope.clearFilters = () ->
KeyValueMapStore.clearKeyValueMap()
$scope.setDefaults()
$scope.fetchResults()
$scope.fetchResults = (page=1) ->
startDateWithTime = $scope.appendStringIfNotEmpty($scope['q']['completed_at_gteq'], ' 00:00:00')
endDateWithTime = $scope.appendStringIfNotEmpty($scope['q']['completed_at_lteq'], ' 23:59:59')
startDateWithTime = $scope.appendStringIfNotEmpty($scope.q?.completed_at_gteq, ' 00:00:00')
endDateWithTime = $scope.appendStringIfNotEmpty($scope.q?.completed_at_lteq, ' 23:59:59')
$scope.resetSelected()
params = {
'q[completed_at_gteq]': startDateWithTime,
'q[completed_at_lteq]': endDateWithTime,
'q[state_eq]': $scope['q']['state_eq'],
'q[number_cont]': $scope['q']['number_cont'],
'q[email_cont]': $scope['q']['email_cont'],
'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
'q[state_eq]': $scope.q?.state_eq,
'q[number_cont]': $scope.q?.number_cont,
'q[email_cont]': $scope.q?.email_cont,
'q[bill_address_firstname_start]': $scope.q?.bill_address_firstname_start,
'q[bill_address_lastname_start]': $scope.q?.bill_address_lastname_start,
# Set default checkbox values to null. See: https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498
'q[completed_at_not_null]': $scope['q']['completed_at_not_null'] || null,
'q[distributor_id_in][]': $scope['q']['distributor_id_in'],
'q[order_cycle_id_in][]': $scope['q']['order_cycle_id_in'],
'q[completed_at_not_null]': $scope.q?.completed_at_not_null || null,
'q[distributor_id_in][]': $scope.q?.distributor_id_in,
'q[order_cycle_id_in][]': $scope.q?.order_cycle_id_in,
'q[s]': $scope.sorting || 'completed_at desc',
shipping_method_id: $scope.shipping_method_id,
shipping_method_id: $scope.q?.shipping_method_id,
per_page: $scope.per_page,
page: page
}
KeyValueMapStore.setStoredValues($scope)
RequestMonitor.load(Orders.index(params).$promise)
$scope.appendStringIfNotEmpty = (baseString, stringToAppend) ->
return baseString unless baseString
return baseString if baseString.endsWith(stringToAppend)
baseString + stringToAppend

View File

@@ -1 +1 @@
angular.module("admin.orders", ['admin.indexUtils', 'ngResource', 'mm.foundation'])
angular.module("admin.orders", ['admin.indexUtils', 'ngResource', 'mm.foundation', "OFNShared"])

View File

@@ -1,5 +1,5 @@
angular.module("admin.products")
.controller "unitsCtrl", ($scope, VariantUnitManager, OptionValueNamer, UnitPrices) ->
.controller "unitsCtrl", ($scope, VariantUnitManager, OptionValueNamer, UnitPrices, PriceParser) ->
$scope.product = { master: {} }
$scope.product.master.product = $scope.product
$scope.placeholder_text = ""
@@ -26,9 +26,9 @@ angular.module("admin.products")
$scope.processUnitValueWithDescription = ->
if $scope.product.master.hasOwnProperty("unit_value_with_description")
match = $scope.product.master.unit_value_with_description.match(/^([\d\.]+(?= *|$)|)( *)(.*)$/)
match = $scope.product.master.unit_value_with_description.match(/^([\d\.,]+(?= *|$)|)( *)(.*)$/)
if match
$scope.product.master.unit_value = parseFloat(match[1])
$scope.product.master.unit_value = PriceParser.parse(match[1])
$scope.product.master.unit_value = null if isNaN($scope.product.master.unit_value)
$scope.product.master.unit_value *= $scope.product.variant_unit_scale if $scope.product.master.unit_value && $scope.product.variant_unit_scale
$scope.product.master.unit_description = match[3]

View File

@@ -1,4 +1,4 @@
angular.module("admin.products").controller "variantUnitsCtrl", ($scope, VariantUnitManager, $timeout, UnitPrices) ->
angular.module("admin.products").controller "variantUnitsCtrl", ($scope, VariantUnitManager, $timeout, UnitPrices, PriceParser) ->
$scope.unitName = (scale, type) ->
VariantUnitManager.getUnitName(scale, type)
@@ -23,7 +23,7 @@ angular.module("admin.products").controller "variantUnitsCtrl", ($scope, Variant
$scope.updateValue = ->
unit_value_human = angular.element('#unit_value_human').val()
$scope.unit_value = unit_value_human * $scope.scale
$scope.unit_value = PriceParser.parse(unit_value_human) * $scope.scale
variant_unit_value = angular.element('#variant_unit_value').val()
$scope.unit_value_human = variant_unit_value / $scope.scale

View File

@@ -1,7 +1,7 @@
angular.module("admin.products").factory "UnitPrices", (VariantUnitManager, localizeCurrencyFilter, unlocalizeCurrencyFilter) ->
angular.module("admin.products").factory "UnitPrices", (VariantUnitManager, localizeCurrencyFilter, PriceParser) ->
class UnitPrices
@displayableUnitPrice: (price, scale, unit_type, unit_value, variant_unit_name) ->
price = unlocalizeCurrencyFilter(price)
price = PriceParser.parse(price)
if price && !isNaN(price) && unit_type && unit_value
value = localizeCurrencyFilter(UnitPrices.price(price, scale, unit_type, unit_value, variant_unit_name))
unit = UnitPrices.unit(scale, unit_type, variant_unit_name)

View File

@@ -0,0 +1,29 @@
angular.module("admin.indexUtils").factory 'KeyValueMapStore', (localStorageService)->
new class KeyValueMapStore
localStorageKey: ''
storableKeys: []
constructor: ->
localStorageService.setStorageType("sessionStorage")
getStoredKeyValueMap: ->
localStorageService.get(@localStorageKey) || {}
setStoredValues: (source) ->
keyValueMap = {}
for key in @storableKeys
keyValueMap[key] = source[key]
localStorageService.set(@localStorageKey, keyValueMap)
restoreValues: (target) ->
storedKeyValueMap = @getStoredKeyValueMap()
return false if _.isEmpty(storedKeyValueMap)
for k,v of storedKeyValueMap
target[k] = v
return true
clearKeyValueMap: () ->
localStorageService.remove(@localStorageKey)

View File

@@ -2,10 +2,13 @@ angular.module("admin.utils").directive "datepicker", ($window, $timeout) ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
$timeout ->
flatpickr(element, Object.assign(
flapickrInstance = flatpickr(element, Object.assign(
{},
$window.FLATPICKR_DATE_DEFAULT, {
onOpen: (selectedDates, dateStr, instance) ->
instance.setDate(ngModel.$modelValue)
}
));
ngModel.$render = () ->
newValue = ngModel.$viewValue;
flapickrInstance?.setDate(newValue)

View File

@@ -1,15 +0,0 @@
angular.module("admin.utils").filter "unlocalizeCurrency", ()->
# Convert string to number using injected currency configuration.
(price) ->
# used decimal and thousands separators from currency configuration
decimal_separator = I18n.toCurrency(.1, {precision: 1, unit: ''}).substring(1,2)
thousands_separator = I18n.toCurrency(1000, {precision: 1, unit: ''}).substring(1,2)
if (price.length > 4)
# remove configured thousands separator if price is greater than 999
price = price.replaceAll(thousands_separator, '')
if (decimal_separator == ",")
price = price.replace(",", ".")
return parseFloat(price)

View File

@@ -0,0 +1,31 @@
angular.module("admin.utils").factory "PriceParser", ->
new class PriceParser
parse: (price) =>
return null unless price
# used decimal and thousands separators from currency configuration
decimal_separator = I18n.toCurrency(.1, {precision: 1, unit: ''}).substring(1,2)
thousands_separator = I18n.toCurrency(1000, {precision: 1, unit: ''}).substring(1,2)
# Replace comma used as a decimal separator and remplace by "."
price = this.replaceCommaByFinalPoint(price)
# Remove configured thousands separator if it is actually a thousands separator
price = this.removeThousandsSeparator(price, thousands_separator)
if (decimal_separator == ",")
price = price.replace(",", ".")
price = parseFloat(price)
return null if isNaN(price)
return price
replaceCommaByFinalPoint : (price) =>
if price.match(/^[0-9]*(,{1})[0-9]{1,2}$/g) then price.replace(",", ".") else price
removeThousandsSeparator : (price, thousands_separator) =>
if (new RegExp("^([0-9]*(" + thousands_separator + "{1})[0-9]{3}[0-9\.,]*)*$", "g").test(price))
price.replaceAll(thousands_separator, '')
else
price

View File

@@ -1,4 +1,5 @@
window.OFNShared = angular.module("OFNShared", [
"mm.foundation"
"mm.foundation",
"LocalStorageModule"
]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"

View File

@@ -1,5 +1,4 @@
#table-filter {
.field {
input[type="text"], input[type="phone"],
input[type="email"], input[type="number"],
@@ -9,6 +8,9 @@
}
.actions {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
column-gap: 20px;
}
}
}

View File

@@ -84,6 +84,8 @@ $color-ste-sold-bg: $color-success !default;
$color-ste-sold-text: $color-1 !default;
$color-ste-pending-bg: $color-notice !default;
$color-ste-pending-text: $color-1 !default;
$color-ste-requires_authorization-bg: $color-notice !default;
$color-ste-requires_authorization-text: $color-1 !default;
$color-ste-awaiting_return-bg: $color-notice !default;
$color-ste-awaiting_return-text: $color-1 !default;
$color-ste-returned-bg: $color-notice !default;
@@ -124,9 +126,9 @@ $color-ste-inactive-bg: $color-notice !default;
$color-ste-inactive-text: $color-1 !default;
// Available states
$states: completed, complete, sold, pending, awaiting_return, returned, credit_owed, paid, shipped, balance_due, backorder, checkout, cart, address, delivery, payment, confirm, canceled, ready, void, active, inactive !default;
$states-bg-colors: $color-ste-completed-bg, $color-ste-complete-bg, $color-ste-sold-bg, $color-ste-pending-bg, $color-ste-awaiting_return-bg, $color-ste-returned-bg, $color-ste-credit_owed-bg, $color-ste-paid-bg, $color-ste-shipped-bg, $color-ste-balance_due-bg, $color-ste-backorder-bg, $color-ste-checkout-bg, $color-ste-cart-bg, $color-ste-address-bg, $color-ste-delivery-bg, $color-ste-payment-bg, $color-ste-confirm-bg, $color-ste-canceled-bg, $color-ste-ready-bg, $color-ste-void-bg, $color-ste-active-bg, $color-ste-inactive-bg !default;
$states-text-colors: $color-ste-completed-text, $color-ste-complete-text, $color-ste-sold-text, $color-ste-pending-text, $color-ste-awaiting_return-text, $color-ste-returned-text, $color-ste-credit_owed-text, $color-ste-paid-text, $color-ste-shipped-text, $color-ste-balance_due-text, $color-ste-backorder-text, $color-ste-checkout-text, $color-ste-cart-text, $color-ste-address-text, $color-ste-delivery-text, $color-ste-payment-text, $color-ste-confirm-text, $color-ste-canceled-text, $color-ste-ready-text, $color-ste-void-text, $color-ste-active-text, $color-ste-inactive-text !default;
$states: completed, complete, sold, pending, awaiting_return, returned, credit_owed, paid, shipped, balance_due, backorder, checkout, cart, address, delivery, payment, confirm, canceled, ready, void, requires_authorization, active, inactive !default;
$states-bg-colors: $color-ste-completed-bg, $color-ste-complete-bg, $color-ste-sold-bg, $color-ste-pending-bg, $color-ste-awaiting_return-bg, $color-ste-returned-bg, $color-ste-credit_owed-bg, $color-ste-paid-bg, $color-ste-shipped-bg, $color-ste-balance_due-bg, $color-ste-backorder-bg, $color-ste-checkout-bg, $color-ste-cart-bg, $color-ste-address-bg, $color-ste-delivery-bg, $color-ste-payment-bg, $color-ste-confirm-bg, $color-ste-canceled-bg, $color-ste-ready-bg, $color-ste-void-bg, $color-ste-requires_authorization-bg, $color-ste-active-bg, $color-ste-inactive-bg !default;
$states-text-colors: $color-ste-completed-text, $color-ste-complete-text, $color-ste-sold-text, $color-ste-pending-text, $color-ste-awaiting_return-text, $color-ste-returned-text, $color-ste-credit_owed-text, $color-ste-paid-text, $color-ste-shipped-text, $color-ste-balance_due-text, $color-ste-backorder-text, $color-ste-checkout-text, $color-ste-cart-text, $color-ste-address-text, $color-ste-delivery-text, $color-ste-payment-text, $color-ste-confirm-text, $color-ste-canceled-text, $color-ste-ready-text, $color-ste-void-text, $color-ste-requires_authorization-text, $color-ste-active-text, $color-ste-inactive-text !default;
// Available actions
$actions: edit, clone, remove, void, capture, save, cancel, mail !default;

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class BulkLineItemsController < Spree::Admin::BaseController
include PaginationData

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ColumnPreferencesController < Admin::ResourceController
before_action :load_collection, only: [:bulk_update]

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@@ -16,7 +18,8 @@ module Admin
# Save any uploaded images
ContentConfig.save
flash[:success] = t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
flash[:success] =
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
redirect_to main_app.edit_admin_contents_path
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/address_finder'
module Admin
@@ -10,7 +12,10 @@ module Admin
tag_rule_mapping = TagRule.mapping_for(Enterprise.where(id: @customer.enterprise))
render_as_json @customer, tag_rule_mapping: tag_rule_mapping
},
failure: lambda { render json: { errors: @customer.errors.full_messages }, status: :unprocessable_entity }
failure: lambda {
render json: { errors: @customer.errors.full_messages },
status: :unprocessable_entity
}
} }
def index

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class EnterpriseFeesController < Admin::ResourceController
before_action :load_enterprise_fee_set, only: :index
@@ -16,7 +18,9 @@ module Admin
respond_to do |format|
format.html
format.json { render_as_json @collection, controller: self, include_calculators: @include_calculators }
format.json {
render_as_json @collection, controller: self, include_calculators: @include_calculators
}
# format.json { @presented_collection = @collection.each_with_index.map { |ef, i| EnterpriseFeePresenter.new(self, ef, i) } }
end
end
@@ -56,10 +60,12 @@ module Admin
order_cycle = OrderCycle.find_by(id: params[:order_cycle_id]) if params[:order_cycle_id]
coordinator = Enterprise.find_by(id: params[:coordinator_id]) if params[:coordinator_id]
order_cycle = OrderCycle.new(coordinator: coordinator) if order_cycle.nil? && coordinator.present?
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, order_cycle).visible_enterprises
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user,
order_cycle).visible_enterprises
EnterpriseFee.for_enterprises(enterprises).order('enterprise_id', 'fee_type', 'name')
else
collection = EnterpriseFee.managed_by(spree_current_user).order('enterprise_id', 'fee_type', 'name')
collection = EnterpriseFee.managed_by(spree_current_user).order('enterprise_id',
'fee_type', 'name')
collection = collection.for_enterprise(current_enterprise) if current_enterprise
collection
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class EnterpriseGroupsController < Admin::ResourceController
before_action :load_data, except: :index

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class EnterpriseRelationshipsController < Admin::ResourceController
def index
@@ -16,7 +18,8 @@ module Admin
if @enterprise_relationship.save
render plain: Api::Admin::EnterpriseRelationshipSerializer.new(@enterprise_relationship).to_json
else
render status: :bad_request, json: { errors: @enterprise_relationship.errors.full_messages.join(', ') }
render status: :bad_request,
json: { errors: @enterprise_relationship.errors.full_messages.join(', ') }
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class EnterpriseRolesController < Admin::ResourceController
def index
@@ -13,7 +15,8 @@ module Admin
render plain: Api::Admin::EnterpriseRoleSerializer.new(@enterprise_role).to_json
else
render status: :bad_request, json: { errors: @enterprise_role.errors.full_messages.join(', ') }
render status: :bad_request,
json: { errors: @enterprise_role.errors.full_messages.join(', ') }
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/referer_parser'
require 'open_food_network/permissions'
require 'open_food_network/order_cycle_permissions'
@@ -32,7 +34,10 @@ module Admin
def index
respond_to do |format|
format.html
format.json { render_as_json @collection, ams_prefix: params[:ams_prefix], spree_current_user: spree_current_user }
format.json {
render_as_json @collection, ams_prefix: params[:ams_prefix],
spree_current_user: spree_current_user
}
end
end
@@ -56,11 +61,15 @@ module Admin
respond_with(@object) do |format|
format.html { redirect_to location_after_save }
format.js { render layout: false }
format.json { render_as_json @object, ams_prefix: 'index', spree_current_user: spree_current_user }
format.json {
render_as_json @object, ams_prefix: 'index', spree_current_user: spree_current_user
}
end
else
respond_with(@object) do |format|
format.json { render json: { errors: @object.errors.messages }, status: :unprocessable_entity }
format.json {
render json: { errors: @object.errors.messages }, status: :unprocessable_entity
}
end
end
end
@@ -101,7 +110,8 @@ module Admin
def for_order_cycle
respond_to do |format|
format.json do
render json: @collection, each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer, order_cycle: @order_cycle, spree_current_user: spree_current_user
render json: @collection,
each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer, order_cycle: @order_cycle, spree_current_user: spree_current_user
end
end
end
@@ -109,7 +119,8 @@ module Admin
def visible
respond_to do |format|
format.json do
render_as_json @collection, ams_prefix: params[:ams_prefix] || 'basic', spree_current_user: spree_current_user
render_as_json @collection, ams_prefix: params[:ams_prefix] || 'basic',
spree_current_user: spree_current_user
end
end
end
@@ -152,7 +163,7 @@ module Admin
if enterprises.present?
enterprises.includes(
supplied_products:
[:supplier, master: [:images], variants: { option_values: :option_type }]
[:supplier, { master: [:images], variants: { option_values: :option_type } }]
)
end
when :index
@@ -284,7 +295,8 @@ module Admin
end
def strip_new_properties
unless spree_current_user.admin? || params.dig(:enterprise, :producer_properties_attributes).nil?
unless spree_current_user.admin? || params.dig(:enterprise,
:producer_properties_attributes).nil?
names = Spree::Property.pluck(:name)
enterprise_params[:producer_properties_attributes].each do |key, property|
enterprise_params[:producer_properties_attributes].delete key unless names.include? property[:property_name]

View File

@@ -1,15 +1,23 @@
# frozen_string_literal: true
module Admin
class InventoryItemsController < Admin::ResourceController
respond_to :json
respond_override update: { json: {
success: lambda { render_as_json @inventory_item },
failure: lambda { render json: { errors: @inventory_item.errors.full_messages }, status: :unprocessable_entity }
failure: lambda {
render json: { errors: @inventory_item.errors.full_messages },
status: :unprocessable_entity
}
} }
respond_override create: { json: {
success: lambda { render_as_json @inventory_item },
failure: lambda { render json: { errors: @inventory_item.errors.full_messages }, status: :unprocessable_entity }
failure: lambda {
render json: { errors: @inventory_item.errors.full_messages },
status: :unprocessable_entity
}
} }
private

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class InvoiceSettingsController < Spree::Admin::BaseController
def update

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ManagerInvitationsController < Spree::Admin::BaseController
authorize_resource class: false
@@ -11,7 +13,8 @@ module Admin
existing_user = Spree::User.find_by(email: @email)
if existing_user
render json: { errors: t('admin.enterprises.invite_manager.user_already_exists') }, status: :unprocessable_entity
render json: { errors: t('admin.enterprises.invite_manager.user_already_exists') },
status: :unprocessable_entity
return
end
@@ -20,7 +23,8 @@ module Admin
if new_user
render json: { user: new_user.id }, status: :ok
else
render json: { errors: t('admin.enterprises.invite_manager.error') }, status: :internal_server_error
render json: { errors: t('admin.enterprises.invite_manager.error') },
status: :internal_server_error
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class MatomoSettingsController < Spree::Admin::BaseController
def update

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class OrderCyclesController < Admin::ResourceController
include OrderCyclesHelper
@@ -156,8 +158,8 @@ module Admin
orders_close_at_gt = raw_params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
raw_params[:q] = {
g: [raw_params.delete(:q) || {}, { m: 'or',
orders_close_at_gt: orders_close_at_gt,
orders_close_at_null: true }]
orders_close_at_gt: orders_close_at_gt,
orders_close_at_null: true }]
}
@collection = collection
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ProducerPropertiesController < Admin::ResourceController
before_action :load_enterprise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'roo'
module Admin
@@ -12,7 +14,8 @@ module Admin
def import
@filepath = save_uploaded_file(params[:file])
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user, params[:settings])
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user,
params[:settings])
@original_filename = params[:file].try(:original_filename)
@non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields
@@ -34,7 +37,8 @@ module Admin
end
def reset_absent_products
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]), spree_current_user, import_into: params[:import_into], enterprises_to_reset: params[:enterprises_to_reset], updated_ids: params[:updated_ids], settings: params[:settings])
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
spree_current_user, import_into: params[:import_into], enterprises_to_reset: params[:enterprises_to_reset], updated_ids: params[:updated_ids], settings: params[:settings])
if params.key?(:enterprises_to_reset) && params.key?(:updated_ids)
@importer.reset_absent(params[:updated_ids])
@@ -52,7 +56,8 @@ module Admin
end
def process_data(method)
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]), spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
begin
@importer.public_send("#{method}_entries")
@@ -75,7 +80,8 @@ module Admin
def check_spreadsheet_has_data(importer)
unless importer.item_count
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
redirect_to '/admin/product_import',
notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
true
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ProxyOrdersController < Admin::ResourceController
respond_to :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class ResourceController < Spree::Admin::BaseController
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/permissions'
require 'order_management/subscriptions/proxy_order_syncer'
@@ -15,18 +17,31 @@ module Admin
respond_to :json
respond_override create: { json: {
success: lambda { render_as_json @schedule, editable_schedule_ids: permissions.editable_schedules.pluck(:id) },
failure: lambda { render json: { errors: @schedule.errors.full_messages }, status: :unprocessable_entity }
success: lambda {
render_as_json @schedule,
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
},
failure: lambda {
render json: { errors: @schedule.errors.full_messages },
status: :unprocessable_entity
}
} }
respond_override update: { json: {
success: lambda { render_as_json @schedule, editable_schedule_ids: permissions.editable_schedules.pluck(:id) },
failure: lambda { render json: { errors: @schedule.errors.full_messages }, status: :unprocessable_entity }
success: lambda {
render_as_json @schedule,
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
},
failure: lambda {
render json: { errors: @schedule.errors.full_messages },
status: :unprocessable_entity
}
} }
def index
respond_to do |format|
format.json do
render_as_json @collection, ams_prefix: params[:ams_prefix], editable_schedule_ids: permissions.editable_schedules.pluck(:id)
render_as_json @collection, ams_prefix: params[:ams_prefix],
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
end
end
end
@@ -111,7 +126,8 @@ module Admin
def check_dependent_subscriptions
return if Subscription.where(schedule_id: @schedule).empty?
render json: { errors: [t('admin.schedules.destroy.associated_subscriptions_error')] }, status: :conflict
render json: { errors: [t('admin.schedules.destroy.associated_subscriptions_error')] },
status: :conflict
end
def permissions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stripe/account_connector'
module Admin

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# This controller is used by super admin users to update the settings the app is using
module Admin

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/permissions'
require 'open_food_network/order_cycle_permissions'
require 'open_food_network/scope_variant_to_hub'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/permissions'
module Admin
@@ -85,7 +87,8 @@ module Admin
def collection
if request.format.json?
permissions.editable_subscriptions.ransack(params[:q]).result
.preload([:shop, :customer, :schedule, :subscription_line_items, :ship_address, :bill_address, proxy_orders: { order: :order_cycle }])
.preload([:shop, :customer, :schedule, :subscription_line_items, :ship_address,
:bill_address, { proxy_orders: { order: :order_cycle } }])
else
Subscription.where("1=0")
end
@@ -116,11 +119,13 @@ module Admin
end
def wrap_bill_address_attrs
subscription_params[:bill_address_attributes] = raw_params[:bill_address].slice(*Spree::Address.attribute_names)
subscription_params[:bill_address_attributes] =
raw_params[:bill_address].slice(*Spree::Address.attribute_names)
end
def wrap_ship_address_attrs
subscription_params[:ship_address_attributes] = raw_params[:ship_address].slice(*Spree::Address.attribute_names)
subscription_params[:ship_address_attributes] =
raw_params[:ship_address].slice(*Spree::Address.attribute_names)
end
def check_for_open_orders
@@ -129,14 +134,16 @@ module Admin
@open_orders_to_keep = @subscription.proxy_orders.placed_and_open.pluck(:id)
return if @open_orders_to_keep.empty? || params[:open_orders] == 'keep'
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } }, status: :conflict
render json: { errors: { open_orders: t('admin.subscriptions.confirm_cancel_open_orders_msg') } },
status: :conflict
end
def check_for_canceled_orders
return if params[:canceled_orders] == 'notified'
return if @subscription.proxy_orders.active.canceled.empty?
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } }, status: :conflict
render json: { errors: { canceled_orders: t('admin.subscriptions.resume_canceled_orders_msg') } },
status: :conflict
end
def strip_banned_attrs

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
class TagRulesController < Admin::ResourceController
respond_to :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/spree_api_key_loader'
module Admin

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Api
module V0
class TaxonsController < Api::V0::BaseController

View File

@@ -52,10 +52,10 @@ class ApplicationController < ActionController::Base
def redirect_to(options = {}, response_status = {})
::Rails.logger.error("Redirected by #{begin
caller(1).first
rescue StandardError
'unknown'
end}")
caller(1).first
rescue StandardError
'unknown'
end}")
super(options, response_status)
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CartController < BaseController
before_action :check_authorization

View File

@@ -137,7 +137,7 @@ class CheckoutController < ::BaseController
last_payment = OrderPaymentFinder.new(@order).last_payment
@order.state == "payment" &&
last_payment&.state == "pending" &&
last_payment&.state == "requires_authorization" &&
last_payment&.response_code == params["payment_intent"]
end
@@ -152,8 +152,8 @@ class CheckoutController < ::BaseController
def checkout_workflow(shipping_method_id)
while @order.state != "complete"
if @order.state == "payment"
return if redirect_to_payment_gateway
if @order.state == "payment" && redirect_to_payment_gateway
return
end
next if OrderWorkflow.new(@order).next({ shipping_method_id: shipping_method_id })

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'discourse/single_sign_on'
class DiscourseSsoController < ApplicationController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/enterprise_injection_data'
class EnterprisesController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupsController < BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class HomeController < BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class LineItemsController < BaseController
respond_to :json

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MapController < BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# For the API
ActionController::Metal.class_eval do
def spree_current_user

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProducersController < BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/spree_api_key_loader'
class RegistrationController < BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ShopController < BaseController
layout "darkswarm"
before_action :require_distributor_chosen, :set_order_cycles, except: :changeable_orders_alert

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class ShopsController < BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class SitemapController < ApplicationController
layout nil

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class AdjustmentsController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class BaseController < ApplicationController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class CountriesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class GeneralSettingsController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ImagesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class InvoicesController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class MailMethodsController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
module Orders

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/spree_api_key_loader'
module Spree
@@ -37,6 +39,11 @@ module Spree
def update
@order.recreate_all_fees!
unless @order.cart?
@order.create_tax_charge!
@order.update_order!
end
unless order_params.present? && @order.update(order_params) && @order.line_items.present?
if @order.line_items.empty? && !params[:suppress_error_msg]
@order.errors.add(:line_items, Spree.t('errors.messages.blank'))

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# this clas was inspired (heavily) from the mephisto admin architecture
module Spree
module Admin

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class PaymentMethodsController < ::Admin::ResourceController

View File

@@ -11,7 +11,7 @@ module Spree
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
# that it can't be processed.
# that it can't be processed.
before_action :ensure_sufficient_stock_lines
respond_to :html
@@ -150,7 +150,7 @@ module Spree
return if !@order.payment? || @order.insufficient_stock_lines.blank?
flash[:error] = I18n.t("spree.orders.line_item.insufficient_stock",
on_hand: "0 #{out_of_stock_item_names}")
on_hand: "0 #{out_of_stock_item_names}")
redirect_to spree.edit_admin_order_url(@order)
end
@@ -171,13 +171,15 @@ module Spree
end
def authorize_stripe_sca_payment
return unless @payment.payment_method.class == Spree::Gateway::StripeSCA
return unless @payment.payment_method.instance_of?(Spree::Gateway::StripeSCA)
@payment.authorize!(full_order_path(@payment.order))
raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending?
unless @payment.pending? || @payment.requires_authorization?
raise Spree::Core::GatewayError, I18n.t('authorization_failure')
end
return unless @payment.authorization_action_required?
return unless @payment.requires_authorization?
PaymentMailer.authorize_payment(@payment).deliver_later
raise Spree::Core::GatewayError, I18n.t('action_required')

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ProductPropertiesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/spree_api_key_loader'
require 'open_food_network/referer_parser'
require 'open_food_network/permissions'
@@ -161,7 +163,9 @@ module Spree
private
def product_set_from_params
collection_hash = Hash[products_bulk_params[:products].each_with_index.map { |p, i| [i, p] }]
collection_hash = Hash[products_bulk_params[:products].each_with_index.map { |p, i|
[i, p]
} ]
Sets::ProductSet.new(collection_attributes: collection_hash)
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class PropertiesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'csv'
require 'open_food_network/reports/list'
@@ -46,7 +48,8 @@ module Spree
def customers
@report_types = report_types[:customers]
@report_type = params[:report_type]
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params, render_content?
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params,
render_content?
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
end
@@ -91,7 +94,8 @@ module Spree
def sales_tax
@distributors = my_distributors
@report_type = params[:report_type]
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params, render_content?
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params,
render_content?
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
end
@@ -101,7 +105,8 @@ module Spree
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params, render_content?
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params,
render_content?
@table = order_grouper_table
csv_file_name = "payments_#{timestamp}.csv"
@@ -279,14 +284,14 @@ module Spree
def describe_report(report)
name = I18n.t(:name, scope: [:admin, :reports, report])
description = begin
I18n.t!(:description, scope: [:admin, :reports, report])
rescue I18n::MissingTranslationData
render_to_string(
partial: "#{report}_description",
layout: false,
locals: { report_types: report_types[report] }
).html_safe
end
I18n.t!(:description, scope: [:admin, :reports, report])
rescue I18n::MissingTranslationData
render_to_string(
partial: "#{report}_description",
layout: false,
locals: { report_types: report_types[report] }
).html_safe
end
{ name: name, url: url_for_report(report), description: description }
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ReturnAuthorizationsController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class SearchController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ShippingCategoriesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ShippingMethodsController < ::Admin::ResourceController
@@ -87,7 +89,7 @@ module Spree
params.require(:shipping_method).permit(
:name, :description, :display_on, :require_ship_address, :tag_list, :calculator_type,
:tax_category_id, distributor_ids: [],
calculator_attributes: PermittedAttributes::Calculator.attributes
calculator_attributes: PermittedAttributes::Calculator.attributes
)
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class StatesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxCategoriesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxRatesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxSettingsController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxonomiesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxonsController < Spree::Admin::BaseController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class UsersController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'open_food_network/scope_variants_for_search'
module Spree

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
module Admin
class ZonesController < ::Admin::ResourceController

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
class OrdersController < ::BaseController
include OrderCyclesHelper
@@ -131,7 +133,7 @@ module Spree
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
unless result.ok?
flash.now[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
flash.now[:error] = "#{I18n.t('payment_could_not_process')}. #{result.error}"
end
@order.reload
end

View File

@@ -26,7 +26,9 @@ module Spree
# sent back and the response is handled in the #confirm action in this controller.
redirect_to provider.express_checkout_url(pp_response, useraction: 'commit')
else
flash[:error] = Spree.t('flash.generic_error', scope: 'paypal', reasons: pp_response.errors.map(&:long_message).join(" "))
flash[:error] =
Spree.t('flash.generic_error', scope: 'paypal',
reasons: pp_response.errors.map(&:long_message).join(" "))
redirect_to main_app.checkout_state_path(:payment)
end
rescue SocketError

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Spree
class UsersController < ::BaseController
layout 'darkswarm'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stripe/account_connector'
module Stripe
@@ -13,7 +15,8 @@ module Stripe
else
flash[:error] = t('admin.controllers.enterprises.stripe_connect_fail')
end
redirect_to main_app.edit_admin_enterprise_path(connector.enterprise, anchor: 'payment_methods')
redirect_to main_app.edit_admin_enterprise_path(connector.enterprise,
anchor: 'payment_methods')
rescue Stripe::StripeError => e
render plain: e.message, status: :internal_server_error
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stripe/webhook_handler'
module Stripe

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserConfirmationsController < DeviseController
# Needed for access to current_ability, so we can authorize! actions
include Spree::Core::ControllerHelpers::Auth

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserPasswordsController < Spree::UserPasswordsController
layout 'darkswarm'

View File

@@ -1,7 +1,9 @@
# frozen_string_literal: true
require 'open_food_network/error_logger'
class UserRegistrationsController < Spree::UserRegistrationsController
I18N_SCOPE = 'devise.user_registrations.spree_user'.freeze
I18N_SCOPE = 'devise.user_registrations.spree_user'
before_action :set_checkout_redirect, only: :create

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Admin
module EnterprisesHelper
def add_check_if_single(count)

Some files were not shown because too many files have changed in this diff Show More