Ausweis, Ausstellung, Adresse
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { Enums, Objekt } from "#lib/client/prisma.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016 } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016.js";
|
||||
import { addNotification } from "#components/Notifications/shared.js";
|
||||
import { addNotification, updateNotification } from "#components/Notifications/shared.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweis_2016_Client } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016_Client.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Client } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016_Client.js";
|
||||
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient;
|
||||
export let aufnahme: AufnahmeKomplettClient;
|
||||
@@ -86,15 +88,15 @@
|
||||
let calculations = null;
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
calculations = endEnergieVerbrauchVerbrauchsausweis_2016(ausweis as VerbrauchsausweisWohnenClient, aufnahme, objekt);
|
||||
calculations = endEnergieVerbrauchVerbrauchsausweis_2016_Client(ausweis as VerbrauchsausweisWohnenClient, aufnahme, objekt);
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
calculations = endEnergieVerbrauchVerbrauchsausweisGewerbe_2016(ausweis as VerbrauchsausweisGewerbeClient, aufnahme, objekt);
|
||||
calculations = endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Client(ausweis as VerbrauchsausweisGewerbeClient, aufnahme, objekt);
|
||||
}
|
||||
|
||||
async function registriernummerAnfordern() {
|
||||
async function registriernummer() {
|
||||
try {
|
||||
const result = await api.admin.registriernummer.GET.fetch({
|
||||
uid: ausweis.id
|
||||
id: ausweis.id
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
@@ -141,7 +143,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function ausweisAusstellen() {
|
||||
async function ausstellen() {
|
||||
const notification = addNotification({
|
||||
message: "Ausweis wird ausgestellt.",
|
||||
subtext: "Der Ausweis wird nun ausgestellt, bitte habe einen Augenblick geduld..",
|
||||
type: "info",
|
||||
timeout: 0,
|
||||
})
|
||||
try {
|
||||
await api.admin.ausstellen.GET.fetch({
|
||||
id_ausweis: ausweis.id
|
||||
@@ -150,8 +158,17 @@
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
ausweis.ausgestellt = true;
|
||||
|
||||
updateNotification(notification, {
|
||||
message: "Ausweis ausgestellt.",
|
||||
subtext: "Der Ausweis wurde erfolgreich ausgestellt.",
|
||||
timeout: 3000,
|
||||
type: "success",
|
||||
})
|
||||
} catch(e) {
|
||||
addNotification({
|
||||
updateNotification(notification, {
|
||||
message: "Das hat nicht geklappt.",
|
||||
subtext: e as string,
|
||||
timeout: 3000,
|
||||
@@ -248,7 +265,7 @@
|
||||
<p class="text-sm font-semibold">Sie haben Hilfe zu diesem Ausweis angefordert. Sie werden innerhalb der nächsten 48 Stunden über die hinterlegte Telefonnummer vom IB Cornelsen kontaktiert.</p>
|
||||
{:else if ausweis.ausweistyp === Enums.AusweisTyp.Offline || ausweis.ausweistyp === Enums.AusweisTyp.OfflineXL}
|
||||
<p class="text-sm font-semibold">Sie haben die offline Variant zu diesem Ausweis angefordert. Bitte übermitteln Sie uns die letzten drei Jahre der Energieabrechnungen Ihres Energieversorgers.</p>
|
||||
{:else}
|
||||
{:else if !ausweis.ausgestellt}
|
||||
<p class="text-sm font-semibold">Der Ausweis wurde von Ihnen freigegeben und befindet sich in Prüfung vom IB Cornelsen</p>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -396,9 +413,9 @@
|
||||
{/if}
|
||||
|
||||
{#if benutzer.rolle === Enums.BenutzerRolle.ADMIN}
|
||||
<button class="button text-sm" on:click={ausweisAusstellen}>A</button>
|
||||
<button class="button text-sm" on:click={ausstellen}>A</button>
|
||||
<button class="button text-sm" on:click={stornieren}>S</button>
|
||||
<button class="button text-sm" on:click={registriernummerAnfordern}>R</button>
|
||||
<button class="button text-sm" on:click={registriernummer}>R</button>
|
||||
{/if}
|
||||
|
||||
<a
|
||||
|
||||
@@ -28,6 +28,12 @@ export function updateNotification(uid: string, updater: Partial<Notification>)
|
||||
value[uid] = { ...defaults, ...value[uid], ...updater } as Notification;
|
||||
return value;
|
||||
})
|
||||
|
||||
if (updater.timeout) {
|
||||
setTimeout(() => {
|
||||
deleteNotification(uid);
|
||||
}, updater.timeout);
|
||||
}
|
||||
}
|
||||
|
||||
export function addNotification(notification: Partial<Notification>): string {
|
||||
|
||||
@@ -61,7 +61,7 @@ function vergleichsWertNichtWohngebaeude(ausweis: VerbrauchsausweisGewerbeClient
|
||||
* @return VerbrauchsausweisGewerbeCalculationResult
|
||||
*/
|
||||
export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016(ausweis: VerbrauchsausweisGewerbeClient, aufnahme: AufnahmeClient, objekt: ObjektClient, klimafaktoren: { month: number, year: number, klimafaktor: number }[]) {
|
||||
if (!aufnahme || !objekt || !ausweis) {
|
||||
if (!aufnahme || !objekt || !ausweis || !klimafaktoren) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,37 @@ import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016 } from "./Verbrauchsau
|
||||
import { Aufnahme, Objekt, VerbrauchsausweisGewerbe } from "#lib/server/prisma.js";
|
||||
import { getKlimafaktoren } from "#lib/Klimafaktoren.js";
|
||||
|
||||
export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server(
|
||||
export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Client(
|
||||
ausweis: VerbrauchsausweisGewerbe,
|
||||
aufnahme: Aufnahme,
|
||||
objekt: Objekt,
|
||||
) {
|
||||
const klimafaktoren = await getKlimafaktoren(
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
let klimafaktoren = await getKlimafaktoren(
|
||||
objekt.plz as string,
|
||||
moment(ausweis.startdatum).toDate(),
|
||||
moment(ausweis.startdatum).add(2, "years").toDate()
|
||||
) || [];
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
);
|
||||
|
||||
if (!klimafaktoren || klimafaktoren.length === 0) {
|
||||
klimafaktoren = [
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year"),
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 1,
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return await endEnergieVerbrauchVerbrauchsausweisGewerbe_2016(ausweis, aufnahme, objekt, klimafaktoren)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,32 @@ export async function endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server(
|
||||
aufnahme: Aufnahme,
|
||||
objekt: Objekt,
|
||||
) {
|
||||
const klimafaktoren = await getKlimafaktorenServer(
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
let klimafaktoren = await getKlimafaktorenServer(
|
||||
objekt.plz as string,
|
||||
moment(ausweis.startdatum).toDate(),
|
||||
moment(ausweis.startdatum).add(2, "years").toDate()
|
||||
) || [];
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
);
|
||||
|
||||
if (klimafaktoren.length === 0) {
|
||||
klimafaktoren = [
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year"),
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 1,
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return await endEnergieVerbrauchVerbrauchsausweisGewerbe_2016(ausweis, aufnahme, objekt, klimafaktoren)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export async function endEnergieVerbrauchVerbrauchsausweis_2016(
|
||||
objekt: ObjektClient,
|
||||
klimafaktoren: {month: number, year: number, klimafaktor: number}[]
|
||||
) {
|
||||
if (!aufnahme || !objekt || !ausweis) {
|
||||
if (!aufnahme || !objekt || !ausweis || !klimafaktoren) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,32 @@ export async function endEnergieVerbrauchVerbrauchsausweis_2016_Client(
|
||||
aufnahme: AufnahmeClient,
|
||||
objekt: ObjektClient,
|
||||
) {
|
||||
const klimafaktoren = await getKlimafaktoren(
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
let klimafaktoren = await getKlimafaktoren(
|
||||
objekt.plz as string,
|
||||
moment(ausweis.startdatum).toDate(),
|
||||
moment(ausweis.startdatum).add(2, "years").toDate()
|
||||
) || [];
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
);
|
||||
|
||||
if (!klimafaktoren || klimafaktoren.length === 0) {
|
||||
klimafaktoren = [
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year"),
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 1,
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt, klimafaktoren)
|
||||
}
|
||||
|
||||
@@ -10,13 +10,39 @@ import { getKlimafaktorenServer } from "#lib/server/klimafaktoren.js";
|
||||
export async function endEnergieVerbrauchVerbrauchsausweis_2016_Server(
|
||||
ausweis: VerbrauchsausweisWohnenClient,
|
||||
aufnahme: AufnahmeClient,
|
||||
objekt: ObjektClient,
|
||||
objekt: ObjektClient
|
||||
) {
|
||||
const klimafaktoren = await getKlimafaktorenServer(
|
||||
const startdatum = moment(ausweis.startdatum);
|
||||
let klimafaktoren = await getKlimafaktorenServer(
|
||||
objekt.plz as string,
|
||||
moment(ausweis.startdatum).toDate(),
|
||||
moment(ausweis.startdatum).add(2, "years").toDate()
|
||||
) || [];
|
||||
startdatum.toDate(),
|
||||
startdatum.add(2, "years").toDate()
|
||||
);
|
||||
|
||||
return await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt, klimafaktoren)
|
||||
if (klimafaktoren.length === 0) {
|
||||
klimafaktoren = [
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year"),
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 1,
|
||||
},
|
||||
{
|
||||
klimafaktor: 1,
|
||||
month: startdatum.get("m"),
|
||||
year: startdatum.get("year") + 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return await endEnergieVerbrauchVerbrauchsausweis_2016(
|
||||
ausweis,
|
||||
aufnahme,
|
||||
objekt,
|
||||
klimafaktoren
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,4 +112,4 @@ export const SERVICES: Record<
|
||||
};
|
||||
|
||||
export const BASE_URI = process.env.NODE_ENV == "production" ? "https://online-energieausweis.org" : "http://localhost:3000";
|
||||
export const LEX_OFFICE_API_KEY = process.env.NODE_ENV == "production" ? "iwQLCU_ZAq6bVV7hmR8RO8MiC8Q" : "znjmkmbA3Hbx9dC7wdKp7TnOf1pcRl_tCUwEBZys7bj-QRPG"
|
||||
export const LEX_OFFICE_API_KEY = process.env.NODE_ENV == "production" ? "iwQLCU_ZAq6bVV7hmR8RO8MiC8Q" : "iwQLCU_ZAq6bVV7hmR8RO8MiC8Q"
|
||||
@@ -5,7 +5,7 @@ import { xml2pdf } from "./elements/xml2pdf.js";
|
||||
import moment from "moment";
|
||||
import { Enums, Heizungsstatus } from "#lib/server/prisma.js";
|
||||
import { copyPage } from "./utils/copyPage.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016_Client.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016_Server.js";
|
||||
|
||||
/* -------------------------------- Pdf Tools ------------------------------- */
|
||||
|
||||
|
||||
@@ -333,8 +333,5 @@ export async function pdfDatenblattVerbrauchsausweisWohnen(ausweis: Verbrauchsau
|
||||
await layoutPage2.draw(pages[1], 0, pages[1].getHeight())
|
||||
await layoutPage3.draw(pages[2], 0, pages[2].getHeight())
|
||||
|
||||
console.log("DONE");
|
||||
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { addCheckMark } from "./utils/checkbox.js";
|
||||
import { addText } from "./utils/text.js";
|
||||
import { addAnsichtsausweisLabel, addDatumGEG } from "./utils/helpers.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016_Client.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016_Server } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016_Server.js";
|
||||
|
||||
|
||||
export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewerbeClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient, vorschau = true) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { AufnahmeClient, BenutzerClient, BildClient, ObjektClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { endEnergieVerbrauchVerbrauchsausweis_2016 } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.js";
|
||||
import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen.js";
|
||||
import { Enums } from "#lib/server/prisma.js";
|
||||
import * as fs from "fs"
|
||||
@@ -21,7 +20,6 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
// const template = VerbrauchsausweisWohnen2016Template as Template;
|
||||
|
||||
const berechnungen = await endEnergieVerbrauchVerbrauchsausweis_2016_Server(ausweis, aufnahme, objekt);
|
||||
console.log(berechnungen?.klimafaktoren);
|
||||
|
||||
const empfehlungen = getEmpfehlungen(ausweis, aufnahme, objekt)
|
||||
|
||||
|
||||
@@ -8,6 +8,26 @@ export async function getVerbrauchsausweisWohnen(id: string): Promise<Verbrauchs
|
||||
})
|
||||
}
|
||||
|
||||
export async function getVerbrauchsausweisWohnenKomplett(id: string) {
|
||||
return await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
where: {
|
||||
id
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function getVerbrauchsausweisGewerbe(id: string): Promise<VerbrauchsausweisGewerbe | null> {
|
||||
return await prisma.verbrauchsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
@@ -16,6 +36,26 @@ export async function getVerbrauchsausweisGewerbe(id: string): Promise<Verbrauch
|
||||
})
|
||||
}
|
||||
|
||||
export async function getVerbrauchsausweisGewerbeKomplett(id: string) {
|
||||
return await prisma.verbrauchsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
id
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisWohnen(id: string): Promise<BedarfsausweisWohnen | null> {
|
||||
return await prisma.bedarfsausweisWohnen.findUnique({
|
||||
where: {
|
||||
@@ -24,6 +64,26 @@ export async function getBedarfsausweisWohnen(id: string): Promise<Bedarfsauswei
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisWohnenKomplett(id: string) {
|
||||
return await prisma.bedarfsausweisWohnen.findUnique({
|
||||
where: {
|
||||
id
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisGewerbe(id: string): Promise<BedarfsausweisGewerbe | null> {
|
||||
return await prisma.bedarfsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -86,7 +86,7 @@ export async function createInvoice(ausweis: VerbrauchsausweisWohnen, rechnung:
|
||||
},
|
||||
"address": {
|
||||
"contactId": user.lex_office_id,
|
||||
"name": rechnung.empfaenger,
|
||||
"name": rechnung.empfaenger || "----",
|
||||
"street": rechnung.strasse,
|
||||
"city": rechnung.ort,
|
||||
"zip": rechnung.plz,
|
||||
@@ -174,13 +174,12 @@ export async function createInvoice(ausweis: VerbrauchsausweisWohnen, rechnung:
|
||||
const response_id = invoice["id"];
|
||||
|
||||
const request = await fetch(`https://api.lexoffice.io/v1/invoices/${response_id}`, {
|
||||
method: "POSGETT",
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: `application/json`,
|
||||
Authorization: `Bearer ${LEX_OFFICE_API_KEY}`,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}
|
||||
})
|
||||
|
||||
const abfrage_response = await request.json()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import Carousel from "#components/Carousel.svelte";
|
||||
import DashboardAusweis from "#components/Dashboard/DashboardAusweis.svelte";
|
||||
import DashboardNachweis from "#components/Dashboard/DashboardNachweis.svelte";
|
||||
import NotificationProvider from "#components/NotificationProvider/NotificationProvider.svelte";
|
||||
import NotificationWrapper from "#components/Notifications/NotificationWrapper.svelte";
|
||||
import { Objekt } from "#lib/client/prisma.js";
|
||||
import mime from "mime"
|
||||
import { ChevronLeft, ChevronRight, FileText } from "radix-svelte-icons";
|
||||
@@ -96,5 +96,5 @@
|
||||
</div>
|
||||
|
||||
<div class="fixed bottom-8 right-8 flex flex-col gap-4">
|
||||
<NotificationProvider component={AusweisPruefenNotification}></NotificationProvider>
|
||||
<NotificationWrapper></NotificationWrapper>
|
||||
</div>
|
||||
@@ -20,6 +20,7 @@ import { PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { s3Client } from "#lib/s3.js";
|
||||
import { createInvoice } from "#lib/server/invoice.js";
|
||||
import { tryCatch } from "#lib/tryCatch.js";
|
||||
import { getBedarfsausweisWohnenKomplett, getVerbrauchsausweisGewerbeKomplett, getVerbrauchsausweisWohnenKomplett } from "#lib/server/db.js";
|
||||
|
||||
export const GET = defineApiRoute({
|
||||
input: z.object({
|
||||
@@ -46,59 +47,11 @@ export const GET = defineApiRoute({
|
||||
| null = null;
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
where: {
|
||||
id: id_ausweis,
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisWohnenKomplett(id_ausweis)
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await prisma.verbrauchsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
id: id_ausweis,
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisGewerbeKomplett(id_ausweis)
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
ausweis = await prisma.bedarfsausweisWohnen.findUnique({
|
||||
where: {
|
||||
id: id_ausweis,
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
include: {
|
||||
bilder: true,
|
||||
objekt: {
|
||||
include: {
|
||||
benutzer: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
ausweis = await getBedarfsausweisWohnenKomplett(id_ausweis)
|
||||
}
|
||||
|
||||
if (!ausweis) {
|
||||
@@ -273,5 +226,34 @@ fax 040 · 209339859
|
||||
subject: `Ihr Originalausweis vom Ingenieurbüro Cornelsen (ID: ${ausweis.id})`,
|
||||
text,
|
||||
});
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
await prisma.verbrauchsausweisWohnen.update({
|
||||
where: {
|
||||
id: ausweis.id
|
||||
},
|
||||
data: {
|
||||
ausgestellt: true
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
await prisma.verbrauchsausweisGewerbe.update({
|
||||
where: {
|
||||
id: ausweis.id
|
||||
},
|
||||
data: {
|
||||
ausgestellt: true
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
await prisma.bedarfsausweisWohnen.update({
|
||||
where: {
|
||||
id: ausweis.id
|
||||
},
|
||||
data: {
|
||||
ausgestellt: true,
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,10 +7,7 @@ import {
|
||||
authorizationHeaders,
|
||||
} from "#lib/middleware/authorization.js";
|
||||
import {
|
||||
BedarfsausweisWohnen,
|
||||
Enums,
|
||||
VerbrauchsausweisGewerbe,
|
||||
VerbrauchsausweisWohnen,
|
||||
} from "#lib/server/prisma.js";
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
@@ -21,14 +18,14 @@ import { getPrismaAusweisAdapter } from "#lib/server/ausweis.js";
|
||||
|
||||
export const GET = defineApiRoute({
|
||||
input: z.object({
|
||||
uid: UUidWithPrefix,
|
||||
id: UUidWithPrefix,
|
||||
}),
|
||||
headers: authorizationHeaders,
|
||||
middleware: adminMiddleware,
|
||||
async fetch({ uid }, context, user) {
|
||||
const ausweisart = getAusweisartFromId(uid);
|
||||
async fetch({ id }, context, user) {
|
||||
const ausweisart = getAusweisartFromId(id);
|
||||
const adapter = getPrismaAusweisAdapter(
|
||||
uid
|
||||
id
|
||||
) as typeof prisma.verbrauchsausweisWohnen;
|
||||
|
||||
if (!adapter) {
|
||||
@@ -40,7 +37,7 @@ export const GET = defineApiRoute({
|
||||
|
||||
const ausweis = await adapter.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
@@ -193,7 +190,7 @@ export const GET = defineApiRoute({
|
||||
adapter as typeof prisma.verbrauchsausweisWohnen
|
||||
).update({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
registriernummer:
|
||||
|
||||
@@ -101,6 +101,19 @@ export const PUT = defineApiRoute({
|
||||
betrag,
|
||||
bezahlmethode: bezahlmethode,
|
||||
status: Enums.Rechnungsstatus.open,
|
||||
abweichende_versand_adresse: input.abweichende_versand_adresse,
|
||||
email: input.email,
|
||||
empfaenger: input.empfaenger,
|
||||
ort: input.ort,
|
||||
plz: input.plz,
|
||||
strasse: input.strasse,
|
||||
telefon: input.telefon,
|
||||
versand_ort: input.versand_ort,
|
||||
versand_empfaenger: input.versand_empfaenger,
|
||||
versand_plz: input.versand_plz,
|
||||
versand_strasse: input.versand_strasse,
|
||||
versand_zusatzzeile: input.versand_zusatzzeile,
|
||||
zusatzzeile: input.zusatzzeile,
|
||||
verbrauchsausweis_wohnen: {
|
||||
connect: {
|
||||
id: ausweis_id
|
||||
@@ -118,6 +131,19 @@ export const PUT = defineApiRoute({
|
||||
betrag,
|
||||
bezahlmethode: bezahlmethode,
|
||||
status: Enums.Rechnungsstatus.open,
|
||||
abweichende_versand_adresse: input.abweichende_versand_adresse,
|
||||
email: input.email,
|
||||
empfaenger: input.empfaenger,
|
||||
ort: input.ort,
|
||||
plz: input.plz,
|
||||
strasse: input.strasse,
|
||||
telefon: input.telefon,
|
||||
versand_ort: input.versand_ort,
|
||||
versand_empfaenger: input.versand_empfaenger,
|
||||
versand_plz: input.versand_plz,
|
||||
versand_strasse: input.versand_strasse,
|
||||
versand_zusatzzeile: input.versand_zusatzzeile,
|
||||
zusatzzeile: input.zusatzzeile,
|
||||
verbrauchsausweis_gewerbe: {
|
||||
connect: {
|
||||
id: ausweis_id
|
||||
@@ -135,6 +161,19 @@ export const PUT = defineApiRoute({
|
||||
betrag,
|
||||
bezahlmethode: bezahlmethode,
|
||||
status: Enums.Rechnungsstatus.open,
|
||||
abweichende_versand_adresse: input.abweichende_versand_adresse,
|
||||
email: input.email,
|
||||
empfaenger: input.empfaenger,
|
||||
ort: input.ort,
|
||||
plz: input.plz,
|
||||
strasse: input.strasse,
|
||||
telefon: input.telefon,
|
||||
versand_ort: input.versand_ort,
|
||||
versand_empfaenger: input.versand_empfaenger,
|
||||
versand_plz: input.versand_plz,
|
||||
versand_strasse: input.versand_strasse,
|
||||
versand_zusatzzeile: input.versand_zusatzzeile,
|
||||
zusatzzeile: input.zusatzzeile,
|
||||
bedarfsausweis_wohnen: {
|
||||
connect: {
|
||||
id: ausweis_id
|
||||
|
||||
Reference in New Issue
Block a user