Ausweistyp

This commit is contained in:
Moritz Utcke
2025-03-24 16:39:39 -03:00
parent a9c2b5c173
commit 84a3a2dd39
20 changed files with 122 additions and 64 deletions

View File

@@ -25,7 +25,6 @@ export const PUT = defineApiRoute({
.object({
ausweisart: z.nativeEnum(Enums.Ausweisart),
ausweis_uid: UUidWithPrefix,
ausweistyp: z.nativeEnum(Enums.AusweisTyp)
})
.merge(
RechnungSchema.omit({
@@ -50,13 +49,7 @@ export const PUT = defineApiRoute({
// Wir erstellen eine Mollie Payment Referenz und eine neue Rechnung in unserer Datenbank, daraufhin geben
// wir eine Checkout URL zurück auf die der Nutzer weitergeleitet werden kann.
const { ausweis_uid, ausweisart, bezahlmethode, services, ausweistyp } = input;
let betrag = PRICES[ausweisart][ausweistyp]
const servicePriceList = SERVICES[ausweisart]
for (const service of input.services) {
betrag += servicePriceList[service]
}
const { ausweis_uid, ausweisart, bezahlmethode, services } = input;
const adapter = getPrismaAusweisAdapter(ausweis_uid);
@@ -87,6 +80,13 @@ export const PUT = defineApiRoute({
});
}
let betrag = PRICES[ausweisart][ausweis.ausweistyp]
const servicePriceList = SERVICES[ausweisart]
for (const service of input.services) {
betrag += servicePriceList[service]
}
// Wir erstellen eine neue Rechnung in unserer Datenbank.
let rechnung: Rechnung | null = null;
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
@@ -102,7 +102,6 @@ export const PUT = defineApiRoute({
}
},
services,
ausweistyp
}
});
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
@@ -118,7 +117,6 @@ export const PUT = defineApiRoute({
}
},
services,
ausweistyp
}
});
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
@@ -134,7 +132,6 @@ export const PUT = defineApiRoute({
}
},
services,
ausweistyp
}
});
}

View File

@@ -9,7 +9,7 @@ import { Enums } from "#lib/server/prisma";
const uid = Astro.url.searchParams.get("uid");
const uid_aufnahme = Astro.url.searchParams.get("aufnahme")
const ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard;
let ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard;
let ausweis: VerbrauchsausweisWohnenClient = {} as VerbrauchsausweisWohnenClient;
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
@@ -37,6 +37,8 @@ if (uid) {
}
});
ausweistyp = ausweis.ausweistyp
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`

View File

@@ -16,16 +16,15 @@ if (!params.has("ausweis") || !params.has("aufnahme") || !params.has("objekt") |
return Astro.redirect("/404")
}
let ausweis, aufnahme, objekt, ausweisart, bilder, ausweistyp;
let ausweis, aufnahme, objekt, ausweisart, bilder;
try {
ausweis = JSON.parse(params.get("ausweis") || "")
aufnahme = JSON.parse(params.get("aufnahme") || "")
objekt = JSON.parse(params.get("objekt") || "")
ausweisart = JSON.parse(params.get("ausweisart") || "") as Enums.Ausweisart;
bilder = JSON.parse(params.get("bilder") || "");
ausweistyp = JSON.parse(params.get("ausweistyp") || "") as Enums.AusweisTyp;
if (!ausweisart || !Object.keys(Enums.Ausweisart).includes(ausweisart) || !ausweistyp || !Object.keys(Enums.AusweisTyp).includes(ausweistyp)) {
if (!ausweisart || !Object.keys(Enums.Ausweisart).includes(ausweisart)) {
throw new Error()
}
} catch(e){
@@ -35,6 +34,6 @@ try {
---
<AusweisLayout title="Kundendaten Aufnehmen - IBCornelsen">
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} {bilder} {ausweisart} {ausweistyp} unterlagen={[]} aktiveBezahlmethode={Enums.Bezahlmethoden.paypal} client:only="svelte" ></KundendatenModule>
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} {bilder} {ausweisart} unterlagen={[]} aktiveBezahlmethode={Enums.Bezahlmethoden.paypal} client:only="svelte" ></KundendatenModule>
</AusweisLayout>