Merge pull request #572 from IBCornelsen/staging
Klimafaktoren Bug Gefixt
This commit is contained in:
@@ -5,7 +5,6 @@ export const createCaller = createCallerFactory({
|
||||
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
|
||||
"postleitzahlen": await import("../src/pages/api/postleitzahlen.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/bedarfsausweis-ausstellen": await import("../src/pages/api/admin/bedarfsausweis-ausstellen.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/stornieren": await import("../src/pages/api/admin/stornieren.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/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/[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": 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"),
|
||||
"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-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"),
|
||||
"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"),
|
||||
"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/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": 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]": await import("../src/pages/api/aufnahme/[id]/index.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"),
|
||||
})
|
||||
@@ -60,6 +60,8 @@
|
||||
return centeredValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let translation_1 = 0;
|
||||
let translation_2 = 0;
|
||||
$: {
|
||||
@@ -74,6 +76,7 @@
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
translation_1 = Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function auditEndEnergie(ausweis: VerbrauchsausweisWohnenClient | V
|
||||
if (aufnahme){
|
||||
if (aufnahme.flaeche && ausweis.verbrauch_1 && ausweis.verbrauch_2 && ausweis.verbrauch_3) {
|
||||
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.
|
||||
const eevva = await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt);
|
||||
if (eevva){
|
||||
|
||||
@@ -10,9 +10,8 @@ export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Client(
|
||||
) {
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
let klimafaktoren = await getKlimafaktoren(
|
||||
objekt.plz as string,
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
objekt.plz as string,
|
||||
);
|
||||
|
||||
if (!klimafaktoren || klimafaktoren.length === 0) {
|
||||
|
||||
@@ -13,12 +13,14 @@ export async function endEnergieVerbrauchVerbrauchsausweis_2016_Client(
|
||||
objekt: ObjektClient,
|
||||
) {
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
|
||||
let klimafaktoren = await getKlimafaktoren(
|
||||
objekt.plz as string,
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
objekt.plz as string
|
||||
);
|
||||
|
||||
console.log("Klimafaktoren", klimafaktoren);
|
||||
|
||||
if (!klimafaktoren || klimafaktoren.length === 0) {
|
||||
klimafaktoren = [
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await api.klimafaktoren.GET.fetch({
|
||||
plz,
|
||||
genauigkeit: "years",
|
||||
@@ -17,7 +16,4 @@ export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
|
||||
enddatum: moment(date).add(2, "years").utc(true).toString(),
|
||||
});
|
||||
return response;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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> {
|
||||
const cache = new Map<string, T>();
|
||||
export function memoize<T extends (...args: any[]) => Promise<any> | any>(func: T): MemoizedFunction<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);
|
||||
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key)!;
|
||||
}
|
||||
|
||||
const result = func(...args);
|
||||
if (result instanceof Promise) {
|
||||
return result.then(resolved => {
|
||||
return resolved;
|
||||
});
|
||||
} else {
|
||||
cache.set(key, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
import { Enums, prisma } from "#lib/server/prisma";
|
||||
import UserLayout from "#layouts/DashboardLayout.astro";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
|
||||
const page = Number(Astro.url.searchParams.get("p"));
|
||||
@@ -13,7 +12,7 @@ if (!user) {
|
||||
|
||||
const totalPageCount = await prisma.aufnahme.count({
|
||||
where:
|
||||
user.rolle !== Enums.BenutzerRolle.ADMIN || Enums.BenutzerRolle.RESELLER
|
||||
((user.rolle !== Enums.BenutzerRolle.ADMIN) && (user.rolle !== Enums.BenutzerRolle.RESELLER))
|
||||
? {
|
||||
benutzer: {
|
||||
id: user.id,
|
||||
@@ -22,6 +21,7 @@ const totalPageCount = await prisma.aufnahme.count({
|
||||
: {},
|
||||
});
|
||||
|
||||
|
||||
if ((page < 1 || page > totalPageCount) && totalPageCount > 0) {
|
||||
return Astro.redirect("/dashboard/objekte?p=1");
|
||||
} else if (totalPageCount === 0) {
|
||||
|
||||
Reference in New Issue
Block a user