From 5f8d30a5a309b5329bca48e19624d2583323ee30 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 17 Feb 2025 11:24:07 +0700 Subject: [PATCH 1/3] Fehler gefixt die beim Testen aufgefallen sind. --- src/astro-typesafe-api-caller.ts | 2 +- src/components/Ausweis/Ausweisart.svelte | 2 +- src/components/Ausweis/StromVerbrauch.svelte | 16 ----- src/components/Ausweis/Verbrauch.svelte | 23 ------- .../RawNotificationWrapper.svelte | 6 +- src/components/TagInput.svelte | 2 +- .../Verbrauchsausweis/audits/KlimaFaktoren.ts | 29 ++++++--- .../Verbrauchsausweis/audits/LeerStand.ts | 2 +- .../audits/VerbrauchAbweichung.ts | 4 +- src/layouts/AusweisLayoutDaten.astro | 33 ++++++---- .../Auth/PasswortVergessenModule.svelte | 4 +- .../Auth/PasswortZuruecksetzenModule.svelte | 7 +- src/modules/Dashboard/DashboardModule.svelte | 3 - src/modules/RegisterModule.svelte | 17 ++++- .../VerbrauchsausweisWohnenModule.svelte | 65 ++++++++++++++----- src/pages/api/user/index.ts | 2 +- .../index.astro | 2 +- 17 files changed, 116 insertions(+), 103 deletions(-) diff --git a/src/astro-typesafe-api-caller.ts b/src/astro-typesafe-api-caller.ts index edb1fa17..34400f59 100644 --- a/src/astro-typesafe-api-caller.ts +++ b/src/astro-typesafe-api-caller.ts @@ -5,12 +5,12 @@ export const createCaller = createCallerFactory({ "postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"), "aufnahme/[uid]": await import("../src/pages/api/aufnahme/[uid].ts"), "aufnahme": await import("../src/pages/api/aufnahme/index.ts"), + "bilder/[uid]": await import("../src/pages/api/bilder/[uid].ts"), "auth/access-token": await import("../src/pages/api/auth/access-token.ts"), "auth/forgot-password": await import("../src/pages/api/auth/forgot-password.ts"), "auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"), "bedarfsausweis-wohnen/[uid]": await import("../src/pages/api/bedarfsausweis-wohnen/[uid].ts"), "bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"), - "bilder/[uid]": await import("../src/pages/api/bilder/[uid].ts"), "objekt": await import("../src/pages/api/objekt/index.ts"), "rechnung": await import("../src/pages/api/rechnung/index.ts"), "ticket": await import("../src/pages/api/ticket/index.ts"), diff --git a/src/components/Ausweis/Ausweisart.svelte b/src/components/Ausweis/Ausweisart.svelte index 0e3049ec..3426cde3 100644 --- a/src/components/Ausweis/Ausweisart.svelte +++ b/src/components/Ausweis/Ausweisart.svelte @@ -5,7 +5,7 @@ //import Label from "#components/Label.svelte"; import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js"; - import { addNotification, deleteNotification } from "@ibcornelsen/ui"; + import { addNotification, deleteNotification } from "#components/Notifications/shared.js"; import TagInput from "../TagInput.svelte"; import { Enums } from "@ibcornelsen/database/client"; import { diff --git a/src/components/Ausweis/StromVerbrauch.svelte b/src/components/Ausweis/StromVerbrauch.svelte index 9bed4411..a59deeae 100644 --- a/src/components/Ausweis/StromVerbrauch.svelte +++ b/src/components/Ausweis/StromVerbrauch.svelte @@ -86,22 +86,6 @@ } } - $: { - console.log(month, year); - - if ((availableDates.filter(date => date.month === month && date.year === year).length === 0) && typeof month === "number" && typeof year === "number") { - addNotification({ - message: "Monat nicht verfügbar.", - subtext: "Der ausgewählte Monat ist in diesem Jahr nicht verfügbar, bitte wählen sie einen neuen Start Monat.", - dismissable: true, - type: "warning", - timeout: 0, - uid: "monat_nicht_verfuegbar", - selector: "select[name='energieverbrauch_zeitraum_monat']" - }) - } - } - $: abweichung = auditVerbrauchAbweichung(ausweis, aufnahme); diff --git a/src/components/Ausweis/Verbrauch.svelte b/src/components/Ausweis/Verbrauch.svelte index 2cfb527f..3c8f7da9 100644 --- a/src/components/Ausweis/Verbrauch.svelte +++ b/src/components/Ausweis/Verbrauch.svelte @@ -78,29 +78,6 @@ } } - $: { - console.log(month, year); - - if ( - availableDates.filter( - (date) => date.month === month && date.year === year - ).length === 0 && - typeof month === "number" && - typeof year === "number" - ) { - addNotification({ - message: "Monat nicht verfügbar.", - subtext: - "Der ausgewählte Monat ist in diesem Jahr nicht verfügbar, bitte wählen sie einen neuen Start Monat.", - dismissable: true, - type: "warning", - timeout: 0, - uid: "monat_nicht_verfuegbar", - selector: "select[name='energieverbrauch_zeitraum_monat']", - }); - } - } - $: abweichung = auditVerbrauchAbweichung(ausweis, aufnahme); diff --git a/src/components/Notifications/RawNotificationWrapper.svelte b/src/components/Notifications/RawNotificationWrapper.svelte index 3ced0a61..364200d2 100644 --- a/src/components/Notifications/RawNotificationWrapper.svelte +++ b/src/components/Notifications/RawNotificationWrapper.svelte @@ -1,5 +1,7 @@ - + + +
\ No newline at end of file diff --git a/src/components/TagInput.svelte b/src/components/TagInput.svelte index 0a2b3146..ed7b818b 100644 --- a/src/components/TagInput.svelte +++ b/src/components/TagInput.svelte @@ -75,7 +75,7 @@ on:focusin={onFocusIn} on:focusout={onFocusOut} on:blur={() => { - if (tag.toString().length >= minlength && tag.toString().length < maxlength) { + if (tag.toString().length >= minlength && tag.toString().length <= maxlength) { addTag(tag) tag = "" } diff --git a/src/components/Verbrauchsausweis/audits/KlimaFaktoren.ts b/src/components/Verbrauchsausweis/audits/KlimaFaktoren.ts index acbdecc2..f5c2e108 100644 --- a/src/components/Verbrauchsausweis/audits/KlimaFaktoren.ts +++ b/src/components/Verbrauchsausweis/audits/KlimaFaktoren.ts @@ -1,20 +1,29 @@ -import { ObjektClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js"; +import { + ObjektClient, + VerbrauchsausweisWohnenClient, +} from "#components/Ausweis/types.js"; import { AuditType, hidden } from "./hidden.js"; import { getKlimafaktoren } from "#lib/Klimafaktoren.js"; -export async function auditKlimaFaktoren(ausweis: VerbrauchsausweisWohnenClient, gebaeude: ObjektClient): Promise { +export async function auditKlimaFaktoren( + ausweis: VerbrauchsausweisWohnenClient, + gebaeude: ObjektClient +): Promise { if (hidden.has(AuditType.KLIMA_FAKTOREN)) { return false; } - if (ausweis.startdatum && gebaeude.plz && ausweis.verbrauch_1) { - try { - const response = await getKlimafaktoren(ausweis.startdatum, gebaeude.plz); - return true; // Alle Klimfaktoren konnten abgefragt werden. - } catch (e) { - return true; + if (ausweis.startdatum && gebaeude.plz && ausweis.verbrauch_1) { + try { + const response = await getKlimafaktoren( + ausweis.startdatum, + gebaeude.plz + ); + return true; // Alle Klimfaktoren konnten abgefragt werden. + } catch (e) { + return true; + } } - } - return false; + return false; } diff --git a/src/components/Verbrauchsausweis/audits/LeerStand.ts b/src/components/Verbrauchsausweis/audits/LeerStand.ts index 667493ca..ac7a9f8c 100644 --- a/src/components/Verbrauchsausweis/audits/LeerStand.ts +++ b/src/components/Verbrauchsausweis/audits/LeerStand.ts @@ -2,7 +2,7 @@ import { AufnahmeClient } from "#components/Ausweis/types.js"; import { AuditType, hidden } from "./hidden.js"; export function auditLeerStand(gebaeude: AufnahmeClient): boolean { - if (gebaeude.leerstand && !hidden.has(AuditType.LEER_STAND)) { + if (gebaeude.leerstand) { return ( (gebaeude.leerstand > 30) ); diff --git a/src/components/Verbrauchsausweis/audits/VerbrauchAbweichung.ts b/src/components/Verbrauchsausweis/audits/VerbrauchAbweichung.ts index 4a0b631f..7ee538f3 100644 --- a/src/components/Verbrauchsausweis/audits/VerbrauchAbweichung.ts +++ b/src/components/Verbrauchsausweis/audits/VerbrauchAbweichung.ts @@ -1,7 +1,7 @@ -import { AufnahmeClient, ObjektClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js"; +import { AufnahmeClient, ObjektClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js"; import { AuditType, hidden } from "./hidden.js"; -export function auditVerbrauchAbweichung(ausweis: VerbrauchsausweisWohnenClient, aufnahme: AufnahmeClient): number[] { +export function auditVerbrauchAbweichung(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient, aufnahme: AufnahmeClient): number[] { if (aufnahme.leerstand && (aufnahme.leerstand > 0)) { return []; } diff --git a/src/layouts/AusweisLayoutDaten.astro b/src/layouts/AusweisLayoutDaten.astro index bf25997f..0d7eec96 100644 --- a/src/layouts/AusweisLayoutDaten.astro +++ b/src/layouts/AusweisLayoutDaten.astro @@ -16,21 +16,25 @@ const { title } = Astro.props;

Willkommen zurück, {user.vorname}!

diff --git a/src/modules/RegisterModule.svelte b/src/modules/RegisterModule.svelte index 73564763..223ff52c 100644 --- a/src/modules/RegisterModule.svelte +++ b/src/modules/RegisterModule.svelte @@ -1,8 +1,10 @@
Speichern - +
diff --git a/src/modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte b/src/modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte index 3bdb5dec..c3dd7bc5 100644 --- a/src/modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte +++ b/src/modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte @@ -239,7 +239,7 @@ lg:grid-cols-2 lg:gap-x-6
- + From 9951179b2a9a8e7332e394af7effaa118b64311b Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 17 Feb 2025 20:46:27 +1100 Subject: [PATCH 3/3] Bestellen auf Rechnung --- build.sh | 2 +- src/astro-typesafe-api-caller.ts | 2 +- src/components/Ausweis/Verbrauch.svelte | 6 +- src/components/AusweisPruefenBox.svelte | 30 ++++---- src/components/AusweisPruefenTooltip.svelte | 4 ++ src/layouts/UserLayout.astro | 14 +--- .../DashboardAusweisePruefenModule.svelte | 25 +++++-- src/modules/KaufabschlussModule.svelte | 11 ++- src/modules/KundendatenModule.svelte | 18 +++-- src/modules/PaymentSuccessModule.svelte | 13 ++++ src/pages/api/rechnung/index.ts | 6 +- src/pages/bilder/[uid].webp.ts | 69 ++++++++++++------- src/pages/dashboard/ausweise-pruefen.astro | 59 ++++++++++++++++ src/pages/dashboard/index.astro | 2 +- src/pages/kundendaten.astro | 2 +- src/pages/payment/success.astro | 15 ++-- 16 files changed, 198 insertions(+), 80 deletions(-) create mode 100644 src/modules/PaymentSuccessModule.svelte create mode 100644 src/pages/dashboard/ausweise-pruefen.astro diff --git a/build.sh b/build.sh index 55a6df4c..f261d1a5 100644 --- a/build.sh +++ b/build.sh @@ -39,7 +39,7 @@ bun link @ibcornelsen/database PERSISTENT_DIR="${HOME}/persistent/${APP_NAME}"; mkdir -p $PERSISTENT_DIR; -# TODO: Wir legen hier die .env Datei an, die die SSL Zertifikate enthält. +# Wir legen hier die .env Datei an, die die SSL Zertifikate enthält. rm -f ~/$APP_NAME/.env; touch ~/$APP_NAME/.env; echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; diff --git a/src/astro-typesafe-api-caller.ts b/src/astro-typesafe-api-caller.ts index 34400f59..1724bc14 100644 --- a/src/astro-typesafe-api-caller.ts +++ b/src/astro-typesafe-api-caller.ts @@ -5,10 +5,10 @@ export const createCaller = createCallerFactory({ "postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"), "aufnahme/[uid]": await import("../src/pages/api/aufnahme/[uid].ts"), "aufnahme": await import("../src/pages/api/aufnahme/index.ts"), - "bilder/[uid]": await import("../src/pages/api/bilder/[uid].ts"), "auth/access-token": await import("../src/pages/api/auth/access-token.ts"), "auth/forgot-password": await import("../src/pages/api/auth/forgot-password.ts"), "auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"), + "bilder/[uid]": await import("../src/pages/api/bilder/[uid].ts"), "bedarfsausweis-wohnen/[uid]": await import("../src/pages/api/bedarfsausweis-wohnen/[uid].ts"), "bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"), "objekt": await import("../src/pages/api/objekt/index.ts"), diff --git a/src/components/Ausweis/Verbrauch.svelte b/src/components/Ausweis/Verbrauch.svelte index 3c8f7da9..3a53f0ed 100644 --- a/src/components/Ausweis/Verbrauch.svelte +++ b/src/components/Ausweis/Verbrauch.svelte @@ -11,7 +11,6 @@ ObjektClient, VerbrauchsausweisWohnenClient, } from "./types.js"; - import { addNotification } from "#components/Notifications/shared.js"; export let objekt: ObjektClient; export let aufnahme: AufnahmeClient; @@ -20,6 +19,7 @@ // Wir dürfen bis zu 4.5 Jahre alte Klimafaktoren benutzen, also nehmen wir alle Monate seitdem und generieren daraus die Auswahl. // Allerdings müssen wir auch berücksichtigen, dass wir drei folgende Jahre brauchen, also // kann der Nutzer nur 36 + 18 Monate zurückgehen. + let availableDates: { year: number; month: number; @@ -62,8 +62,8 @@ fuelMap[fuel[0]].push(fuel[1]); } - let month = ausweis.startdatum?.getMonth(); - let year = ausweis.startdatum?.getFullYear(); + let month = moment(ausweis.startdatum).month(); + let year = moment(ausweis.startdatum).year(); $: { if (typeof month === "number" && typeof year === "number") { diff --git a/src/components/AusweisPruefenBox.svelte b/src/components/AusweisPruefenBox.svelte index 5107b473..c272f04c 100644 --- a/src/components/AusweisPruefenBox.svelte +++ b/src/components/AusweisPruefenBox.svelte @@ -2,27 +2,31 @@ import { endEnergieVerbrauchVerbrauchsausweis_2016 } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.js"; import moment from "moment"; import { + AufnahmeClient, + getAusweisartFromUUID, + ObjektClient, + UploadedGebaeudeBild, VerbrauchsausweisWohnenClient, } from "./Ausweis/types.js"; import AusweisPruefenTooltip from "./AusweisPruefenTooltip.svelte"; import { addNotification } from "./NotificationProvider/shared.js"; import { CheckCircled, CrossCircled, Image } from "radix-svelte-icons"; import ChevronDown from "radix-svelte-icons/src/lib/icons/ChevronDown.svelte"; + import { Event } from "@ibcornelsen/database/client"; export let ausweis: VerbrauchsausweisWohnenClient; + export let aufnahme: AufnahmeClient; + export let objekt: ObjektClient; + export let bilder: UploadedGebaeudeBild[] + export let events: Event[] export let calculations: Awaited< ReturnType >; - console.log(ausweis); - - const aufnahme = ausweis.aufnahme - const ausweisArt = "VA"; // TODO: Das ist ein Platzhalter, hier muss die Ausweisart aus dem Ausweisobjekt kommen - - const images = ausweis.aufnahme.objekt.gebaeude_bilder; + const ausweisArt = getAusweisartFromUUID(ausweis.uid) // TODO: Das ist ein Platzhalter, hier muss die Ausweisart aus dem Ausweisobjekt kommen let verbrauchWWGesamt_1 = ""; let verbrauchWWGesamt_2 = ""; @@ -145,13 +149,13 @@ ) { if (aufnahme.solarsystem_warmwasser) { // Wenn Warmwasser enthalten und Anteil bekannt und Solarsystem - verbrauchWWGesamt_1 = `${calculations?.energieVerbrauchGesamt_1} kWh x ${ausweis.anteil_warmwasser_1 / 100} x 0.6`; - verbrauchWWGesamt_2 = `${calculations?.energieVerbrauchGesamt_2} kWh x ${ausweis.anteil_warmwasser_2 / 100} x 0.6`; + verbrauchWWGesamt_1 = `${calculations?.energieVerbrauchGesamt_1} kWh x ${(ausweis.anteil_warmwasser_1 || 0) / 100} x 0.6`; + verbrauchWWGesamt_2 = `${calculations?.energieVerbrauchGesamt_2} kWh x ${(ausweis.anteil_warmwasser_2 || 0) / 100} x 0.6`; solarsystemWarmwasser = "Solarsystem Warmwasser"; } else { // Wenn Warmwasser enthalten und Anteil bekannt und **kein** Solarsystem - verbrauchWWGesamt_1 = `${calculations?.energieVerbrauchGesamt_1} kWh x ${ausweis.anteil_warmwasser_1 / 100} x 0.6` - verbrauchWWGesamt_2 = `${calculations?.energieVerbrauchGesamt_2} kWh x ${ausweis.anteil_warmwasser_2 / 100} x 0.6` + verbrauchWWGesamt_1 = `${calculations?.energieVerbrauchGesamt_1} kWh x ${(ausweis.anteil_warmwasser_1 || 0) / 100} x 0.6` + verbrauchWWGesamt_2 = `${calculations?.energieVerbrauchGesamt_2} kWh x ${(ausweis.anteil_warmwasser_2 || 0) / 100} x 0.6` solarsystemWarmwasser = "kein Solarsystem Warmwasser"; } } else { @@ -674,13 +678,13 @@