fix(medusa): Missing refund amount when creating claim (#3224)
This commit is contained in:
1 parent
91234c14b5
commit
472f96d7fb
3 files changed
+48
-9
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): Missing refund amount when creating claim
|
||||||
@@ -38,6 +38,48 @@ describe("Claims", () => {
|
|||||||
return await doAfterEach()
|
return await doAfterEach()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("creates a refund claim with custom refund amount", async () => {
|
||||||
|
await adminSeeder(dbConnection)
|
||||||
|
|
||||||
|
const order = await createReturnableOrder(dbConnection)
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api.post(
|
||||||
|
`/admin/orders/${order.id}/claims`,
|
||||||
|
{
|
||||||
|
type: "refund",
|
||||||
|
refund_amount: 1000,
|
||||||
|
claim_items: [
|
||||||
|
{
|
||||||
|
item_id: "test-item",
|
||||||
|
reason: "missing_item",
|
||||||
|
quantity: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
authorization: "Bearer test_token",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.order.claims[0]).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
order_id: expect.any(String),
|
||||||
|
refund_amount: 1000,
|
||||||
|
claim_items: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
item: expect.any(Object),
|
||||||
|
item_id: "test-item",
|
||||||
|
quantity: 1,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test("creates a refund claim", async () => {
|
test("creates a refund claim", async () => {
|
||||||
await adminSeeder(dbConnection)
|
await adminSeeder(dbConnection)
|
||||||
|
|
||||||
@@ -66,7 +108,6 @@ describe("Claims", () => {
|
|||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.order.claims[0]).toEqual(
|
expect(response.data.order.claims[0]).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: expect.stringMatching(/^claim_*/),
|
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
refund_amount: 1200,
|
refund_amount: 1200,
|
||||||
claim_items: expect.arrayContaining([
|
claim_items: expect.arrayContaining([
|
||||||
|
|||||||
@@ -157,14 +157,7 @@ export default async (req, res) => {
|
|||||||
await claimService.withTransaction(manager).create({
|
await claimService.withTransaction(manager).create({
|
||||||
idempotency_key: idempotencyKey.idempotency_key,
|
idempotency_key: idempotencyKey.idempotency_key,
|
||||||
order,
|
order,
|
||||||
type: value.type,
|
...value,
|
||||||
shipping_address: value.shipping_address,
|
|
||||||
claim_items: value.claim_items,
|
|
||||||
return_shipping: value.return_shipping,
|
|
||||||
additional_items: value.additional_items,
|
|
||||||
shipping_methods: value.shipping_methods,
|
|
||||||
no_notification: value.no_notification,
|
|
||||||
metadata: value.metadata,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in new issue
Block a user