Skip to content

Commit

Permalink
Merge branch 'main' into pdf-hinweisblatt
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer6497 committed Aug 21, 2024
2 parents f83fb13 + 0aaaa2f commit e497538
Show file tree
Hide file tree
Showing 39 changed files with 830 additions and 500 deletions.
3 changes: 2 additions & 1 deletion app/components/StandaloneLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type StandaloneLinkProps = Readonly<{
className?: string;
}>;

const OPEN_NEW_TAB = "öffnet neues Fenster";
export const OPEN_NEW_TAB = "öffnet neues Fenster";

export const StandaloneLink = ({
url,
Expand All @@ -22,6 +22,7 @@ export const StandaloneLink = ({
const shouldOpenNewTab = isExternal || isDownload;
const anchorProps: React.AnchorHTMLAttributes<HTMLAnchorElement> = {
href: url,
"aria-label": text,
className: classNames("text-link min-h-[24px] inline-block", className),
...(shouldOpenNewTab
? {
Expand Down
4 changes: 2 additions & 2 deletions app/flows/beratungshilfeFormular/context.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { beratungshilfeAbgabe } from "~/flows/beratungshilfeFormular/abgabe/context";
import { beratungshilfeAnwaltlicheVertretung } from "./anwaltlicheVertretung/context";
import { beratungshilfeFinanzielleAngaben } from "./finanzielleAngaben/context";
import { beratungshilfeGrundvoraussetzungen } from "./grundvoraussetzung/context";
import { beratungshilfePersoenlicheDaten } from "./persoenlicheDaten/context";
import { beratungshilfeRechtsproblem } from "./rechtsproblem/context";
import { abgabeContext } from "../shared/abgabe/context";

export const beratungshilfeFormularContext = {
...beratungshilfeAnwaltlicheVertretung,
...beratungshilfeGrundvoraussetzungen,
...beratungshilfeRechtsproblem,
...beratungshilfeFinanzielleAngaben,
...beratungshilfePersoenlicheDaten,
...beratungshilfeAbgabe,
...abgabeContext,
} as const;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beratungshilfeFinanzielleAngabeDone } from "~/flows/beratungshilfeFormular/finanzielleAngaben/navStates";
import * as navStatesEigentum from "~/flows/beratungshilfeFormular/finanzielleAngaben/navStatesEigentum";
import * as eigentumZusammenfassungDone from "../eigentumZusammenfassungDone";
import { beratungshilfeFinanzielleAngabeDone } from "../navStates";
import * as eigentumZusammenfassungDone from "../navStatesEigentumZusammenfassungDone";

describe("navStates", () => {
afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable sonarjs/no-duplicate-string */
import {
bankKontoDone,
eigentumDone,
geldanlagenDone,
grundeigentumDone,
kraftfahrzeugeDone,
wertsachenDone,
} from "~/flows/beratungshilfeFormular/finanzielleAngaben/navStatesEigentum";
} from "~/flows/shared/finanzielleAngaben/navStates";
import { eigentumDone } from "../guards";

describe("eigentumDone", () => {
it("passes with all fields no", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as navStates from "~/flows/shared/finanzielleAngaben/navStates";
import { eigentumZusammenfassungDone } from "../navStatesEigentumZusammenfassungDone";

describe("eigentumZusammenfassungDone", () => {
it("passes with all sub-flows done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(true);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(true);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(true);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(true);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(true);

expect(eigentumZusammenfassungDone({ context: {} })).toBeTruthy();
});

it("fails with bankkonto not done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(false);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(true);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(true);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(true);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(true);

expect(eigentumZusammenfassungDone({ context: {} })).toBeFalsy();
});

it("fails with geldanlagen not done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(true);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(false);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(true);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(true);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(true);

expect(eigentumZusammenfassungDone({ context: {} })).toBeFalsy();
});

it("fails with grundeigentum not done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(true);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(true);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(false);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(true);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(true);

expect(eigentumZusammenfassungDone({ context: {} })).toBeFalsy();
});

it("fails with kraftfahrzeug not done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(true);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(true);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(true);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(false);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(true);

expect(eigentumZusammenfassungDone({ context: {} })).toBeFalsy();
});

it("fails with wertsachen not done", () => {
vi.spyOn(navStates, "bankKontoDone").mockReturnValue(true);
vi.spyOn(navStates, "geldanlagenDone").mockReturnValue(true);
vi.spyOn(navStates, "grundeigentumDone").mockReturnValue(true);
vi.spyOn(navStates, "kraftfahrzeugeDone").mockReturnValue(true);
vi.spyOn(navStates, "wertsachenDone").mockReturnValue(false);

expect(eigentumZusammenfassungDone({ context: {} })).toBeFalsy();
});
});
173 changes: 12 additions & 161 deletions app/flows/beratungshilfeFormular/finanzielleAngaben/context.ts
Original file line number Diff line number Diff line change
@@ -1,176 +1,27 @@
import { z } from "zod";
import { staatlicheLeistungen } from "~/flows/beratungshilfeVorabcheck/context";
import {
bankkontenArraySchema,
eigentumTotalWorthSchema,
gelanlagenArraySchema,
grundeigentumArraySchema,
kinderArraySchema,
kraftfahrzeugeArraySchema,
partnerschaftSchema,
unterhaltszahlungSchema,
wertsachenArraySchema,
} from "~/flows/shared/finanzielleAngaben/context";
import { pageDataSchema } from "~/services/flow/pageDataSchema";
import { checkedOptional } from "~/services/validation/checkedCheckbox";
import { createDateSchema } from "~/services/validation/date";
import { integerSchema } from "~/services/validation/integer";
import { buildMoneyValidationSchema } from "~/services/validation/money/buildMoneyValidationSchema";
import { optionalOrSchema } from "~/services/validation/optionalOrSchema";
import { stringOptionalSchema } from "~/services/validation/stringOptional";
import { stringRequiredSchema } from "~/services/validation/stringRequired";
import { createYearSchema } from "~/services/validation/year";
import {
YesNoAnswer,
customRequiredErrorMessage,
} from "~/services/validation/YesNoAnswer";
import { addYears, today } from "~/util/date";

export const Eigentuemer = z.enum(
["myself", "partner", "myselfAndPartner", "myselfAndSomeoneElse"],
customRequiredErrorMessage,
);

const MINUS_150_YEARS = -150;

export const GrundeigentumArt = z.enum(
[
"eigentumswohnung",
"einfamilienhaus",
"mehrereWohnungen",
"unbebaut",
"erbbaurecht",
"garage",
],
customRequiredErrorMessage,
);

export const unterhaltszahlungSchema = z.object({
firstName: stringRequiredSchema,
surname: stringRequiredSchema,
familyRelationship: z.enum(
[
"mother",
"father",
"grandmother",
"grandfather",
"kid",
"grandchild",
"ex-spouse-f",
"ex-spouse-m",
],
customRequiredErrorMessage,
),
birthday: createDateSchema({
earliest: () => addYears(today(), MINUS_150_YEARS),
latest: () => today(),
}),
monthlyPayment: buildMoneyValidationSchema(),
});

export const bankkontenArraySchema = z.array(
z.object({
bankName: stringRequiredSchema,
kontostand: buildMoneyValidationSchema({}),
iban: stringOptionalSchema,
kontoEigentuemer: Eigentuemer,
kontoDescription: stringOptionalSchema,
}),
);

export const kraftfahrzeugeArraySchema = z.array(
z.object({
art: stringRequiredSchema,
marke: stringRequiredSchema,
eigentuemer: Eigentuemer,
verkaufswert: optionalOrSchema(buildMoneyValidationSchema()),
kilometerstand: integerSchema,
anschaffungsjahr: createYearSchema({
optional: true,
latest: () => today().getFullYear(),
}),
baujahr: createYearSchema({ latest: () => today().getFullYear() }),
bemerkung: stringRequiredSchema,
hasArbeitsweg: YesNoAnswer,
wert: z.enum(
["under10000", "over10000", "unsure"],
customRequiredErrorMessage,
),
}),
);

export const gelanlagenArraySchema = z.array(
z.object({
art: z.enum(
[
"bargeld",
"wertpapiere",
"guthabenkontoKrypto",
"giroTagesgeldSparkonto",
"befristet",
"forderung",
"sonstiges",
],
customRequiredErrorMessage,
),
eigentuemer: Eigentuemer,
wert: buildMoneyValidationSchema(),

kontoBankName: stringOptionalSchema,
kontoIban: stringOptionalSchema,
kontoBezeichnung: stringOptionalSchema,

befristetArt: z
.enum(
["lifeInsurance", "buildingSavingsContract", "fixedDepositAccount"],
customRequiredErrorMessage,
)
.optional(),

forderung: stringOptionalSchema,
verwendungszweck: stringOptionalSchema,
auszahlungdatum: stringOptionalSchema,
}),
);

export const eigentumTotalWorthSchema = z.enum(
["less10000", "more10000", "unsure"],
customRequiredErrorMessage,
);

export const grundeigentumArraySchema = z.array(
z.object({
isBewohnt: z.enum(["yes", "family", "no"], customRequiredErrorMessage),
art: GrundeigentumArt,
eigentuemer: Eigentuemer,
flaeche: stringRequiredSchema,
verkaufswert: buildMoneyValidationSchema(),
strassehausnummer: stringRequiredSchema,
plz: stringOptionalSchema,
ort: stringRequiredSchema,
land: stringRequiredSchema,
}),
);

export const wertsachenArraySchema = z.array(
z.object({
art: stringRequiredSchema,
eigentuemer: Eigentuemer,
wert: buildMoneyValidationSchema(),
}),
);

export const partnerschaftSchema = z.enum(
["yes", "no", "separated", "widowed"],
customRequiredErrorMessage,
);

export const kinderArraySchema = z.array(
z.object({
vorname: stringRequiredSchema,
nachname: stringRequiredSchema,
geburtsdatum: createDateSchema({
earliest: () => addYears(today(), -24),
latest: () => today(),
}),
wohnortBeiAntragsteller: z.enum(["yes", "no", "partially"]),
eigeneEinnahmen: YesNoAnswer,
einnahmen: buildMoneyValidationSchema(),
unterhalt: YesNoAnswer,
unterhaltsSumme: buildMoneyValidationSchema(),
}),
);

export type Unterhaltszahlung = z.infer<typeof unterhaltszahlungSchema>;
import { today } from "~/util/date";

export const beratungshilfeFinanzielleAngaben = {
einkommen: buildMoneyValidationSchema(),
Expand Down

This file was deleted.

Loading

0 comments on commit e497538

Please sign in to comment.