Verbrauchsausweis Wohnen Ausweis fertig
This commit is contained in:
@@ -479,11 +479,11 @@
|
||||
<td><button on:click={() => infoVisible = !infoVisible}><ChevronDown size={22} class="transition-all {infoVisible ? "" : "rotate-180"}"></ChevronDown></button></td>
|
||||
<td class="w-6 px-2"
|
||||
>
|
||||
{#if aufnahme.erledigt}
|
||||
{#if ausweis.ausgestellt}
|
||||
<div class="tooltip" data-tip="Ausweis wurde ausgestellt">
|
||||
<div class="rounded-full w-6 h-6 bg-success"></div>
|
||||
</div>
|
||||
{:else if aufnahme.bestellt}
|
||||
{:else if ausweis.bestellt}
|
||||
<div class="tooltip" data-tip="Ausweis wurde bestellt">
|
||||
<div class="rounded-full w-6 h-6 bg-warning"></div>
|
||||
</div>
|
||||
|
||||
BIN
src/lib/pdf/images/stempel-unterschrift.png
Normal file
BIN
src/lib/pdf/images/stempel-unterschrift.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 503 KiB |
@@ -4,7 +4,7 @@ import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen.js";
|
||||
import { Enums } from "@ibcornelsen/database/server";
|
||||
import * as fs from "fs"
|
||||
import moment from "moment";
|
||||
import { PDFDocument, PDFFont, PDFImage, PDFName, PDFNumber, PDFPage, StandardFonts, TextAlignment } from "pdf-lib";
|
||||
import { PDFDocument, PDFFont, PDFImage, PDFName, PDFNumber, PDFPage, rgb, StandardFonts, TextAlignment } from "pdf-lib";
|
||||
|
||||
|
||||
export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewerbeClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: UploadedGebaeudeBild[], user: BenutzerClient) {
|
||||
@@ -44,80 +44,75 @@ export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewe
|
||||
}
|
||||
|
||||
pages[0].drawText(aufnahme.gebaeudetyp || "", {
|
||||
x: 181,
|
||||
y: height - 191,
|
||||
x: 211,
|
||||
y: height - 166,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(objekt.adresse || "", {
|
||||
x: 181,
|
||||
y: height - 210,
|
||||
x: 211,
|
||||
y: height - 194,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(aufnahme.gebaeudeteil || "", {
|
||||
x: 181,
|
||||
y: height - 226,
|
||||
x: 211,
|
||||
y: height - 214.5,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(aufnahme.baujahr_gebaeude?.toString() || "", {
|
||||
x: 181,
|
||||
y: height - 242.5,
|
||||
x: 211,
|
||||
y: height - 229.5,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(aufnahme.baujahr_heizung?.toString() || "", {
|
||||
x: 181,
|
||||
y: height - 259,
|
||||
x: 211,
|
||||
y: height - 250,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(aufnahme.nutzflaeche?.toString() || "", {
|
||||
x: 181,
|
||||
y: height - 295,
|
||||
x: 211,
|
||||
y: height - 271.5,
|
||||
size: 10
|
||||
})
|
||||
|
||||
pages[0].drawText(`${aufnahme.brennstoff_1}, ${aufnahme.brennstoff_2 || ""}`, {
|
||||
x: 181,
|
||||
y: height - 314,
|
||||
x: 211,
|
||||
y: height - 285,
|
||||
size: 10
|
||||
})
|
||||
|
||||
if (ausweis.warmwasser_enthalten) {
|
||||
pages[0].drawText(`${aufnahme.brennstoff_1}, ${aufnahme.brennstoff_2 || ""}`, {
|
||||
x: 211,
|
||||
y: height - 299,
|
||||
size: 10
|
||||
})
|
||||
}
|
||||
|
||||
function checkbox(page: PDFPage, x: number, y: number) {
|
||||
page.drawSvgPath(`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg>`, {
|
||||
x,
|
||||
y,
|
||||
scale: 0.4,
|
||||
color: rgb(0,0,0)
|
||||
})
|
||||
}
|
||||
|
||||
if (aufnahme.lueftung === Enums.Lueftungskonzept.Fensterlueftung) {
|
||||
checkbox(pages[0], 213, height - 334)
|
||||
} else if (aufnahme.lueftung === Enums.Lueftungskonzept.Schachtlueftung) {
|
||||
checkbox(pages[0], 213, height - 345)
|
||||
} else if (aufnahme.lueftung === Enums.Lueftungskonzept.LueftungsanlageMitWaermerueckgewinnung) {
|
||||
checkbox(pages[0], 355, height - 334)
|
||||
} else if (aufnahme.lueftung === Enums.Lueftungskonzept.LueftungsanlageOhneWaermerueckgewinnung) {
|
||||
checkbox(pages[0], 355, height - 345)
|
||||
}
|
||||
|
||||
|
||||
// const gebaeudetyp = fillFormField("gebaeudetyp", aufnahme.gebaeudetyp || "")
|
||||
|
||||
// const adresse = fillFormField("adresse", objekt.adresse)
|
||||
|
||||
|
||||
// const gebaeudeteil = fillFormField("gebaeudeteil", aufnahme.gebaeudeteil || "")
|
||||
|
||||
// const baujahr_gebaeude = fillFormField("baujahr_gebaeude", aufnahme.baujahr_gebaeude?.toString())
|
||||
|
||||
// const baujahr_heizung = fillFormField("baujahr_heizung", aufnahme.baujahr_heizung?.toString())
|
||||
|
||||
// const einheiten = fillFormField("einheiten", aufnahme.einheiten?.toString())
|
||||
|
||||
// const nutzflaeche = fillFormField("nutzflaeche", `${aufnahme.nutzflaeche?.toString()}m²`)
|
||||
|
||||
// fillFormField("energietraeger_heizung", `${aufnahme.brennstoff_1}, ${aufnahme.brennstoff_2 || ""}`)
|
||||
|
||||
// if (ausweis.warmwasser_enthalten) {
|
||||
// fillFormField("energietraeger_warmwasser", `${aufnahme.brennstoff_1}, ${aufnahme.brennstoff_2 || ""}`)
|
||||
// }
|
||||
|
||||
// toggleCheck("fensterlueftung", aufnahme.lueftung == Enums.Lueftungskonzept.Fensterlueftung)
|
||||
// toggleCheck("schachtlueftung", aufnahme.lueftung == Enums.Lueftungskonzept.Schachtlueftung)
|
||||
// toggleCheck("lueftungsanlage_ohne_waermerueckgewinnung", aufnahme.lueftung == Enums.Lueftungskonzept.LueftungsanlageOhneWaermerueckgewinnung)
|
||||
// toggleCheck("lueftungsanlage_waermerueckgewinnung", aufnahme.lueftung == Enums.Lueftungskonzept.LueftungsanlageMitWaermerueckgewinnung)
|
||||
|
||||
// toggleCheck("anlass_neubau", ausweis.ausstellgrund == "Neubau")
|
||||
// toggleCheck("anlass_vermietung", ausweis.ausstellgrund == "Vermietung" || ausweis.ausstellgrund == "Verkauf")
|
||||
// toggleCheck("anlass_modernisierung", ausweis.ausstellgrund == "Modernisierung")
|
||||
// toggleCheck("anlass_sonstiges", ausweis.ausstellgrund == "Sonstiges")
|
||||
|
||||
|
||||
const gebaeudeBild = bilder.find(image => image.kategorie === Enums.BilderKategorie.Gebaeude);
|
||||
|
||||
@@ -129,10 +124,10 @@ export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewe
|
||||
image = await pdf.embedPng(gebaeudeBild?.base64)
|
||||
}
|
||||
pages[0].drawImage(image, {
|
||||
x: 424.5,
|
||||
y: height - 321,
|
||||
x: 460.5,
|
||||
y: height - 289,
|
||||
width: 111,
|
||||
height: 143
|
||||
height: 138
|
||||
})
|
||||
}
|
||||
|
||||
@@ -368,7 +363,7 @@ export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewe
|
||||
const addEmpfehlungenGenerator = () => {
|
||||
let i = 0;
|
||||
let yOffset = 43;
|
||||
const initialHeight = 568
|
||||
const initialHeight = 562
|
||||
const initialXOffset = 36;
|
||||
return (bauteil?: string, beschreibung?: string, alsEinzelmassnahme?: boolean, amortisationszeit?: string, kosten?: string) => {
|
||||
pages[3].drawText((i + 1).toString(), {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Enums } from "@ibcornelsen/database/server";
|
||||
import * as fs from "fs"
|
||||
import moment from "moment";
|
||||
import { PDFDocument, PDFFont, PDFImage, PDFPage, RotationTypes, StandardFonts, TextAlignment } from "pdf-lib";
|
||||
import { addCheckMark } from "./utils/checkbox.js";
|
||||
|
||||
/* -------------------------------- Pdf Tools ------------------------------- */
|
||||
|
||||
@@ -91,6 +92,48 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
})
|
||||
}
|
||||
|
||||
if (aufnahme.flaeche == 0) {
|
||||
addCheckMark(pages[0], 274, height - 277)
|
||||
}
|
||||
|
||||
// Checkmark Angabe energetische Qualität des Gebäudes.
|
||||
addCheckMark(pages[0], 43, height - 560)
|
||||
|
||||
// Datenerhebung durch Eigentümer
|
||||
addCheckMark(pages[0], 298, height - 590)
|
||||
|
||||
// Ausstellungsdatum
|
||||
pages[0].drawText(moment().format("DD.MM.YYYY"), {
|
||||
font,
|
||||
size: 10,
|
||||
x: 508,
|
||||
y: height - 771
|
||||
})
|
||||
|
||||
// Gültig bis
|
||||
pages[0].drawText(moment().add(10, "years").format("DD.MM.YYYY"), {
|
||||
font: bold,
|
||||
size: 10,
|
||||
x: 90,
|
||||
y: height - 113
|
||||
})
|
||||
|
||||
// Stempel und Unterschrift
|
||||
|
||||
// TODO: ausweis.erledigt
|
||||
if (ausweis.ausgestellt) {
|
||||
const stempel = await pdf.embedPng(fs.readFileSync(new URL("./images/stempel-unterschrift.png", import.meta.url), "base64"));
|
||||
const stempelHeight = 60
|
||||
|
||||
pages[0].drawImage(stempel, {
|
||||
x: 450,
|
||||
y: height - 770,
|
||||
height: stempelHeight,
|
||||
width: stempel.width / (stempel.height / stempelHeight)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------- Seite 2 -------------------------------- */
|
||||
|
||||
|
||||
@@ -112,7 +155,7 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
|
||||
page.drawImage(pfeilNachUnten, {
|
||||
x: endenergieverbrauchTranslationX,
|
||||
y: height - 215,
|
||||
y: height - 212,
|
||||
width: pfeilWidth,
|
||||
height: 30
|
||||
})
|
||||
@@ -149,7 +192,7 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
|
||||
page.drawImage(pfeilNachOben, {
|
||||
x: primaerenergieverbrauchTranslationX,
|
||||
y: height - 298,
|
||||
y: height - 297,
|
||||
width: pfeilWidth,
|
||||
height: 30
|
||||
})
|
||||
@@ -184,6 +227,22 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
|
||||
addEnergieverbrauchSkalaPfeile(pages[2])
|
||||
|
||||
// CO2 Emissionen
|
||||
pages[2].drawText(berechnungen?.co2EmissionenGesamt.toString() || "", {
|
||||
x: 392,
|
||||
y: height - 166.5,
|
||||
font,
|
||||
size: 10
|
||||
})
|
||||
|
||||
// Endenergieverbrauch
|
||||
pages[2].drawText(berechnungen?.endEnergieVerbrauchGesamt.toString() || "", {
|
||||
x: 455,
|
||||
y: height - 326,
|
||||
font,
|
||||
size: 10
|
||||
})
|
||||
|
||||
/* -------------------------------- Seite 3 -------------------------------- */
|
||||
|
||||
// Verbräuche
|
||||
@@ -447,11 +506,21 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
})
|
||||
}
|
||||
|
||||
function addDatumGEG(page: PDFPage, font: PDFFont) {
|
||||
page.drawText("20. Juli 2022", {
|
||||
x: 308,
|
||||
y: page.getHeight() - 70,
|
||||
size: 10,
|
||||
font
|
||||
})
|
||||
}
|
||||
|
||||
for (const page of pages) {
|
||||
addAnsichtsausweisLabel(page, font)
|
||||
addDatumGEG(page, font)
|
||||
}
|
||||
|
||||
// pdf.getForm().flatten()
|
||||
pdf.getForm().flatten()
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
Binary file not shown.
13
src/lib/pdf/utils/checkbox.ts
Normal file
13
src/lib/pdf/utils/checkbox.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { PDFPage, rgb } from "pdf-lib";
|
||||
|
||||
export function addCheckMark(page: PDFPage, x: number, y: number) {
|
||||
page.drawSvgPath(
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg>`,
|
||||
{
|
||||
x,
|
||||
y,
|
||||
scale: 0.4,
|
||||
color: rgb(0, 0, 0),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -113,6 +113,41 @@ export const PUT = defineApiRoute({
|
||||
});
|
||||
}
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
await prisma.bedarfsausweisWohnen.update({
|
||||
where: {
|
||||
uid: ausweis_uid
|
||||
},
|
||||
data: {
|
||||
bestellt: true
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
await prisma.verbrauchsausweisGewerbe.update({
|
||||
where: {
|
||||
uid: ausweis_uid
|
||||
},
|
||||
data: {
|
||||
bestellt: true
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
// Wir müssen überprüfen, ob dem Nutzer der Ausweis tatsächlich gehört.
|
||||
await prisma.verbrauchsausweisWohnen.update({
|
||||
where: {
|
||||
uid: ausweis_uid
|
||||
},
|
||||
data: {
|
||||
bestellt: true
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new APIError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Ausweisart nicht unterstützt.",
|
||||
});
|
||||
}
|
||||
|
||||
if (bezahlmethode === Enums.Bezahlmethoden.rechnung) {
|
||||
return { uid: rechnung.uid }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user