feat(falukant): add scandalExtraDailyPct field and update related components
All checks were successful
Deploy to production / deploy (push) Successful in 2m59s

- Introduced a new field `scandalExtraDailyPct` in the relationship state model to track additional scandal risk per day, with validation constraints.
- Updated the FalukantService to include the new field in relevant calculations and data handling.
- Enhanced the frontend components, including RevenueSection and FamilyView, to display the scandal risk information and updated price calculations.
- Added localization entries for the new field in multiple languages to ensure clarity for users.
This commit is contained in:
Torsten Schulz (local)
2026-04-13 15:31:47 +02:00
parent b0624422b8
commit 86e14a875d
12 changed files with 176 additions and 26 deletions

View File

@@ -436,6 +436,7 @@ export default {
vehicles: [],
activeTab: 'production',
productPricesCache: {}, // Cache für regionale Preise: { productId: price }
productNetMetricsCache: {}, // Netto-Metriken vom Backend: { productId: { netPerPiece, netPerMinute, ... } }
/** Cache-Schlüssel: Region + ob MAX(worth) über alle Filialregionen (bei Fahrzeug) */
productPricesCacheKey: null,
tabs: [
@@ -739,6 +740,7 @@ export default {
async loadProductPricesForCurrentBranch() {
if (!this.selectedBranch || !this.selectedBranch.regionId) {
this.productPricesCache = {};
this.productNetMetricsCache = {};
this.productPricesCacheKey = null;
return;
}
@@ -755,6 +757,7 @@ export default {
}
const { data } = await apiClient.get('/api/falukant/products/prices-in-region', { params });
this.productPricesCache = data.prices || {};
this.productNetMetricsCache = data.netMetrics || {};
this.productPricesCacheKey = cacheKey;
} catch (error) {
console.error(`Error loading product prices for region ${this.selectedBranch.regionId}:`, error);
@@ -780,6 +783,7 @@ export default {
}
}
this.productPricesCache = prices;
this.productNetMetricsCache = {};
this.productPricesCacheKey = cacheKey;
}
},
@@ -873,6 +877,13 @@ export default {
},
calculateProductProfit(product) {
const netMetrics = this.productNetMetricsCache?.[product.id];
if (netMetrics && Number.isFinite(Number(netMetrics.netPerPiece)) && Number.isFinite(Number(netMetrics.netPerMinute))) {
return {
absolute: Number(netMetrics.netPerPiece).toFixed(2),
perMinute: Number(netMetrics.netPerMinute).toFixed(2),
};
}
const { absolute: revenueAbsoluteStr, perMinute: revenuePerMinuteStr }
= this.calculateProductRevenue(product);
const revenueAbsolute = parseFloat(revenueAbsoluteStr);

View File

@@ -397,6 +397,10 @@
<dt>{{ $t('falukant.family.lovers.maintenance') }}</dt>
<dd>{{ lover.maintenanceLevel }}</dd>
</div>
<div>
<dt>{{ $t('falukant.family.lovers.scandalExtraDailyPct') }}</dt>
<dd>{{ Number(lover.scandalExtraDailyPct || 0).toFixed(1) }}%</dd>
</div>
<div>
<dt>{{ $t('falukant.family.lovers.monthlyCost') }}</dt>
<dd>