Rework real estate model: purchase price + mortgage + amortization only, no appreciation; amortization counts against savings quota; sale price/tax entered at transition time with correct mortgage payoff; carry over income/expenses to new phases
Deploy App / deploy (push) Successful in 1m31s
Deploy App / deploy (push) Successful in 1m31s
This commit is contained in:
@@ -31,9 +31,12 @@ export async function POST(
|
||||
const lastPhase = await prisma.phase.findFirst({
|
||||
where: { planId },
|
||||
orderBy: { sequenceNumber: "desc" },
|
||||
include: { incomeEntries: true, expenseEntries: true },
|
||||
});
|
||||
const nextSequence = (lastPhase?.sequenceNumber ?? 0) + 1;
|
||||
|
||||
// Einkommen und Ausgaben werden 1:1 aus der letzten Phase uebernommen (manuell
|
||||
// anpassbar), damit man sie nicht bei jeder neuen Phase erneut eintippen muss.
|
||||
const phase = await prisma.phase.create({
|
||||
data: {
|
||||
planId,
|
||||
@@ -41,7 +44,21 @@ export async function POST(
|
||||
name: parsed.data.name,
|
||||
durationYears: parsed.data.durationYears,
|
||||
inflationRate: parsed.data.inflationRate ?? null,
|
||||
incomeMode: parsed.data.incomeMode,
|
||||
incomeMode: lastPhase?.incomeMode ?? parsed.data.incomeMode,
|
||||
incomeEntries: lastPhase
|
||||
? {
|
||||
create: lastPhase.incomeEntries.map((e) => ({
|
||||
personId: e.personId,
|
||||
label: e.label,
|
||||
amount: e.amount,
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
expenseEntries: lastPhase
|
||||
? {
|
||||
create: lastPhase.expenseEntries.map((e) => ({ label: e.label, amount: e.amount })),
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
include: phaseInclude,
|
||||
});
|
||||
|
||||
@@ -80,12 +80,9 @@ export async function POST(
|
||||
realEstates: {
|
||||
create: phase.realEstates.map((re) => ({
|
||||
name: re.name,
|
||||
marketValue: re.marketValue,
|
||||
purchasePrice: re.purchasePrice,
|
||||
mortgage: re.mortgage,
|
||||
valueGrowth: re.valueGrowth,
|
||||
amortization: re.amortization,
|
||||
salePrice: re.salePrice,
|
||||
saleTaxRate: re.saleTaxRate,
|
||||
})),
|
||||
},
|
||||
oneTimeEvents: {
|
||||
|
||||
Reference in New Issue
Block a user