* chore: added get route for admin categories API
* chore: add tree method to mock repository
* chore: added changeset to the PR
* chore: rename id to productCategoryId in service
* chore: switch cli option to string
* chore: lint fixes, tests for parent category
* chore: move Nested Categories behind feature flag
* chore: use transformQuery hook in api
* chore: add feature flag in migrations
* chore: remove migration FF, fix FF name
* chore: add free text search + count repo function
* chore: added list endpoint for admin
* chore: added changeset for feature
* chore: address pr review comments
* chore: change oas comment
* chore: add nullable parent category filter + test
**What**
The order cancelation does not include the refunds relation. It means that the check of the length of the refund is never true and therefore no errors are thrown if the order contains the refunds.
**How**
Add the refunds relation and tests
FIXES CORE-976
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
**What:**
Introduces a new folder under which repository specs will be placed.
Why:
We don't currently have a good place to test ORM logic or custom queries against the database. The repository folder tests are a place for just exactly that.
How:
Creates an internal package similar to other integration tests - api and plugins.
CORE-965
**What**
- Add integration test suite for database options
- Expose integration tests DB to additional options
- Add test for `idle_in_transaction_session_timeout`
* 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
* add support for customer first- and last names and phone
* test for querying customer first_name, last_name and phone
* add customer as prop for querying orders
* polishing before pr
* changeset
**What**
Move to transformQuery which adds a default ordering and also allows to order the product list from the store API
**How**
Among other things, fix the product repo to allow ordering by either a key from the product or a key from a relation
FIXES CORE-911
FIXES CORE-901
* chore: tax_rate is added to giftcards
* chore: minor
* chore: update gift card tax calculations to look at giftCard.tax_rate
* chore: gift card transactions use tax rate from gift card for legacy
* fix: gift cart total check for transaction should check the length
* chore: use tax exclusive cost + use giftcard tax rate for gctransactions + refactor
* chore: fix integration test
* chore: address issues brought up in comments
* chore: move gift card creation as a part of order service on order placed
* chore: add type handling for gift card creation
* chore: fix specs
* chore: use taxLines to calculate tax of a gift card
* chore: specs for line items containing gift cards and without
* chore: add integration specs + fix tax rate bug
* chore: round totaling + add GC application specs
* chore: cleanup trialables
* chore: write migration script to backfill gift cards with null tax_rate
* chore: update legacy totals service for gift cards
* chore: add changeset
* chore: address PR review changes
* chore: fix tests based on new totals calc
* chore: address review comments
Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**what**
The goal of that PR is to first refactor the payment provider and payment plugin to support the new API that removes the data mutation from within the plugin to be done by the core instead. In any case, this pr does not include the steps of the deeper refactoring. The last part will come in later pr.
**How**
- The payment plugin is now capable to handle both the deprecated and new API and the plugin works the same as it use to works.
- The mutation made by the plugin have been moved into the core as well as the subscriber
- The tests have been updated to reflect the changed
- Remove all new methods introduced by the payment collections
- Mutualise types
- Update provider and payment collection services
- cleanup around all those refactoring including cleanup of the payment collection
- refactor stripe payment plugin
FIXES CORE-887
* test subtotals on draft order operations
* fetch cart with subtotals when doing draft order operations
* write test for updating discounts seeing changes in totals
* formatting
* udpate test
* force taxes
* missing select
* add import
* rm force_taxes
**What**
- enable to filter sales channels of a Publishable API Key with a free text search param
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**What**
When a discount is deleted from a cart, the line item adjustments must be refreshed. Now, the cart service `removeDiscount` includes updating the adjustments.
**Tests**
**Add a new integration test which:**
- create a cart with a discount
- add a line item
- validate the adjustments
- remove the discount
- check that the adjustments are not present anymore
**Update unit tests**
The actual tests cases now check that the adjustments repository is called when needed
FIXES CORE-890
**What**
I have created a new method on the cart service which is `addLineItems`, allowing a user to add one or multiple items in an optimized way. Also updated the `generate` method from the line item service which now also accept a object data or a collection of data which. Various places have been optimized and cache support has been added to the price selection strategy.
The overall optimization allows to reach another 9000% improvement in the response time as a median (Creating a cart with 6 items):
| | Min (ms) | Median (ms) | Max (ms) | Median Improvement (%)
|---|:-:|---|---|---|
| Before optimisation | 1200 | 9999 | 12698 | N/A
| After optimisation | 63 | 252 | 500 | 39x
| After re optimisation | 56 | 82 | 399 | 121x
| After including addressed feedback | 65 | 202 | 495 | 49x
FIXES CORE-722
**What**
- add/ remove sales channels to/from PublishableApiKey in batch
- associate created cart with SC defined by PK
- filter products if PK with SC association is present
- retrieve a list of sales channels for a PK
- implement 3 new middleware
- `extendRequestParams`
- _extend req object with PK scopes (a list of sales channels) if a publishable key is present in the header of the request_
- `validateProductSalesChannelAssociation`
- _validate if the passed product id belongs to a SC from the PK's scope_
- `validateSalesChannelParam`
- _validate that passed SC ids in the req body/query are within the scope of the PK_
**How**
- The general idea was to reuse existing logic in the controller layer which expects `sales_channel_id` array to be passed. The middleware sets associated SC ids in the request context if a PK is present. These ids are then merged in the controller and passed to the service layer.
**TODO**
- filter response from the search endpoint (CORE-824)
**Testing**
- _integration tests_
- add sales channels to the publishable API key scope
- remove sales channels from the publishable API key scope
- returns products from a specific channel associated with a publishable key
- returns products from multiples sales channels associated with a publishable key
- returns all products if PK is not passed
- returns all products if passed PK doesn't have associated channels
- should assign sales channel to order on cart completion if PK is present in the header
- list sales channels from the publishable api key
- throws because sales channel in query/body is not in the scope of passed PK
---
**Discussion**
- what about the other endpoints (e.g. GET /store/product/:id - do we return 404 if the product is not in the SC associated with passed PK)
- what about products search route
- what about `/admin/products` & `/admin/orders` routes (do we add the middleware there as well)
---
RESOLVES CORE-792
RESOLVES CORE-793
RESOLVES CORE-816
* use correct authentication middleware
* remove guard from get-session since it's guarded by middleware doing the same check
* Add integration tests
* Create lazy-swans-agree.md
Co-authored-by: olivermrbl <oliver@mrbltech.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**What**
Fix system error (500) with DraftOrder create operation when payload includes discount in a tax-inclusive context.
**How**
* Ensure newly created cart contains all required relation in order to calculate line item tax-inclusive pricing with discounts.
* Add resilience to TotalsService.getLineDiscounts()
* Ensure newly generate line items have variant relation loaded.
* fix TotalsService.getLineItemTotals to use the passed lineItem instead of relying on cartOrOrder.items.
**Test**
* Unit:
* TotalsService.getLineDiscounts - coverage
* Integration:
* Admin API draft-order - coverage
* Admin API draft-order create w/ discount in tax-inclusive
Resolves: CORE-771
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
**What**
- update PK endpoint
- medusa-js/react implementation
- add a title property to the entity
- update the migration file
- pass a title on create
- list PKs by title
- update the client libs with new param signatures
- change id prefix to: "pk_"
**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**
- Ensure that swaps can be created for orders with discounts in tax inclusive regions
**How**
- Retrieve cart with discounts and region before creating adjustments for line items in cart.
- In `discountService.calculateDiscountForLineItem` we used the method `totalsService.getLineItemTotals` if a line-item is tax inclusive. This method uses some fields from the cart that aren't populated on cart creation (such a `items` which caused the original error).
**Testing**
- add integration test `swaps > tax inclusive > "Complete swap flow with discount"` that creates a swap in the following environment
- tax inclusive region
- tax inclusive line item to be swapped
- fixed type discount with allocation: total
Fixes CORE-748
**What**
- validate shipping option requirements including tax if the shipping option is tax inclusive
**Testing**
- " given a cart with total above min-threshold and subtotal below min-threshold shipping option with tax inclusive pricing is available and can be applied"
- "given a cart with total above max-threshold and subtotal below max-threshold shipping option with tax inclusive pricing is not available"
Fixes CORE-752