Vorvertrag-Verbrauch als Schätzwert im Folgevertrag
ContractForm (Strom/Gas): Wenn ein previousContractId gesetzt ist, wird der Vorvertrag samt Readings nachgeladen, der Verbrauch clientseitig berechnet und als "Vorvertrag: X kWh [Übernehmen]" unter dem Jahresverbrauch-Feld angezeigt. Bei Gas auch unter "Jahresverbrauch (kWh)". ContractDetail (Strom/Gas): Wenn annualConsumption leer ist und ein berechenbarer Vorvertrag existiert, wird "~X kWh, geschätzt aus Vorvertrag" in der Jahresverbrauch-Zelle angezeigt – damit der Wert beim Lesen schon als Anhaltspunkt da steht. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1718,6 +1718,23 @@ export default function ContractDetail() {
|
||||
}
|
||||
|
||||
const c = data.data;
|
||||
// Verbrauch aus Vorvertrag als Hinweis, wenn der Jahresverbrauch im aktuellen
|
||||
// Vertrag noch leer ist. Greift nur bei Strom/Gas mit einem berechenbaren
|
||||
// Vorvertrag.
|
||||
const previousConsumption = (() => {
|
||||
const pc = c.previousContract;
|
||||
if (!pc?.energyDetails || !pc.startDate || !pc.endDate) return null;
|
||||
if (c.type !== 'ELECTRICITY' && c.type !== 'GAS') return null;
|
||||
const cms = pc.energyDetails.contractMeters || [];
|
||||
if (cms.length > 0) {
|
||||
return calculateMultiMeterConsumption(cms, pc.startDate, pc.endDate, c.type);
|
||||
}
|
||||
const readings = pc.energyDetails.meter?.readings || [];
|
||||
if (readings.length === 0) return null;
|
||||
return calculateConsumption(readings, pc.startDate, pc.endDate, c.type);
|
||||
})();
|
||||
const previousConsumptionUsable = previousConsumption
|
||||
&& (previousConsumption.type === 'exact' || previousConsumption.type === 'projected');
|
||||
const fallbackBack = isCustomerPortal ? '/contracts' : (c.customer ? `/customers/${c.customer.id}?tab=contracts` : '/contracts');
|
||||
const back = popHistory(location.state, fallbackBack);
|
||||
|
||||
@@ -2595,7 +2612,7 @@ export default function ContractDetail() {
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
{c.energyDetails.annualConsumption && (
|
||||
{c.energyDetails.annualConsumption ? (
|
||||
<div>
|
||||
<dt className="text-sm text-gray-500">
|
||||
Jahresverbrauch {c.type === 'ELECTRICITY' ? '' : '(m³)'}
|
||||
@@ -2605,13 +2622,39 @@ export default function ContractDetail() {
|
||||
{c.type === 'ELECTRICITY' ? 'kWh' : 'm³'}
|
||||
</dd>
|
||||
</div>
|
||||
) : previousConsumptionUsable && (
|
||||
<div>
|
||||
<dt className="text-sm text-gray-500">
|
||||
Jahresverbrauch {c.type === 'ELECTRICITY' ? '' : '(m³)'}
|
||||
</dt>
|
||||
<dd className="text-blue-700">
|
||||
~{(c.type === 'GAS'
|
||||
? previousConsumption!.consumptionM3 ?? previousConsumption!.consumptionKwh
|
||||
: previousConsumption!.consumptionKwh
|
||||
).toLocaleString('de-DE', { maximumFractionDigits: 0 })}{' '}
|
||||
{c.type === 'GAS' ? 'm³' : 'kWh'}
|
||||
<div className="text-xs text-gray-500 mt-0.5">
|
||||
geschätzt aus Vorvertrag{previousConsumption!.type === 'projected' ? ' (hochgerechnet)' : ''}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
{c.type === 'GAS' && c.energyDetails.annualConsumptionKwh && (
|
||||
{c.type === 'GAS' && c.energyDetails.annualConsumptionKwh ? (
|
||||
<div>
|
||||
<dt className="text-sm text-gray-500">Jahresverbrauch (kWh)</dt>
|
||||
<dd>{c.energyDetails.annualConsumptionKwh.toLocaleString('de-DE')} kWh</dd>
|
||||
</div>
|
||||
)}
|
||||
) : (c.type === 'GAS' && previousConsumptionUsable) ? (
|
||||
<div>
|
||||
<dt className="text-sm text-gray-500">Jahresverbrauch (kWh)</dt>
|
||||
<dd className="text-blue-700">
|
||||
~{previousConsumption!.consumptionKwh.toLocaleString('de-DE', { maximumFractionDigits: 0 })} kWh
|
||||
<div className="text-xs text-gray-500 mt-0.5">
|
||||
geschätzt aus Vorvertrag{previousConsumption!.type === 'projected' ? ' (hochgerechnet)' : ''}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
) : null}
|
||||
{c.energyDetails.basePrice != null && (
|
||||
<div>
|
||||
<dt className="text-sm text-gray-500">Grundpreis</dt>
|
||||
|
||||
Reference in New Issue
Block a user