fix: Liquidität Kontostand + ganzzahlig + Jahresspalte
- Kontostand/LIQUIDITAET: Jahresspalte zeigt Dez-Wert (nicht Summe) - Alle Werte ganzzahlig (keine Nachkommastellen) - Engine: Brutto, Sozial, AfA, Material alles Math.round() - formatCell: immer maximumFractionDigits: 0 - GuV: Jahreswerte gerundet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,8 +53,7 @@ function getValues(row: SheetRow): Record<string, number> {
|
||||
function formatCell(v: number | undefined): string {
|
||||
if (v === undefined || v === null) return ''
|
||||
if (v === 0) return '—'
|
||||
if (Math.abs(v) >= 1000) return v.toLocaleString('de-DE', { maximumFractionDigits: 0 })
|
||||
return v.toLocaleString('de-DE', { maximumFractionDigits: 2 })
|
||||
return Math.round(v).toLocaleString('de-DE', { maximumFractionDigits: 0 })
|
||||
}
|
||||
|
||||
export default function FinanzplanSlide({ lang }: FinanzplanSlideProps) {
|
||||
@@ -199,7 +198,7 @@ export default function FinanzplanSlide({ lang }: FinanzplanSlideProps) {
|
||||
const v = values[`y${y}`] || 0
|
||||
return (
|
||||
<td key={y} className={`text-right py-1.5 px-3 ${v < 0 ? 'text-red-400' : v > 0 ? (isSumRow ? 'text-white/80' : 'text-white/50') : 'text-white/15'} ${isSumRow ? 'font-bold' : ''}`}>
|
||||
{v === 0 ? '—' : v.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
|
||||
{v === 0 ? '—' : Math.round(v).toLocaleString('de-DE', { maximumFractionDigits: 0 })}
|
||||
</td>
|
||||
)
|
||||
})}
|
||||
@@ -232,10 +231,17 @@ export default function FinanzplanSlide({ lang }: FinanzplanSlideProps) {
|
||||
const label = getLabel(row)
|
||||
const isSumRow = row.is_sum_row || label.includes('GESAMT') || label.includes('Summe') || label.includes('UEBERSCHUSS') || label.includes('LIQUIDITAET')
|
||||
const isEditable = row.is_editable
|
||||
// Balance rows show Dec value, flow rows show annual sum
|
||||
const isBalanceRow = label.includes('Kontostand') || label === 'LIQUIDITAET'
|
||||
|
||||
// Annual sum for visible year
|
||||
let annual = 0
|
||||
for (let m = monthStart; m <= monthEnd; m++) annual += values[`m${m}`] || 0
|
||||
if (isBalanceRow) {
|
||||
// Point-in-time: show last month (December) value
|
||||
annual = values[`m${monthEnd}`] || 0
|
||||
} else {
|
||||
// Flow: sum all 12 months
|
||||
for (let m = monthStart; m <= monthEnd; m++) annual += values[`m${m}`] || 0
|
||||
}
|
||||
|
||||
return (
|
||||
<tr
|
||||
|
||||
@@ -39,10 +39,10 @@ export function computePersonalkosten(positions: FPPersonalkosten[]): FPPersonal
|
||||
const { year } = monthToDate(m)
|
||||
const yearsFromStart = year - startDate.getFullYear()
|
||||
const raise = Math.pow(1 + (p.annual_raise_pct || 0) / 100, yearsFromStart)
|
||||
const monthlyBrutto = Math.round(p.brutto_monthly * raise * 100) / 100
|
||||
const monthlyBrutto = Math.round(p.brutto_monthly * raise)
|
||||
|
||||
brutto[`m${m}`] = monthlyBrutto
|
||||
sozial[`m${m}`] = Math.round(monthlyBrutto * (p.ag_sozial_pct || 20.425) / 100 * 100) / 100
|
||||
sozial[`m${m}`] = Math.round(monthlyBrutto * (p.ag_sozial_pct || 20.425) / 100)
|
||||
total[`m${m}`] = brutto[`m${m}`] + sozial[`m${m}`]
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export function computeInvestitionen(items: FPInvestitionen[]): FPInvestitionen[
|
||||
// AfA (linear depreciation)
|
||||
if (item.afa_years && item.afa_years > 0) {
|
||||
const afaMonths = item.afa_years * 12
|
||||
const monthlyAfa = Math.round(item.purchase_amount / afaMonths * 100) / 100
|
||||
const monthlyAfa = Math.round(item.purchase_amount / afaMonths)
|
||||
for (let m = purchaseM; m < purchaseM + afaMonths && m <= MONTHS; m++) {
|
||||
if (m >= 1) afa[`m${m}`] = monthlyAfa
|
||||
}
|
||||
@@ -170,7 +170,7 @@ export async function computeFinanzplan(pool: Pool, scenarioId: string): Promise
|
||||
if (qty && price) {
|
||||
for (let m = 1; m <= MONTHS; m++) {
|
||||
const v = (qty.values[`m${m}`] || 0) * (price.values[`m${m}`] || 0)
|
||||
rev.values[`m${m}`] = Math.round(v * 100) / 100
|
||||
rev.values[`m${m}`] = Math.round(v)
|
||||
totalRevenue[`m${m}`] += rev.values[`m${m}`]
|
||||
}
|
||||
await pool.query('UPDATE fp_umsatzerloese SET values = $1 WHERE id = $2', [JSON.stringify(rev.values), rev.id])
|
||||
@@ -194,7 +194,7 @@ export async function computeFinanzplan(pool: Pool, scenarioId: string): Promise
|
||||
if (uc && qty) {
|
||||
for (let m = 1; m <= MONTHS; m++) {
|
||||
const v = (qty.values[`m${m}`] || 0) * (uc.values[`m${m}`] || 0)
|
||||
cost.values[`m${m}`] = Math.round(v * 100) / 100
|
||||
cost.values[`m${m}`] = Math.round(v)
|
||||
totalMaterial[`m${m}`] += cost.values[`m${m}`]
|
||||
}
|
||||
await pool.query('UPDATE fp_materialaufwand SET values = $1 WHERE id = $2', [JSON.stringify(cost.values), cost.id])
|
||||
|
||||
Reference in New Issue
Block a user