Commit Graph

17744 Commits

Author SHA1 Message Date
Rachel Arnould
27be0f6fd1 Merge pull request #13912 from dacook/sourced-variant1-13887
Create linked variants
2026-03-20 10:59:46 +01:00
Maikel Linke
b4b3e21cf6 Replace deprecated option bypass
- https://github.com/heartcombo/devise/pull/5803
2026-03-20 11:32:49 +11:00
Maikel Linke
ce90ec0f5b Ignore unused authentication_token column 2026-03-20 11:32:49 +11:00
Maikel Linke
2998432744 Remove use of devise token_authenticable
Our production servers don't show any use of this feature. The
associated column is nil for all users.

The gem has not been updated in seven years and it's blocking an
important upgrade of devise.
2026-03-20 11:32:48 +11:00
Maikel
c5aaecf76a Merge pull request #13961 from mkllnk/taler-checkout-stock-error
Taler checkout stock error
2026-03-20 11:29:58 +11:00
David Cook
8e6f1c4e99 Show display name 2026-03-18 14:30:27 +11:00
David Cook
2004934399 Register only necessary elements
This should be more efficient.

Best viewed with whitespace ignored.
2026-03-18 14:30:23 +11:00
David Cook
827ba1990d Ensure changes are tracked on newly added variant
I considered a few ways to do this. Cloned products are done with MutationObserver but it doesn't quite sit right with me. A dedicated controller for newly added rows would provide a good general solution. But do we want yet another controller? I'm not sure. This works and is pretty simple (although it requires a quick loop over _every_ form element.. let's see if we can avoid that.)
2026-03-18 14:03:11 +11:00
Gaetan Craig-Riou
c134bbf49b Add missing ability for credit customer
Fix the specs to use a non super admin user, so it should catch missing
ability in the future.
2026-03-11 15:34:27 +11:00
Maikel Linke
35e03ea3c7 Check stock before completing order after Taler payment 2026-03-11 15:12:21 +11:00
Maikel Linke
9ca1a9e33f Allow orders to be paid before checkout
Taler puts the payment completion into the hands of the user. So we
can't strictly finalise the payment and order together.

And in the bigger picture, it should be okay if a payment goes through
but we have to abort checkout due to stock issues. Then we want to be
able to check out again, using the existing complete payment. Any
refunds can be handled later by the shop owner.
2026-03-11 14:46:06 +11:00
David Cook
18fb1cfa74 Rename variant 'owner' to 'hub'
As discussed by team, and using same nomenclature as VariantOverride.
2026-03-11 11:09:13 +11:00
David Cook
e9ce2df5a9 Rename 'source variant' to linked variant (in most places)
There are two types of linked variant associations: source and target, so we need to keep the name there.
But when cloning a variant and retaining a link as source,  we will prefer the general term 'linked variant'. Hopefully this name works well.
2026-03-11 11:09:13 +11:00
David Cook
c165ade4ba Avoid unnecessary save
Actually, the variant factory is still adding an extra save. We should refactor Variant to avoid that.. but the afternoon slump has got me.
2026-03-11 11:09:12 +11:00
David Cook
7e8b3694be Move class instance variable to helper 2026-03-11 11:09:12 +11:00
David Cook
05c31db46a Remove touch
I think I was just following convention from existing relationships. Perhaps you could argue that a variant is affected by the links added/removed.. but we never look at updated_at so really there's no point at all.
2026-03-11 11:09:12 +11:00
David Cook
299ada1220 Refactor: move variant duplication to model
I tried to avoid it but rubocop made me move it. I think maybe it will need to go into a concern or service class later, but hopefully it's ok here for now.
2026-03-11 11:09:12 +11:00
David Cook
5757f086ec Set owner enterprise when creating source variant 2026-03-11 11:09:12 +11:00
David Cook
8955ffe126 AddOwnerToSpreeVariants [migration]
Should existing variants be migrated to have an owner (copied from supplier)? No, because you can change supplier. This concept needs work.
2026-03-11 11:09:09 +11:00
David Cook
b26152cf0e Only show option when you have permission
Preload the allow list once in the controller. This controller was initially set up to avoid instance variables, and pass variables explicitly to the template. That's a good principle, but in practice we have a growing list of variables passed down the chain to multiple partials which is getting cumbersome. I think instance variables have their place after all.
2026-03-11 11:08:50 +11:00
David Cook
78db179ff3 haml-lint:disable ViewLength
TIL we have linting on haml.

I couldn't think of a better way to handle this but would be glad to receive feedback.
2026-03-11 11:08:50 +11:00
David Cook
5fc6d25a69 Display presence of variant link in UI
It's quite ugly. But we will be iterating on this later.
2026-03-11 11:08:50 +11:00
David Cook
b877540f5f Create sourced variant link on clone 2026-03-11 11:08:50 +11:00
copilot-swe-agent[bot]
04c0adf960 Fix source_variants and target_variants associations in Variant model
Co-authored-by: dacook <4188088+dacook@users.noreply.github.com>

Thanks co-pilot for sending me in the right direction.
Would this be neater as a has_and_belongs_to_many? Maybe but I will try to keep moving.
2026-03-11 11:08:50 +11:00
David Cook
1c89e9979e CreateVariantLinks [migration]
Tried using the rails generator, but as usual it was a waste of time becuase it doesn't handle unusual cases.

I found more good guidance from that stackoverflow post:
> why are you worrying about your indexes? Build your app!

Something's not right in the model, see next commit.
2026-03-11 11:08:47 +11:00
David Cook
eba2fbcc30 Create source variants 2026-03-11 11:07:08 +11:00
David Cook
940aa57daf Set up permissions for creating source variants 2026-03-11 11:07:08 +11:00
David Cook
6fe2357ca0 Add enterprise permission create_sourced_variants 2026-03-11 11:07:08 +11:00
David Cook
bd01b5f113 Add 'create sourced variant' option in variant actions menu
For now, we will only be able to create sourced variant from variants that are visible to us (variants that we manage)

    In a later commit I will hide the option if you can't use it
2026-03-11 11:07:08 +11:00
Gaetan Craig-Riou
4810b02233 Merge pull request #13702 from marincarroll/improve-accessibility-of-admin-pagination
Improve accessibility of admin pagination
2026-03-10 22:12:57 +11:00
Gaetan Craig-Riou
251a1acffc Clean up enterprise controller 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
d5dec05ab1 Remove payment method ApiCustomerCredit 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
7790259c27 Add transaction origin for internal credit payments 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
6a99d2a3c8 Add transaction origin in descriptiopn 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
e7a2b7ea48 Remove payment method from customer account transaction 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
bc23423521 Remove the link between enterprise and internal payment method
Enterprise have access to the internal payment method by default.
The access is handled at the application level so we don't have to
manage database links.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
a4ca56c7a5 Refactored internal payment method
We now check on known payment method type, instead of using the internal
collumn.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
9f7655852d Provide helper method to get internal payment method 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
ec106a8f83 Add new payment method ApiCustomerCredit
It was previously modelled by a "Check" payment method
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
2e7237197a Refactor customer credit payment method
Set fixed name and description
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
25c579c478 Per review, small code fixes 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
ed3f928783 Fix diplaying customer transactions when no transaction 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
63a9601812 Add scroll bar to modal component
When content is too big, the bottom is displayed off screen
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
3b068b7125 Add created_by to customer account transactions
It allows tracking of who credited the customer via :
- customer account transaction API
- order payment screen
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
597c0590ed Add the ability to show ID on backoffice customer screen
The customer ID is needed for the customer account transaction api
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
b9b91620ef Make sure to link credit payment method on create and update 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
c67d47a773 Check if internal payment can be voided
Add extra security, we don't want to void a credit payment that is not
completed, otherwise we would be refunding credit that was not used.
A credit payment should not be in a non completed state, but you never
know.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
34c91613f7 Customer account transaction, simplify balance calculation
Lock the customer to ensure the balance calculation is correct. Much
simpler than locking the first transaction.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
219e3ca9c8 Fix typo 2026-03-10 16:07:42 +11:00
Gaetan Craig-Riou
628810eb33 Fix spec to work with the internal payment method 2026-03-10 16:07:42 +11:00