Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions integration-tests/http/__tests__/order/admin/order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2896,11 +2896,20 @@ medusaIntegrationTestRunner({
amount: -106,
reference: "order",
reference_id: order.id,
metadata: { note: "Store credit refund" },
},
adminHeaders
)

expect(response2.data.order.summary.pending_difference).toEqual(0)
// SHOULD ADD METADATA TO THE CREDIT LINE
expect(response2.data.order.credit_lines).toEqual(
expect.arrayContaining([
expect.objectContaining({
metadata: { note: "Store credit refund" },
}),
])
)

const response3 = await api
.post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export const OrderBalanceSettlementForm = ({
amount: parseFloat(data.credit_line!.amount! as string) * -1,
reference: data.credit_line!.reference ?? "order",
reference_id: data.credit_line!.reference_id ?? order.id,
metadata: {
note: "Store credit refund",
},
},
{
onSuccess: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,8 @@ const CreditLinesBreakdown = ({
.split("-")
.join(" ")

const prettyReferenceId = creditLine.reference_id ? (
<DisplayId id={creditLine.reference_id} />
) : null
const hasNote = !!creditLine.metadata?.note
const isGiftCard = creditLine.reference_id?.startsWith("gcard_")

return (
<div
Expand All @@ -813,7 +812,9 @@ const CreditLinesBreakdown = ({
weight="plus"
className="truncate"
>
<DisplayId id={creditLine.id} />
{hasNote
? (creditLine.metadata?.note as string)
: "Credit line"}
</Text>

<Text size="small" leading="compact">
Expand All @@ -825,9 +826,20 @@ const CreditLinesBreakdown = ({
</div>

<div className="hidden items-center justify-end gap-x-2 sm:flex">
<Text size="small" leading="compact" className="capitalize">
{prettyReference} ({prettyReferenceId})
</Text>
{isGiftCard ? (
<Link
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg"
to={`/gift-cards/${creditLine.reference_id}`}
>
<Text
size="small"
leading="compact"
className="capitalize"
>
{prettyReference}
</Text>
</Link>
) : null}
</div>

<div className="flex items-center justify-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const createOrderCreditLinesWorkflow = createWorkflow(
reference: creditLine.reference!,
reference_id: creditLine.reference_id!,
amount: creditLine.amount,
details: { metadata: creditLine.metadata },
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@opentelemetry/api": "^1.9.0",
"@types/express": "^4.17.17",
"chokidar": "^3.4.2",
"compression": "1.7.4",
"compression": "1.7.5",
"connect-redis": "5.2.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FindConfig, QueryConfig, RequestQueryFields } from "@medusajs/types"
import {
buildOrder,
isDefined,
isPresent,
MedusaError,
Expand Down Expand Up @@ -212,7 +213,7 @@ export function prepareListQuery<T extends RequestQueryFields, TEntity>(
}
}

const finalOrder = isPresent(orderBy) ? orderBy : undefined
const finalOrder = isPresent(orderBy) ? buildOrder(orderBy) : undefined
return {
listConfig: {
select: select.length ? select : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OrderChangeProcessing.registerActionType(ChangeActionType.CREDIT_LINE_ADD, {
amount: MathBN.convert(action.amount!),
reference: action.reference!,
reference_id: action.reference_id!,
metadata: action.details?.metadata,
}

creditLines.push(newCreditLine)
Expand Down
26 changes: 24 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6323,7 +6323,7 @@ __metadata:
"@types/jsonwebtoken": ^8.5.9
awilix: ^8.0.1
chokidar: ^3.4.2
compression: 1.7.4
compression: 1.7.5
connect-dynamodb: ^3.0.5
connect-redis: 5.2.0
cookie-parser: ^1.4.6
Expand Down Expand Up @@ -18559,7 +18559,7 @@ __metadata:
languageName: node
linkType: hard

"compressible@npm:~2.0.16":
"compressible@npm:~2.0.16, compressible@npm:~2.0.18":
version: 2.0.18
resolution: "compressible@npm:2.0.18"
dependencies:
Expand All @@ -18583,6 +18583,21 @@ __metadata:
languageName: node
linkType: hard

"compression@npm:1.7.5":
version: 1.7.5
resolution: "compression@npm:1.7.5"
dependencies:
bytes: 3.1.2
compressible: ~2.0.18
debug: 2.6.9
negotiator: ~0.6.4
on-headers: ~1.0.2
safe-buffer: 5.2.1
vary: ~1.1.2
checksum: 35c9d2d57c86d8107eab5e637f2146fcefec8475a2ff3e162f5eb0982ff856d385fb5d8c9823c3d50e075f2d9304bc622dac3df27bfef0355309c0a5307861c5
languageName: node
linkType: hard

"concat-map@npm:0.0.1":
version: 0.0.1
resolution: "concat-map@npm:0.0.1"
Expand Down Expand Up @@ -27189,6 +27204,13 @@ __metadata:
languageName: node
linkType: hard

"negotiator@npm:~0.6.4":
version: 0.6.4
resolution: "negotiator@npm:0.6.4"
checksum: 3e677139c7fb7628a6f36335bf11a885a62c21d5390204590a1a214a5631fcbe5ea74ef6a610b60afe84b4d975cbe0566a23f20ee17c77c73e74b80032108dea
languageName: node
linkType: hard

"neo-async@npm:^2.6.0, neo-async@npm:^2.6.2":
version: 2.6.2
resolution: "neo-async@npm:2.6.2"
Expand Down