diff --git a/README.md b/README.md
index 017545d1f5..449b1f0e0b 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@
+ Medusa Admin |
Website |
Roadmap |
Blog |
@@ -57,6 +58,8 @@ Medusa is an open-source headless commerce engine that enables developers to cre
curl localhost:9000/store/products | python -m json.tool
```
+We have a prebuilt admin dashboard that you can use to configure and manage your store find it here: [Medusa Admin](https://github.com/medusajs/admin)
+
After these four steps and only a couple of minutes, you now have a complete commerce engine running locally. You may now explore [the documentation](https://docs.medusa-commerce.com/api) to learn how to interact with the Medusa API. You may also add [plugins](https://github.com/medusajs/medusa/tree/master/packages) to your Medusa store by specifying them in your `medusa-config.js` file.
## 🛒 Setting up a storefront for your Medusa project
diff --git a/integration-tests/api/__tests__/admin/swaps.js b/integration-tests/api/__tests__/admin/swaps.js
index 78ec6db9e8..cf53d3c25e 100644
--- a/integration-tests/api/__tests__/admin/swaps.js
+++ b/integration-tests/api/__tests__/admin/swaps.js
@@ -72,6 +72,36 @@ describe("/admin/swaps", () => {
expect(response.data.swap.cart).toHaveProperty("discount_total")
expect(response.data.swap.cart).toHaveProperty("gift_card_total")
})
+
+ it("gets a swap with a discount", async () => {
+ const api = useApi()
+
+ const response = await api
+ .get("/admin/swaps/disc-swap", {
+ headers: {
+ Authorization: "Bearer test_token",
+ },
+ })
+ .catch((err) => {
+ console.log(err)
+ })
+ expect(response.status).toEqual(200)
+ expect(response.data.swap).toEqual(
+ expect.objectContaining({
+ id: "disc-swap",
+ })
+ )
+
+ expect(response.data.swap.cart).toEqual(
+ expect.objectContaining({
+ id: "disc-swap-cart",
+ discount_total: -800,
+ shipping_total: 1000,
+ subtotal: -8000,
+ total: -6200,
+ })
+ )
+ })
})
describe("GET /admin/swaps/", () => {
diff --git a/integration-tests/api/helpers/swap-seeder.js b/integration-tests/api/helpers/swap-seeder.js
index c35fcc08ef..233cf0177b 100644
--- a/integration-tests/api/helpers/swap-seeder.js
+++ b/integration-tests/api/helpers/swap-seeder.js
@@ -1,15 +1,8 @@
const {
- ShippingProfile,
- Customer,
- MoneyAmount,
+ Discount,
+ DiscountRule,
LineItem,
- Country,
- ShippingOption,
ShippingMethod,
- Product,
- ProductVariant,
- Region,
- Payment,
Order,
Swap,
Cart,
@@ -334,4 +327,108 @@ module.exports = async (connection, data = {}) => {
price: 1000,
data: {},
})
+
+ await createSwap({ id: "disc-swap" }, manager)
+}
+
+const createSwap = async (options, manager) => {
+ const swapId = options.id
+
+ const dRule = manager.create(DiscountRule, {
+ id: `${swapId}-cart-discount-rule`,
+ description: "Ten percent rule",
+ type: "percentage",
+ value: 10,
+ allocation: "total",
+ })
+ await manager.save(dRule)
+
+ const discount = manager.create(Discount, {
+ code: `${swapId}`,
+ is_dynamic: false,
+ is_disabled: false,
+ rule: dRule,
+ })
+ await manager.save(discount)
+
+ const cart = manager.create(Cart, {
+ id: `${swapId}-cart`,
+ customer_id: "test-customer",
+ email: "test-customer@email.com",
+ shipping_address_id: "test-shipping-address",
+ billing_address_id: "test-billing-address",
+ region_id: "test-region",
+ type: "swap",
+ discounts: [discount],
+ metadata: {
+ swap_id: swapId,
+ parent_order_id: "order-with-swap",
+ },
+ })
+
+ await manager.save(cart)
+
+ const swapTemplate = async () => {
+ return {
+ order_id: `order-with-swap`,
+ fulfillment_status: "fulfilled",
+ payment_status: "not_paid",
+ cart_id: cart.id,
+ }
+ }
+
+ const swapWithReturn = manager.create(Swap, {
+ id: swapId,
+ return_order: {
+ id: `${swapId}-return-id`,
+ status: "requested",
+ refund_amount: 0,
+ },
+ ...(await swapTemplate(swapId)),
+ })
+
+ await manager.save(swapWithReturn)
+ const li = manager.create(LineItem, {
+ id: `${swapId}-return-item-1`,
+ fulfilled_quantity: 1,
+ title: "Return Line Item",
+ description: "Line Item Desc",
+ thumbnail: "https://test.js/1234",
+ unit_price: 8000,
+ quantity: 1,
+ variant_id: "test-variant",
+ order_id: "order-with-swap",
+ cart_id: cart.id,
+ })
+
+ await manager.save(li)
+
+ const li2 = manager.create(LineItem, {
+ id: `${swapId}-test-item-many`,
+ fulfilled_quantity: 4,
+ title: "Line Item",
+ description: "Line Item Desc",
+ thumbnail: "https://test.js/1234",
+ unit_price: 8000,
+ quantity: 4,
+ variant_id: "test-variant",
+ order_id: "order-with-swap",
+ })
+
+ await manager.save(li2)
+
+ const return_item1 = manager.create(LineItem, {
+ ...li,
+ unit_price: -1 * li.unit_price,
+ })
+
+ await manager.save(return_item1)
+
+ await manager.insert(ShippingMethod, {
+ id: `${swapId}-test-method`,
+ shipping_option_id: "test-option",
+ cart_id: cart.id,
+ price: 1000,
+ data: {},
+ })
}
diff --git a/packages/medusa-plugin-meilisearch/CHANGELOG.md b/packages/medusa-plugin-meilisearch/CHANGELOG.md
index edee9f2a0e..1646be5736 100644
--- a/packages/medusa-plugin-meilisearch/CHANGELOG.md
+++ b/packages/medusa-plugin-meilisearch/CHANGELOG.md
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.6...medusa-plugin-meilisearch@0.0.7) (2021-11-03)
+
+### Bug Fixes
+
+- include discount rule in swap retrieval ([#682](https://github.com/medusajs/medusa/issues/682)) ([a5fe1c2](https://github.com/medusajs/medusa/commit/a5fe1c2e284ff5cb757b792c1a3c8414c211e4e8))
+
## [0.0.6](https://github.com/medusajs/medusa/compare/medusa-plugin-meilisearch@0.0.5...medusa-plugin-meilisearch@0.0.6) (2021-10-19)
### Bug Fixes
diff --git a/packages/medusa-plugin-meilisearch/package.json b/packages/medusa-plugin-meilisearch/package.json
index dd11098c42..ca9cc82a03 100644
--- a/packages/medusa-plugin-meilisearch/package.json
+++ b/packages/medusa-plugin-meilisearch/package.json
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-meilisearch",
- "version": "0.0.6",
+ "version": "0.0.7",
"description": "A starter for Medusa projects.",
"main": "index.js",
"repository": {
diff --git a/packages/medusa-plugin-meilisearch/yarn.lock b/packages/medusa-plugin-meilisearch/yarn.lock
index 2cd22af7e9..15a5be80b3 100644
--- a/packages/medusa-plugin-meilisearch/yarn.lock
+++ b/packages/medusa-plugin-meilisearch/yarn.lock
@@ -953,18 +953,6 @@
exec-sh "^0.3.2"
minimist "^1.2.0"
-"@hapi/hoek@^9.0.0":
- version "9.2.1"
- resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.1.tgz#9551142a1980503752536b5050fd99f4a7f13b17"
- integrity sha512-gfta+H8aziZsm8pZa0vj04KO6biEiisppNgA1kbJvFrrWu9Vm7eaUEy76DIxsuTaWvti5fkJVhllWc6ZTE+Mdw==
-
-"@hapi/topo@^5.0.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012"
- integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==
- dependencies:
- "@hapi/hoek" "^9.0.0"
-
"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
@@ -1166,23 +1154,6 @@
readdirp "^2.2.1"
upath "^1.1.1"
-"@sideway/address@^4.1.0":
- version "4.1.2"
- resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1"
- integrity sha512-idTz8ibqWFrPU8kMirL0CoPH/A29XOzzAzpyN3zQ4kAWnzmNfFmRaoMNN6VI8ske5M73HZyhIaW4OuSFIdM4oA==
- dependencies:
- "@hapi/hoek" "^9.0.0"
-
-"@sideway/formula@^3.0.0":
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
- integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
-
-"@sideway/pinpoint@^2.0.0":
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
- integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
-
"@sinonjs/commons@^1.7.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
@@ -3531,22 +3502,6 @@ jest@^25.5.2:
import-local "^3.0.2"
jest-cli "^25.5.4"
-joi-objectid@^3.0.1:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668"
- integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ==
-
-joi@^17.3.0:
- version "17.4.2"
- resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.2.tgz#02f4eb5cf88e515e614830239379dcbbe28ce7f7"
- integrity sha512-Lm56PP+n0+Z2A2rfRvsfWVDXGEWjXxatPopkQ8qQ5mxCEhwHG+Ettgg5o98FFaxilOxozoa14cFhrE/hOzh/Nw==
- dependencies:
- "@hapi/hoek" "^9.0.0"
- "@hapi/topo" "^5.0.0"
- "@sideway/address" "^4.1.0"
- "@sideway/formula" "^3.0.0"
- "@sideway/pinpoint" "^2.0.0"
-
js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -3777,21 +3732,6 @@ media-typer@0.3.0:
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
-medusa-core-utils@^1.1.20, medusa-core-utils@^1.1.23:
- version "1.1.23"
- resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.23.tgz#1e9260d5066117350dbf56dc176dd25e488e90a1"
- integrity sha512-3KnfbCGud09xYC7qrc+kw2XmBFa4UuGBOPT2IU3j70BjFhEU9ftD45oolKXNUziOZIIGRf/FIwGj+Lwgy6IAfA==
- dependencies:
- joi "^17.3.0"
- joi-objectid "^3.0.1"
-
-medusa-interfaces@^1.1.23:
- version "1.1.24"
- resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-1.1.24.tgz#13d0bc4afbd56c028c9e4bc562b0ce7a2023453c"
- integrity sha512-jzdHRN6AmX2Tuh3nbZd9PQJ0z1b6TzAAfyjak2rmakfoXzv19cAcXq5iUV04kQk+659Q+A14ei1LD/IemMYDmA==
- dependencies:
- medusa-core-utils "^1.1.23"
-
meilisearch@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.20.0.tgz#42899fec7a2ddefcd035e30ed5dd47aa65a6727f"
diff --git a/packages/medusa/CHANGELOG.md b/packages/medusa/CHANGELOG.md
index e550dbba5a..fcfdb22a4f 100644
--- a/packages/medusa/CHANGELOG.md
+++ b/packages/medusa/CHANGELOG.md
@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.1.51](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.50...@medusajs/medusa@1.1.51) (2021-11-03)
+
+### Bug Fixes
+
+- include discount rule in swap retrieval ([#682](https://github.com/medusajs/medusa/issues/682)) ([a5fe1c2](https://github.com/medusajs/medusa/commit/a5fe1c2e284ff5cb757b792c1a3c8414c211e4e8))
+
+## [1.1.50](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.49...@medusajs/medusa@1.1.50) (2021-11-02)
+
+**Note:** Version bump only for package @medusajs/medusa
+
## [1.1.49](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.48...@medusajs/medusa@1.1.49) (2021-10-26)
### Bug Fixes
diff --git a/packages/medusa/package.json b/packages/medusa/package.json
index 9642a6ca51..d45d27b020 100644
--- a/packages/medusa/package.json
+++ b/packages/medusa/package.json
@@ -1,6 +1,6 @@
{
"name": "@medusajs/medusa",
- "version": "1.1.49",
+ "version": "1.1.51",
"description": "E-commerce for JAMstack",
"main": "dist/index.js",
"bin": {
diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js
index 8e73dbf83e..aef327f1b6 100644
--- a/packages/medusa/src/services/claim.js
+++ b/packages/medusa/src/services/claim.js
@@ -365,6 +365,7 @@ class ClaimService extends BaseService {
"order",
"order.billing_address",
"order.discounts",
+ "order.discounts.rule",
"order.payments",
],
})
diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js
index 08621de695..6de354c198 100644
--- a/packages/medusa/src/services/swap.js
+++ b/packages/medusa/src/services/swap.js
@@ -127,6 +127,8 @@ class SwapService extends BaseService {
relationSet.add("cart.items")
relationSet.add("cart.gift_cards")
relationSet.add("cart.discounts")
+ relationSet.add("cart.discounts.rule")
+ relationSet.add("cart.discounts.rule.valid_for")
relationSet.add("cart.shipping_methods")
relationSet.add("cart.region")
relations = [...relationSet]