This commit is contained in:
Moritz Utcke
2025-04-01 13:49:47 -03:00
parent be94bd482c
commit 71f5093a49
23 changed files with 939 additions and 920 deletions

View File

@@ -35,6 +35,14 @@ export default defineConfig({
on("task", {
async verbrauchsausweisWohnen(query) {
return await prisma.verbrauchsausweisWohnen.findFirst(query)
},
async plz() {
const total = await prisma.postleitzahlen.count()
const result = await prisma.postleitzahlen.findFirst({
skip: Math.floor(Math.random() * total)
})
return result?.plz
}
})
},

View File

@@ -13,28 +13,28 @@ export const createCaller = createCallerFactory({
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].ts"),
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
"bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
"bedarfsausweis-gewerbe/[uid]": await import("../src/pages/api/bedarfsausweis-gewerbe/[uid].ts"),
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
"bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
"bilder/[id]": await import("../src/pages/api/bilder/[id].ts"),
"geg-nachweis-gewerbe/[uid]": await import("../src/pages/api/geg-nachweis-gewerbe/[uid].ts"),
"geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"),
"geg-nachweis-wohnen/[uid]": await import("../src/pages/api/geg-nachweis-wohnen/[uid].ts"),
"geg-nachweis-wohnen/[id]": await import("../src/pages/api/geg-nachweis-wohnen/[id].ts"),
"geg-nachweis-wohnen": await import("../src/pages/api/geg-nachweis-wohnen/index.ts"),
"geg-nachweis-gewerbe/[id]": await import("../src/pages/api/geg-nachweis-gewerbe/[id].ts"),
"geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"),
"objekt": await import("../src/pages/api/objekt/index.ts"),
"rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"),
"rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"),
"rechnung": await import("../src/pages/api/rechnung/index.ts"),
"ticket": await import("../src/pages/api/ticket/index.ts"),
"user": await import("../src/pages/api/user/index.ts"),
"user/self": await import("../src/pages/api/user/self.ts"),
"verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"),
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
"user": await import("../src/pages/api/user/index.ts"),
"user/self": await import("../src/pages/api/user/self.ts"),
"verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"),
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
"webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"),

View File

@@ -195,7 +195,7 @@ export async function nachweisSpeichern(
} else {
const { id } = await putRoute.fetch({
nachweis,
uid_aufnahme: aufnahme.id
aufnahme_id: aufnahme.id
}, {
headers: {
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`

View File

@@ -5,12 +5,12 @@
import Overlay from "#components/Overlay.svelte";
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
import { AusweisTyp, BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
import { openWindowWithPost } from "#lib/helpers/window.js";
import { PRICES } from "#lib/constants.js";
import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js";
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
export let bilder: BildClient[];
export let unterlagen: UnterlageClient[] = [];
export let user: BenutzerClient | null;
@@ -46,7 +46,17 @@
return;
}
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
openWindowWithPost("/kundendaten", {
ausweis: { ...ausweis, nachweistyp: ausweistyp },
objekt,
aufnahme,
bilder,
unterlagen,
ausweisart,
ausweistyp
}, "")
} else {
openWindowWithPost("/kundendaten", {
ausweis: { ...ausweis, ausweistyp },
objekt,
@@ -57,6 +67,7 @@
ausweistyp
}, "")
}
}
let loginAction: () => any = ausweisAbschicken;

View File

@@ -26,6 +26,10 @@
Bedarfsausweis Wohnen
{:else if ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe}
Bedarfsausweis Gewerbe
{:else if ausweisart === Enums.Ausweisart.GEGNachweisWohnen}
GEG Nachweis Wohngebäude
{:else if ausweisart === Enums.Ausweisart.GEGNachweisGewerbe}
GEG Nachweis Gewerbegebäude
{/if}
{#if ausweistyp === Enums.AusweisTyp.Beratung}
mit Beratung

View File

@@ -4,15 +4,15 @@
import HelpLabel from "#components/labels/HelpLabel.svelte";
export let kategorie: string = "";
export let files: UnterlageClient[] = [];
export let files: Unterlage[] = [];
export let max: number = Infinity;
export let min: number = 1;
export let name: string = "";
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
export let objekt: ObjektClient;
import mime from "mime-types";
import { api } from "astro-typesafe-api/client";
import { BedarfsausweisGewerbe } from "#lib/client/prisma.js";
import { BedarfsausweisGewerbe, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js";
function getAllFiles(this: HTMLInputElement) {
@@ -43,14 +43,14 @@
const mimeType = mime.types[file.name.split(".").pop() as string]
const { uid } = await api.unterlage.PUT.fetch({
const { id } = await api.unterlage.PUT.fetch({
data: reader.result as string,
kategorie,
mime: mimeType,
name: file.name
})
files.push({ uid, kategorie, name: file.name, mime: mimeType });
files.push({ id, kategorie, name: file.name, mime: mimeType, aufnahme_id: null });
files = files;

View File

@@ -7,7 +7,7 @@
import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js";
import { addNotification, deleteNotification } from "#components/Notifications/shared.js";
import TagInput from "../TagInput.svelte";
import { BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
import {
AufnahmeClient,
ObjektClient,
@@ -15,8 +15,8 @@
} from "../Ausweis/types.js";
export let objekt: ObjektClient;
export let ausweis:
BedarfsausweisGewerbe;
export let nachweis:
BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
export let aufnahme: AufnahmeClient;
export let ausweisart: Enums.Ausweisart;
@@ -38,7 +38,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
class="rounded-e-none"
name="ausstellgrund"
placeholder="Anlass"
bind:value={ausweis.ausstellgrund}
bind:value={nachweis.ausstellgrund}
required
data-cy="ausstellgrund"
>

View File

@@ -8,6 +8,7 @@ import moment from "moment";
describe("Verbrauchsausweis erstellen Schritt 1", () => {
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
cy.task("plz").then(plz => {
cy.visit("/angebot-anfragen/geg-nachweis-gewerbe-anfragen");
cy.wait(2000);
@@ -56,18 +57,18 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Postleitzahl
cy.get("input[name='plz']").type(
faker.location.zipCode({
format: "#####",
})
plz as string
);
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
cy.get("[data-cy='plz-container']").find("button").first().click()
// Nutzflaeche
cy.get("input[name='nutzflaeche']")
.should("have.attr", "type", "number")
.type(faker.number.int({ min: 50, max: 1000 }).toString());
// Gebäudeteil
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
const options = $dropdown.find('option');
// Select the option at the random index
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
});
// Keller
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length).parent().select(faker.number.int({
@@ -99,7 +100,6 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
const telefon = faker.phone.number()
const strasse = faker.location.streetAddress({ useFullAddress: true })
const plz = faker.location.zipCode("#####")
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
@@ -107,24 +107,17 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Rechnung
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").type(`${vorname} ${nachname}`);
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz as string);
cy.get("[data-cy='plz-container']").children().first().click()
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
cy.get("button[data-cy='bestellen']").click();
cy.get("a[data-cy='registrieren']").should("be.visible").click();
// Wir sind jetzt registriert und können uns nun einloggen.
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
cy.get("form[name='signup'] button[type='submit']").click();
cy.get("form[name='login'] button[type='submit']").click();
cy.intercept({ method: "PUT", url: "**/api/rechnung/anfordern" }).as("anfordern")
cy["form:signup"](email, passwort, vorname, nachname)
cy.wait("@anfordern")
cy.url().should("contain", "/einpreisung/success")
})
});
});

View File

@@ -8,6 +8,7 @@ import moment from "moment";
describe("Verbrauchsausweis erstellen Schritt 1", () => {
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
cy.task("plz").then(plz => {
cy.visit("/angebot-anfragen/geg-nachweis-wohnen-anfragen");
cy.wait(2000);
@@ -51,18 +52,18 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Postleitzahl
cy.get("input[name='plz']").type(
faker.location.zipCode({
format: "#####",
})
plz as string
);
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
cy.get("[data-cy='plz-container']").find("button").first().click()
// Nutzflaeche
cy.get("input[name='nutzflaeche']")
.should("have.attr", "type", "number")
.type(faker.number.int({ min: 50, max: 1000 }).toString());
// Gebäudeteil
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
const options = $dropdown.find('option');
// Select the option at the random index
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
});
// Keller
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length).parent().select(faker.number.int({
@@ -94,7 +95,6 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
const telefon = faker.phone.number()
const strasse = faker.location.streetAddress({ useFullAddress: true })
const plz = faker.location.zipCode("#####")
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
@@ -102,24 +102,17 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Rechnung
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").type(`${vorname} ${nachname}`);
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz as string);
cy.get("[data-cy='plz-container']").children().first().click()
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
cy.get("button[data-cy='bestellen']").click();
cy.get("a[data-cy='registrieren']").should("be.visible").click();
// Wir sind jetzt registriert und können uns nun einloggen.
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
cy.get("form[name='signup'] button[type='submit']").click();
cy.get("form[name='login'] button[type='submit']").click();
cy.intercept({ method: "PUT", url: "**/api/rechnung/anfordern" }).as("anfordern")
cy["form:signup"](email, passwort, vorname, nachname)
cy.wait("@anfordern")
cy.url().should("contain", "/einpreisung/success")
});
});
});

View File

@@ -1,14 +1,12 @@
import fuelList from "#components/Ausweis/brennstoffListe.js";
import { faker } from "@faker-js/faker";
import { type Enums } from "#lib/client/prisma.js";
import { Enums } from "#lib/client/prisma.js";
import "cypress-file-upload"
import moment from "moment";
describe("Verbrauchsausweis erstellen Schritt 1", () => {
const ausstellgrund = (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]);
const heizungsstatus = (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]);
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
cy.task("plz").then(plz => {
cy.visit("/energieausweis-erstellen/verbrauchsausweis-gewerbe");
cy.wait(1000);
@@ -55,9 +53,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Postleitzahl
cy.get("input[name='plz']").type(
faker.location.zipCode({
format: "#####",
})
plz as string
);
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
@@ -74,14 +70,14 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
.type(faker.number.int({ min: 50, max: 1000 }).toString());
// Keller
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", heizungsstatus.length).parent().select(faker.number.int({
max: heizungsstatus.length,
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", Object.keys(Enums.Heizungsstatus).length).parent().select(faker.number.int({
max: Object.keys(Enums.Heizungsstatus).length,
min: 1
}));
// Dachgeschoss
cy.get("select[name='dachgeschoss']").find("option:not([disabled])").should("have.length", heizungsstatus.length).parent().select(faker.number.int({
max: heizungsstatus.length,
cy.get("select[name='dachgeschoss']").find("option:not([disabled])").should("have.length", Object.keys(Enums.Heizungsstatus).length).parent().select(faker.number.int({
max: Object.keys(Enums.Heizungsstatus).length,
min: 1
}));
@@ -273,7 +269,6 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
const telefon = faker.phone.number()
const strasse = faker.location.streetAddress({ useFullAddress: true })
const plz = faker.location.zipCode("#####")
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
@@ -281,7 +276,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Rechnung
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").type(`${vorname} ${nachname}`);
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz as string);
cy.get("[data-cy='plz-container']").children().first().click()
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
@@ -289,24 +284,13 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
cy.get("button[data-cy='bestellen']").click();
cy.get("a[data-cy='registrieren']").should("be.visible").click();
// Wir sind jetzt registriert und können uns nun einloggen.
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
cy.get("form[name='signup'] button[type='submit']").click();
cy.wait("@signup")
cy.get("form[name='login'] button[type='submit']").click();
cy["form:signup"](email, passwort, vorname, nachname)
cy.origin('https://www.mollie.com', () => {
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
cy.get("input[type='radio'][name='final_state'][value='paid']").check();
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
})
})
});
});

View File

@@ -6,6 +6,7 @@ import moment from "moment";
describe("Verbrauchsausweis erstellen Schritt 1", () => {
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
cy.task("plz").then(plz => {
const email = faker.internet.email();
const passwort = "test1234";
const vorname = faker.person.firstName();
@@ -13,7 +14,6 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
const telefon = faker.phone.number()
const strasse = faker.location.streetAddress({ useFullAddress: true })
const plz = faker.location.zipCode("#####")
const preLogin = Math.random() > 0.5;
@@ -68,9 +68,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Postleitzahl
cy.get("input[name='plz']").type(
faker.location.zipCode({
format: "#####",
})
plz as string
);
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
@@ -269,7 +267,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
}
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz as string);
cy.get("[data-cy='plz-container']").children().first().click()
cy.get("[data-cy='paypal']").click()
@@ -277,19 +275,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
cy.get("button[data-cy='bestellen']").click();
if (!preLogin) {
cy.get("a[data-cy='registrieren']").should("be.visible").click();
// Wir sind jetzt registriert und können uns nun einloggen.
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
cy.get("form[name='signup'] button[type='submit']").click();
cy.wait("@signup")
cy.get("form[name='login'] button[type='submit']").click();
cy["form:signup"](email, passwort, vorname, nachname)
}
cy.origin('https://www.mollie.com', () => {
@@ -298,4 +284,5 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
})
});
});
});

View File

@@ -30,11 +30,28 @@ Cypress.Commands.add("signup", (email, passwort, vorname, name) => {
cy.url().should("include", "/auth/login")
})
Cypress.Commands.add("form:signup", (email, passwort, vorname, name) => {
cy.get("a[data-cy='registrieren']").should("be.visible").click();
// Wir sind jetzt registriert und können uns nun einloggen.
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(name);
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
cy.get("form[name='signup'] button[type='submit']").click();
cy.wait("@signup")
cy.get("form[name='login'] button[type='submit']").click();
})
declare global {
namespace Cypress {
interface Chainable {
login(email: string, passwort: string): Chainable<void>
signup(email: string, passwort: string, vorname: string, name: string): Chainable<void>
"form:signup"(email: string, passwort: string, vorname: string, name: string): Chainable<void>
}
}
}

View File

@@ -1,4 +1,4 @@
import { Aufnahme, BedarfsausweisGewerbe, BedarfsausweisWohnen, Bild, Objekt, prisma, Unterlage, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "./prisma.js";
import { Aufnahme, BedarfsausweisGewerbe, BedarfsausweisWohnen, Bild, GEGNachweisGewerbe, GEGNachweisWohnen, Objekt, prisma, Unterlage, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "./prisma.js";
export async function getVerbrauchsausweisWohnen(id: string): Promise<VerbrauchsausweisWohnen | null> {
return await prisma.verbrauchsausweisWohnen.findUnique({
@@ -32,6 +32,22 @@ export async function getBedarfsausweisGewerbe(id: string): Promise<Bedarfsauswe
})
}
export async function getGEGNachweisWohnen(id: string): Promise<GEGNachweisWohnen | null> {
return await prisma.gEGNachweisWohnen.findUnique({
where: {
id
}
})
}
export async function getGEGNachweisGewerbe(id: string): Promise<GEGNachweisGewerbe | null> {
return await prisma.gEGNachweisGewerbe.findUnique({
where: {
id
}
})
}
export async function getAufnahme(id: string): Promise<Aufnahme | null> {
return await prisma.aufnahme.findUnique({
where: {

View File

@@ -111,7 +111,7 @@
<GEGAusweisart
bind:objekt
bind:aufnahme
bind:ausweis={nachweis}
bind:nachweis={nachweis}
{ausweisart}
/>
</Bereich>

View File

@@ -9,64 +9,50 @@
BildClient,
} from "#components/Ausweis/types.js";
import Bereich from "#components/labels/Bereich.svelte";
import { Enums } from "#lib/client/prisma.js";
import { Enums, Unterlage } from "#lib/client/prisma.js";
import InputLabel from "#components/labels/InputLabel.svelte";
import HelpLabel from "#components/labels/HelpLabel.svelte";
import Progressbar from "#components/Ausweis/Progressbar.svelte";
import FileGrid from "#components/FileGrid.svelte";
import ButtonWeiterHilfe from "#components/Ausweis/ButtonWeiterHilfe.svelte";
import GEGAusweisart from "#components/GEGNachweis/GEGAusweisart.svelte";
import moment from "moment";
export let nachweis: GEGNachweisWohnenClient;
export let objekt: ObjektClient;
export let aufnahme: AufnahmeClient;
export let user: BenutzerClient = {} as BenutzerClient;
export let bilder: BildClient[] = [];
export let plaene: UnterlageClient[] = [];
export let unterlagen: UnterlageClient[] = [];
export let plaene: Unterlage[] = [];
export let unterlagen: Unterlage[] = [];
export let nachweistyp: Enums.AusweisTyp = Enums.AusweisTyp.Standard;
export let id: string | null;
if (Object.keys(nachweis).length === 0) {
const localStorageAusweis = localStorage.getItem(
"geg-nachweis-wohnen.ausweis"
);
if (localStorageAusweis) {
nachweis = JSON.parse(localStorageAusweis);
}
if ((user && user.rolle !== Enums.BenutzerRolle.ADMIN) && !id && (!nachweis.updated_at || moment(localStorage.getItem("geg-nachweis-wohnen.updated_at") || new Date()).isAfter(nachweis.updated_at))) {
const localStorageNachweis = localStorage.getItem("geg-nachweis-wohnen.ausweis");
if (localStorageNachweis) {
nachweis = JSON.parse(localStorageNachweis)
nachweis.nachweistyp = nachweistyp;
}
if (Object.keys(aufnahme).length === 0) {
const localStorageAufnahme = localStorage.getItem(
"geg-nachweis-wohnen.aufnahme"
);
const localStorageAufnahme = localStorage.getItem("geg-nachweis-wohnen.aufnahme");
if (localStorageAufnahme) {
aufnahme = JSON.parse(localStorageAufnahme);
}
aufnahme = JSON.parse(localStorageAufnahme)
}
if (Object.keys(objekt).length === 0) {
const localStorageObjekt = localStorage.getItem(
"geg-nachweis-wohnen.objekt"
);
const localStorageObjekt = localStorage.getItem("geg-nachweis-wohnen.objekt");
if (localStorageObjekt) {
objekt = JSON.parse(localStorageObjekt);
}
objekt = JSON.parse(localStorageObjekt)
}
if (Object.keys(bilder).length === 0) {
const localStorageBilder = localStorage.getItem(
"geg-nachweis-wohnen.bilder"
);
const localStorageBilder = localStorage.getItem("geg-nachweis-wohnen.bilder");
if (localStorageBilder) {
bilder = JSON.parse(localStorageBilder);
}
bilder = JSON.parse(localStorageBilder)
}
if (Object.keys(unterlagen).length === 0) {
const localStorageUnterlagen = localStorage.getItem(
"geg-nachweis-wohnen.unterlagen"
);
const localStorageUnterlagen = localStorage.getItem("geg-nachweis-wohnen.unterlagen");
if (localStorageUnterlagen) {
unterlagen = JSON.parse(localStorageUnterlagen);
unterlagen = JSON.parse(localStorageUnterlagen)
}
}
@@ -110,6 +96,7 @@
{ausweisart}
{anliegen}
steps={["Gebäudedaten", "Kundendaten", "Anfragebestätigung"]}
ausweistyp={nachweistyp}
/>
</div>
@@ -121,7 +108,7 @@
<GEGAusweisart
bind:objekt
bind:aufnahme
bind:ausweis={nachweis}
bind:nachweis
{ausweisart}
/>
</Bereich>

View File

@@ -1,90 +1,87 @@
---
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
import { AufnahmeClient, BildClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient } from "#components/Ausweis/types";
import { createCaller } from "src/astro-typesafe-api-caller";
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
import { validateAccessTokenServer } from "#server/lib/validateAccessToken.js";
import GEGNachweisWohnenModule from "#modules/angebot-anfragen/GEGNachweisWohnenModule.svelte";
import { getGEGNachweisWohnen, getAufnahme, getObjekt, getBilder } from "#lib/server/db";
import { Enums, Aufnahme, Objekt, Bild, GEGNachweisWohnen, Unterlage } from "#lib/server/prisma";
import { getCurrentUser } from "#lib/server/user";
import { getUnterlagen } from "#lib/server/db";
const uid = Astro.url.searchParams.get("uid");
let nachweis: GEGNachweisWohnenClient = {} as GEGNachweisWohnenClient;
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
let objekt: ObjektClient = {} as ObjektClient;
let bilder: BildClient[] = []
let unterlagen: UnterlageClient[] = []
const id = Astro.url.searchParams.get("id");
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
let ausweistyp = Astro.url.searchParams.get("ausweistyp") as Enums.AusweisTyp || Enums.AusweisTyp.Standard;
const valid = validateAccessTokenServer(Astro);
let nachweis: GEGNachweisWohnen = {} as GEGNachweisWohnen;
let aufnahme: Aufnahme = {} as Aufnahme;
let objekt: Objekt = {} as Objekt;
let bilder: Bild[] = []
let unterlagen: Unterlage[] = []
const caller = createCaller(Astro);
const user = await getCurrentUser(Astro)
if (uid) {
if (!valid) {
if (id) {
if (!user) {
return Astro.redirect(
`/auth/login?redirect=${Astro.url.toString()}`
);
}
try {
nachweis = await caller["geg-nachweis-wohnen"]._uid.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
uid
}
});
nachweis = await getGEGNachweisWohnen(id) as GEGNachweisWohnen
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
uid: nachweis.uid_aufnahme
}
})
objekt = await caller.objekt._uid.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
uid: nachweis.uid_objekt
}
})
bilder = await caller.aufnahme._uid.bilder.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
uid: nachweis.uid_aufnahme
}
})
unterlagen = await caller.aufnahme._uid.unterlagen.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
uid: nachweis.uid_aufnahme
}
})
if (!nachweis) {
if (!nachweis || nachweis.benutzer_id !== user.id) {
// Der Ausweis scheint nicht zu existieren.
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
// Wir leiten auf die generische Ausweisseite ohne ID weiter.
return Astro.redirect(
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
} catch(e) {
aufnahme = await getAufnahme(nachweis.aufnahme_id) as Aufnahme
if (!aufnahme) {
// Die Aufnahme existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
return Astro.redirect(
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
if (!objekt) {
// Das Objekt existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
bilder = await getBilder(aufnahme.id);
unterlagen = await getUnterlagen(aufnahme.id);
} else if (aufnahme_id) {
if (!user) {
return Astro.redirect(
`/auth/login?redirect=${Astro.url.toString()}`
);
}
aufnahme = await getAufnahme(nachweis.aufnahme_id) as Aufnahme
if (!aufnahme) {
// Die Aufnahme existiert wohl nicht.
return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
if (!objekt) {
// Das Objekt existiert nicht.
return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
}
---
<AusweisLayout title="GEG Nachweis Wohnen anfragen">
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} />
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} {id} />
</AusweisLayout>

View File

@@ -1,4 +1,6 @@
import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
import { generatePrefixedId } from "#lib/db.js";
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
import { prisma } from "#lib/server/prisma.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
nachweis: GEGNachweisGewerbeSchema.omit({
id: true,
benutzer_id: true,
uid: true,
aufnahme_id: true,
created_at: true,
updated_at: true,
geg_einpreisung_id: true,
rechnung_id: true
}),
uid_aufnahme: UUidWithPrefix
aufnahme_id: UUidWithPrefix
}),
output: z.object({
uid: UUidWithPrefix,
objekt_uid: UUidWithPrefix,
aufnahme_uid: UUidWithPrefix,
id: UUidWithPrefix,
objekt_id: UUidWithPrefix,
aufnahme_id: UUidWithPrefix,
}),
headers: authorizationHeaders,
middleware: authorizationMiddleware,
async fetch(input, ctx, user) {
const aufnahme = await prisma.aufnahme.findUnique({
where: {
uid: input.uid_aufnahme
id: input.aufnahme_id
}
})
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
})
}
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisGewerbe)
const nachweis = await prisma.gEGNachweisGewerbe.create({
data: {
id,
...input.nachweis,
benutzer: {
connect: {
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
}
},
select: {
uid: true,
id: true,
aufnahme: {
select: {
uid: true,
id: true,
objekt: {
select: {
uid: true,
id: true,
},
},
},
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
});
return {
uid: nachweis.uid,
objekt_uid: nachweis.aufnahme.objekt.uid,
aufnahme_uid: nachweis.aufnahme.uid,
id: nachweis.id,
objekt_id: nachweis.aufnahme.objekt.id,
aufnahme_id: nachweis.aufnahme.id,
};
},
});
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
headers: authorizationHeaders,
middleware: authorizationMiddleware,
async fetch(input, context, user) {
const { uid } = context.params;
const { id } = context.params;
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
where: {
uid,
id,
},
include: {
benutzer: true,
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
include: {
benutzer: {
select: {
uid: true,
id: true,
},
},
},

View File

@@ -1,13 +1,15 @@
import { GEGNachweisWohnenClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
import { generatePrefixedId } from "#lib/db.js";
import { exclude } from "#lib/exclude.js";
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
import { GEGNachweisWohnenSchema, prisma } from "#lib/server/prisma";
import { prisma } from "#lib/server/prisma.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
import { GEGNachweisWohnenSchema } from "src/generated/zod/gegnachweiswohnen.js";
import { z } from "zod";
export const PATCH = defineApiRoute({
input: GEGNachweisWohnenSchema.omit({
uid: true,
id: true,
benutzer_id: true,
geg_einpreisung_id: true,
@@ -21,7 +23,7 @@ export const PATCH = defineApiRoute({
async fetch(input, ctx, user) {
const objekt = await prisma.gEGNachweisWohnen.findUnique({
where: {
uid: ctx.params.uid,
id: ctx.params.id,
benutzer: {
id: user.id
}
@@ -37,7 +39,7 @@ export const PATCH = defineApiRoute({
await prisma.gEGNachweisWohnen.update({
where: {
uid: ctx.params.uid
id: ctx.params.id
},
data: input
})
@@ -51,9 +53,9 @@ export const DELETE = defineApiRoute({
headers: authorizationHeaders,
middleware: authorizationMiddleware,
async fetch(input, ctx, user) {
const { uid } = ctx.params;
const { id } = ctx.params;
if (!UUidWithPrefix.safeParse(uid).success) {
if (!UUidWithPrefix.safeParse(id).success) {
throw new APIError({
code: "BAD_REQUEST",
message: "UID konnte nicht verifiziert werden."
@@ -64,7 +66,7 @@ export const DELETE = defineApiRoute({
// Dieser MUSS mit dem Nutzer verknüpft sein.
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
where: {
uid,
id,
}
});
@@ -111,10 +113,13 @@ export const DELETE = defineApiRoute({
}
})
const event_id =
// Wir erstellen ein Event, dass der Nachweis storniert wurde
// Dann können wir das in der Historie anzeigen
await prisma.event.create({
data: {
id: generatePrefixedId(6, VALID_UUID_PREFIXES.Event),
title: "Nachweis storniert",
description: ((user.rolle === "ADMIN") && (nachweis.benutzer_id !== user.id)) ? "Nachweis wurde von einem Administrator storniert." : "Nachweis wurde vom Besitzer storniert.",
benutzer: {
@@ -150,9 +155,9 @@ export const GET = defineApiRoute({
}
},
output: GEGNachweisWohnenSchema.merge(z.object({
uid_aufnahme: UUidWithPrefix,
uid_objekt: UUidWithPrefix,
uid_benutzer: UUidWithPrefix.optional()
aufnahme_id: UUidWithPrefix,
objekt_id: UUidWithPrefix,
benutzer_id: UUidWithPrefix.optional()
})).omit({
id: true,
aufnahme_id: true,
@@ -160,32 +165,32 @@ export const GET = defineApiRoute({
}),
middleware: authorizationMiddleware,
async fetch(input, context, user) {
const { uid } = context.params;
const { id } = context.params;
if (!uid) {
if (!id) {
throw new APIError({
code: "BAD_REQUEST",
message: "Missing uid in request params"
})
}
const Nachweis = await prisma.gEGNachweisWohnen.findUnique({
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
where: {
uid,
id,
benutzer_id: user.id
},
include: {
benutzer: {
select: {
uid: true
id: true
}
},
aufnahme: {
select: {
uid: true,
id: true,
objekt: {
select: {
uid: true
id: true
}
}
}
@@ -193,7 +198,7 @@ export const GET = defineApiRoute({
}
});
if (!Nachweis) {
if (!nachweis) {
// Falls wir den Nachweis nicht finden können, werfen wir einen Fehler
throw new APIError({
code: "NOT_FOUND",
@@ -202,10 +207,10 @@ export const GET = defineApiRoute({
}
return {
uid_aufnahme: Nachweis.aufnahme.uid,
uid_objekt: Nachweis.aufnahme.objekt.uid,
uid_benutzer: Nachweis.benutzer?.uid,
...exclude(Nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
aufnahme_id: nachweis.aufnahme.id,
objekt_id: nachweis.aufnahme.objekt.id,
benutzer_id: nachweis.benutzer?.id,
...exclude(nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
}
},
});

View File

@@ -1,4 +1,6 @@
import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
import { generatePrefixedId } from "#lib/db.js";
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
import { prisma } from "#lib/server/prisma.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
nachweis: GEGNachweisWohnenSchema.omit({
id: true,
benutzer_id: true,
uid: true,
aufnahme_id: true,
updated_at: true,
created_at: true,
geg_einpreisung_id: true,
rechnung_id: true
}),
uid_aufnahme: UUidWithPrefix
aufnahme_id: UUidWithPrefix
}),
output: z.object({
uid: UUidWithPrefix,
objekt_uid: UUidWithPrefix,
aufnahme_uid: UUidWithPrefix,
id: UUidWithPrefix,
objekt_id: UUidWithPrefix,
aufnahme_id: UUidWithPrefix,
}),
headers: authorizationHeaders,
middleware: authorizationMiddleware,
async fetch(input, ctx, user) {
const aufnahme = await prisma.aufnahme.findUnique({
where: {
uid: input.uid_aufnahme
id: input.aufnahme_id
}
})
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
})
}
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisWohnen)
const nachweis = await prisma.gEGNachweisWohnen.create({
data: {
id,
...input.nachweis,
benutzer: {
connect: {
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
}
},
select: {
uid: true,
id: true,
aufnahme: {
select: {
uid: true,
id: true,
objekt: {
select: {
uid: true,
id: true,
},
},
},
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
});
return {
uid: nachweis.uid,
objekt_uid: nachweis.aufnahme.objekt.uid,
aufnahme_uid: nachweis.aufnahme.uid,
id: nachweis.id,
objekt_id: nachweis.aufnahme.objekt.id,
aufnahme_id: nachweis.aufnahme.id,
};
},
});
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
headers: authorizationHeaders,
middleware: authorizationMiddleware,
async fetch(input, context, user) {
const { uid } = context.params;
const { id } = context.params;
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
where: {
uid,
id,
},
include: {
benutzer: true,
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
include: {
benutzer: {
select: {
uid: true,
id: true,
},
},
},

View File

@@ -1,8 +1,10 @@
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
import { generatePrefixedId } from "#lib/db.js";
import { omit } from "#lib/helpers.js";
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
import { Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
import { GEGEinpreisungSchema } from "src/generated/zod/gegeinpreisung.js";
import { z } from "zod";
@@ -21,7 +23,7 @@ export const PUT = defineApiRoute({
const ausweisart = getAusweisartFromId(input.nachweis_id);
let einpreisung;
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe | BedarfsausweisGewerbe;
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
nachweis = await prisma.gEGNachweisWohnen.findUnique({
where: {
@@ -55,9 +57,12 @@ export const PUT = defineApiRoute({
})
}
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGEinpreisung)
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
einpreisung = await prisma.gEGEinpreisung.create({
data: {
id,
...omit(input, ["nachweis_id"]),
status: Enums.Einpreisungsstatus.open,
benutzer: {
@@ -75,6 +80,7 @@ export const PUT = defineApiRoute({
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
einpreisung = await prisma.gEGEinpreisung.create({
data: {
id,
...omit(input, ["nachweis_id"]),
status: Enums.Einpreisungsstatus.open,
benutzer: {
@@ -92,6 +98,7 @@ export const PUT = defineApiRoute({
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
einpreisung = await prisma.gEGEinpreisung.create({
data: {
id,
...omit(input, ["nachweis_id"]),
status: Enums.Einpreisungsstatus.open,
benutzer: {
@@ -111,7 +118,7 @@ export const PUT = defineApiRoute({
await sendGEGAnforderungsMail(nachweis, user)
return {
id: einpreisung.id
id
}
},
})

View File

@@ -1,10 +1,8 @@
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import { BenutzerClient, getAusweisartFromId, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
import { pdfDatenblattVerbrauchsausweisGewerbe } from "#lib/pdf/pdfDatenblattVerbrauchsausweisGewerbe.js";
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
import { Enums } from "#lib/client/prisma.js";
import { Aufnahme, Benutzer, Bild, Enums, Objekt, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "#lib/client/prisma.js";
import { APIRoute } from "astro";
import { createCaller } from "src/astro-typesafe-api-caller.js";
import { getS3File } from "#lib/s3.js";
@@ -20,11 +18,11 @@ export const GET: APIRoute = async (Astro) => {
const ausweisart = getAusweisartFromId(ausweis_id)
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | null = null;
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
let objekt: ObjektClient = {} as ObjektClient;
let user: BenutzerClient = {} as BenutzerClient;
let bilder: UploadedGebaeudeBild[] = []
let ausweis: VerbrauchsausweisWohnen | VerbrauchsausweisGewerbe | null = null;
let aufnahme: Aufnahme = {} as Aufnahme;
let objekt: Objekt = {} as Objekt;
let user: Benutzer = {} as Benutzer;
let bilder: Bild[] = []
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)