@bytebrand/fe-ui-core-autobahn 1.0.11 → 1.0.13

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.
@@ -29,11 +29,9 @@ const _leasCfg = (defaultConfig as any).leasing || {};
29
29
  /** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
30
30
  const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
31
31
  const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
32
- /** leasing terms inputs (only when the config carries mileage + period), e.g. "10.000 km/Jahr · 48 Monate". */
32
+ /** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
33
33
  const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
34
34
  const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
35
- const _hasLeasTerms = Boolean(_leasMileage && _leasPeriod);
36
- const _leasMileageStr = _leasMileage ? Number(_leasMileage).toLocaleString('de-DE') : '';
37
35
 
38
36
  /** mileage → 'X.XXX km' (de-DE grouping). */
39
37
  export function fmtKm(n: number): string {
@@ -422,6 +420,16 @@ const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, f
422
420
  */
423
421
  export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
424
422
  const hasLease = car.lease != null;
423
+ // Terms of the config the displayed rate was actually computed with (per-car:
424
+ // dealer rate + the user's saved localStorage adjustments) — default config
425
+ // terms only when the car doesn't carry its own.
426
+ const finFirstInstallment =
427
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
428
+ const finMonths = car.finMonths ?? _finMonths;
429
+ const leasMileage = car.leaseMileage ?? _leasMileage;
430
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
431
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
432
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
425
433
  return (
426
434
  <div className="pricepaths">
427
435
  <div className="pp-hero">
@@ -432,18 +440,18 @@ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t })
432
440
  </div>
433
441
  <div className="pp-hero-terms">
434
442
  {t('autobahn:card.price.financeTerms', {
435
- firstInstallment: _finFirstInstallment,
436
- months: _finMonths,
437
- count: _finMonths,
443
+ firstInstallment: finFirstInstallment,
444
+ months: finMonths,
445
+ count: finMonths,
438
446
  })}
439
447
  </div>
440
448
  </div>
441
449
  {hasLease && (
442
450
  <div className="pp-lease-row">
443
451
  <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." />
444
- {_hasLeasTerms && (
452
+ {hasLeasTerms && (
445
453
  <div className="pp-sub-terms">
446
- {t('autobahn:card.price.leaseTerms', { mileage: _leasMileageStr, months: _leasPeriod })}
454
+ {t('autobahn:card.price.leaseTerms', { mileage: leasMileageStr, months: leasMonths })}
447
455
  </div>
448
456
  )}
449
457
  </div>
package/cards/types.ts CHANGED
@@ -57,6 +57,13 @@ export interface AutobahnCar {
57
57
  // --- price (always real) ---
58
58
  /** financing monthly rate in EUR — the LEAD price on every card. */
59
59
  monthly: number;
60
+ /**
61
+ * financing terms the `monthly` rate was computed with — the per-car merged
62
+ * config (dealer rate + the user's saved localStorage adjustments, ADV-157).
63
+ * Absent → the card falls back to the fe-financing default-config terms.
64
+ */
65
+ finFirstInstallment?: number;
66
+ finMonths?: number;
60
67
  /** purchase price in EUR (raw number; formatted de-DE by the cards). */
61
68
  price: number;
62
69
 
@@ -107,6 +114,12 @@ export interface AutobahnCar {
107
114
  marketHigh?: number;
108
115
  /** leasing monthly rate in EUR. */
109
116
  lease?: number;
117
+ /**
118
+ * leasing terms the `lease` rate was computed with — per-car merged config,
119
+ * same as finFirstInstallment/finMonths. Absent → default-config terms.
120
+ */
121
+ leaseMileage?: number;
122
+ leaseMonths?: number;
110
123
  /** number of buyers currently watching this car. */
111
124
  watchers?: number;
112
125
  /** number of recent views (drives the 'vor N Std' cue). */
@@ -305,6 +305,14 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
305
305
  // (getFinancing.ts:82 `monthlyInstallment`), spread into price.financing by
306
306
  // transformDataForVehicles (DataTransformers.ts:345). It is the LEAD price.
307
307
  const monthly = num(price?.financing?.monthlyInstallment) ?? 0;
308
+ // financing terms the monthly rate was computed with — same merged per-car
309
+ // config (dealer rate + the user's saved localStorage adjustments, ADV-157).
310
+ // Emitted only when real; the cards fall back to the default-config terms.
311
+ // paybackPeriod FIRST: it carries the user's saved term, while rawPaybackPeriod
312
+ // is stamped from the dealer rate at normalize time and never reflects
313
+ // adjustments (normalizeRateObject.ts `rawPaybackPeriod: paybackPeriod`).
314
+ const finFirstInstallment = num(price?.financing?.firstInstallment);
315
+ const finMonths = num(price?.financing?.paybackPeriod) ?? num(price?.financing?.rawPaybackPeriod);
308
316
  // price ← price.currentSalesPrice (DataTransformers.ts:352).
309
317
  const purchase = num(price?.currentSalesPrice) ?? 0;
310
318
 
@@ -352,6 +360,11 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
352
360
  // (instead of computing/showing a leasing rate the car isn't eligible for).
353
361
  const leasingActive = !!(price && price.leasing && price.leasing.isActive);
354
362
  const lease = leasingActive ? num(price?.leasing?.monthlyInstallment) : undefined;
363
+ // leasing terms the lease rate was computed with — same merged per-car config
364
+ // as the financing terms above (annualMileage/paybackPeriod carry the user's
365
+ // saved adjustments). Only meaningful alongside an active lease rate.
366
+ const leaseMileage = leasingActive ? num(price?.leasing?.annualMileage) : undefined;
367
+ const leaseMonths = leasingActive ? num(price?.leasing?.paybackPeriod) : undefined;
355
368
 
356
369
  // --- optional: list price / savings — ONLY from a real strike price ---
357
370
  // transformDataForVehicles exposes oldMonthlyInstallment / highestPrice via
@@ -410,6 +423,8 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
410
423
 
411
424
  // price
412
425
  monthly,
426
+ ...(finFirstInstallment != null ? { finFirstInstallment } : {}),
427
+ ...(finMonths != null ? { finMonths } : {}),
413
428
  price: purchase,
414
429
 
415
430
  // media
@@ -437,6 +452,8 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
437
452
  ...(listPrice != null ? { listPrice } : {}),
438
453
  ...(savings != null ? { savings } : {}),
439
454
  ...(lease != null ? { lease } : {}),
455
+ ...(leaseMileage != null ? { leaseMileage } : {}),
456
+ ...(leaseMonths != null ? { leaseMonths } : {}),
440
457
  ...(drop != null ? { drop } : {}),
441
458
  ...(dropPct != null ? { dropPct } : {}),
442
459
  ...(zeroDown ? { zeroDown } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
5
5
  "main": "index.ts",
6
6
  "license": "UNLICENSED",