**What**
- Add `transformQuery` to get endpoints for product, order and cart
- ensure that the default relations (when getting a singular entity) includes sales channels when enabled
- Add `EmptyQueryParams` class in common types to prevent query parameters while using `transformQuery`
- update product-, order- and cartFactory to include sales channels if provided
- remove `packages/medusa/src/controllers/products/admin-list-products.ts`
**Testing**
- expands sales channel for single order
- expands sales channels for orders with expand parameter
- returns single product with sales channel
- expands sales channels for products with expand parameter
- returns cart with sales channel for single cart
Fixes CORE-293
Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
Co-authored-by: Adrien de Peretti <25098370+adrien2p@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.
**What**
- Add `feature_flags` string array to store response
**Why**
- to provide conditional ui in admin corresponding to enabled features
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
* fix: caching deps + add true parallelization to integration tests api
* fix: github action
* chore: upgrade to yarn berry (#1762)
* init migration
* remove: yarn.lock from all pkgs
* fix: build script in pkgs
* adjust yarn config
* fix: yarn.lock and yarnrc.yml
* fix: github actions
* fix: wrong type
* fix (medusa-react): use dts-cli instead of tsdx
* fix: yarn.lock
* fix: yarn v
* fix: prepare script
* add: comment on why we need to downgrade yarn before medusa-dev
* chore: move to Turborepo (#1763)
* increase number of parallel nodes
* fix (medusa-fulfillment-webshipper): build script
* fix: use new version of medusa-dev
* fix: rename cache-bootstrap to cache-deps
* feat: add feature flag loading in projects
* fix: make feature flag consume itself
* fix: rename container registration to featureFlagRouter
* fix: refactor
* behavioral feature flags
* add environment to server
* limit "useTemplateDb" to non feature flagged migrations
* filter migrations and entities according to those which are enabled in the environment
* run only migrations that are enabled when running 'medusa migrations run'
* add logging to the featureflag loader
* initial implementation of featureFlagEntity
* column descriptors
* initial startServerWithEnv (to be refactored)
* update commands
* final touches
* update loaders to fix unit tests
* enable all batch job tests
* update seed method
* add api test capabilities
* revert batch job test
* revert formatting changes
* pr feedback
* pr feedback
* remove unused imports
* rename feature flag decorators
* pr feedback
Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
* add initial testing files
* prepare for github
* remove empty files
* remove ids
* set user and password for postgres service
* remove node setup
* remove unused flag from yarn install
* correct medusajs package
* arguments for create-medusa project
* make create command into one line
* working directory update
* update workflow
* add build
* run scripts from medusa-cli
* move scripts to medusa-cli
* add install
* get server output
* rename build to install
* update login script to get feedback
* add arguments to login script
* add argument for directory to get-product
* pass cli-test to get-products script
* add wait command
* fix waiting
* update wait-for-server
* echo status
* update start testing
* refactor code into test-action
* add list config for testing
* include shell
* update get-products script
* test to see if action fails when given wrong input
* use custom action for testing devleopment server and extend waiting for server to spin up
* update actions
* remove cache version
* yarn and build in cli-test directory
* update core
* update working directories
* test working dir after cd up
* update
* fix directories
* update directories
* use setup server action
* invoke correct action
* test
* update cli action
* remove action
* test with medusa-dev
* remove medusa dev for now
* test
* include medusa-dev
* remove invalid medusa new command
* try moving project one dir up
* add silent to curl output from live server wait
* update seed data directory
* test
* remove sub workflow
* add matrix and postgres override for medusa-config
* fix matrix syntax
* add database url to job
* update yaml
* cli should fail on logging in
* create setup server action
* update test-server
* update scripts
* run scripts directory instead of cli scripts
* make directories current
* remove tests from cli
* run only on pr
* update name
* remove batch job model (for testing purposes)
* remove ls from test server action
* get content from develop
* undo changes to generate reference
* remove comments from scripts
* test failing command
* redo migrate command failing
* move scripts into interation tests
* Apply suggestions from code review
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
* fix: return prices when lsiting products with a query
* add: integration test
* fix: integration test
* fix: move WithRequiredProperty to common.ts
* fix: comment
* refactor(medusa): Move some column to a base entity to make it easier to add new models without forgetting some columns
* styles(medusa): Cleanup models
* fix(medusa): typings due to model typings update
* feat(medusa): Cleanup models
* fix(medusa): A model must not return the generateId as part of the entity
* fix(medusa): Plugin integration snapshot
* fix(medusa): Typings from discount-rule-migration scripts
* refactor(medusa): Introduct BaseEntity/SoftDeletableEntity that the entity extends
* styles(medusa): Fix models linting
* test(medusa): Fix integration plugin tests
* feat(medusa): Create generateEntityId standalong function utility and update config to properly supprt ts spec files
* feat(medusa): Update entities to use the new utils to generate and apply the id
* test(medusa): Fix test suits
* feat(medusa): Improve generateEntityId utility
* feat(medusa): Add /admin/products/:id/variants end point
* test(medusa): Fix get-variants test casees
* feat(medusa): Include the config to the ProdutService#retrieveVariants as a method parameter
* feat(medusa): Improve get-variants endpoint
* feat(medusa): Improve get-variants endpoint
* test(medusa): Fix unit tests
* test(medusa): Fix unit tests
* feat(medusa): Improve typings
* feat(medusa): Update according to feedback
* feat(medusa): Update according to feedback
* test(medusa): Fix list-variants tests
* feat(medusa): Getting the variants from the product end point should use the productVariantService
* fix(medusa): list-variants expand possibly undefined
* Fix(medusa): List-variants endpoint
* fix(medusa): Tests suite for list-variant
* test(integration-tests): Fix yarn lock
* test(integration-tests): Fix yarn lock
* add customer groups to price list factory
* add integration test for filtering price lists by customer group
* normalize list price list query
* add customer groups to list-price-list queryparameters
* query based on customergroups if they exist for price lists
* remove verbose flag
* add another price list with a customer group
* remove console.log
* pr feedback
* add query type to repository
* add query type to repository
* set groups to undefined instead of deleting parameter
* remove wildcard destructing
* make buildQuery type specific to price lists
* steal Adriens types
* fix(medusa): support searching for price lists (#1407)
* delete instead of settting groups to undefined
* add groups to query with q
* use simple customer group factory instead of manual creation
* Update simple-customer-group-factory.ts
* remove comma that breaks integration-tests
Co-authored-by: Zakaria El Asri <33696020+zakariaelas@users.noreply.github.com>