@dainamite/cpq 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/MIGRATION.md +74 -0
  3. package/dist/modules/cpq/acl.js +1 -0
  4. package/dist/modules/cpq/acl.js.map +2 -2
  5. package/dist/modules/cpq/api/_helpers/adjustmentCommandRoute.js +45 -0
  6. package/dist/modules/cpq/api/_helpers/adjustmentCommandRoute.js.map +7 -0
  7. package/dist/modules/cpq/api/_helpers/quoteMutationGuard.js +23 -0
  8. package/dist/modules/cpq/api/_helpers/quoteMutationGuard.js.map +7 -0
  9. package/dist/modules/cpq/api/_helpers/quoteRouteOpenApi.js +19 -0
  10. package/dist/modules/cpq/api/_helpers/quoteRouteOpenApi.js.map +7 -0
  11. package/dist/modules/cpq/api/orders/[orderId]/route.js +17 -1
  12. package/dist/modules/cpq/api/orders/[orderId]/route.js.map +2 -2
  13. package/dist/modules/cpq/api/orders/route.js +47 -2
  14. package/dist/modules/cpq/api/orders/route.js.map +2 -2
  15. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/restore/route.js +54 -0
  16. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/restore/route.js.map +7 -0
  17. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js +42 -2
  18. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js.map +2 -2
  19. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js +27 -2
  20. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js.map +2 -2
  21. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/[adjustmentId]/route.js +47 -0
  22. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/[adjustmentId]/route.js.map +7 -0
  23. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/preview/route.js +30 -0
  24. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/preview/route.js.map +7 -0
  25. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/route.js +47 -0
  26. package/dist/modules/cpq/api/quotes/[quoteId]/price-adjustments/route.js.map +7 -0
  27. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js +32 -2
  28. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js.map +2 -2
  29. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js +33 -2
  30. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js.map +2 -2
  31. package/dist/modules/cpq/api/quotes/price/route.js +43 -3
  32. package/dist/modules/cpq/api/quotes/price/route.js.map +2 -2
  33. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js +1 -1
  34. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js.map +1 -1
  35. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js +22 -8
  36. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js.map +2 -2
  37. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js +89 -232
  38. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js.map +2 -2
  39. package/dist/modules/cpq/backend/cpq/orders/page.meta.js +1 -1
  40. package/dist/modules/cpq/backend/cpq/orders/page.meta.js.map +1 -1
  41. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentDialog.js +205 -0
  42. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentDialog.js.map +7 -0
  43. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentsPanel.js +79 -0
  44. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentsPanel.js.map +7 -0
  45. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/arcLineRemoval.js +53 -0
  46. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/arcLineRemoval.js.map +7 -0
  47. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/priceAdjustmentContext.js +107 -0
  48. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/priceAdjustmentContext.js.map +7 -0
  49. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/usePriceAdjustments.js +130 -0
  50. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/usePriceAdjustments.js.map +7 -0
  51. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js +144 -221
  52. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js.map +3 -3
  53. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js +1 -1
  54. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js.map +1 -1
  55. package/dist/modules/cpq/ce.js +8 -0
  56. package/dist/modules/cpq/ce.js.map +2 -2
  57. package/dist/modules/cpq/cli.js +34 -1
  58. package/dist/modules/cpq/cli.js.map +2 -2
  59. package/dist/modules/cpq/commands/price-adjustments.js +107 -0
  60. package/dist/modules/cpq/commands/price-adjustments.js.map +7 -0
  61. package/dist/modules/cpq/components/ArcLineDiff.js +53 -0
  62. package/dist/modules/cpq/components/ArcLineDiff.js.map +7 -0
  63. package/dist/modules/cpq/components/ChargeBreakdownTable.js +154 -0
  64. package/dist/modules/cpq/components/ChargeBreakdownTable.js.map +7 -0
  65. package/dist/modules/cpq/components/PriceWaterfall.js +66 -0
  66. package/dist/modules/cpq/components/PriceWaterfall.js.map +7 -0
  67. package/dist/modules/cpq/components/PricingSummaryCard.js +117 -0
  68. package/dist/modules/cpq/components/PricingSummaryCard.js.map +7 -0
  69. package/dist/modules/cpq/components/useGrantedFeatures.js +27 -0
  70. package/dist/modules/cpq/components/useGrantedFeatures.js.map +7 -0
  71. package/dist/modules/cpq/data/entities.js +97 -0
  72. package/dist/modules/cpq/data/entities.js.map +2 -2
  73. package/dist/modules/cpq/data/price-adjustments.js +70 -0
  74. package/dist/modules/cpq/data/price-adjustments.js.map +7 -0
  75. package/dist/modules/cpq/data/validators.js +4 -0
  76. package/dist/modules/cpq/data/validators.js.map +2 -2
  77. package/dist/modules/cpq/di.js +6 -0
  78. package/dist/modules/cpq/di.js.map +2 -2
  79. package/dist/modules/cpq/events.js +47 -0
  80. package/dist/modules/cpq/events.js.map +2 -2
  81. package/dist/modules/cpq/index.js +1 -1
  82. package/dist/modules/cpq/index.js.map +2 -2
  83. package/dist/modules/cpq/lib/auditActor.js +10 -0
  84. package/dist/modules/cpq/lib/auditActor.js.map +7 -0
  85. package/dist/modules/cpq/lib/formatMoney.js +7 -0
  86. package/dist/modules/cpq/lib/formatMoney.js.map +7 -0
  87. package/dist/modules/cpq/lib/priceAdjustmentDefaults.js +60 -0
  88. package/dist/modules/cpq/lib/priceAdjustmentDefaults.js.map +7 -0
  89. package/dist/modules/cpq/lib/priceAdjustmentView.js +169 -0
  90. package/dist/modules/cpq/lib/priceAdjustmentView.js.map +7 -0
  91. package/dist/modules/cpq/lib/quotePermissions.js +13 -0
  92. package/dist/modules/cpq/lib/quotePermissions.js.map +7 -0
  93. package/dist/modules/cpq/lib/quoteSummaryView.js +28 -0
  94. package/dist/modules/cpq/lib/quoteSummaryView.js.map +7 -0
  95. package/dist/modules/cpq/migrations/Migration20261110213052.js +22 -0
  96. package/dist/modules/cpq/migrations/Migration20261110213052.js.map +7 -0
  97. package/dist/modules/cpq/services/arcLineRemoval.js +53 -0
  98. package/dist/modules/cpq/services/arcLineRemoval.js.map +7 -0
  99. package/dist/modules/cpq/services/arcPriceFreeze.js +79 -0
  100. package/dist/modules/cpq/services/arcPriceFreeze.js.map +7 -0
  101. package/dist/modules/cpq/services/cpqOrderService.js +25 -28
  102. package/dist/modules/cpq/services/cpqOrderService.js.map +2 -2
  103. package/dist/modules/cpq/services/cpqPricingService.js +7 -0
  104. package/dist/modules/cpq/services/cpqPricingService.js.map +2 -2
  105. package/dist/modules/cpq/services/cpqQuotingService.js +330 -109
  106. package/dist/modules/cpq/services/cpqQuotingService.js.map +2 -2
  107. package/dist/modules/cpq/services/orderPricingSummary.js +26 -0
  108. package/dist/modules/cpq/services/orderPricingSummary.js.map +7 -0
  109. package/dist/modules/cpq/services/priceAdjustments/adjustmentService.js +264 -0
  110. package/dist/modules/cpq/services/priceAdjustments/adjustmentService.js.map +7 -0
  111. package/dist/modules/cpq/services/priceAdjustments/chargeWaterfall.js +25 -0
  112. package/dist/modules/cpq/services/priceAdjustments/chargeWaterfall.js.map +7 -0
  113. package/dist/modules/cpq/services/priceAdjustments/loadQuoteAdjustments.js +38 -0
  114. package/dist/modules/cpq/services/priceAdjustments/loadQuoteAdjustments.js.map +7 -0
  115. package/dist/modules/cpq/services/priceAdjustments/pricingSnapshot.js +104 -0
  116. package/dist/modules/cpq/services/priceAdjustments/pricingSnapshot.js.map +7 -0
  117. package/dist/modules/cpq/services/priceAdjustments/quoteAdjustmentLifecycle.js +102 -0
  118. package/dist/modules/cpq/services/priceAdjustments/quoteAdjustmentLifecycle.js.map +7 -0
  119. package/dist/modules/cpq/services/priceAdjustments/quotePricingEvents.js +52 -0
  120. package/dist/modules/cpq/services/priceAdjustments/quotePricingEvents.js.map +7 -0
  121. package/dist/modules/cpq/services/priceAdjustments/quotePricingWrite.js +37 -0
  122. package/dist/modules/cpq/services/priceAdjustments/quotePricingWrite.js.map +7 -0
  123. package/dist/modules/cpq/services/priceAdjustments/resolveManualAdjustments.js +107 -0
  124. package/dist/modules/cpq/services/priceAdjustments/resolveManualAdjustments.js.map +7 -0
  125. package/dist/modules/cpq/services/priceAdjustments/storedAdjustmentFailure.js +30 -0
  126. package/dist/modules/cpq/services/priceAdjustments/storedAdjustmentFailure.js.map +7 -0
  127. package/dist/modules/cpq/services/types.js.map +2 -2
  128. package/dist/modules/cpq/setup.js +6 -0
  129. package/dist/modules/cpq/setup.js.map +2 -2
  130. package/package.json +1 -1
  131. package/src/modules/cpq/__integration__/TC-CPQ-ARC-012.spec.ts +134 -0
  132. package/src/modules/cpq/acl.ts +1 -0
  133. package/src/modules/cpq/api/__tests__/adjustmentRoutes.test.ts +79 -0
  134. package/src/modules/cpq/api/__tests__/quoteWriteGuards.test.ts +100 -0
  135. package/src/modules/cpq/api/_helpers/__tests__/quoteMutationGuard.test.ts +48 -0
  136. package/src/modules/cpq/api/_helpers/adjustmentCommandRoute.ts +45 -0
  137. package/src/modules/cpq/api/_helpers/quoteMutationGuard.ts +38 -0
  138. package/src/modules/cpq/api/_helpers/quoteRouteOpenApi.ts +19 -0
  139. package/src/modules/cpq/api/orders/[orderId]/route.ts +18 -0
  140. package/src/modules/cpq/api/orders/route.ts +51 -1
  141. package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/restore/route.ts +56 -0
  142. package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.ts +48 -1
  143. package/src/modules/cpq/api/quotes/[quoteId]/items/route.ts +31 -1
  144. package/src/modules/cpq/api/quotes/[quoteId]/price-adjustments/[adjustmentId]/route.ts +39 -0
  145. package/src/modules/cpq/api/quotes/[quoteId]/price-adjustments/preview/route.ts +24 -0
  146. package/src/modules/cpq/api/quotes/[quoteId]/price-adjustments/route.ts +40 -0
  147. package/src/modules/cpq/api/quotes/[quoteId]/recalculate/__tests__/route.test.ts +95 -0
  148. package/src/modules/cpq/api/quotes/[quoteId]/recalculate/route.ts +40 -1
  149. package/src/modules/cpq/api/quotes/[quoteId]/status/__tests__/route.test.ts +74 -0
  150. package/src/modules/cpq/api/quotes/[quoteId]/status/route.ts +37 -1
  151. package/src/modules/cpq/api/quotes/price/__tests__/route.test.ts +37 -0
  152. package/src/modules/cpq/api/quotes/price/route.ts +28 -2
  153. package/src/modules/cpq/backend/cpq/inventory/page.meta.ts +1 -1
  154. package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.tsx +32 -10
  155. package/src/modules/cpq/backend/cpq/orders/[id]/page.tsx +60 -269
  156. package/src/modules/cpq/backend/cpq/orders/page.meta.ts +1 -1
  157. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentDialog.tsx +260 -0
  158. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/PriceAdjustmentsPanel.tsx +124 -0
  159. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/__tests__/PriceAdjustmentsPanel.test.tsx +76 -0
  160. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/arcLineRemoval.tsx +76 -0
  161. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/priceAdjustmentContext.tsx +133 -0
  162. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/usePriceAdjustments.tsx +165 -0
  163. package/src/modules/cpq/backend/cpq/quotes/[id]/page.tsx +174 -263
  164. package/src/modules/cpq/backend/cpq/quotes/page.meta.ts +1 -1
  165. package/src/modules/cpq/ce.ts +8 -0
  166. package/src/modules/cpq/cli.ts +48 -1
  167. package/src/modules/cpq/commands/__tests__/price-adjustments.test.ts +54 -0
  168. package/src/modules/cpq/commands/price-adjustments.ts +90 -0
  169. package/src/modules/cpq/components/ArcLineDiff.tsx +87 -0
  170. package/src/modules/cpq/components/ChargeBreakdownTable.tsx +201 -0
  171. package/src/modules/cpq/components/PriceWaterfall.tsx +94 -0
  172. package/src/modules/cpq/components/PricingSummaryCard.tsx +128 -0
  173. package/src/modules/cpq/components/__tests__/PriceWaterfall.test.tsx +38 -0
  174. package/src/modules/cpq/components/useGrantedFeatures.ts +35 -0
  175. package/src/modules/cpq/data/__tests__/price-adjustment-migration.test.ts +11 -0
  176. package/src/modules/cpq/data/__tests__/price-adjustments.test.ts +26 -0
  177. package/src/modules/cpq/data/entities.ts +83 -0
  178. package/src/modules/cpq/data/price-adjustments.ts +67 -0
  179. package/src/modules/cpq/data/validators.ts +3 -0
  180. package/src/modules/cpq/di.ts +6 -0
  181. package/src/modules/cpq/events.ts +53 -2
  182. package/src/modules/cpq/index.ts +1 -1
  183. package/src/modules/cpq/lib/__tests__/auditActor.test.ts +12 -0
  184. package/src/modules/cpq/lib/__tests__/priceAdjustmentDefaults.test.ts +37 -0
  185. package/src/modules/cpq/lib/__tests__/priceAdjustmentView.test.ts +152 -0
  186. package/src/modules/cpq/lib/__tests__/quotePermissions.test.ts +30 -0
  187. package/src/modules/cpq/lib/__tests__/quoteSummaryView.test.ts +56 -0
  188. package/src/modules/cpq/lib/auditActor.ts +13 -0
  189. package/src/modules/cpq/lib/formatMoney.ts +4 -0
  190. package/src/modules/cpq/lib/priceAdjustmentDefaults.ts +36 -0
  191. package/src/modules/cpq/lib/priceAdjustmentView.ts +259 -0
  192. package/src/modules/cpq/lib/quotePermissions.ts +22 -0
  193. package/src/modules/cpq/lib/quoteSummaryView.ts +51 -0
  194. package/src/modules/cpq/migrations/.snapshot-open-mercato.json +3298 -2423
  195. package/src/modules/cpq/migrations/Migration20261110213052.ts +22 -0
  196. package/src/modules/cpq/services/__tests__/_helpers/mockEm.ts +9 -2
  197. package/src/modules/cpq/services/__tests__/adjustmentService.test.ts +183 -0
  198. package/src/modules/cpq/services/__tests__/arcLineRemoval.test.ts +109 -0
  199. package/src/modules/cpq/services/__tests__/arcPriceFreeze.test.ts +141 -0
  200. package/src/modules/cpq/services/__tests__/chargeWaterfall.test.ts +28 -0
  201. package/src/modules/cpq/services/__tests__/cpqOrderService.test.ts +35 -2
  202. package/src/modules/cpq/services/__tests__/cpqPricingService.test.ts +57 -0
  203. package/src/modules/cpq/services/__tests__/cpqQuotingService.arc.test.ts +237 -0
  204. package/src/modules/cpq/services/__tests__/cpqQuotingService.test.ts +58 -3
  205. package/src/modules/cpq/services/__tests__/orderPricingSummary.test.ts +50 -0
  206. package/src/modules/cpq/services/__tests__/pricingSnapshot.test.ts +62 -0
  207. package/src/modules/cpq/services/__tests__/quoteAdjustmentLifecycle.test.ts +35 -0
  208. package/src/modules/cpq/services/__tests__/quoteAdjustmentPricing.test.ts +65 -0
  209. package/src/modules/cpq/services/__tests__/quoteCloneAdjustments.test.ts +45 -0
  210. package/src/modules/cpq/services/__tests__/quoteDetachTargetAdjustments.test.ts +54 -0
  211. package/src/modules/cpq/services/__tests__/quoteEventsService.test.ts +72 -0
  212. package/src/modules/cpq/services/__tests__/quotePricingEvents.test.ts +126 -0
  213. package/src/modules/cpq/services/__tests__/quotePricingIsolation.test.ts +52 -0
  214. package/src/modules/cpq/services/__tests__/quotePricingWrite.test.ts +74 -0
  215. package/src/modules/cpq/services/__tests__/resolveManualAdjustments.test.ts +90 -0
  216. package/src/modules/cpq/services/__tests__/storedAdjustmentFailure.test.ts +9 -0
  217. package/src/modules/cpq/services/arcLineRemoval.ts +87 -0
  218. package/src/modules/cpq/services/arcPriceFreeze.ts +165 -0
  219. package/src/modules/cpq/services/cpqOrderService.ts +22 -28
  220. package/src/modules/cpq/services/cpqPricingService.ts +8 -0
  221. package/src/modules/cpq/services/cpqQuotingService.ts +374 -125
  222. package/src/modules/cpq/services/orderPricingSummary.ts +47 -0
  223. package/src/modules/cpq/services/priceAdjustments/adjustmentService.ts +249 -0
  224. package/src/modules/cpq/services/priceAdjustments/chargeWaterfall.ts +28 -0
  225. package/src/modules/cpq/services/priceAdjustments/loadQuoteAdjustments.ts +25 -0
  226. package/src/modules/cpq/services/priceAdjustments/pricingSnapshot.ts +86 -0
  227. package/src/modules/cpq/services/priceAdjustments/quoteAdjustmentLifecycle.ts +68 -0
  228. package/src/modules/cpq/services/priceAdjustments/quotePricingEvents.ts +94 -0
  229. package/src/modules/cpq/services/priceAdjustments/quotePricingWrite.ts +51 -0
  230. package/src/modules/cpq/services/priceAdjustments/resolveManualAdjustments.ts +116 -0
  231. package/src/modules/cpq/services/priceAdjustments/storedAdjustmentFailure.ts +31 -0
  232. package/src/modules/cpq/services/types.ts +34 -1
  233. package/src/modules/cpq/setup.ts +7 -1
@@ -12,23 +12,20 @@ import {
12
12
  orderCpqStatusMap
13
13
  } from "../../../../components/statusMaps.js";
14
14
  import { StatusPath } from "../../../../components/StatusPath.js";
15
+ import { ChargeBreakdownTable } from "../../../../components/ChargeBreakdownTable.js";
16
+ import { PricingSummaryCard } from "../../../../components/PricingSummaryCard.js";
17
+ import { ArcLineDiff, LineActionBadge } from "../../../../components/ArcLineDiff.js";
18
+ import { arcRecurringDelta } from "../../../../lib/quoteSummaryView.js";
19
+ import { isArcCancelledLine } from "../../../../services/arcLineRemoval.js";
20
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
21
+ function toChargeRow(c) {
22
+ return { ...c, chargeName: c.chargeName ?? "\u2014", chargeType: c.chargeType ?? "mrc", unitPrice: c.unitPrice ?? 0, totalPrice: c.totalPrice ?? null };
23
+ }
15
24
  const ARC_BADGE_VARIANTS = {
16
25
  amend: "brand",
17
26
  renew: "success",
18
27
  cancel: "error"
19
28
  };
20
- const RULE_TYPE_LABELS = {
21
- discount_percent: "% discount",
22
- discount_absolute: "fixed discount",
23
- surcharge_percent: "% surcharge",
24
- surcharge_absolute: "fixed surcharge",
25
- price_override: "override"
26
- };
27
- function fmtRuleValue(adj, currency) {
28
- if (adj.ruleType === "discount_percent" || adj.ruleType === "surcharge_percent") return `${adj.value}%`;
29
- if (currency) return fmt(adj.value, currency);
30
- return String(adj.value);
31
- }
32
29
  function fmt(amount, currency) {
33
30
  return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(amount);
34
31
  }
@@ -277,23 +274,19 @@ function CpqOrderDetailPage(props) {
277
274
  /* @__PURE__ */ jsx(MetaCard, { label: "Created", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: new Date(order.createdAt).toLocaleDateString() }) }),
278
275
  /* @__PURE__ */ jsx(MetaCard, { label: "Currency", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: currency }) })
279
276
  ] }),
280
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
281
- /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium mb-3", children: "Pricing Summary" }),
282
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
283
- /* @__PURE__ */ jsxs("div", { children: [
284
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Non-Recurring (NRC)" }),
285
- /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold font-mono", children: fmt(order.pricingSummary.nrcTotal, currency) })
286
- ] }),
287
- /* @__PURE__ */ jsxs("div", { children: [
288
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Monthly Recurring (MRC)" }),
289
- /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold font-mono", children: fmt(order.pricingSummary.mrcTotal, currency) })
290
- ] })
291
- ] })
292
- ] }),
277
+ /* @__PURE__ */ jsx(
278
+ PricingSummaryCard,
279
+ {
280
+ summary: order.pricingSummary,
281
+ currency,
282
+ arcDelta: order.quoteType === "amend" || order.quoteType === "renew" ? arcRecurringDelta(order.lines.map((l) => ({ ...l, action: l.action }))) : null
283
+ }
284
+ ),
293
285
  /* @__PURE__ */ jsx(
294
286
  OrderLineTree,
295
287
  {
296
288
  lines: order.lines,
289
+ quoteType: order.quoteType,
297
290
  currency,
298
291
  expandedLines,
299
292
  pricingDetail,
@@ -311,6 +304,7 @@ function MetaCard({ label, children }) {
311
304
  }
312
305
  function OrderLineTree({
313
306
  lines,
307
+ quoteType,
314
308
  currency,
315
309
  expandedLines,
316
310
  pricingDetail,
@@ -345,6 +339,7 @@ function OrderLineTree({
345
339
  {
346
340
  line,
347
341
  lineIdx,
342
+ quoteType,
348
343
  currency,
349
344
  isExpanded,
350
345
  isBundle,
@@ -368,6 +363,7 @@ function OrderLineTree({
368
363
  {
369
364
  line: child,
370
365
  lineIdx: childIdx,
366
+ quoteType,
371
367
  currency,
372
368
  isExpanded: expandedLines.has(child.lineId),
373
369
  isBundle: false,
@@ -385,26 +381,37 @@ function OrderLineTree({
385
381
  }) })
386
382
  ] });
387
383
  }
388
- function OrderLineRow({ line, lineIdx, currency, isExpanded, isBundle, childCount, indent, pricingDetail, onToggle, onTogglePricingDetail }) {
384
+ function OrderLineRow({ line, lineIdx, quoteType, currency, isExpanded, isBundle, childCount, indent, pricingDetail, onToggle, onTogglePricingDetail }) {
385
+ const t = useT();
389
386
  const paddingLeft = indent > 0 ? `${indent * 2 + 1}rem` : void 0;
387
+ const isRemoved = isArcCancelledLine(line, quoteType);
390
388
  return /* @__PURE__ */ jsxs("div", { children: [
391
389
  /* @__PURE__ */ jsxs(
392
390
  "div",
393
391
  {
394
- className: "flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors cursor-pointer",
392
+ className: `flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors cursor-pointer ${isRemoved ? "bg-muted/20" : ""}`,
395
393
  style: paddingLeft ? { paddingLeft } : void 0,
396
394
  onClick: onToggle,
395
+ "data-testid": "cpq-order-line",
396
+ "data-removed": isRemoved ? "true" : void 0,
397
397
  children: [
398
398
  /* @__PURE__ */ jsx("button", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx("svg", { className: `h-4 w-4 transition-transform ${isExpanded ? "rotate-90" : ""}`, fill: "none", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) }) }),
399
399
  /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
400
400
  indent > 0 && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: "\u2514" }),
401
401
  isBundle && /* @__PURE__ */ jsx(Tag, { variant: "brand", className: "px-1.5 text-xs", children: "bundle" }),
402
- /* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: line.offeringName }),
402
+ /* @__PURE__ */ jsx("span", { className: `font-medium text-sm ${isRemoved ? "text-muted-foreground line-through" : ""}`, children: line.offeringName }),
403
403
  line.quantity > 1 && /* @__PURE__ */ jsxs("span", { className: "rounded bg-muted px-1.5 py-0.5 text-xs font-medium", children: [
404
404
  "\xD7",
405
405
  line.quantity
406
406
  ] }),
407
- /* @__PURE__ */ jsx(Tag, { variant: "info", className: "px-1.5 text-xs", children: line.action }),
407
+ /* @__PURE__ */ jsx(
408
+ LineActionBadge,
409
+ {
410
+ action: line.action,
411
+ label: isRemoved ? t("cpq.quotes.arc.lineRemoved", "remove") : void 0,
412
+ title: isRemoved ? t("cpq.quotes.arc.lineRemovedHint", "This item is cancelled on the subscription when the order is activated") : void 0
413
+ }
414
+ ),
408
415
  isBundle && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
409
416
  childCount,
410
417
  " component",
@@ -412,6 +419,10 @@ function OrderLineRow({ line, lineIdx, currency, isExpanded, isBundle, childCoun
412
419
  ] })
413
420
  ] }) }),
414
421
  /* @__PURE__ */ jsxs("div", { className: "shrink-0 text-right text-xs space-y-0.5", children: [
422
+ isRemoved && line.arcSource && line.arcSource.mrcAmount > 0 && /* @__PURE__ */ jsxs("div", { children: [
423
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "MRC " }),
424
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-muted-foreground line-through", children: fmt(line.arcSource.mrcAmount, currency) })
425
+ ] }),
415
426
  line.nrcTotal > 0 && /* @__PURE__ */ jsxs("div", { children: [
416
427
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "NRC " }),
417
428
  /* @__PURE__ */ jsx("span", { className: "font-mono font-medium", children: fmt(line.nrcTotal, currency) })
@@ -425,7 +436,7 @@ function OrderLineRow({ line, lineIdx, currency, isExpanded, isBundle, childCoun
425
436
  }
426
437
  ),
427
438
  isExpanded && (() => {
428
- const internalKeys = /* @__PURE__ */ new Set(["_arcMirroredName", "_arcMirroredFromItemId", "offeringName"]);
439
+ const internalKeys = /* @__PURE__ */ new Set(["_arcMirroredName", "_arcMirroredFromItemId", "_arcPriceFrozen", "_arcRepriced", "offeringName"]);
429
440
  const visibleConfigEntries = Object.entries(line.configuration).filter(
430
441
  ([key]) => !internalKeys.has(key)
431
442
  );
@@ -435,174 +446,68 @@ function OrderLineRow({ line, lineIdx, currency, isExpanded, isBundle, childCoun
435
446
  const hasArcDiff = !!line.arcSource;
436
447
  const mirroredFromItemId = line.configuration?._arcMirroredFromItemId ?? null;
437
448
  const isEmpty = !hasConfig && !hasCharges && !hasTerm && !hasArcDiff;
438
- return /* @__PURE__ */ jsxs(
449
+ return /* @__PURE__ */ jsx(
439
450
  "div",
440
451
  {
441
452
  className: "border-t bg-muted/10 px-12 py-3 space-y-3",
442
453
  style: paddingLeft ? { paddingLeft: `calc(${paddingLeft} + 2rem)` } : void 0,
443
- children: [
444
- hasArcDiff && /* @__PURE__ */ jsx(ArcLineDiff, { line, currency }),
445
- isEmpty ? /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground space-y-1", children: [
446
- /* @__PURE__ */ jsxs("div", { children: [
447
- "No detailed breakdown for this line.",
448
- mirroredFromItemId && " Mirrored from existing subscription item."
454
+ children: isEmpty ? /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground space-y-1", children: [
455
+ /* @__PURE__ */ jsxs("div", { children: [
456
+ "No detailed breakdown for this line.",
457
+ mirroredFromItemId && " Mirrored from existing subscription item."
458
+ ] }),
459
+ (line.nrcTotal > 0 || line.mrcTotal > 0) && /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
460
+ line.nrcTotal > 0 && /* @__PURE__ */ jsxs("span", { children: [
461
+ "NRC ",
462
+ /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-foreground", children: fmt(line.nrcTotal, currency) })
449
463
  ] }),
450
- (line.nrcTotal > 0 || line.mrcTotal > 0) && /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
451
- line.nrcTotal > 0 && /* @__PURE__ */ jsxs("span", { children: [
452
- "NRC ",
453
- /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-foreground", children: fmt(line.nrcTotal, currency) })
454
- ] }),
455
- line.mrcTotal > 0 && /* @__PURE__ */ jsxs("span", { children: [
456
- "MRC ",
457
- /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-foreground", children: fmt(line.mrcTotal, currency) })
458
- ] })
464
+ line.mrcTotal > 0 && /* @__PURE__ */ jsxs("span", { children: [
465
+ "MRC ",
466
+ /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-foreground", children: fmt(line.mrcTotal, currency) })
459
467
  ] })
460
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
461
- hasConfig && /* @__PURE__ */ jsxs("div", { children: [
462
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground mb-1", children: "Configuration" }),
463
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-1", children: visibleConfigEntries.map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "text-xs", children: [
464
- /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
465
- key,
466
- ": "
467
- ] }),
468
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: String(value) })
469
- ] }, key)) })
468
+ ] })
469
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
470
+ hasConfig && /* @__PURE__ */ jsxs("div", { children: [
471
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground mb-1", children: "Configuration" }),
472
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-1", children: visibleConfigEntries.map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "text-xs", children: [
473
+ /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
474
+ key,
475
+ ": "
476
+ ] }),
477
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: String(value) })
478
+ ] }, key)) })
479
+ ] }),
480
+ hasCharges && /* @__PURE__ */ jsx(
481
+ ChargeBreakdownTable,
482
+ {
483
+ charges: line.charges.map(toChargeRow),
484
+ currency,
485
+ openDetailIndex: pricingDetail?.lineIdx === lineIdx ? pricingDetail.chargeIdx : null,
486
+ onToggleDetail: (chargeIdx) => onTogglePricingDetail(lineIdx, chargeIdx)
487
+ }
488
+ ),
489
+ hasTerm && /* @__PURE__ */ jsxs("div", { className: "flex gap-4 text-xs text-muted-foreground", children: [
490
+ line.startDate && /* @__PURE__ */ jsxs("span", { children: [
491
+ "Start: ",
492
+ new Date(line.startDate).toLocaleDateString()
470
493
  ] }),
471
- hasCharges && /* @__PURE__ */ jsxs("div", { children: [
472
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground mb-1", children: "Charges" }),
473
- /* @__PURE__ */ jsx(
474
- ChargeBreakdown,
475
- {
476
- line,
477
- lineIdx,
478
- currency,
479
- pricingDetail,
480
- onTogglePricingDetail
481
- }
482
- )
494
+ line.termMonths && /* @__PURE__ */ jsxs("span", { children: [
495
+ "Term: ",
496
+ line.termMonths,
497
+ "mo"
483
498
  ] }),
484
- hasTerm && /* @__PURE__ */ jsxs("div", { className: "flex gap-4 text-xs text-muted-foreground", children: [
485
- line.startDate && /* @__PURE__ */ jsxs("span", { children: [
486
- "Start: ",
487
- new Date(line.startDate).toLocaleDateString()
488
- ] }),
489
- line.termMonths && /* @__PURE__ */ jsxs("span", { children: [
490
- "Term: ",
491
- line.termMonths,
492
- "mo"
493
- ] }),
494
- line.endDate && /* @__PURE__ */ jsxs("span", { children: [
495
- "End: ",
496
- new Date(line.endDate).toLocaleDateString()
497
- ] })
499
+ line.endDate && /* @__PURE__ */ jsxs("span", { children: [
500
+ "End: ",
501
+ new Date(line.endDate).toLocaleDateString()
498
502
  ] })
499
- ] })
500
- ]
503
+ ] }),
504
+ hasArcDiff && /* @__PURE__ */ jsx(ArcLineDiff, { line, currency })
505
+ ] })
501
506
  }
502
507
  );
503
508
  })()
504
509
  ] });
505
510
  }
506
- function ChargeBreakdown({ line, lineIdx, currency, pricingDetail, onTogglePricingDetail }) {
507
- return /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
508
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "text-muted-foreground", children: [
509
- /* @__PURE__ */ jsx("th", { className: "text-left py-1 font-medium", children: "Charge" }),
510
- /* @__PURE__ */ jsx("th", { className: "text-left py-1 font-medium", children: "Type" }),
511
- /* @__PURE__ */ jsx("th", { className: "text-right py-1 font-medium", children: "Unit Price" }),
512
- /* @__PURE__ */ jsx("th", { className: "text-right py-1 font-medium", children: "Qty" }),
513
- /* @__PURE__ */ jsx("th", { className: "text-right py-1 font-medium", children: "Total" }),
514
- /* @__PURE__ */ jsx("th", { className: "w-8" })
515
- ] }) }),
516
- /* @__PURE__ */ jsx("tbody", { children: line.charges.map((c, i) => {
517
- const hasDetail = !!(c.breakdown?.tiers?.length || c.adjustments?.length);
518
- const isDetailOpen = pricingDetail?.lineIdx === lineIdx && pricingDetail?.chargeIdx === i;
519
- return /* @__PURE__ */ jsxs(React.Fragment, { children: [
520
- /* @__PURE__ */ jsxs("tr", { className: "border-t border-dashed border-border/50", children: [
521
- /* @__PURE__ */ jsx("td", { className: "py-1", children: c.chargeName ?? "\u2014" }),
522
- /* @__PURE__ */ jsx("td", { className: "py-1 uppercase", children: c.chargeType ?? "\u2014" }),
523
- /* @__PURE__ */ jsx("td", { className: "py-1 text-right font-mono", children: c.unitPrice != null ? fmt(c.unitPrice, currency) : "\u2014" }),
524
- /* @__PURE__ */ jsx("td", { className: "py-1 text-right font-mono", children: c.quantity ?? "\u2014" }),
525
- /* @__PURE__ */ jsx("td", { className: "py-1 text-right font-mono", children: c.totalPrice != null ? fmt(c.totalPrice, currency) : c.note ?? "\u2014" }),
526
- /* @__PURE__ */ jsx("td", { className: "py-1 text-center", children: hasDetail && /* @__PURE__ */ jsx(
527
- "button",
528
- {
529
- onClick: () => onTogglePricingDetail(lineIdx, i),
530
- className: "inline-flex items-center justify-center rounded p-0.5 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",
531
- title: "Show pricing breakdown",
532
- children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" }) })
533
- }
534
- ) })
535
- ] }),
536
- isDetailOpen && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 6, className: "pb-3 pt-1", children: /* @__PURE__ */ jsxs("div", { className: "rounded border bg-background p-3 space-y-3 text-xs", children: [
537
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
538
- /* @__PURE__ */ jsxs("span", { className: "font-semibold text-sm", children: [
539
- "Pricing Details \u2014 ",
540
- c.chargeName
541
- ] }),
542
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: c.pricingMethod ?? "flat" })
543
- ] }),
544
- c.breakdown?.tiers && c.breakdown.tiers.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
545
- /* @__PURE__ */ jsx("div", { className: "font-medium text-muted-foreground mb-1", children: "Tier Breakdown" }),
546
- /* @__PURE__ */ jsxs("table", { className: "w-full", children: [
547
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "text-muted-foreground", children: [
548
- /* @__PURE__ */ jsx("th", { className: "text-left py-0.5 font-medium", children: "Tier" }),
549
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Range" }),
550
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Price/Unit" }),
551
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Qty" }),
552
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Subtotal" })
553
- ] }) }),
554
- /* @__PURE__ */ jsxs("tbody", { children: [
555
- c.breakdown.tiers.map((t) => /* @__PURE__ */ jsxs("tr", { className: "border-t border-border/30", children: [
556
- /* @__PURE__ */ jsx("td", { className: "py-0.5", children: t.tier }),
557
- /* @__PURE__ */ jsxs("td", { className: "py-0.5 text-right font-mono", children: [
558
- t.from,
559
- "\u2013",
560
- t.to
561
- ] }),
562
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmt(t.pricePerUnit, currency) }),
563
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: t.quantity }),
564
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmt(t.subtotal, currency) })
565
- ] }, t.tier)),
566
- /* @__PURE__ */ jsxs("tr", { className: "border-t font-medium", children: [
567
- /* @__PURE__ */ jsx("td", { colSpan: 4, className: "py-0.5 text-right", children: "Tiered Total" }),
568
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmt(c.breakdown.tiers.reduce((s, t) => s + t.subtotal, 0), currency) })
569
- ] })
570
- ] })
571
- ] })
572
- ] }),
573
- c.adjustments && c.adjustments.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
574
- /* @__PURE__ */ jsx("div", { className: "font-medium text-muted-foreground mb-1", children: "Applied Price Rules" }),
575
- /* @__PURE__ */ jsxs("table", { className: "w-full", children: [
576
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "text-muted-foreground", children: [
577
- /* @__PURE__ */ jsx("th", { className: "text-left py-0.5 font-medium", children: "Rule" }),
578
- /* @__PURE__ */ jsx("th", { className: "text-left py-0.5 font-medium", children: "Type" }),
579
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Value" }),
580
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Before" }),
581
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "After" }),
582
- /* @__PURE__ */ jsx("th", { className: "text-right py-0.5 font-medium", children: "Delta" })
583
- ] }) }),
584
- /* @__PURE__ */ jsx("tbody", { children: c.adjustments.map((adj, ai) => /* @__PURE__ */ jsxs("tr", { className: "border-t border-border/30", children: [
585
- /* @__PURE__ */ jsx("td", { className: "py-0.5", children: adj.ruleName }),
586
- /* @__PURE__ */ jsx("td", { className: "py-0.5", children: RULE_TYPE_LABELS[adj.ruleType] ?? adj.ruleType }),
587
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmtRuleValue(adj, currency) }),
588
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmt(adj.unitPriceBefore, currency) }),
589
- /* @__PURE__ */ jsx("td", { className: "py-0.5 text-right font-mono", children: fmt(adj.unitPriceAfter, currency) }),
590
- /* @__PURE__ */ jsxs("td", { className: `py-0.5 text-right font-mono ${adj.delta < 0 ? "text-destructive" : adj.delta > 0 ? "text-status-success-text" : ""}`, children: [
591
- adj.delta > 0 ? "+" : "",
592
- fmt(adj.delta, currency)
593
- ] })
594
- ] }, ai)) })
595
- ] })
596
- ] }),
597
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1 border-t text-sm font-semibold", children: [
598
- /* @__PURE__ */ jsx("span", { children: "Final Total" }),
599
- /* @__PURE__ */ jsx("span", { className: "font-mono", children: c.totalPrice != null ? fmt(c.totalPrice, currency) : "\u2014" })
600
- ] })
601
- ] }) }) })
602
- ] }, i);
603
- }) })
604
- ] });
605
- }
606
511
  function Spinner() {
607
512
  return /* @__PURE__ */ jsxs("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", children: [
608
513
  /* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
@@ -623,54 +528,6 @@ function ErrorBanner({ message, onDismiss }) {
623
528
  )
624
529
  ] });
625
530
  }
626
- function ArcLineDiff({ line, currency }) {
627
- const src = line.arcSource;
628
- if (!src) return null;
629
- const isCancel = line.action === "cancel";
630
- const beforeMrc = src.mrcAmount;
631
- const beforeNrc = src.nrcAmount;
632
- const beforeQty = src.quantity;
633
- const afterMrc = isCancel ? 0 : line.mrcTotal;
634
- const afterNrc = isCancel ? 0 : line.nrcTotal;
635
- const afterQty = isCancel ? 0 : line.quantity;
636
- const mrcDelta = afterMrc - beforeMrc;
637
- const nrcDelta = afterNrc - beforeNrc;
638
- const qtyDelta = afterQty - beforeQty;
639
- return /* @__PURE__ */ jsxs("div", { children: [
640
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground mb-1.5", children: "Change Preview" }),
641
- /* @__PURE__ */ jsx("div", { className: "rounded border bg-background overflow-hidden", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
642
- /* @__PURE__ */ jsx("thead", { className: "bg-muted/40", children: /* @__PURE__ */ jsxs("tr", { className: "text-muted-foreground", children: [
643
- /* @__PURE__ */ jsx("th", { className: "text-left px-3 py-1.5 font-medium" }),
644
- /* @__PURE__ */ jsx("th", { className: "text-right px-3 py-1.5 font-medium", children: "Before" }),
645
- /* @__PURE__ */ jsx("th", { className: "text-right px-3 py-1.5 font-medium", children: "After" }),
646
- /* @__PURE__ */ jsx("th", { className: "text-right px-3 py-1.5 font-medium", children: "\u0394" })
647
- ] }) }),
648
- /* @__PURE__ */ jsxs("tbody", { children: [
649
- /* @__PURE__ */ jsx(ArcDiffRow, { label: "Quantity", before: beforeQty, after: afterQty, delta: qtyDelta, currency: null, dimAfter: isCancel }),
650
- /* @__PURE__ */ jsx(ArcDiffRow, { label: "MRC", before: beforeMrc, after: afterMrc, delta: mrcDelta, currency, dimAfter: isCancel }),
651
- /* @__PURE__ */ jsx(ArcDiffRow, { label: "NRC", before: beforeNrc, after: afterNrc, delta: nrcDelta, currency, dimAfter: isCancel })
652
- ] })
653
- ] }) }),
654
- isCancel && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive mt-1 italic", children: "Cancellation \u2014 item will be terminated on activation." })
655
- ] });
656
- }
657
- function ArcDiffRow({
658
- label,
659
- before,
660
- after,
661
- delta,
662
- currency,
663
- dimAfter
664
- }) {
665
- const fmtVal = (v) => currency ? fmt(v, currency) : String(v);
666
- const showDelta = delta !== 0;
667
- return /* @__PURE__ */ jsxs("tr", { className: "border-t border-dashed border-border/40", children: [
668
- /* @__PURE__ */ jsx("td", { className: "px-3 py-1 text-muted-foreground", children: label }),
669
- /* @__PURE__ */ jsx("td", { className: "px-3 py-1 text-right font-mono", children: fmtVal(before) }),
670
- /* @__PURE__ */ jsx("td", { className: `px-3 py-1 text-right font-mono ${dimAfter ? "text-muted-foreground line-through" : ""}`, children: fmtVal(after) }),
671
- /* @__PURE__ */ jsx("td", { className: `px-3 py-1 text-right font-mono font-medium ${showDelta ? delta > 0 ? "text-status-success-text" : "text-destructive" : "text-muted-foreground"}`, children: showDelta ? `${delta > 0 ? "+" : ""}${fmtVal(delta)}` : "\u2014" })
672
- ] });
673
- }
674
531
  export {
675
532
  CpqOrderDetailPage as default
676
533
  };