Skip to content

Commit b2249b6

Browse files
authored
Merge branch 'develop' into feat/calculated-so-rma
2 parents 88ed8aa + a73c977 commit b2249b6

File tree

1,102 files changed

+33621
-17988
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,102 files changed

+33621
-17988
lines changed

.changeset/cuddly-monkeys-grow.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/admin-shared": patch
3+
"@medusajs/dashboard": patch
4+
"@medusajs/js-sdk": patch
5+
---
6+
7+
feat(dashboard,js-sdk,admin-shared): add customer addresses + layout change

.changeset/eight-numbers-know.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/ui-preset": patch
3+
"@medusajs/icons": patch
4+
"@medusajs/dashboard": patch
5+
---
6+
7+
chore(ui-preset,icons,dashboard): Sync with Figma, and update ArrowRight import

.changeset/fifty-badgers-punch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/workflows-sdk": patch
3+
---
4+
5+
fix: hooks auto-generated types to have precise input options

.changeset/giant-llamas-study.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/types": patch
3+
"@medusajs/medusa": patch
4+
"@medusajs/js-sdk": patch
5+
---
6+
7+
feat(medusa,types,js-sdk): add enabled plugins route

.changeset/good-wolves-travel.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@medusajs/workflow-engine-inmemory": patch
3+
"@medusajs/workflow-engine-redis": patch
4+
"@medusajs/orchestration": patch
5+
"@medusajs/types": patch
6+
---
7+
8+
chore(workflow-engine): expose cancel method

.changeset/hot-dolls-promise.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/locking": patch
3+
---
4+
5+
fix: register locking provider with its unique id

.changeset/late-shirts-begin.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/link-modules": patch
3+
"@medusajs/modules-sdk": patch
4+
"@medusajs/utils": patch
5+
---
6+
7+
feat: add check for uniqueness when creating links with isList=false

.changeset/pretty-fishes-grow.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@medusajs/order": patch
3+
"@medusajs/types": patch
4+
"@medusajs/medusa": patch
5+
"@medusajs/core-flows": patch
6+
---
7+
8+
feat(order,types,medusa,core-flows): fix(types,order,medusa,core-flows): create order credit lines during order refund

.changeset/tricky-zoos-perform.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/core-flows": patch
3+
"@medusajs/types": patch
4+
"@medusajs/utils": patch
5+
---
6+
7+
feat(core-flows,types,utils): make payment optional when cart balance is 0

.changeset/violet-trainers-sleep.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@medusajs/admin-shared": patch
3+
"@medusajs/dashboard": patch
4+
"@medusajs/js-sdk": patch
5+
---
6+
7+
feat(dashboard,js-sdk,admin-shared): add customer addresses + layout change

.github/workflows/generate-public-references.yml

+5
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ jobs:
146146
- name: Generate API Reference
147147
run: yarn openapi:generate
148148

149+
- name: Run prep script
150+
run: yarn prep
151+
working-directory: www/apps/api-reference
152+
149153
- name: Create Pull Request
150154
uses: peter-evans/create-pull-request@v4
151155
with:
@@ -156,6 +160,7 @@ jobs:
156160
add-paths: |
157161
www/apps/api-reference/specs
158162
www/utils/generated/oas-output
163+
www/apps/api-reference/generated
159164
branch: "docs/generate-api-ref"
160165
branch-suffix: "timestamp"
161166
dml:

integration-tests/http/__tests__/cart/store/cart.spec.ts

+50-3
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,9 @@ medusaIntegrationTestRunner({
10851085
{ option_id: shippingOption.id },
10861086
storeHeaders
10871087
)
1088+
})
10881089

1090+
it("should successfully complete cart", async () => {
10891091
const paymentCollection = (
10901092
await api.post(
10911093
`/store/payment-collections`,
@@ -1099,9 +1101,7 @@ medusaIntegrationTestRunner({
10991101
{ provider_id: "pp_system_default" },
11001102
storeHeaders
11011103
)
1102-
})
11031104

1104-
it("should successfully complete cart", async () => {
11051105
createCartCreditLinesWorkflow.run({
11061106
input: [
11071107
{
@@ -1144,6 +1144,53 @@ medusaIntegrationTestRunner({
11441144
)
11451145
})
11461146

1147+
it("should successfully complete cart with credit lines alone", async () => {
1148+
const oldCart = (
1149+
await api.get(`/store/carts/${cart.id}`, storeHeaders)
1150+
).data.cart
1151+
1152+
createCartCreditLinesWorkflow.run({
1153+
input: [
1154+
{
1155+
cart_id: oldCart.id,
1156+
amount: oldCart.total,
1157+
currency_code: "usd",
1158+
reference: "test",
1159+
reference_id: "test",
1160+
},
1161+
],
1162+
container: appContainer,
1163+
})
1164+
1165+
const response = await api.post(
1166+
`/store/carts/${cart.id}/complete`,
1167+
{},
1168+
storeHeaders
1169+
)
1170+
1171+
expect(response.status).toEqual(200)
1172+
expect(response.data.order).toEqual(
1173+
expect.objectContaining({
1174+
id: expect.any(String),
1175+
currency_code: "usd",
1176+
credit_line_total: 2395,
1177+
discount_total: 100,
1178+
credit_lines: [
1179+
expect.objectContaining({
1180+
amount: 2395,
1181+
}),
1182+
],
1183+
items: expect.arrayContaining([
1184+
expect.objectContaining({
1185+
unit_price: 1500,
1186+
compare_at_unit_price: null,
1187+
quantity: 1,
1188+
}),
1189+
]),
1190+
})
1191+
)
1192+
})
1193+
11471194
it("should successfully complete cart without shipping for digital products", async () => {
11481195
/**
11491196
* Product has a shipping profile so cart item should not require shipping
@@ -1181,7 +1228,7 @@ medusaIntegrationTestRunner({
11811228
)
11821229
).data.product
11831230

1184-
let cart = (
1231+
cart = (
11851232
await api.post(
11861233
`/store/carts`,
11871234
{

integration-tests/http/__tests__/order/admin/order.spec.ts

+184
Original file line numberDiff line numberDiff line change
@@ -1075,5 +1075,189 @@ medusaIntegrationTestRunner({
10751075
})
10761076
})
10771077
})
1078+
1079+
describe("POST /orders/:id/credit-lines", () => {
1080+
beforeEach(async () => {
1081+
const inventoryItemOverride = (
1082+
await api.post(
1083+
`/admin/inventory-items`,
1084+
{ sku: "test-variant", requires_shipping: false },
1085+
adminHeaders
1086+
)
1087+
).data.inventory_item
1088+
1089+
seeder = await createOrderSeeder({
1090+
api,
1091+
container: getContainer(),
1092+
inventoryItemOverride,
1093+
withoutShipping: true,
1094+
})
1095+
order = seeder.order
1096+
1097+
order = (await api.get(`/admin/orders/${order.id}`, adminHeaders)).data
1098+
.order
1099+
})
1100+
1101+
it("should successfully create credit lines", async () => {
1102+
const error = await api
1103+
.post(
1104+
`/admin/orders/${order.id}/credit-lines`,
1105+
{
1106+
amount: -106,
1107+
reference: "order",
1108+
reference_id: order.id,
1109+
},
1110+
adminHeaders
1111+
)
1112+
.catch((e) => e)
1113+
1114+
expect(error.response.status).toBe(400)
1115+
expect(error.response.data.message).toBe(
1116+
"Can only create positive credit lines if the order has a positive pending difference"
1117+
)
1118+
1119+
const error2 = await api
1120+
.post(
1121+
`/admin/orders/${order.id}/credit-lines`,
1122+
{
1123+
amount: 10000,
1124+
reference: "order",
1125+
reference_id: order.id,
1126+
},
1127+
adminHeaders
1128+
)
1129+
.catch((e) => e)
1130+
1131+
expect(error2.response.status).toBe(400)
1132+
expect(error2.response.data.message).toBe(
1133+
"Cannot create more positive credit lines with amount more than the pending difference"
1134+
)
1135+
1136+
const response = await api.post(
1137+
`/admin/orders/${order.id}/credit-lines`,
1138+
{
1139+
amount: 106,
1140+
reference: "order",
1141+
reference_id: order.id,
1142+
},
1143+
adminHeaders
1144+
)
1145+
1146+
expect(response.status).toBe(200)
1147+
expect(response.data.order).toEqual(
1148+
expect.objectContaining({
1149+
id: order.id,
1150+
total: 0,
1151+
subtotal: 100,
1152+
summary: expect.objectContaining({
1153+
current_order_total: 0,
1154+
accounting_total: 0,
1155+
pending_difference: 0,
1156+
}),
1157+
})
1158+
)
1159+
1160+
await api.post(
1161+
"/admin/order-edits",
1162+
{
1163+
order_id: order.id,
1164+
description: "Test",
1165+
},
1166+
adminHeaders
1167+
)
1168+
1169+
const item = order.items[0]
1170+
1171+
let result = (
1172+
await api.post(
1173+
`/admin/order-edits/${order.id}/items/item/${item.id}`,
1174+
{ quantity: 0 },
1175+
adminHeaders
1176+
)
1177+
).data.order_preview
1178+
1179+
result = (
1180+
await api.post(
1181+
`/admin/order-edits/${order.id}/request`,
1182+
{},
1183+
adminHeaders
1184+
)
1185+
).data.order_preview
1186+
1187+
result = (
1188+
await api.post(
1189+
`/admin/order-edits/${order.id}/confirm`,
1190+
{},
1191+
adminHeaders
1192+
)
1193+
).data.order_preview
1194+
1195+
result = (await api.get(`/admin/orders/${order.id}`, adminHeaders)).data
1196+
.order
1197+
1198+
const errorResponse = await api
1199+
.post(
1200+
`/admin/orders/${order.id}/credit-lines`,
1201+
{
1202+
amount: 106,
1203+
reference: "order",
1204+
reference_id: order.id,
1205+
},
1206+
adminHeaders
1207+
)
1208+
.catch((e) => e)
1209+
1210+
expect(errorResponse.response.status).toBe(400)
1211+
expect(errorResponse.response.data.message).toBe(
1212+
"Can only create negative credit lines if the order has a negative pending difference"
1213+
)
1214+
1215+
const error3 = await api
1216+
.post(
1217+
`/admin/orders/${order.id}/credit-lines`,
1218+
{
1219+
amount: -10000,
1220+
reference: "order",
1221+
reference_id: order.id,
1222+
},
1223+
adminHeaders
1224+
)
1225+
.catch((e) => e)
1226+
1227+
expect(error3.response.status).toBe(400)
1228+
expect(error3.response.data.message).toBe(
1229+
"Cannot create more negative credit lines with amount more than the pending difference"
1230+
)
1231+
1232+
const response2 = await api.post(
1233+
`/admin/orders/${order.id}/credit-lines`,
1234+
{
1235+
amount: -106,
1236+
reference: "order",
1237+
reference_id: order.id,
1238+
},
1239+
adminHeaders
1240+
)
1241+
1242+
expect(response2.data.order.summary.pending_difference).toEqual(0)
1243+
1244+
const response3 = await api
1245+
.post(
1246+
`/admin/orders/${order.id}/credit-lines`,
1247+
{
1248+
amount: -106,
1249+
reference: "order",
1250+
reference_id: order.id,
1251+
},
1252+
adminHeaders
1253+
)
1254+
.catch((e) => e)
1255+
1256+
expect(response3.response.status).toBe(400)
1257+
expect(response3.response.data.message).toBe(
1258+
"Can only create credit lines if the order has a positive or negative pending difference"
1259+
)
1260+
})
1261+
})
10781262
},
10791263
})

integration-tests/http/__tests__/promotions/admin/promotions.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ medusaIntegrationTestRunner({
617617
storeHeaders
618618
)
619619
).data.cart
620-
console.log("cartWithPromotion2 -- ", cartWithPromotion2.promotions)
620+
621621
expect(cartWithPromotion2).toEqual(
622622
expect.objectContaining({
623623
promotions: [

integration-tests/modules/__tests__/cart/store/carts.spec.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,7 @@ medusaIntegrationTestRunner({
13891389
const paymentCollection = (
13901390
await api.post(
13911391
`/store/payment-collections`,
1392-
{
1393-
cart_id: cart.id,
1394-
},
1392+
{ cart_id: cart.id },
13951393
storeHeaders
13961394
)
13971395
).data.payment_collection

0 commit comments

Comments
 (0)