@bytebrand/fe-ui-core-autobahn 1.0.205 → 1.0.207

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.
@@ -53,6 +53,22 @@ const finKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
53
53
  finalInstallment: car.finFinal,
54
54
  });
55
55
 
56
+ /**
57
+ * ADV-405 follow-up (leasing confirmed 19.11): the car's real leasing key figures — computed in
58
+ * toAutobahnCar from price.leasing with the Leasingdetails layer's arithmetic (leasingKeyFigures).
59
+ * Sonderzahlung/term are the lease rate's own terms; nothing falls back to the default config.
60
+ */
61
+ const leaseKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
62
+ kind: 'leasing',
63
+ down: car.leaseFirstInstallment,
64
+ months: car.leaseMonths,
65
+ cashPrice: car.leaseCashPrice,
66
+ total: car.leaseTotal,
67
+ residual: car.leaseResidual,
68
+ nominal: car.leaseNominal,
69
+ apr: car.leaseApr,
70
+ });
71
+
56
72
  /** mileage → 'X.XXX km' (de-DE grouping). */
57
73
  export function fmtKm(n: number): string {
58
74
  return n.toLocaleString('de-DE') + ' km';
@@ -786,7 +802,16 @@ export const PriceTerms: React.FunctionComponent<{
786
802
  // fest · … eff. Jahreszins · Finanzierungsdetails"), inside the same .cc-terms so its 12px
787
803
  // #0e2238 typography applies; the block grows to 2+ lines (the stack cell takes the tallest
788
804
  // slot). Leasing keeps its line; with no real figure the old financing terms line stays.
789
- const kf = finKeyFigures(car);
805
+ // Leasing (19.11): the leasing key figures the same way ("0 € Anzahlung · 60 Mon. · … € Barpreis ·
806
+ // … € Gesamtbetrag" / "Kaufpflicht · … Sollzins fest · … eff. Jahreszins · Details").
807
+ const kf = mode === 'leasing' ? leaseKeyFigures(car) : finKeyFigures(car);
808
+ if (car.lease != null && hasCreditKeyFigures(kf) && mode === 'leasing') {
809
+ return (
810
+ <div className="cc-terms">
811
+ <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
812
+ </div>
813
+ );
814
+ }
790
815
  if (mode === 'financing' && hasCreditKeyFigures(kf)) {
791
816
  return (
792
817
  <div className="cc-terms">
@@ -1180,6 +1205,7 @@ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, c
1180
1205
  car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1181
1206
  const finMonths = car.finMonths ?? _finMonths;
1182
1207
  const finKf = finKeyFigures(car);
1208
+ const leaseKf = leaseKeyFigures(car);
1183
1209
  const leasFirstInstallment =
1184
1210
  car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1185
1211
  const leasMileage = car.leaseMileage ?? _leasMileage;
@@ -1232,7 +1258,14 @@ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, c
1232
1258
  {hasLease && (
1233
1259
  <div className="pp-lease-row">
1234
1260
  <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1235
- {hasLeasTerms && (
1261
+ {/* ADV-405 follow-up (leasing, 19.11): the leasing key figures replace the compact
1262
+ terms, in this row's own size, as one wrapping paragraph like the financing figures
1263
+ above (SRL desktop exception); without any real figure the old terms stay. */}
1264
+ {hasCreditKeyFigures(leaseKf) ? (
1265
+ <div className="pp-sub-terms">
1266
+ <CreditKeyFigures t={t} figures={leaseKf} details={detailsLink('leasing')} cls="pp-ckf" fit={false} />
1267
+ </div>
1268
+ ) : hasLeasTerms && (
1236
1269
  <div className="pp-sub-terms">
1237
1270
  {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1238
1271
  wording there stays untouched, but includes the same Sonderzahlung figure.
package/cards/types.ts CHANGED
@@ -157,6 +157,14 @@ export interface AutobahnCar {
157
157
  leaseMileage?: number;
158
158
  leaseMonths?: number;
159
159
  leaseFirstInstallment?: number;
160
+ /** leasing key figures of the same computed rate (ADV-405 Kerndaten, as in the Leasingdetails
161
+ * layer — ui/CreditKeyFigures leasingKeyFigures): Anschaffungspreis, Gesamt inkl. Restwert,
162
+ * Restwert, nominal and effective annual rate. Absent → not shown. */
163
+ leaseCashPrice?: number;
164
+ leaseTotal?: number;
165
+ leaseResidual?: number;
166
+ leaseNominal?: number;
167
+ leaseApr?: number;
160
168
  /** number of buyers currently watching this car. */
161
169
  watchers?: number;
162
170
  /** number of recent views (drives the 'vor N Std' cue). */
@@ -28,6 +28,7 @@ import { formatTimestamp } from '../utils/DateUtils';
28
28
  import { getPowerLabel } from '../utils/power';
29
29
 
30
30
  import { AutobahnCar, AutobahnPhev } from '../cards/types';
31
+ import { leasingKeyFigures } from '../ui/CreditKeyFigures';
31
32
  import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class } from '../constants/autobahn';
32
33
 
33
34
  /**
@@ -447,6 +448,22 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
447
448
  const leaseMileage = leasingActive ? num(price?.leasing?.annualMileage) : undefined;
448
449
  const leaseMonths = leasingActive ? num(price?.leasing?.paybackPeriod) : undefined;
449
450
  const leaseFirstInstallment = leasingActive ? num(price?.leasing?.firstInstallment) : undefined;
451
+ // ADV-405 leasing key figures of that same computed leasing (getLeasing output + common.basePrice),
452
+ // with the Leasingdetails layer's own arithmetic (leasingKeyFigures).
453
+ const leaseKf = leasingActive
454
+ ? leasingKeyFigures({
455
+ price: num(price?.currentSalesPrice) ?? num(price?.common?.currentSalesPrice),
456
+ basePrice: num(price?.common?.basePrice),
457
+ monthly: lease,
458
+ term: leaseMonths,
459
+ down: leaseFirstInstallment,
460
+ residual: num(price?.leasing?.finalInstallment),
461
+ withAddServices: !!price?.leasing?.withAddServices,
462
+ addServicesCostRaw: num(price?.leasing?.addServicesCostRaw),
463
+ nominal: num(price?.leasing?.nominalInterestRate),
464
+ apr: num(price?.leasing?.annualPercentageRate),
465
+ })
466
+ : undefined;
450
467
 
451
468
  // --- optional: list price / savings — ONLY from a real strike price ---
452
469
  // transformDataForVehicles exposes oldMonthlyInstallment / highestPrice via
@@ -559,6 +576,11 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
559
576
  ...(leaseMileage != null ? { leaseMileage } : {}),
560
577
  ...(leaseMonths != null ? { leaseMonths } : {}),
561
578
  ...(leaseFirstInstallment != null ? { leaseFirstInstallment } : {}),
579
+ ...(leaseKf && leaseKf.cashPrice != null ? { leaseCashPrice: leaseKf.cashPrice } : {}),
580
+ ...(leaseKf && leaseKf.total != null ? { leaseTotal: leaseKf.total } : {}),
581
+ ...(leaseKf && leaseKf.residual != null ? { leaseResidual: leaseKf.residual } : {}),
582
+ ...(leaseKf && leaseKf.nominal != null ? { leaseNominal: leaseKf.nominal } : {}),
583
+ ...(leaseKf && leaseKf.apr != null ? { leaseApr: leaseKf.apr } : {}),
562
584
  ...(drop != null ? { drop } : {}),
563
585
  ...(dropPct != null ? { dropPct } : {}),
564
586
  ...(zeroDown ? { zeroDown } : {}),
@@ -71,6 +71,10 @@
71
71
  "kfTotal": "Gesamtbetrag: {{value}} €",
72
72
  "kfNominal": "{{value}} Sollzins fest",
73
73
  "kfApr": "{{value}} eff. Jahreszins",
74
+ "kfLeaseDown": "{{value}} € Anzahlung",
75
+ "kfCashPrice": "{{value}} € Barpreis",
76
+ "kfLeaseTotal": "{{value}} € Gesamtbetrag",
77
+ "kfPurchaseObligation": "Kaufpflicht",
74
78
  "termSelection": "Laufzeit",
75
79
  "termSelectionMonths": "Laufzeit (Monate)",
76
80
  "change": "Ändern",
@@ -71,6 +71,10 @@
71
71
  "kfTotal": "Total amount: €{{value}}",
72
72
  "kfNominal": "{{value}} fixed borrowing rate",
73
73
  "kfApr": "{{value}} APR",
74
+ "kfLeaseDown": "€{{value}} down payment",
75
+ "kfCashPrice": "€{{value}} cash price",
76
+ "kfLeaseTotal": "€{{value}} total amount",
77
+ "kfPurchaseObligation": "Purchase obligation",
74
78
  "termSelection": "Term",
75
79
  "termSelectionMonths": "Term (months)",
76
80
  "change": "Change",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.205",
3
+ "version": "1.0.207",
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",
package/theme/md3.css CHANGED
@@ -9207,9 +9207,14 @@ line-height: 31px;
9207
9207
  cell takes the tallest line's height so switching tabs never changes the card's height. */
9208
9208
  .md3 .cc-terms-stack {
9209
9209
  display: grid;
9210
+ /* ADV-405: the column is the card's width, not the widest slot's min-content — the key figures'
9211
+ unbroken lines (also in the hidden slots) used to widen it past the card, so their auto-fit
9212
+ never shrank them and the card clipped the lines and the warning panel. */
9213
+ grid-template-columns: minmax(0, 1fr);
9210
9214
  }
9211
9215
  .md3 .cc-terms-slot {
9212
9216
  grid-area: 1 / 1;
9217
+ min-width: 0;
9213
9218
  /* own block formatting context: keeps .cc-terms' margins inside the slot (not collapsing
9214
9219
  through it), so every slot measures margin + line exactly as the single line did before */
9215
9220
  display: flow-root;
@@ -9,17 +9,27 @@ import { formatEur, formatEurCents, formatPct } from '../utils/financeFormat';
9
9
  * "6,78 % Sollzins fest · 6,99 % eff. Jahreszins · Details". Same sources as the
10
10
  * Finanzierungsdetails layer (FinanceDetailsModal): term = paybackPeriod, net loan =
11
11
  * netLoanAmount, total = totalFinancingAmount (falls back to grossLoanAmount), nominal rate =
12
- * nominalInterestRate, effective rate = annualPercentageRate.
12
+ * nominalInterestRate, effective rate = annualPercentageRate. Leasing (kind: 'leasing', 19.11): see
13
+ * leasingKeyFigureLines / leasingKeyFigures below.
13
14
  */
14
15
  export interface CreditKeyFiguresData {
16
+ /** financing (default) or leasing — the two products word their lines differently. */
17
+ kind?: 'financing' | 'leasing';
15
18
  /** contract term (paybackPeriod) — exactly the layer's "Vertragslaufzeit" (e.g. 48, also with a Schlussrate). */
16
19
  months?: number | null;
17
20
  /** final instalment (Schlussrate) of the same calculation — not shown; kept for the hosts' data. */
18
21
  finalInstallment?: number | null;
19
22
  netLoan?: number | null;
23
+ /** financing: Gesamtbetrag; leasing: the layer's "Gesamt inkl. Restwert" (see leasingKeyFigures). */
20
24
  total?: number | null;
21
25
  nominal?: number | null;
22
26
  apr?: number | null;
27
+ /** leasing: the layer's "Einmalige Sonderzahlung" (0 is a real figure: "0 € Anzahlung"). */
28
+ down?: number | null;
29
+ /** leasing: the layer's "Anschaffungspreis" ("… € Barpreis"). */
30
+ cashPrice?: number | null;
31
+ /** leasing: the layer's "Restwert (verpflichtend)" — "Kaufpflicht" is shown when it is real. */
32
+ residual?: number | null;
23
33
  }
24
34
 
25
35
  export interface CreditKeyFiguresProps {
@@ -38,6 +48,7 @@ const real = (n: number | null | undefined): n is number => typeof n === 'number
38
48
 
39
49
  /** the parts of both lines — only real figures, never a fabricated value; empty lines are dropped. */
40
50
  export function creditKeyFigureLines(t: TranslationFunction, f: CreditKeyFiguresData): string[][] {
51
+ if (f.kind === 'leasing') return leasingKeyFigureLines(t, f);
41
52
  const line1: string[] = [];
42
53
  const line2: string[] = [];
43
54
  if (real(f.months)) {
@@ -61,14 +72,99 @@ export function creditKeyFigureLines(t: TranslationFunction, f: CreditKeyFigures
61
72
  const v = formatPct(f.apr);
62
73
  line2.push(t('autobahn:finance.kfApr', { value: v, defaultValue: `${v} eff. Jahreszins` }));
63
74
  }
64
- // keep every € / % on its amount's line (no-break space), like the € in the hosts' money strings
65
- const keepUnits = (part: string): string => part.replace(/ (€|%)/g, '\u00a0$1');
75
+ return [line1.map(keepUnits), line2.map(keepUnits)];
76
+ }
77
+
78
+ // keep every € / % on its amount's line (no-break space), like the € in the hosts' money strings
79
+ const keepUnits = (part: string): string => part.replace(/ (€|%)/g, '\u00a0$1');
80
+
81
+ /**
82
+ * Leasing key figures, worded as the PM's leasing mock ("Vorschlag: Restwert - Leasing", 19.11):
83
+ * "0 € Anzahlung · 60 Mon. · 24.549 € Barpreis · 31.776,28 € Gesamtbetrag" /
84
+ * "Kaufpflicht · 6,78 % Sollzins fest · 6,99 % eff. Jahreszins · Details". Anzahlung = the layer's
85
+ * Einmalige Sonderzahlung, Barpreis = Anschaffungspreis, Gesamtbetrag = Gesamt inkl. Restwert,
86
+ * "Kaufpflicht" = the mandatory Restwert (only when there is one). € with a space, as in the
87
+ * financing mock next to it.
88
+ */
89
+ function leasingKeyFigureLines(t: TranslationFunction, f: CreditKeyFiguresData): string[][] {
90
+ const line1: string[] = [];
91
+ const line2: string[] = [];
92
+ if (typeof f.down === 'number' && isFinite(f.down) && f.down >= 0) {
93
+ const v = formatEur(Math.round(f.down));
94
+ line1.push(t('autobahn:finance.kfLeaseDown', { value: v, defaultValue: `${v} € Anzahlung` }));
95
+ }
96
+ if (real(f.months)) {
97
+ const months = Math.round(f.months);
98
+ line1.push(t('autobahn:finance.kfMonths', { months, defaultValue: `${months} Mon.` }));
99
+ }
100
+ if (real(f.cashPrice)) {
101
+ const v = formatEur(Math.round(f.cashPrice));
102
+ line1.push(t('autobahn:finance.kfCashPrice', { value: v, defaultValue: `${v} € Barpreis` }));
103
+ }
104
+ if (real(f.total)) {
105
+ const v = formatEurCents(f.total);
106
+ line1.push(t('autobahn:finance.kfLeaseTotal', { value: v, defaultValue: `${v} € Gesamtbetrag` }));
107
+ }
108
+ if (real(f.residual)) {
109
+ line2.push(t('autobahn:finance.kfPurchaseObligation', { defaultValue: 'Kaufpflicht' }));
110
+ }
111
+ if (real(f.nominal)) {
112
+ const v = formatPct(f.nominal);
113
+ line2.push(t('autobahn:finance.kfNominal', { value: v, defaultValue: `${v} Sollzins fest` }));
114
+ }
115
+ if (real(f.apr)) {
116
+ const v = formatPct(f.apr);
117
+ line2.push(t('autobahn:finance.kfApr', { value: v, defaultValue: `${v} eff. Jahreszins` }));
118
+ }
66
119
  return [line1.map(keepUnits), line2.map(keepUnits)];
67
120
  }
68
121
 
69
122
  /** true when at least one figure is real (otherwise hosts keep their previous conditions line). */
70
123
  export function hasCreditKeyFigures(f: CreditKeyFiguresData): boolean {
71
- return [f.months, f.netLoan, f.total, f.nominal, f.apr].some(real);
124
+ return [f.months, f.netLoan, f.total, f.nominal, f.apr, f.cashPrice].some(real);
125
+ }
126
+
127
+ /** inputs of the Leasingdetails layer (FinanceDetailsModal, leasing) — see leasingKeyFigures. */
128
+ export interface LeasingKeyFigureInputs {
129
+ /** currentSalesPrice — the Anschaffungspreis fallback when there is no basePrice. */
130
+ price?: number | null;
131
+ /** common.basePrice ("no package" price). */
132
+ basePrice?: number | null;
133
+ monthly?: number | null;
134
+ term?: number | null;
135
+ /** Einmalige Sonderzahlung (leasing firstInstallment). */
136
+ down?: number | null;
137
+ /** Restwert (leasing finalInstallment). */
138
+ residual?: number | null;
139
+ withAddServices?: boolean | null;
140
+ /** the leasing package's one-time price (leasing addServicesCostRaw). */
141
+ addServicesCostRaw?: number | null;
142
+ nominal?: number | null;
143
+ apr?: number | null;
144
+ }
145
+
146
+ /**
147
+ * The leasing key figures with the Leasingdetails layer's own arithmetic (FinanceDetailsModal,
148
+ * leasing branch), so line and layer never disagree: Anschaffungspreis = (basePrice, else price)
149
+ * + the package when it is in the rate; Gesamt inkl. Restwert = term × rate + Sonderzahlung + the
150
+ * package when paid separately + Restwert. A missing input leaves its figure out (never invented).
151
+ */
152
+ export function leasingKeyFigures(i: LeasingKeyFigureInputs): CreditKeyFiguresData {
153
+ const raw = real(i.addServicesCostRaw) ? i.addServicesCostRaw : 0;
154
+ const base = real(i.basePrice) ? i.basePrice : real(i.price) ? i.price : undefined;
155
+ const down = typeof i.down === 'number' && isFinite(i.down) && i.down >= 0 ? i.down : undefined;
156
+ const residual = real(i.residual) ? i.residual : 0;
157
+ const ratesSum = real(i.monthly) && real(i.term) ? i.monthly * i.term : undefined;
158
+ return {
159
+ kind: 'leasing',
160
+ down,
161
+ months: real(i.term) ? i.term : undefined,
162
+ cashPrice: base != null ? base + (i.withAddServices && raw > 0 ? raw : 0) : undefined,
163
+ total: ratesSum != null ? ratesSum + (down || 0) + (raw > 0 && !i.withAddServices ? raw : 0) + residual : undefined,
164
+ residual: residual > 0 ? residual : undefined,
165
+ nominal: real(i.nominal) ? i.nominal : undefined,
166
+ apr: real(i.apr) ? i.apr : undefined,
167
+ };
72
168
  }
73
169
 
74
170
  /** smallest font the auto-fit goes down to (px); the PM wants both lines to stay one line each. */
package/ui/index.ts CHANGED
@@ -33,8 +33,8 @@ export type { StatChipProps, StatChipTone } from './StatChip';
33
33
  export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
34
34
  export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
35
35
 
36
- export { default as CreditKeyFigures, creditKeyFigureLines, hasCreditKeyFigures } from './CreditKeyFigures';
37
- export type { CreditKeyFiguresProps, CreditKeyFiguresData } from './CreditKeyFigures';
36
+ export { default as CreditKeyFigures, creditKeyFigureLines, hasCreditKeyFigures, leasingKeyFigures } from './CreditKeyFigures';
37
+ export type { CreditKeyFiguresProps, CreditKeyFiguresData, LeasingKeyFigureInputs } from './CreditKeyFigures';
38
38
 
39
39
  export { default as Segmented } from './Segmented';
40
40
  export type { SegmentedProps, SegmentedOption } from './Segmented';