Skip to content

Commit fe4e748

Browse files
authored
feat(order,dashboard): version order credit lines (medusajs#13766)
* feat(): version order credit lines * undo last change * adjust where * remove date on ui * Create five-donuts-obey.md * add test * nit comment * woops
1 parent bad0858 commit fe4e748

File tree

9 files changed

+206
-55
lines changed

9 files changed

+206
-55
lines changed

.changeset/five-donuts-obey.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/order": patch
3+
"@medusajs/dashboard": patch
4+
---
5+
6+
feat(order,dashboard): version order credit lines

packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {
3838
} from "@medusajs/ui"
3939

4040
import { AdminReservation } from "@medusajs/types/src/http"
41-
import { format } from "date-fns"
4241
import { ActionMenu } from "../../../../../components/common/action-menu"
4342
import DisplayId from "../../../../../components/common/display-id/display-id"
4443
import { Thumbnail } from "../../../../../components/common/thumbnail"
@@ -872,26 +871,6 @@ const DiscountAndTotalBreakdown = ({
872871
<span className="txt-small text-ui-fg-subtle mx-1">
873872
-
874873
</span>
875-
<Tooltip
876-
content={format(
877-
new Date(creditLine.created_at),
878-
"dd MMM, yyyy, HH:mm:ss"
879-
)}
880-
>
881-
<Text
882-
size="small"
883-
leading="compact"
884-
className="txt-small text-ui-fg-subtle"
885-
>
886-
{format(
887-
new Date(creditLine.created_at),
888-
"dd MMM, yyyy"
889-
)}
890-
</Text>
891-
</Tooltip>
892-
<span className="txt-small text-ui-fg-subtle mx-1">
893-
-
894-
</span>
895874
<Text
896875
size="small"
897876
leading="compact"

packages/modules/order/integration-tests/__tests__/order-edit.spec.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
608608
quantity: 1,
609609
},
610610
},
611+
{
612+
action: ChangeActionType.CREDIT_LINE_ADD,
613+
order_id: createdOrder.id,
614+
version: createdOrder.version,
615+
reference: "gesture_of_goodwill",
616+
reference_id: "refr_123",
617+
amount: 10,
618+
},
611619
],
612620
})
613621

@@ -627,9 +635,15 @@ moduleIntegrationTestRunner<IOrderModuleService>({
627635
"items.detail",
628636
"summary",
629637
"shipping_methods",
638+
"credit_lines",
639+
"transactions",
640+
],
641+
relations: [
642+
"items",
643+
"shipping_methods",
644+
"credit_lines",
630645
"transactions",
631646
],
632-
relations: ["items", "shipping_methods", "transactions"],
633647
})
634648

635649
const serializedModifiedOrder = JSON.parse(JSON.stringify(modified))
@@ -643,6 +657,10 @@ moduleIntegrationTestRunner<IOrderModuleService>({
643657
expect(serializedModifiedOrder.shipping_methods).toHaveLength(1)
644658
expect(serializedModifiedOrder.shipping_methods[0].amount).toEqual(10)
645659

660+
expect(serializedModifiedOrder.credit_lines).toHaveLength(1)
661+
expect(serializedModifiedOrder.credit_lines[0].amount).toEqual(10)
662+
expect(serializedModifiedOrder.credit_lines[0].version).toEqual(2)
663+
646664
expect(serializedModifiedOrder.items).toEqual(
647665
expect.arrayContaining([
648666
expect.objectContaining({
@@ -694,8 +712,9 @@ moduleIntegrationTestRunner<IOrderModuleService>({
694712
"items.detail",
695713
"summary",
696714
"shipping_methods",
715+
"credit_lines",
697716
],
698-
relations: ["items"],
717+
relations: ["items", "credit_lines"],
699718
})
700719

701720
const serializedRevertedOrder = JSON.parse(
@@ -710,6 +729,8 @@ moduleIntegrationTestRunner<IOrderModuleService>({
710729
expect(serializedRevertedOrder.shipping_methods).toHaveLength(1)
711730
expect(serializedRevertedOrder.shipping_methods[0].amount).toEqual(10)
712731

732+
expect(serializedRevertedOrder.credit_lines).toHaveLength(0)
733+
713734
expect(serializedRevertedOrder.items).toEqual(
714735
expect.arrayContaining([
715736
expect.objectContaining({

0 commit comments

Comments
 (0)