**What**
- Fix stock locations quantities being shown as `undefined` and `NaN`
- Throw if updates to location levels are made with negative quantities through the api
- Show "allocated" in order summary for partially fulfilled orders
Fixes CORE-1268, CORE-1267, CORE-1265
**What**
- Adjust reservations correctly according to the following heuristic:
adjustment by addition: (i.e. positive quantity adjustment passed to the adjustment method)
- if a reservation for the line-item in the location exists add quantity to that
- if not create a new reservation
adjustment by subtraction:
- if a reservation with the exact quantity exists, delete it and return
- if a reservation with a greater quantity exists, subtract from it and return
- otherwise delete from reservations until a reservation with greater quantity than the remaining is found and adjust that with the remaining quantity OR there are no more reservations
Fixes CORE-1247
**What**
- Remove related inventory levels and reservation items when a stock location is removed
**How**
- Add bulk deletion methods for both inventory levels and reservation items to the inventory service api
- invoke both on location removal
Fixes CORE-1232
**What**
- Toggle manage inventory in the inventory management modal
**How**
- Create/update/remove inventory item based on if `manage_inventory` is set and if an inventory item already exists
- Move all stock location updates to when the modal is submitted
- Add create-inventory-item endpoint in the core
Fixes CORE-1196
Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
**What**
- include location id when creating a fulfillment
- Allow location updates to reservations without passing along quantity
**Why**
- location_id on fulfillment was null after creation
Fixes CORE-1242, CORE-1243
* add location_id to request_return endpoint to support "receive_now" returns
* changeset
* admin request return
* add locations to recieving returns
* cleanup test
* add check for inventory service
* update create fulfillment flow
* move transaction service creation close to where it's used
* integration tests
* fix feedback
* use transformBody
* add changeset
* only add ordering select if not already selected
* add integration test
* add changeset
* remove catch
* linting and suggestion from adrien
* add sales channel filtering when listing locations
* add changeset
* add exception back into sales channel location service
---------
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
* remove duplicate key from oas
* changeset
* initial suggestion for adding locations to fulfillments
* update migration
* re-add functionality for removing entire reservations
* fix tests
* add location when adjusting reserved inventory of a line_item
* add changest
* handle multiple reservations for a product in the same channel
* confirm inventory in stock location previous to creating the fulfillment
* fix tests after updating create-fulfillment to confirm inventory prior to creating fulfillment
* remove bugged code
* initial validation
* initial changes for review
* chekcpoint
* update validate inventory at location
* redo some unwanted changes
* typing
* update snapshots
* redo change for eslintrc
* add eslint disable
* re-order methods in interface
* assert no_notification
* iterate one time less
* add test for validation of correct inventory adjustments in case of no inventory service installation
* ensure correct adjustments for order cancellations
* remove comment
* fix tests
* fix but with coalescing
* remove location id from confirm inventory
* don't throw when adjusting reservations for a line item without reservations
* move reservation adjustments to the api
* add multiplication for updating a reservation quantity
* move inventory adjustments from the service layer to the api
* delete reservation if quantity is adjusted to 0
* rename updateReservation to updateReservationItem
* update dto fields
* reference the correct fields
* update with transaction
* add jsdocs
* force boolean cast
* context-ize cancel and create fulfillment transaction methods
* undo notification cast
* update with changes
* refactor withTransaction to variable
* use maps
* fix service mocks
* add mw feature flag
* add services
* add types
* add module interfaces
* add interface export
* add models for mw
* to be ammended
* remove featureflag
* use correct count
* update cart completion strategy
* swap service conversion
* update return service
* update order service
* update claim service
* add exception to claim item
* update cart service
* add indicies
* add changeset
* nullable changes in store
* store model update
* fix unit tests
* remove old inventory service
* format integration test
* update snapshots
* remove old inventory service tests
* update snapshots
* remove old code
* option updates
* naming
* add jsdoc to pv inventory service
* rename class variables
* pr feedback
* rename option to context
* if(variant_id) instead of if(typeof varia...)
* update tests
* add jsdoc
* go for custom
* update code for readability
**What**
If `total` or `subtotal` are selected then get the line item totals and assign them to the items.
I also had to remove the totals from the cart update service since they are not used and that by having them the items get the tax lines attached and since the update is performed by passing the entire cart, it is trying to insert the tax lines with the cart update
**Tests**
Add an integration tests to validate that the items includes the totals in the order and draft order
FIXES CORE-687
**What**
The existing totals calculations are extremely heavy and perform an enormous amount of duplicate work. The changes here remove large parts of the overhead and improves response times for cart endpoints up to 30x.
**What**
- refactor swap service to typescript
- reimplement legacy methods
- use enums instead of magic strings
RESOLVES CORE-396
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**What**
Since the release of the Tax API the line item totals calculations on orders with gift cards have been wrong. To understand the bug consider the below order:
Region:
- tax_rate: 25%
- gift_cards_taxable: true
Order:
- applied gift card: 1000
- items:
- A: unit_price: 1000
- B: unit_price: 500
- Subtotal: 1500
**Previous calculation method**
1. Determine how much of the gift card is used for each item using `item_total / subtotal * gift_card_amount`:
- Item A: 1000/1500 * 1000 = 666.67
- Item B: 500/1500 * 1000 = 333.33
2. Calculate line item totals including taxes using `(unit_price - gift_card) * (1 + tax_rate)`
- Item A: 1000 - 666.67 = 333.33; vat amount -> 83.33
- Item B: 500 - 333.33 = 166.67; vat amount -> 41.67
3. Add up the line item totals: order subtotal = 500; vat amount = 125; total = 625
This is all correct at the totals level; but at the line item level we should still use the "original prices" i.e. the line item total for item a should be (1000 * 1.25) = 1250 with a tax amount of 250.
**New calculation method**
1. Use default totals calculations
- Item A: subtotal: 1000, tax_total: 250, total: 1250
- Item B: subtotal: 500, tax_total: 125, total: 625
2. Add up the line item totals: subtotal: 1500, tax_total: 375, total: 1875
3. Reduce total with gift card: subtotal: 1500 - 1000 = 500, tax_total: 375 - 250 = 125, total = 625
Totals can now be forwarded correctly to accounting plugins.
Fixes CORE-310.
* fix: make plugin tests run with integration test suites"
* add: plugins to test pipeline
* add: run integration tests on different jobs + fix failing test command
* fix: typo
* fix: pipeline