**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
**What**
- add error handling when loading project config
**How**
- Add error parameter to get-medusa-config result if an error was thrown (previously we returned an empty config)
- Discussion:
A different, but equally valid approach could be just throwing the error rather than creating an error parameter. This causes a more ugly output without warnings and changes the api a bit but it would force error handling. wdyt?
**Why**
- cli would fail with database error `databaseMissingDriverError` if config was invalid, ex. missing a comma
### example (missing `,` in config)
**old output**
```
Successfully compiled 2 files with Babel (143ms).
[medusa-config] ⚠️ redis_url not found. A fake redis instance will be used.
[medusa-config] ⚠️ database_type not found. fallback to default sqlite.
info: Using flag MEDUSA_FF_ORDER_EDITING from environment with value true
info: Using flag MEDUSA_FF_SALES_CHANNELS from environment with value true
info: Using flag MEDUSA_FF_TAX_INCLUSIVE_PRICING from environment with value true
info: Using fake Redis
✔ Models initialized – 13ms
✔ Plugin models initialized – 0ms
✔ Repositories initialized – 17ms
⠋ Initializing databaseMissingDriverError: Wrong driver: "undefined" given. Supported drivers are: "aurora-data-api", "aurora-data-api-pg", "better-sqlite3", "capacitor", "cockroachdb", "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "nativescript", "oracle", "postgres", "react-native", "sap", "sqlite", "sqljs".
```
**new output**
```
Successfully compiled 2 files with Babel (185ms).
error: Error in loading config: Unexpected identifier
error: /Users/phko/projects/community/my-medusa-store/medusa-config.js:129
plugins,
^^^^^^^
SyntaxError: Unexpected identifier
at compileFunction (<anonymous>)
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at getConfigFile (/Users/phko/projects/community/my-medusa-store/node_modules/medusa-core-utils/dist/get-config-file.js:26:20)
```
**What**
- Adds new entity AnalyticsConfig
- Adds new service AnalyticsConfigService
- Adds new repository AnalyticsConfigRepository
- Adds new endpoints to get, create, update, and delete analytics configs
**Why**
As we begin gathering usage insights to help us improve Medusa, we want to give each individual users the ability to control what data they share with us, or not share any data with us at all. The AnalyticsConfig holds information that is used to check if the user wishes for their data to be anonymized or if they have opted out of sharing usage data.
The entire feature can be disabled on a store level by setting the feature flag `MEDUSA_FF_ANALYTICS=false` in their environment variables, the feature is enabled by default.
**Testing**
Adds integration test for each of the new endpoints
Resolves CORE-656, CORE-655, CORE-654
Also resolves CORE-574
**What**
Create a data structure that facilitate the addition of new column descriptor for both export and import and ensure that the column name is shared between bother import and export to facilitate the import with an exported file.
**Tests**
Add an additional integration tests that export a file, update the data, and re import the same file
FIXES CORE-716
FIXES CORE-713
**what**
- Add support to remove resources by batch on discount conditions
- Add support on medusa-js and medusa-react
**Tests**
- Add integration tests to validate that the resources have been deleted and the length is the one expected
- Add unit tests on medusa react
FIXES CORE-609
* feat(medusa): Allow to add items to a discount condition by batch + cleanup of discounts and discount conditions end points
* style(medusa): cleanup catch and log
* feat(medusa-react, medusa-js): Add support to add item batch to discount condition
* cleanup
* cleanup
* rename items to resources
* fix(medusa-js): url
* Create fast-suns-repair.md
* update naming
* tests(integration): Update tests to reflect API changes
* feat(medusa): Delete a condition should be idempotent on discount and condition
* revert
**What**
- Adds the use of price selection strategy to the endpoint `GET /admin/variants`
- Updates medusa-js to reflect this change (expanding the parameters).
**Testing**
- Adds a new integration test validating that returned variants are now of type PricedVariant, with the expected fields: original_price, calculated_price, etc.
**Why**
- Our current RMA flows (in our admin dashboard) relied heavily on simply using `order.tax_rate` to calculate variant prices in the different RMA menus. As taxes in Medusa, have become feature complete this approach had become very naive and has several potential issues. Moving the responsibility for calculating the correct prices guarantees that we always show the correct prices to admins.
**What**
- Fixes `GET /products` in both admin and store API so they no longer accept the param `type?: string`, but instead accept `type_id?: string[]`
**Why**
- Filtering by type would never return any products as `ptyp_:id` !== `ProductType`.
**Testing**
- Added an integration test for each endpoint.
Closes CORE-695
**What**
- allow the product type field to be null
**How**
- in case the type is `null`, pass `undefined` as the value of type prop to product create/update services, otherwise pass an object with `{value}` which will be upserted
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**What**
- when deleting an OE cloned items are deleted, this would fail if there were changes associated with the OE since line items were referenced from the item changes and couldn't be deleted
**How**
- when deleting an order edit also remove it's item changes
Fixes CORE-689
* What - fixing PR #2350
* Why - In the ProductImportStrategy class, the getImportInstructions improperly checks the product.id for each row. With it setup this way, products will always be considered new because the product.id column is not read here. So products will never be updated. [Link to the code line](bd94130916/packages/medusa/src/strategies/batch-jobs/product/import.ts (L166))
* How - Replacing `row["product.product.id"]` to `row["product.id"]`
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
**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**
Add allowed relations to list orders and get order to throw appropriate error message + status code
**Test**
- Integration: Throw on invalid relation provided to list orders
- Integration: Add test suite get order
- Successfully retrieve order with expand + fields
- Throw on invalid relation provided
* wait for update to order edit model
* delete line item tests
* create remove method for lineitem with tax lines
* add remove item tests
* split delete allocation tests into two: more and less than total
* remove unused import
* cleanup
* add medusa-js and react endpoints
* pr feedback fixes
* linting
* remove unused relation from query
* remove removed-event and unused imports
* add await
**What**
Allow a customer to complete a requested order edit.
**Test**
- Unit tests complete flow
- Unit tests medusa react
- Integration tests of order edit completion
FIXES CORE-501
**What**
Improve transform query middleware management of the allowed fields and relations in order to improve security upon access data
FIXES CORE-651
**what**
Support confirm of an order edit:
Upon confirmation, the items of the original order are detached and the items from the order edit are attached to the order.
The order total is recomputed with the correct total which can defer from the paid_total and refundable_amount (based on the paid_total)
**Tests**
- Unit tests medusa-js and medusa-react as well as the core
- Integration test of the confirmation flow which check that the order edit is properly confirmed and can be confirmed idempotently. Also validate the totals and that the order items correspond to the order edit items. Also validate the order totals.
FIXES CORE-498
**What**
- Implement adding a line item to order (edit)
**How**
- _by implementing the following "flow"_
- generate a line item
- computing line item adjustments for that line item
- creating tax lines
- creating a change record
**Testing**
- **_integration tests_**
- check if line item and order item change objects are created (with correct tax lines)
- line item adjustments are generated if
- fixed discount is applied to cart
- percentage discount is applied
- **_unit tests_**
- ensure that methods from Inventory, LineItem, LineItemAdjustment etc. services are called
---
RESOLVES CORE-495
**what**
Support `updateLineItem` which does the following:
- If no item change exist then create a new one and attaches the clone item with the adjustments and tax lines
- if an item change exists then delete/create adjustments and tax lines and update the cloned item quantity
**Tests**
- Unit tests core + client
- integration tests
- When no item change already exists
- When an item change already exists
FIXES CORE-497
**What**
- Improve `retrieveActive` to take into account `(confirmed/canceled/declined)_at`
**Test**
- one more Integration test on that case
FIXES CORE-601
**What**
- a MoneyAmount record can be created with either providing region or currency. MA records cannot be inserted in the DB without currency due to not null constraints therefore the currency needs to be inferred from provided region
**How**
- by using the same utility that fixes this issue on PL update
**Testing**
- extend the "create PL" integration test to handle a MA with a region
---
FIXES CORE-525