diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json
index 610615299a731..66c2f132a26a0 100644
--- a/packages/admin/dashboard/src/i18n/translations/en.json
+++ b/packages/admin/dashboard/src/i18n/translations/en.json
@@ -901,7 +901,16 @@
"allocateItems": "Allocate items",
"editOrder": "Edit order",
"editOrderContinue": "Continue order edit",
- "inventoryKit": "Consists of {{count}}x inventory items"
+ "inventoryKit": "Consists of {{count}}x inventory items",
+ "itemTotal": "Item Total",
+ "shippingTotal": "Shipping Total",
+ "discountTotal": "Discount Total",
+ "taxTotalIncl": "Tax Total (included)",
+ "itemSubtotal": "Item Subtotal",
+ "shippingSubtotal": "Shipping Subtotal",
+ "discountSubtotal": "Discount Subtotal",
+ "taxTotal": "Tax Total"
+
},
"payment": {
"title": "Payments",
diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx
index f6015ff6a5694..4c03d6c488290 100644
--- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx
+++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx
@@ -18,6 +18,7 @@ import {
AdminOrder,
AdminOrderLineItem,
AdminOrderPreview,
+ AdminRegion,
AdminReturn,
} from "@medusajs/types"
import {
@@ -31,6 +32,7 @@ import {
toast,
Tooltip,
usePrompt,
+ clx,
} from "@medusajs/ui"
import { AdminPaymentCollection } from "../../../../../../../../core/types/dist/http/payment/admin/entities"
@@ -528,9 +530,9 @@ const Cost = ({
secondaryValue,
tooltip,
}: {
- label: string
+ label: ReactNode
value: string | number
- secondaryValue: string
+ secondaryValue?: string
tooltip?: ReactNode
}) => (
@@ -550,45 +552,191 @@ const Cost = ({
)
-const CostBreakdown = ({ order }: { order: AdminOrder }) => {
+const CostBreakdown = ({
+ order,
+}: {
+ order: AdminOrder & { region: AdminRegion }
+}) => {
const { t } = useTranslation()
+ const [isTaxOpen, setIsTaxOpen] = useState(false)
+ const [isShippingOpen, setIsShippingOpen] = useState(false)
+
+ const discountCodes = useMemo(() => {
+ const codes = new Set()
+ order.items.forEach((item) =>
+ item.adjustments?.forEach((adj) => {
+ codes.add(adj.code)
+ })
+ )
+
+ return Array.from(codes).sort()
+ }, [order])
+
+ const taxCodes = useMemo(() => {
+ const taxCodeMap = {}
+
+ order.items.forEach((item) => {
+ item.tax_lines?.forEach((line) => {
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total
+ })
+ })
+
+ order.shipping_methods.forEach((sm) => {
+ sm.tax_lines?.forEach((line) => {
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total
+ })
+ })
+
+ return taxCodeMap
+ }, [order])
+
+ const automaticTaxesOn = !!order.region!.automatic_taxes
+ const hasTaxLines = !!Object.keys(taxCodes).length
+
+ const discountTotal = automaticTaxesOn
+ ? order.discount_total
+ : order.discount_subtotal
return (
moved to line items now
- // secondaryValue={
- // order.discounts.length > 0
- // ? order.discounts.map((d) => d.code).join(", ")
- // : "-"
- // }
+ label={t(
+ automaticTaxesOn
+ ? "orders.summary.itemTotal"
+ : "orders.summary.itemSubtotal"
+ )}
+ value={getLocaleAmount(order.item_total, order.currency_code)}
+ />
+ setIsShippingOpen((o) => !o)}
+ className="flex cursor-pointer items-center gap-1"
+ >
+
+ {t(
+ automaticTaxesOn
+ ? "orders.summary.shippingTotal"
+ : "orders.summary.shippingSubtotal"
+ )}
+
+
+
+ }
+ value={getLocaleAmount(
+ automaticTaxesOn ? order.shipping_total : order.shipping_subtotal,
+ order.currency_code
+ )}
+ />
+
+ {isShippingOpen && (
+
+ {(order.shipping_methods || [])
+ .sort((m1, m2) =>
+ (m1.created_at as string).localeCompare(m2.created_at as string)
+ )
+ .map((sm, i) => {
+ return (
+
+
+
+ {sm.name}
+ {sm.detail.return_id &&
+ ` (${t("fields.returnShipping")})`}{" "}
+
+
+
+
+
+ {getLocaleAmount(
+ automaticTaxesOn ? sm.total : sm.subtotal,
+ order.currency_code
+ )}
+
+
+ )
+ })}
+
+ )}
+
+ 0
- ? `- ${getLocaleAmount(order.discount_total, order.currency_code)}`
+ discountTotal > 0
+ ? `- ${getLocaleAmount(discountTotal, order.currency_code)}`
: "-"
}
/>
- {(order.shipping_methods || [])
- .sort((m1, m2) =>
- (m1.created_at as string).localeCompare(m2.created_at as string)
- )
- .map((sm, i) => {
- return (
-
-
}
+
+ <>
+
+
hasTaxLines && setIsTaxOpen((o) => !o)}
+ className={clx("flex items-center gap-1", {
+ "cursor-pointer": hasTaxLines,
+ })}
+ >
+
+ {t(
+ automaticTaxesOn
+ ? "orders.summary.taxTotalIncl"
+ : "orders.summary.taxTotal"
+ )}
+
+ {hasTaxLines && (
+
-
- )
- })}
+ )}
+
+
+
+
+ {getLocaleAmount(order.tax_total, order.currency_code)}
+
+
+
+ {isTaxOpen && (
+
+ {Object.entries(taxCodes).map(([code, total]) => {
+ return (
+
+
+
+ {code}
+
+
+
+
+ {getLocaleAmount(total, order.currency_code)}
+
+
+ )
+ })}
+
+ )}
+ >
)
}
diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts
index cfa1993d31104..ae13fbb92f63c 100644
--- a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts
+++ b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts
@@ -8,8 +8,11 @@ const DEFAULT_PROPERTIES = [
"currency_code",
// --- TOTALS ---
"total",
+ "item_total",
+ "shipping_subtotal",
"subtotal",
- "discounts_total",
+ "discount_total",
+ "discount_subtotal",
"shipping_total",
"shipping_tax_total",
"tax_total",
@@ -40,6 +43,7 @@ const DEFAULT_RELATIONS = [
"*payment_collections.payments",
"*payment_collections.payments.refunds",
"*payment_collections.payments.refunds.refund_reason",
+ "region.automatic_taxes",
]
export const DEFAULT_FIELDS = `${DEFAULT_PROPERTIES.join(