-
-
Notifications
You must be signed in to change notification settings - Fork 724
Tech Doc: Orders and Adjustments updates
Luis Ramos edited this page Apr 11, 2019
·
1 revision
Updating adjustments can be a bit tricky in Spree due to a web of callbacks. Adjustments can be in three different states (simplified): open, closed and finalised. An adjustment can be updated either open or closed.
But when an adjustment is associated to an order, and update triggers the after_save callback update_adjustable
which calls update!
on the order and that eventually triggers a reset of the adjustment unless it's closed. Here is the rough call trace:
-
adjustment.update_attributes
triggersadjustable.update!
. -
Order#update!
triggers theSpree::OrderUpdater
. - The updater updates all shipments and adjustments.
-
Adjustment#update!
doesn't do anything if the adjustment is closed. - When the adjustment is open,
originator.update_adjustment
is called. -
ShippingMethod#Adjustment
recalculates the amount and callsadjustment.update_attribute_without_callbacks(:amount, compute_amount(calculable))
.
All this is Spree code. It's not something we accidentally caused with OFN overrides. So Spree defines this way:
- Open shipping adjustments are always recalculated -> can't be changed to a custom value.
- Closed shipping adjustments are not recalculated -> can be changed to a custom value.
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
Instance-specific configuration
External services
Design