fix(medusa): Missing refund amount when creating claim (#3224)
This commit is contained in:
committed by
GitHub
parent
91234c14b5
commit
472f96d7fb
5
.changeset/gentle-pets-press.md
Normal file
5
.changeset/gentle-pets-press.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Missing refund amount when creating claim
|
||||
@@ -38,6 +38,48 @@ describe("Claims", () => {
|
||||
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 () => {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
@@ -66,7 +108,6 @@ describe("Claims", () => {
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.order.claims[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.stringMatching(/^claim_*/),
|
||||
order_id: expect.any(String),
|
||||
refund_amount: 1200,
|
||||
claim_items: expect.arrayContaining([
|
||||
|
||||
@@ -157,14 +157,7 @@ export default async (req, res) => {
|
||||
await claimService.withTransaction(manager).create({
|
||||
idempotency_key: idempotencyKey.idempotency_key,
|
||||
order,
|
||||
type: value.type,
|
||||
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,
|
||||
...value,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user