Bilder fix Datenblatt
This commit is contained in:
22
prisma/migrations/20250331182241_nachweise/migration.sql
Normal file
22
prisma/migrations/20250331182241_nachweise/migration.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `updated_at` to the `BedarfsausweisGewerbe` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `updated_at` to the `GEGNachweisGewerbe` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `updated_at` to the `GEGNachweisWohnen` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "BedarfsausweisGewerbe" ADD COLUMN "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "nachweistyp" "AusweisTyp" NOT NULL DEFAULT 'Standard',
|
||||
ADD COLUMN "updated_at" TIMESTAMP(3) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GEGNachweisGewerbe" ADD COLUMN "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "nachweistyp" "AusweisTyp" NOT NULL DEFAULT 'Standard',
|
||||
ADD COLUMN "updated_at" TIMESTAMP(3) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GEGNachweisWohnen" ADD COLUMN "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "nachweistyp" "AusweisTyp" NOT NULL DEFAULT 'Standard',
|
||||
ADD COLUMN "updated_at" TIMESTAMP(3) NOT NULL;
|
||||
@@ -25,6 +25,11 @@ model BedarfsausweisGewerbe {
|
||||
bauteilaktivierung Boolean? @default(false)
|
||||
klimatisierung Boolean? @default(false)
|
||||
|
||||
nachweistyp AusweisTyp @default(Standard)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
/// @zod.describe("Die ID des Benutzers, welchem dieser Ausweis gehört")
|
||||
benutzer_id String?
|
||||
benutzer Benutzer? @relation(fields: [benutzer_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@ -16,6 +16,11 @@ model GEGNachweisGewerbe {
|
||||
/// @zod.describe("Beschreibung des Bauvorhabens")
|
||||
beschreibung String? @db.Text
|
||||
|
||||
nachweistyp AusweisTyp @default(Standard)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
/// @zod.describe("Die ID des Benutzers, welchem dieser Ausweis gehört")
|
||||
benutzer_id String?
|
||||
benutzer Benutzer? @relation(fields: [benutzer_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@ -16,6 +16,11 @@ model GEGNachweisWohnen {
|
||||
/// @zod.describe("Beschreibung des Bauvorhabens")
|
||||
beschreibung String? @db.Text
|
||||
|
||||
nachweistyp AusweisTyp @default(Standard)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
/// @zod.describe("Die ID des Benutzers, welchem dieser Ausweis gehört")
|
||||
benutzer_id String?
|
||||
benutzer Benutzer? @relation(fields: [benutzer_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@ -12,7 +12,6 @@ export const createCaller = createCallerFactory({
|
||||
"admin/post-ausstellen": await import("../src/pages/api/admin/post-ausstellen.ts"),
|
||||
"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"),
|
||||
@@ -21,6 +20,7 @@ export const createCaller = createCallerFactory({
|
||||
"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"),
|
||||
|
||||
@@ -4,10 +4,10 @@ import { exclude } from "#lib/exclude.js";
|
||||
import Cookies from "js-cookie";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BildClient, ObjektClient, UnterlageClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { Enums } from "#lib/client/prisma.js";
|
||||
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
|
||||
|
||||
export async function nachweisSpeichern(
|
||||
nachweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient,
|
||||
nachweis: BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe,
|
||||
objekt: ObjektClient,
|
||||
aufnahme: AufnahmeClient,
|
||||
bilder: BildClient[],
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
import Overlay from "#components/Overlay.svelte";
|
||||
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
|
||||
|
||||
import { AusweisTyp, Enums } from "#lib/client/prisma.js";
|
||||
import { AusweisTyp, BedarfsausweisGewerbe, Enums } 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 | GEGNachweisWohnenClient;
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
|
||||
export let bilder: BildClient[];
|
||||
export let unterlagen: UnterlageClient[] = [];
|
||||
export let user: BenutzerClient | null;
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | Awaited<ReturnType<typeof nachweisSpeichern>> | null = null;
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||
result = await nachweisSpeichern({ ...ausweis, ausweistyp }, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
||||
result = await nachweisSpeichern({ ...ausweis, nachweistyp: ausweistyp }, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
||||
ausweis.id = result.nachweis_id;
|
||||
} else {
|
||||
result = await ausweisSpeichern({ ...ausweis, ausweistyp }, objekt, aufnahme, bilder, ausweisart)
|
||||
|
||||
@@ -107,7 +107,7 @@ export const UUidWithPrefix = z.string().refine((value) => {
|
||||
return false;
|
||||
})
|
||||
|
||||
export function getAusweisartFromUUID(id: string): Enums.Ausweisart | null {
|
||||
export function getAusweisartFromId(id: string): Enums.Ausweisart | null {
|
||||
if (!UUidWithPrefix.safeParse(id).success) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import moment from "moment";
|
||||
import {
|
||||
AufnahmeClient,
|
||||
getAusweisartFromUUID,
|
||||
getAusweisartFromId,
|
||||
ObjektClient,
|
||||
BildClient,
|
||||
VerbrauchsausweisWohnenClient,
|
||||
@@ -31,7 +31,7 @@
|
||||
async function ausweisAusstellen(uid: string) {
|
||||
try {
|
||||
await api.admin.ausstellen.GET.fetch({
|
||||
uid_ausweis: uid
|
||||
id_ausweis: uid
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
|
||||
|
||||
const ausweisArt = getAusweisartFromUUID(ausweis.id)
|
||||
const ausweisArt = getAusweisartFromId(ausweis.id)
|
||||
|
||||
let verbrauchWWGesamt_1 = "";
|
||||
let verbrauchWWGesamt_2 = "";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { AufnahmeKomplettClient, BedarfsausweisWohnenClient, BenutzerClient, getAusweisartFromUUID, RechnungClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeKomplettClient, BedarfsausweisWohnenClient, BenutzerClient, getAusweisartFromId, RechnungClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import moment from "moment";
|
||||
import { dialogs } from "svelte-dialogs";
|
||||
import {
|
||||
@@ -24,7 +24,7 @@
|
||||
export let benutzer: BenutzerClient;
|
||||
const progress = ausweis.ausgestellt ? 100 : ausweis.bestellt ? 66 : 33;
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.id);
|
||||
const ausweisart = getAusweisartFromId(ausweis.id);
|
||||
|
||||
const id = ausweis.alte_ausweis_id || ausweis.id;
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
async function ausweisAusstellen() {
|
||||
try {
|
||||
await api.admin.ausstellen.GET.fetch({
|
||||
uid_ausweis: ausweis.id
|
||||
id_ausweis: ausweis.id
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { AufnahmeKomplettClient, GEGNachweisWohnenClient, getAusweisartFromUUID } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeKomplettClient, GEGNachweisWohnenClient, getAusweisartFromId } from "#components/Ausweis/types.js";
|
||||
import {
|
||||
CrossCircled,
|
||||
DotsVertical,
|
||||
Pencil2,
|
||||
QuestionMarkCircled,
|
||||
@@ -12,7 +11,7 @@
|
||||
export let aufnahme: AufnahmeKomplettClient;
|
||||
export let objekt: Objekt;
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(nachweis.uid);
|
||||
const ausweisart = getAusweisartFromId(nachweis.id);
|
||||
|
||||
let hilfeModal: HTMLDialogElement;
|
||||
</script>
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
export let max: number = Infinity;
|
||||
export let min: number = 1;
|
||||
export let name: string = "";
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | GEGNachweisWohnenClient;
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
|
||||
export let objekt: ObjektClient;
|
||||
import mime from "mime-types";
|
||||
import { api } from "astro-typesafe-api/client";
|
||||
import { BedarfsausweisGewerbe } from "#lib/client/prisma.js";
|
||||
|
||||
|
||||
function getAllFiles(this: HTMLInputElement) {
|
||||
|
||||
@@ -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 { Enums } from "#lib/client/prisma.js";
|
||||
import { BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
|
||||
import {
|
||||
AufnahmeClient,
|
||||
ObjektClient,
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
export let objekt: ObjektClient;
|
||||
export let ausweis:
|
||||
GEGNachweisWohnenClient;
|
||||
BedarfsausweisGewerbe;
|
||||
export let aufnahme: AufnahmeClient;
|
||||
|
||||
export let ausweisart: Enums.Ausweisart;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import HelpLabel from "#components/labels/HelpLabel.svelte";
|
||||
import type { Enums } from "#lib/client/prisma.js";
|
||||
import { tryCatch } from "#lib/tryCatch.js";
|
||||
|
||||
export let max: number = 2;
|
||||
export let min: number = 1;
|
||||
@@ -15,6 +16,7 @@
|
||||
VerbrauchsausweisWohnenClient,
|
||||
} from "./Ausweis/types.js";
|
||||
import { api } from "astro-typesafe-api/client";
|
||||
import { addNotification } from "./Notifications/shared.js";
|
||||
|
||||
export let images: BildClient[] = [];
|
||||
export let ausweis:
|
||||
@@ -79,17 +81,27 @@
|
||||
// Get the scaled-down data from the canvas in the desired output format and quality
|
||||
const dataURL = canvas.toDataURL("image/jpeg", 0.8);
|
||||
|
||||
const { id } = await api.bild.PUT.fetch({
|
||||
const [result, error] = await tryCatch(api.bild.PUT.fetch({
|
||||
data: dataURL,
|
||||
kategorie,
|
||||
name: file.name
|
||||
})
|
||||
}))
|
||||
|
||||
images.push({ id, kategorie });
|
||||
images = images;
|
||||
if (error) {
|
||||
addNotification({
|
||||
message: "Das hat nicht geklappt.",
|
||||
type: "error",
|
||||
timeout: 3000,
|
||||
subtext: "Bild konnte nicht hochgeladen werden, bitte versuchen sie es erneut.",
|
||||
dismissable: true
|
||||
})
|
||||
} else {
|
||||
images.push({ id: result.id, kategorie });
|
||||
images = images;
|
||||
|
||||
if (i == Math.min(files.length, max) - 1) {
|
||||
this.value = "";
|
||||
if (i == Math.min(files.length, max) - 1) {
|
||||
this.value = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "#lib/server/prisma.js";
|
||||
import { VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "#lib/client/prisma.js";
|
||||
import moment from "moment";
|
||||
|
||||
export let addYear: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as z from "zod"
|
||||
import { Ausstellgrund } from "@prisma/client"
|
||||
import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const BedarfsausweisGewerbeSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -19,6 +19,9 @@ export const BedarfsausweisGewerbeSchema = z.object({
|
||||
fussbodenheizung: z.boolean().nullish(),
|
||||
bauteilaktivierung: z.boolean().nullish(),
|
||||
klimatisierung: z.boolean().nullish(),
|
||||
nachweistyp: z.nativeEnum(AusweisTyp),
|
||||
created_at: z.date(),
|
||||
updated_at: z.date(),
|
||||
benutzer_id: z.string().describe("Die ID des Benutzers, welchem dieser Ausweis gehört").nullish(),
|
||||
aufnahme_id: z.string(),
|
||||
rechnung_id: z.string().nullish(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as z from "zod"
|
||||
import { Ausstellgrund } from "@prisma/client"
|
||||
import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const GEGNachweisGewerbeSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -9,6 +9,9 @@ export const GEGNachweisGewerbeSchema = z.object({
|
||||
bestellt: z.boolean().describe("Falls der Nachweis bestellt wurde, sollte dieser Wert auf true stehen").nullish(),
|
||||
zurueckgestellt: z.boolean().describe("Falls der Nachweis vom Aussteller zurückgestellt wurde, sollte dieser Wert auf true stehen").nullish(),
|
||||
beschreibung: z.string().describe("Beschreibung des Bauvorhabens").nullish(),
|
||||
nachweistyp: z.nativeEnum(AusweisTyp),
|
||||
created_at: z.date(),
|
||||
updated_at: z.date(),
|
||||
benutzer_id: z.string().describe("Die ID des Benutzers, welchem dieser Ausweis gehört").nullish(),
|
||||
aufnahme_id: z.string(),
|
||||
rechnung_id: z.string().nullish(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as z from "zod"
|
||||
import { Ausstellgrund } from "@prisma/client"
|
||||
import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const GEGNachweisWohnenSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -9,6 +9,9 @@ export const GEGNachweisWohnenSchema = z.object({
|
||||
bestellt: z.boolean().describe("Falls der Nachweis bestellt wurde, sollte dieser Wert auf true stehen").nullish(),
|
||||
zurueckgestellt: z.boolean().describe("Falls der Nachweis vom Aussteller zurückgestellt wurde, sollte dieser Wert auf true stehen").nullish(),
|
||||
beschreibung: z.string().describe("Beschreibung des Bauvorhabens").nullish(),
|
||||
nachweistyp: z.nativeEnum(AusweisTyp),
|
||||
created_at: z.date(),
|
||||
updated_at: z.date(),
|
||||
benutzer_id: z.string().describe("Die ID des Benutzers, welchem dieser Ausweis gehört").nullish(),
|
||||
aufnahme_id: z.string(),
|
||||
rechnung_id: z.string().nullish(),
|
||||
|
||||
@@ -12,7 +12,7 @@ export class Checkbox extends PDFElement {
|
||||
throw new Error('Method not supported.');
|
||||
}
|
||||
|
||||
draw(page: PDFPage, x: number, y: number): void {
|
||||
async draw(page: PDFPage, x: number, y: number) {
|
||||
page.drawRectangle({
|
||||
x: x + this.borderWidth,
|
||||
// NOTE: Keine Ahnung warum * 1.5 aber dann passt es...
|
||||
|
||||
@@ -103,15 +103,15 @@ export class Flex extends PDFElement {
|
||||
return currentWidth;
|
||||
}
|
||||
|
||||
draw(page: PDFPage, x: number = this.x, y: number = this.y): void {
|
||||
async draw(page: PDFPage, x: number = this.x, y: number = this.y) {
|
||||
const childPositions = this.calculateChildPositions(x + this.margin.left + this.padding.left, y - this.margin.top - this.padding.top);
|
||||
|
||||
// Draw each child
|
||||
this.children.forEach((child, i) => {
|
||||
const pos = childPositions[i];
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
const child = this.children[i];
|
||||
const pos = childPositions[i];
|
||||
|
||||
child.draw(page, pos.x, pos.y);
|
||||
});
|
||||
await child.draw(page, pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
|
||||
private calculateChildPositions(x: number, y: number): { x: number; y: number }[] {
|
||||
|
||||
@@ -50,9 +50,9 @@ export class Image extends PDFElement {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.options.src.split(".").pop() === "png") {
|
||||
try {
|
||||
embed = await page.doc.embedPng(img)
|
||||
} else {
|
||||
} catch(e) {
|
||||
embed = await page.doc.embedJpg(img)
|
||||
}
|
||||
} else if (this.options.data) {
|
||||
@@ -73,8 +73,6 @@ export class Image extends PDFElement {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
page.drawImage(embed, {
|
||||
x: x + this.margin.left + this.padding.left,
|
||||
y: y - this.height - this.margin.top - this.padding.top,
|
||||
|
||||
@@ -59,11 +59,11 @@ export class Layout extends PDFElement {
|
||||
this._height = value;
|
||||
}
|
||||
|
||||
draw(page: PDFPage, x: number, y: number): void {
|
||||
async draw(page: PDFPage, x: number, y: number) {
|
||||
let currentY = y - this.margin.top - this.padding.top;
|
||||
|
||||
for (const child of this.children) {
|
||||
child.draw(page, x + this.margin.left + this.padding.left, currentY);
|
||||
await child.draw(page, x + this.margin.left + this.padding.left, currentY);
|
||||
|
||||
currentY -= child.height + child.margin.top + child.margin.bottom;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ export abstract class PDFElement {
|
||||
return this._height === "auto" ? 0 : this._height;
|
||||
}
|
||||
|
||||
abstract draw(page: PDFPage, x: number, y: number): void;
|
||||
async draw(page: PDFPage, x: number, y: number): Promise<void> {
|
||||
throw new Error("Method is not implemented.")
|
||||
}
|
||||
|
||||
abstract addChild(...children: PDFElement[]): void;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class Text extends PDFElement {
|
||||
return this._width + this.padding.left + this.padding.right;
|
||||
}
|
||||
|
||||
draw(page: PDFPage, x: number, y: number): void {
|
||||
async draw(page: PDFPage, x: number, y: number): Promise<void> {
|
||||
page.drawText(this.content, {
|
||||
x: x + this.margin.left + this.padding.left,
|
||||
y: y - this.height - this.margin.top - this.padding.top,
|
||||
|
||||
@@ -51,7 +51,7 @@ export function xml2pdf(xml: string, fonts: Record<string, PDFFont> & { "default
|
||||
color = rgb(...colorValue.map((x) => parseInt(x) / 255) as [number, number, number]);
|
||||
}
|
||||
|
||||
const text = new Text(child.children[0] || "", { font: child.attributes.hasOwnProperty("font") ? fonts[child.attributes["font"]] : fonts["default"], lineHeight: parseFloat(child.attributes.lineHeight), fontSize: parseFloat(child.attributes.size) || 10, color, margin: {
|
||||
const text = new Text(child.children[0] as string || "", { font: child.attributes.hasOwnProperty("font") ? fonts[child.attributes["font"]] : fonts["default"], lineHeight: parseFloat(child.attributes.lineHeight), fontSize: parseFloat(child.attributes.size) || 10, color, margin: {
|
||||
bottom: parseFloat(child.attributes.marginBottom) || 0,
|
||||
left: parseFloat(child.attributes.marginLeft) || 0,
|
||||
right: parseFloat(child.attributes.marginRight) || 0,
|
||||
@@ -115,42 +115,3 @@ export function xml2pdf(xml: string, fonts: Record<string, PDFFont> & { "default
|
||||
|
||||
return layout
|
||||
}
|
||||
|
||||
// const pdf = await PDFDocument.create()
|
||||
|
||||
// const page = pdf.addPage()
|
||||
|
||||
// const font = await pdf.embedFont(StandardFonts.Helvetica)
|
||||
// const bold = await pdf.embedFont(StandardFonts.HelveticaBold)
|
||||
|
||||
// console.log(page.getWidth(), "WIDTH");
|
||||
|
||||
|
||||
// const layout = xml2pdf(`
|
||||
// <flex direction="column" justify="end" width="${page.getWidth()}" height="${page.getHeight()}">
|
||||
// <flex direction="row" gap="5" align="center">
|
||||
// <checkbox width="8" height="8"></checkbox>
|
||||
// <text size="12">awd1</text>
|
||||
// </flex>
|
||||
// <flex direction="row" gap="5" align="center">
|
||||
// <checkbox width="8" height="8"></checkbox>
|
||||
// <text size="12">awd2</text>
|
||||
// </flex>
|
||||
// <flex direction="row" gap="5" align="center">
|
||||
// <checkbox width="8" height="8"></checkbox>
|
||||
// <text size="12">awd3</text>
|
||||
// </flex>
|
||||
// <flex direction="row" gap="5" align="center">
|
||||
// <checkbox width="8" height="8"></checkbox>
|
||||
// <text size="12">awd4</text>
|
||||
// </flex>
|
||||
// </flex>`, {
|
||||
// "default": font
|
||||
// })
|
||||
|
||||
// layout.draw(page, 0, page.getHeight())
|
||||
|
||||
// import { writeFileSync } from "fs"
|
||||
// import { FixedLengthArray } from "#lib/Berechnungen/BedarfsausweisWohnen/types.js"
|
||||
|
||||
// writeFileSync("./test-pdf.pdf", await pdf.save())
|
||||
@@ -382,78 +382,9 @@ export async function pdfDatenblattVerbrauchsausweisGewerbe(ausweis: Verbrauchsa
|
||||
${images.map(badge => `<flex direction="row" justify="space-between" width="${pages[2].getWidth() - 120}" height="${(pages[2].getHeight() - marginY * 2) / 4}" marginTop="15">${badge.join("")}</flex>`).join("")}
|
||||
</layout>`, { "default": font })
|
||||
|
||||
layout.draw(pages[0], 0, pages[0].getHeight())
|
||||
layoutPage2.draw(pages[1], 0, pages[1].getHeight())
|
||||
layoutPage3.draw(pages[2], 0, pages[2].getHeight())
|
||||
|
||||
// const containerWidth = width - marginX;
|
||||
|
||||
// const layout = flex([
|
||||
// flex([
|
||||
// checkbox(8, 8), text("Neubau", {
|
||||
// color: rgb(0,0,0),
|
||||
// font,
|
||||
// fontSize: 12
|
||||
// })
|
||||
// ], {
|
||||
// align: "center",
|
||||
// justify: "center",
|
||||
// gap: 5,
|
||||
// height: 12,
|
||||
// page: pages[0]
|
||||
// }),
|
||||
// flex([
|
||||
// checkbox(8, 8), text("Vermietung/Verkauf", {
|
||||
// color: rgb(0,0,0),
|
||||
// font,
|
||||
// fontSize: 12
|
||||
// })
|
||||
// ], {
|
||||
// align: "center",
|
||||
// justify: "center",
|
||||
// gap: 5,
|
||||
// height: 12,
|
||||
// page: pages[0]
|
||||
// }),
|
||||
// flex([
|
||||
// checkbox(8, 8), text("Modernisierung", {
|
||||
// color: rgb(0,0,0),
|
||||
// font,
|
||||
// fontSize: 12
|
||||
// })
|
||||
// ], {
|
||||
// align: "center",
|
||||
// justify: "center",
|
||||
// gap: 5,
|
||||
// height: 12,
|
||||
// page: pages[0]
|
||||
// }),
|
||||
// flex([
|
||||
// checkbox(8, 8), text("Sonstiges", {
|
||||
// color: rgb(0,0,0),
|
||||
// font,
|
||||
// fontSize: 12
|
||||
// })
|
||||
// ], {
|
||||
// align: "center",
|
||||
// justify: "center",
|
||||
// gap: 5,
|
||||
// height: 12,
|
||||
// page: pages[0]
|
||||
// })
|
||||
// ], {
|
||||
// align: "center",
|
||||
// justify: "space-between",
|
||||
// gap: 15,
|
||||
// x: marginX,
|
||||
// y: height - marginY - 165,
|
||||
// height: 12,
|
||||
// width: containerWidth
|
||||
// })
|
||||
|
||||
// layout.draw(pages[0])
|
||||
|
||||
// pdf.getForm().flatten()
|
||||
await layout.draw(pages[0], 0, pages[0].getHeight())
|
||||
await layoutPage2.draw(pages[1], 0, pages[1].getHeight())
|
||||
await layoutPage3.draw(pages[2], 0, pages[2].getHeight())
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
@@ -298,7 +298,7 @@ export async function pdfDatenblattVerbrauchsausweisWohnen(ausweis: Verbrauchsau
|
||||
const images: string[][] = []
|
||||
|
||||
for (const bild of bilder) {
|
||||
let badge: string[];
|
||||
let batch: string[];
|
||||
let image: string = "";
|
||||
|
||||
if (bild.kategorie === Enums.BilderKategorie.Gebaeude) {
|
||||
@@ -310,26 +310,30 @@ export async function pdfDatenblattVerbrauchsausweisWohnen(ausweis: Verbrauchsau
|
||||
}
|
||||
|
||||
if (images.length > 0) {
|
||||
let badge = images[images.length - 1]
|
||||
if (badge.length == 3) {
|
||||
badge = [image]
|
||||
images.push(badge)
|
||||
let batch = images[images.length - 1]
|
||||
if (batch.length == 3) {
|
||||
batch = [image]
|
||||
images.push(batch)
|
||||
} else {
|
||||
badge.push(image)
|
||||
batch.push(image)
|
||||
}
|
||||
} else {
|
||||
badge = [image]
|
||||
images.push(badge)
|
||||
batch = [image]
|
||||
images.push(batch)
|
||||
}
|
||||
}
|
||||
|
||||
const layoutPage3 = xml2pdf(`<layout height="${pages[2].getHeight()}" width="${pages[2].getWidth()}" marginTop="150" marginLeft="60" marginRight="60">
|
||||
${images.map(badge => `<flex direction="row" justify="space-between" width="${pages[2].getWidth() - 120}" height="${(pages[2].getHeight() - marginY * 2) / 4}" marginTop="15">${badge.join("")}</flex>`).join("")}
|
||||
${images.map(batch => `<flex direction="row" justify="space-between" width="${pages[2].getWidth() - 120}" height="${(pages[2].getHeight() - marginY * 2) / 4}" marginTop="15">${batch.join("")}</flex>`).join("")}
|
||||
</layout>`, { "default": font })
|
||||
|
||||
layout.draw(pages[0], 0, pages[0].getHeight())
|
||||
layoutPage2.draw(pages[1], 0, pages[1].getHeight())
|
||||
layoutPage3.draw(pages[2], 0, pages[2].getHeight())
|
||||
|
||||
await layout.draw(pages[0], 0, pages[0].getHeight())
|
||||
await layoutPage2.draw(pages[1], 0, pages[1].getHeight())
|
||||
await layoutPage3.draw(pages[2], 0, pages[2].getHeight())
|
||||
|
||||
console.log("DONE");
|
||||
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
||||
import * as fs from "fs";
|
||||
import { tryCatch } from "./tryCatch.js";
|
||||
|
||||
export const s3Client = new S3Client({
|
||||
region: "eu-central-1",
|
||||
@@ -17,21 +18,18 @@ export async function getS3File(
|
||||
bucket: string,
|
||||
key: string
|
||||
): Promise<Buffer | null> {
|
||||
try {
|
||||
let command = new GetObjectCommand({ Bucket: bucket, Key: key });
|
||||
let response = await s3Client.send(command);
|
||||
let command = new GetObjectCommand({ Bucket: bucket, Key: key });
|
||||
|
||||
const body = response.Body;
|
||||
let [response, error] = await tryCatch(s3Client.send(command));
|
||||
|
||||
if (!body) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let buffer = await streamToBuffer(body as unknown as fs.ReadStream);
|
||||
return buffer;
|
||||
} catch (e) {
|
||||
if (error || response === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const body = response.Body;
|
||||
|
||||
let buffer = await streamToBuffer(body as unknown as fs.ReadStream);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
async function streamToBuffer(stream: fs.ReadStream): Promise<Buffer> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, BildClient, getAusweisartFromUUID, ObjektClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, BildClient, getAusweisartFromId, ObjektClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { pdfDatenblattVerbrauchsausweisGewerbe } from "#lib/pdf/pdfDatenblattVerbrauchsausweisGewerbe.js";
|
||||
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
||||
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
|
||||
@@ -10,7 +10,7 @@ import { Enums, prisma } from "#lib/server/prisma.js";
|
||||
* @param id Die Ausweis UID
|
||||
*/
|
||||
export function getPrismaAusweisAdapter(id: string) {
|
||||
const ausweisart = getAusweisartFromUUID(id);
|
||||
const ausweisart = getAusweisartFromId(id);
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
return prisma.verbrauchsausweisWohnen
|
||||
@@ -25,7 +25,7 @@ export function getPrismaAusweisAdapter(id: string) {
|
||||
* Gibt den richtigen Ansichtsausweis basierend auf der Ausweisart zurück.
|
||||
* @param ausweis
|
||||
*/
|
||||
export async function getAnsichtsausweis(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient, ausweisart = getAusweisartFromUUID(ausweis.uid)) {
|
||||
export async function getAnsichtsausweis(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient, ausweisart = getAusweisartFromId(ausweis.uid)) {
|
||||
if (!ausweisart) {
|
||||
return null
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export async function getAnsichtsausweis(ausweis: VerbrauchsausweisWohnenClient
|
||||
* Gibt das richtige Datenblatt basierend auf der Ausweisart zurück.
|
||||
* @param ausweis
|
||||
*/
|
||||
export async function getDatenblatt(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient, ausweisart = getAusweisartFromUUID(ausweis.uid)) {
|
||||
export async function getDatenblatt(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient, ausweisart = getAusweisartFromId(ausweis.uid)) {
|
||||
if (!ausweisart) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Aufnahme, Bild, Objekt, prisma, VerbrauchsausweisWohnen } from "./prisma.js";
|
||||
import { Aufnahme, BedarfsausweisGewerbe, Bild, Objekt, prisma, Unterlage, VerbrauchsausweisWohnen } from "./prisma.js";
|
||||
|
||||
export async function getVerbrauchsausweisWohnen(id: string): Promise<VerbrauchsausweisWohnen | null> {
|
||||
return await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
@@ -8,6 +8,14 @@ export async function getVerbrauchsausweisWohnen(id: string): Promise<Verbrauchs
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisGewerbe(id: string): Promise<BedarfsausweisGewerbe | null> {
|
||||
return await prisma.bedarfsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function getAufnahme(id: string): Promise<Aufnahme | null> {
|
||||
return await prisma.aufnahme.findUnique({
|
||||
where: {
|
||||
@@ -31,3 +39,11 @@ export async function getBilder(aufnahme_id: string): Promise<Bild[]> {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function getUnterlagen(aufnahme_id: string): Promise<Unterlage[]> {
|
||||
return await prisma.unterlage.findMany({
|
||||
where: {
|
||||
aufnahme_id
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types.js";
|
||||
import { BASE_URI } from "#lib/constants.js";
|
||||
import { transport } from "#lib/mail.js";
|
||||
import {
|
||||
@@ -32,7 +32,7 @@ export async function sendInvoiceMail(
|
||||
return;
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.id);
|
||||
const ausweisart = getAusweisartFromId(ausweis.id);
|
||||
|
||||
if (!ausweisart) {
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types.js";
|
||||
import { transport } from "#lib/mail.js";
|
||||
import {
|
||||
Benutzer,
|
||||
@@ -32,7 +32,7 @@ export async function sendPaymentSuccessMail(
|
||||
}
|
||||
|
||||
let info: string = "";
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.id);
|
||||
const ausweisart = getAusweisartFromId(ausweis.id);
|
||||
|
||||
if (!ausweisart) {
|
||||
return;
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
AufnahmeClient,
|
||||
BenutzerClient,
|
||||
UnterlageClient,
|
||||
GEGNachweisWohnenClient,
|
||||
BildClient,
|
||||
} from "#components/Ausweis/types.js";
|
||||
import Bereich from "#components/labels/Bereich.svelte";
|
||||
import { Enums } from "#lib/client/prisma.js";
|
||||
import { BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
|
||||
import Progressbar from "#components/Ausweis/Progressbar.svelte";
|
||||
import FileGrid from "#components/FileGrid.svelte";
|
||||
import ButtonWeiterHilfe from "#components/Ausweis/ButtonWeiterHilfe.svelte";
|
||||
@@ -18,57 +17,45 @@
|
||||
import SanierungszustandFensterTueren from "#components/Ausweis/SanierungszustandFensterTueren.svelte";
|
||||
import SanierungszustandWaermedammung from "#components/Ausweis/SanierungszustandWaermedammung.svelte";
|
||||
import AnlagenTechnik from "#components/Ausweis/AnlagenTechnik.svelte";
|
||||
import moment from "moment";
|
||||
|
||||
export let nachweis: GEGNachweisWohnenClient;
|
||||
export let nachweis: BedarfsausweisGewerbe;
|
||||
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 ausweistyp: Enums.AusweisTyp;
|
||||
export let id: string | null;
|
||||
|
||||
if (Object.keys(nachweis).length === 0) {
|
||||
const localStorageAusweis = localStorage.getItem(
|
||||
"geg-nachweis-wohnen.ausweis"
|
||||
);
|
||||
// Falls die Daten im localStorage neuer sind als der Ausweis den wir von der Datenbank bekommen haben, benutzen wir lieber diese.
|
||||
// Wir schauen auch ob der Benutzer nicht vielleicht ein Admin ist, dann sollten wir nichts aus dem localStorage holen.
|
||||
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 localStorageAusweis = localStorage.getItem("geg-nachweis-wohnen.ausweis");
|
||||
if (localStorageAusweis) {
|
||||
nachweis = JSON.parse(localStorageAusweis);
|
||||
nachweis = JSON.parse(localStorageAusweis)
|
||||
nachweis.nachweistyp = ausweistyp;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
bilder = JSON.parse(localStorageUnterlagen)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +99,7 @@
|
||||
{ausweisart}
|
||||
{anliegen}
|
||||
steps={["Gebäudedaten", "Kundendaten", "Anfragebestätigung"]}
|
||||
{ausweistyp}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,90 +1,88 @@
|
||||
---
|
||||
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 VerbrauchsausweisWohnenModule from "#modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte";
|
||||
import { AufnahmeClient, BildClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { Aufnahme, BedarfsausweisGewerbe, Bild, Enums, Objekt, Unterlage, VerbrauchsausweisWohnen } from "#lib/server/prisma";
|
||||
import { getAufnahme, getBedarfsausweisGewerbe, getBilder, getObjekt, getUnterlagen, getVerbrauchsausweisWohnen } from "#lib/server/db";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
import BedarfsausweisGewerbeModule from "#modules/angebot-anfragen/BedarfsausweisGewerbeModule.svelte";
|
||||
|
||||
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: BedarfsausweisGewerbe = {} as BedarfsausweisGewerbe;
|
||||
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["bedarfsausweis-gewerbe"]._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
nachweis = await getBedarfsausweisGewerbe(id) as BedarfsausweisGewerbe
|
||||
|
||||
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) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
|
||||
return Astro.redirect(
|
||||
"/angebot-anfragen/bedarfsausweis-gewerbe-anfragen"
|
||||
);
|
||||
}
|
||||
} catch(e) {
|
||||
if (!nachweis || nachweis.benutzer_id !== user.id) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne ID weiter.
|
||||
return Astro.redirect(
|
||||
"/angebot-anfragen/bedarfsausweis-gewerbe-anfragen"
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
"/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="Bedarfsausweis Gewerbe anfragen">
|
||||
<BedarfsausweisGewerbeModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} />
|
||||
<BedarfsausweisGewerbeModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} {id} {ausweistyp} />
|
||||
</AusweisLayout>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types.js";
|
||||
import { adminMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
||||
import { Enums, prisma } from "#lib/server/prisma";
|
||||
import { Enums, prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { z } from "astro:content";
|
||||
import { fileURLToPath } from "url";
|
||||
@@ -14,17 +12,17 @@ import { PERSISTENT_DIR } from "#lib/server/constants.js";
|
||||
|
||||
export const GET = defineApiRoute({
|
||||
input: z.object({
|
||||
uid_ausweis: z.string(),
|
||||
id_ausweis: z.string(),
|
||||
}),
|
||||
output: z.void(),
|
||||
middleware: adminMiddleware,
|
||||
async fetch({ uid_ausweis }, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(uid);
|
||||
async fetch({ id_ausweis }, context, user) {
|
||||
const ausweisart = getAusweisartFromId(id_ausweis);
|
||||
|
||||
if (ausweisart === "VerbrauchsausweisWohnen") {
|
||||
const ausweis = await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: uid_ausweis,
|
||||
id: id_ausweis
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
@@ -50,7 +48,7 @@ export const GET = defineApiRoute({
|
||||
const rechnung = await prisma.rechnung.findFirst({
|
||||
where: {
|
||||
verbrauchsausweis_wohnen: {
|
||||
uid: uid_ausweis
|
||||
id: id_ausweis
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
@@ -100,7 +98,7 @@ export const GET = defineApiRoute({
|
||||
if (pdfAusweis) {
|
||||
const pdfAusweisPath = fileURLToPath(
|
||||
new URL(
|
||||
`${PERSISTENT_DIR}/generated/Ausweis-${ausweis.uid}.pdf`,
|
||||
`${PERSISTENT_DIR}/generated/Ausweis-${ausweis.id}.pdf`,
|
||||
import.meta.url
|
||||
)
|
||||
);
|
||||
@@ -110,7 +108,7 @@ export const GET = defineApiRoute({
|
||||
if (pdfDatenblatt) {
|
||||
const pdfDatenblattPath = fileURLToPath(
|
||||
new URL(
|
||||
`${PERSISTENT_DIR}/generated/Datenblatt-${ausweis.uid}.pdf`,
|
||||
`${PERSISTENT_DIR}/generated/Datenblatt-${ausweis.id}.pdf`,
|
||||
import.meta.url
|
||||
)
|
||||
);
|
||||
@@ -160,7 +158,7 @@ fax 040 · 209339859
|
||||
<tr><td>IBAN</td><td>:<td>\t DE81 2004 0000 0348 6008 00</td>
|
||||
<tr><td>BIC</td><td>:</td><td>\t COBADEFFXXX</td>
|
||||
<tr><td>Betrag</td><td>:</td><td>\t <b>${rechnung.betrag}€</b></td>
|
||||
<tr><td>Verwendungszweck</td><td>:</td><td>\t <b>${rechnung.uid}</b></td>
|
||||
<tr><td>Verwendungszweck</td><td>:</td><td>\t <b>${rechnung.id}</b></td>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -170,11 +168,11 @@ Alternativ können Sie auch direkt online zahlen indem Sie auf den entsprechende
|
||||
<br>
|
||||
|
||||
<table>
|
||||
<tr><td>Per Einzuglastschrift zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=SEPA'>jetzt per ELV bezahlen</a></td></tr>
|
||||
<tr><td>Per Sofortüberweisung zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Sofort'>jetzt per Sofortüberweisung bezahlen</a></td></tr>
|
||||
<tr><td>Über PayPal zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=PayPal'>jetzt per Paypal bezahlen</a></td></tr>
|
||||
<tr><td>Per Giropay zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Giropay'>jetzt per Giropay bezahlen</a></td></tr>
|
||||
<tr><td>Per Visa oder MasterCard zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Kreditkarte'>jetzt per Kreditkarte bezahlen</a></td></tr>
|
||||
<tr><td>Per Einzuglastschrift zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=SEPA'>jetzt per ELV bezahlen</a></td></tr>
|
||||
<tr><td>Per Sofortüberweisung zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Sofort'>jetzt per Sofortüberweisung bezahlen</a></td></tr>
|
||||
<tr><td>Über PayPal zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=PayPal'>jetzt per Paypal bezahlen</a></td></tr>
|
||||
<tr><td>Per Giropay zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Giropay'>jetzt per Giropay bezahlen</a></td></tr>
|
||||
<tr><td>Per Visa oder MasterCard zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Kreditkarte'>jetzt per Kreditkarte bezahlen</a></td></tr>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -204,7 +202,7 @@ fax 040 · 209339859
|
||||
await transport.sendMail({
|
||||
from: `"IBCornelsen" <info@online-energieausweis.org>`,
|
||||
to: user.email,
|
||||
subject: `Ihr Originalausweis vom Ingenieurbüro Cornelsen (ID: ${ausweis.uid})`,
|
||||
subject: `Ihr Originalausweis vom Ingenieurbüro Cornelsen (ID: ${ausweis.id})`,
|
||||
text,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
getAusweisartFromUUID,
|
||||
getAusweisartFromId,
|
||||
UUidWithPrefix,
|
||||
} from "#components/Ausweis/types.js";
|
||||
import {
|
||||
@@ -26,7 +26,7 @@ export const GET = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: adminMiddleware,
|
||||
async fetch({ uid }, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(uid);
|
||||
const ausweisart = getAusweisartFromId(uid);
|
||||
const adapter = getPrismaAusweisAdapter(
|
||||
uid
|
||||
) as typeof prisma.verbrauchsausweisWohnen;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UUidWithPrefix, getAusweisartFromUUID } from "#components/Ausweis/types.js"
|
||||
import { UUidWithPrefix, getAusweisartFromId } from "#components/Ausweis/types.js"
|
||||
import { Enums } from "#lib/client/prisma.js"
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js"
|
||||
import { mollieClient } from "#lib/mollie.js"
|
||||
@@ -88,7 +88,7 @@ export const PATCH = defineApiRoute({
|
||||
})
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.id)
|
||||
const ausweisart = getAusweisartFromId(ausweis.id)
|
||||
|
||||
if (!ausweisart) {
|
||||
throw new APIError({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAusweisartFromUUID, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { omit } from "#lib/helpers.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
|
||||
@@ -18,7 +18,7 @@ export const PUT = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(input.nachweis_id);
|
||||
const ausweisart = getAusweisartFromId(input.nachweis_id);
|
||||
|
||||
let einpreisung;
|
||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types";
|
||||
import AusweisLayoutPruefung from "#layouts/AusweisLayoutPruefung.astro";
|
||||
import { getPrismaAusweisAdapter } from "#lib/server/ausweis";
|
||||
import { Enums } from "#lib/server/prisma";
|
||||
@@ -16,7 +16,7 @@ if (!uid) {
|
||||
|
||||
const user = await getCurrentUser(Astro)
|
||||
const adapter = getPrismaAusweisAdapter(uid)
|
||||
const ausweisart = getAusweisartFromUUID(uid)
|
||||
const ausweisart = getAusweisartFromId(uid)
|
||||
|
||||
if (!user || !adapter || !ausweisart) {
|
||||
return Astro.redirect("/404")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromUUID, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
|
||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
||||
@@ -14,7 +14,7 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis_id)
|
||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromUUID, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, 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";
|
||||
@@ -16,7 +16,7 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(uidAusweis)
|
||||
const ausweisart = getAusweisartFromId(uidAusweis)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user