@fluid-app/portal-sdk 0.1.1089 → 0.1.1090

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.
@@ -3790,6 +3790,26 @@ function reconciledBreakdown(subtotalUnit, totalUnit, quantity, currencyCode) {
3790
3790
  };
3791
3791
  }
3792
3792
  /**
3793
+ * A subscription's next bill as its summary renders it: the reconciled line,
3794
+ * plus the paid milestone add-ons, with the total taken from the rounded
3795
+ * parts so every row adds up.
3796
+ *
3797
+ * subtotalUnit - Per-unit price before any discount.
3798
+ * totalUnit - Per-unit price after the attached discount.
3799
+ * quantity - Units on the subscription.
3800
+ * addOns - What the next order charges for paid add-ons.
3801
+ * currencyCode - ISO 4217 code, which fixes the minor units.
3802
+ */
3803
+ function nextBillBreakdown(subtotalUnit, totalUnit, quantity, addOns, currencyCode) {
3804
+ const line = reconciledBreakdown(subtotalUnit, totalUnit, quantity, currencyCode);
3805
+ const roundedAddOns = roundToMinorUnits(addOns, currencyCode);
3806
+ return {
3807
+ ...line,
3808
+ addOns: roundedAddOns,
3809
+ total: roundToMinorUnits(line.total + roundedAddOns, currencyCode)
3810
+ };
3811
+ }
3812
+ /**
3793
3813
  * Format one amount in a given currency.
3794
3814
  *
3795
3815
  * `amount` is already denominated in `currencyCode`: it comes from the
@@ -3826,6 +3846,13 @@ function formatCurrency(amount, currencyCode, locale = "en-US") {
3826
3846
  const code = currencyCode?.trim().toUpperCase() || FALLBACK_CURRENCY;
3827
3847
  return tryFormatCurrency(amount, code, locale.trim().replaceAll("_", "-")) ?? tryFormatCurrency(amount, code, "en-US") ?? tryFormatCurrency(amount, FALLBACK_CURRENCY, "en-US") ?? String(amount);
3828
3848
  }
3849
+ /**
3850
+ * A bare figure at the currency's minor units, for callers that print their
3851
+ * own symbol: no grouping, so `1200` stays `1200`.
3852
+ */
3853
+ function formatAmount(amount, currencyCode) {
3854
+ return roundToMinorUnits(amount, currencyCode).toFixed(currencyMinorUnits(currencyCode));
3855
+ }
3829
3856
  /** Returns the formatted amount, or null when Intl rejects the pair. */
3830
3857
  function tryFormatCurrency(amount, currency, locale) {
3831
3858
  const minorUnits = currencyMinorUnits(currency);
@@ -4168,11 +4195,15 @@ function formatLongDate(iso) {
4168
4195
  * hidden until qty>1 surfaced the mismatch with the detail view.
4169
4196
  */
4170
4197
  function formatPrice(sub) {
4171
- return (sub.price * (sub.quantity ?? 1)).toFixed(2);
4198
+ return formatAmount(sub.price * (sub.quantity ?? 1), sub.currency?.code);
4172
4199
  }
4173
4200
  /** Detail-shape counterpart for bundle member rows. */
4174
4201
  function formatDetailPrice(sub) {
4175
- return (sub.price * (sub.quantity ?? 1)).toFixed(2);
4202
+ return formatAmount(sub.price * (sub.quantity ?? 1), sub.currency?.code);
4203
+ }
4204
+ /** Bundle card total: every member's line total, in the bundle's currency. */
4205
+ function formatBundleTotal(subs) {
4206
+ return formatAmount(subs.reduce((sum, s) => sum + s.price * (s.quantity ?? 1), 0), subs[0]?.currency?.code);
4176
4207
  }
4177
4208
  /**
4178
4209
  * Unit price for the "qty × price" line that sits with a row's line total.
@@ -4181,7 +4212,7 @@ function formatDetailPrice(sub) {
4181
4212
  * price (CURRENT-3974). Mirrors `formatPrice`'s symbol-less formatting.
4182
4213
  */
4183
4214
  function formatUnitPrice(sub) {
4184
- return sub.price.toFixed(2);
4215
+ return formatAmount(sub.price, sub.currency?.code);
4185
4216
  }
4186
4217
  const PLACEHOLDER_VARIANT_TITLES = new Set([
4187
4218
  "default",
@@ -4216,7 +4247,7 @@ function detailDiscountLine(sub, t) {
4216
4247
  return {
4217
4248
  code: attachment.discount.code,
4218
4249
  label: t("discount"),
4219
- amountLabel: `-${sub.currency?.symbol ?? ""}${amount.toFixed(2)}`
4250
+ amountLabel: `-${sub.currency?.symbol ?? ""}${formatAmount(amount, sub.currency?.code)}`
4220
4251
  };
4221
4252
  }
4222
4253
  /**
@@ -4432,7 +4463,6 @@ const BUNDLE_INLINE_LIMIT = 2;
4432
4463
  function BundleCard({ bundle, onSubscriptionClick, t }) {
4433
4464
  const [popoverOpen, setPopoverOpen] = useState(false);
4434
4465
  const { isMobile } = useSidebar();
4435
- const total = bundle.subscriptions.reduce((sum, s) => sum + s.price * (s.quantity ?? 1), 0);
4436
4466
  const nextBillLong = bundle.next_bill_date ? formatLongDate(bundle.next_bill_date) : null;
4437
4467
  const inlineMembers = bundle.subscriptions.slice(0, BUNDLE_INLINE_LIMIT);
4438
4468
  const overflowCount = bundle.subscriptions.length - inlineMembers.length;
@@ -4529,7 +4559,7 @@ function BundleCard({ bundle, onSubscriptionClick, t }) {
4529
4559
  children: t("list_bill_amount")
4530
4560
  }), /* @__PURE__ */ jsx("div", {
4531
4561
  className: "text-foreground mt-1 text-base font-bold tracking-tight tabular-nums",
4532
- children: total.toFixed(2)
4562
+ children: formatBundleTotal(bundle.subscriptions)
4533
4563
  })]
4534
4564
  })]
4535
4565
  })]
@@ -7537,11 +7567,11 @@ function SubscriptionItemsSection({ subscription, displayQuantity, displayNextBi
7537
7567
  const quantityInputId = `subscription-${subscription.subscription_token}-quantity`;
7538
7568
  const pricing = computeSubscriptionPricing(subscription);
7539
7569
  const currencyCode = subscription.currency?.code;
7540
- const amounts = reconciledBreakdown(pricing.subtotalUnit, pricing.totalUnit, quantity, currencyCode);
7541
- const addOnsAmount = subscription.milestones?.paid_total ?? 0;
7570
+ const amounts = nextBillBreakdown(pricing.subtotalUnit, pricing.totalUnit, quantity, subscription.milestones?.paid_total ?? 0, currencyCode);
7571
+ const addOnsAmount = amounts.addOns;
7542
7572
  const discountAmount = amounts.discount;
7543
7573
  const subtotal = formatCurrency(amounts.subtotal, currencyCode, locale);
7544
- const totalPrice = formatCurrency(roundToMinorUnits(amounts.total + addOnsAmount, currencyCode), currencyCode, locale);
7574
+ const totalPrice = formatCurrency(amounts.total, currencyCode, locale);
7545
7575
  const effectiveNextBillDate = displayNextBillDate ?? subscription.next_bill_date;
7546
7576
  const nextOrderTimeOfDay = displayStatus === "completed" ? "" : formatTime(effectiveNextBillDate, subscription.timezone, locale);
7547
7577
  const nextBillDisplayLabels = {
@@ -10365,4 +10395,4 @@ const subscriptionsScreenPropertySchema = {
10365
10395
  //#endregion
10366
10396
  export { subscriptionsScreenPropertySchema as n, SubscriptionsScreen as t };
10367
10397
 
10368
- //# sourceMappingURL=SubscriptionsScreen-DgOkTIyv.mjs.map
10398
+ //# sourceMappingURL=SubscriptionsScreen-Bbk6N0Td.mjs.map