Merge branch 'staging' into dev

This commit is contained in:
Moritz Utcke
2025-09-14 14:03:42 -04:00
8 changed files with 43 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ export const createCaller = createCallerFactory({
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"), "klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"), "postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
"unterlage": await import("../src/pages/api/unterlage.ts"), "unterlage": await import("../src/pages/api/unterlage.ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"), "admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"),
"admin/bedarfsausweis-ausstellen": await import("../src/pages/api/admin/bedarfsausweis-ausstellen.ts"), "admin/bedarfsausweis-ausstellen": await import("../src/pages/api/admin/bedarfsausweis-ausstellen.ts"),
"admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"), "admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"),
@@ -14,32 +13,33 @@ export const createCaller = createCallerFactory({
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"), "admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"), "admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
"ausweise": await import("../src/pages/api/ausweise/index.ts"), "ausweise": await import("../src/pages/api/ausweise/index.ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"auth/access-token": await import("../src/pages/api/auth/access-token.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/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"), "auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
"bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].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/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"), "bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/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"),
"bilder/[id]": await import("../src/pages/api/bilder/[id].ts"), "bilder/[id]": await import("../src/pages/api/bilder/[id].ts"),
"geg-nachweis-gewerbe/[id]": await import("../src/pages/api/geg-nachweis-gewerbe/[id].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"), "geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"),
"geg-nachweis-wohnen/[id]": await import("../src/pages/api/geg-nachweis-wohnen/[id].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-wohnen": await import("../src/pages/api/geg-nachweis-wohnen/index.ts"),
"objekt": await import("../src/pages/api/objekt/index.ts"),
"rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"), "rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"),
"rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"), "rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"),
"rechnung": await import("../src/pages/api/rechnung/index.ts"), "rechnung": await import("../src/pages/api/rechnung/index.ts"),
"objekt": await import("../src/pages/api/objekt/index.ts"), "ticket": await import("../src/pages/api/ticket/index.ts"),
"user": await import("../src/pages/api/user/index.ts"), "user": await import("../src/pages/api/user/index.ts"),
"user/self": await import("../src/pages/api/user/self.ts"), "user/self": await import("../src/pages/api/user/self.ts"),
"ticket": await import("../src/pages/api/ticket/index.ts"),
"verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"),
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
"verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"), "verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"),
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"), "verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
"objekt/[id]": await import("../src/pages/api/objekt/[id]/index.ts"), "verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"),
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
"webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"),
"aufnahme/[id]/bilder": await import("../src/pages/api/aufnahme/[id]/bilder.ts"), "aufnahme/[id]/bilder": await import("../src/pages/api/aufnahme/[id]/bilder.ts"),
"aufnahme/[id]": await import("../src/pages/api/aufnahme/[id]/index.ts"), "aufnahme/[id]": await import("../src/pages/api/aufnahme/[id]/index.ts"),
"aufnahme/[id]/unterlagen": await import("../src/pages/api/aufnahme/[id]/unterlagen.ts"), "aufnahme/[id]/unterlagen": await import("../src/pages/api/aufnahme/[id]/unterlagen.ts"),
"webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"), "objekt/[id]": await import("../src/pages/api/objekt/[id]/index.ts"),
}) })

View File

@@ -60,6 +60,8 @@
return centeredValue; return centeredValue;
} }
let translation_1 = 0; let translation_1 = 0;
let translation_2 = 0; let translation_2 = 0;
$: { $: {
@@ -74,6 +76,7 @@
if (!result) { if (!result) {
return; return;
} }
translation_1 = Math.max( translation_1 = Math.max(
0, 0,
Math.min( Math.min(

View File

@@ -11,7 +11,7 @@ export async function auditEndEnergie(ausweis: VerbrauchsausweisWohnenClient | V
if (aufnahme){ if (aufnahme){
if (aufnahme.flaeche && ausweis.verbrauch_1 && ausweis.verbrauch_2 && ausweis.verbrauch_3) { if (aufnahme.flaeche && ausweis.verbrauch_1 && ausweis.verbrauch_2 && ausweis.verbrauch_3) {
try { try {
const response = await getKlimafaktoren(ausweis.startdatum, objekt.plz); const response = await getKlimafaktoren(ausweis.startdatum as Date, objekt.plz as string);
// Alle Klimfaktoren konnten abgefragt werden. // Alle Klimfaktoren konnten abgefragt werden.
const eevva = await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt); const eevva = await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt);
if (eevva){ if (eevva){

View File

@@ -10,9 +10,8 @@ export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Client(
) { ) {
const startdatum = moment(ausweis.startdatum); const startdatum = moment(ausweis.startdatum);
let klimafaktoren = await getKlimafaktoren( let klimafaktoren = await getKlimafaktoren(
objekt.plz as string,
startdatum.toDate(), startdatum.toDate(),
startdatum.add(2, "years").toDate() objekt.plz as string,
); );
if (!klimafaktoren || klimafaktoren.length === 0) { if (!klimafaktoren || klimafaktoren.length === 0) {

View File

@@ -13,12 +13,14 @@ export async function endEnergieVerbrauchVerbrauchsausweis_2016_Client(
objekt: ObjektClient, objekt: ObjektClient,
) { ) {
const startdatum = moment(ausweis.startdatum); const startdatum = moment(ausweis.startdatum);
let klimafaktoren = await getKlimafaktoren( let klimafaktoren = await getKlimafaktoren(
objekt.plz as string,
startdatum.toDate(), startdatum.toDate(),
startdatum.add(2, "years").toDate() objekt.plz as string
); );
console.log("Klimafaktoren", klimafaktoren);
if (!klimafaktoren || klimafaktoren.length === 0) { if (!klimafaktoren || klimafaktoren.length === 0) {
klimafaktoren = [ klimafaktoren = [
{ {

View File

@@ -7,17 +7,13 @@ export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
return null; return null;
} }
try { const response = await api.klimafaktoren.GET.fetch({
const response = await api.klimafaktoren.GET.fetch({ plz,
plz, genauigkeit: "years",
genauigkeit: "years", // @ts-ignore Der Adapter nimmt z.coerce.date()
// @ts-ignore Der Adapter nimmt z.coerce.date() startdatum: moment(date).utc(true).toString(),
startdatum: moment(date).utc(true).toString(), // @ts-ignore Der Adapter nimmt z.coerce.date()
// @ts-ignore Der Adapter nimmt z.coerce.date() enddatum: moment(date).add(2, "years").utc(true).toString(),
enddatum: moment(date).add(2, "years").utc(true).toString(), });
}); return response;
return response;
} catch (e) {
return null;
}
}); });

View File

@@ -1,18 +1,21 @@
type MemoizedFunction<T> = (...args: any[]) => T; type MemoizedFunction<T extends (...args: any[]) => Promise<any> | any> = (...args: Parameters<T>) => Promise<ReturnType<T>> | ReturnType<T>;
export function memoize<T>(func: (...args: any[]) => T): MemoizedFunction<T> { export function memoize<T extends (...args: any[]) => Promise<any> | any>(func: T): MemoizedFunction<T> {
const cache = new Map<string, T>(); const cache = new Map<string, ReturnType<T>>();
return (...args: any[]): T => { return (...args: Parameters<T>): Promise<ReturnType<T>> | ReturnType<T> => {
const key = JSON.stringify(args); const key = JSON.stringify(args);
if (cache.has(key)) { if (cache.has(key)) {
return cache.get(key)!; return cache.get(key)!;
} }
const result = func(...args); const result = func(...args);
cache.set(key, result); if (result instanceof Promise) {
return result.then(resolved => {
return result; return resolved;
});
} else {
cache.set(key, result);
return result;
}
}; };
} }

View File

@@ -1,6 +1,5 @@
--- ---
import { Enums, prisma } from "#lib/server/prisma"; import { Enums, prisma } from "#lib/server/prisma";
import UserLayout from "#layouts/DashboardLayout.astro";
import { getCurrentUser } from "#lib/server/user"; import { getCurrentUser } from "#lib/server/user";
const page = Number(Astro.url.searchParams.get("p")); const page = Number(Astro.url.searchParams.get("p"));
@@ -13,7 +12,7 @@ if (!user) {
const totalPageCount = await prisma.aufnahme.count({ const totalPageCount = await prisma.aufnahme.count({
where: where:
user.rolle !== Enums.BenutzerRolle.ADMIN || Enums.BenutzerRolle.RESELLER ((user.rolle !== Enums.BenutzerRolle.ADMIN) && (user.rolle !== Enums.BenutzerRolle.RESELLER))
? { ? {
benutzer: { benutzer: {
id: user.id, id: user.id,
@@ -22,6 +21,7 @@ const totalPageCount = await prisma.aufnahme.count({
: {}, : {},
}); });
if ((page < 1 || page > totalPageCount) && totalPageCount > 0) { if ((page < 1 || page > totalPageCount) && totalPageCount > 0) {
return Astro.redirect("/dashboard/objekte?p=1"); return Astro.redirect("/dashboard/objekte?p=1");
} else if (totalPageCount === 0) { } else if (totalPageCount === 0) {