PDF Abrechnung

This commit is contained in:
Moritz Utcke
2025-08-05 09:25:37 -04:00
parent a05c32167e
commit 648ecc5901
9 changed files with 17 additions and 92 deletions

View File

@@ -1,76 +0,0 @@
name: Auto Merge Staging into Main
on:
schedule:
- cron: '0 2 * * *' # 2:00 UTC = 4:00 Europäische Zeit
workflow_dispatch:
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Fetch all branches
run: |
git fetch origin main
git fetch origin staging
- name: Check if main has commits not in staging
id: check
run: |
git fetch origin
if [ $(git rev-list --count origin/staging..origin/main) -gt 0 ]; then
echo "❌ Staging is behind main and requires manual merging."
exit 1
fi
- name: Create PR from staging to main
id: create_pr
run: |
PR_URL=$(gh pr create --base main --head staging --title "Auto-merge staging into main" --body "This PR was created automatically by GitHub Actions. It merges the latest \`staging\` into \`main\`.")
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
PR_NUMBER=$(echo $PR_URL | awk -F'/' '{print $NF}')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge on PR
if: steps.create_pr.outputs.PR_NUMBER != ''
run: |
gh pr merge ${{ steps.create_pr.outputs.PR_NUMBER }} --merge --auto
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify_failure:
needs: merge
if: failure()
runs-on: ubuntu-latest
steps:
- name: Send Discord notification on failure
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"🚨 Auto-Merge fehlgeschlagen! Bitte manuell prüfen: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}
notify_success:
needs: merge
if: success()
runs-on: ubuntu-latest
steps:
- name: Send Discord notification on success
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"✅ Auto-Merge ausgeführt! Ergebnis jetzt auf [GitHub](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) und [online-energieausweis.org](https://online-energieausweis.org) einsehen.\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "benutzer" ADD COLUMN "partner_code" TEXT;

View File

@@ -21,6 +21,7 @@ model Benutzer {
rolle BenutzerRolle @default(USER)
firma String?
lex_office_id String?
partner_code String?
verified Boolean @default(false)

View File

@@ -82,6 +82,7 @@
<summary class="flex justify-between items-center cursor-pointer p-4 bg-gray-100 hover:bg-gray-200">
<span class="font-semibold">{moment(dt).format("MMMM YYYY")}</span>
<div class="flex flex-row gap-4 items-center">
<a href={`/dashboard/abrechnung/monatlich.pdf?d=${moment(dt).format("YYYY-MM")}`} target="_blank" rel="noreferrer noopener">PDF generieren</a>
<span class="text-gray-500">{provisionMonat.toFixed(2)}</span>
<svg class="w-4 h-4 transition-transform duration-300 group-open:rotate-180" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>

View File

@@ -17,6 +17,7 @@ export const BenutzerSchema = z.object({
rolle: z.nativeEnum(BenutzerRolle),
firma: z.string().nullish(),
lex_office_id: z.string().nullish(),
partner_code: z.string().nullish(),
verified: z.boolean(),
created_at: z.date(),
updated_at: z.date(),

View File

@@ -24,7 +24,7 @@ let bestellungen;
if (start.isValid() && end.isValid()) {
bestellungen = await prisma.rechnung.findMany({
where: {
partner_code: "immowelt",
partner_code: benutzer.partner_code,
OR: [
{
verbrauchsausweis_gewerbe: {
@@ -91,7 +91,7 @@ if (start.isValid() && end.isValid()) {
} else {
bestellungen = await prisma.rechnung.findMany({
where: {
partner_code: "immowelt",
partner_code: benutzer.partner_code,
OR: [
{
verbrauchsausweis_gewerbe: {
@@ -153,12 +153,12 @@ if (!startdatum) {
created_at: true,
},
where: {
partner_code: "immowelt",
OR: [
{
verbrauchsausweis_gewerbe: {
ausgestellt: true,
},
partner_code: benutzer.partner_code,
OR: [
{
verbrauchsausweis_gewerbe: {
ausgestellt: true,
},
},
{
bedarfsausweis_wohnen: {

View File

@@ -16,7 +16,7 @@ if (!benutzer) {
let bestellungen = await prisma.rechnung.findMany({
where: {
partner_code: "immowelt",
partner_code: benutzer.partner_code,
OR: [
{
verbrauchsausweis_gewerbe: {

View File

@@ -61,5 +61,5 @@ Astro.cookies.set(API_ACCESS_TOKEN_COOKIE_NAME, accessToken, {
expires: moment().add(30, "minutes").toDate()
})
return Astro.redirect("/dashboard")
return Astro.redirect("/dashboard");
---

View File

@@ -31,7 +31,7 @@ if ((page < 1 || page > totalPageCount) && totalPageCount > 0) {
let result: { id: string; updated_at: Date }[] = [];
// Wir fragen den neuesten Ausweis ab
// Falls der Nutzer ein Admin ist dann kommt der ganz neueste ansonsten der neueste des eingeloggten Benutzers.
if (user.rolle !== Enums.BenutzerRolle.ADMIN || user.rolle === Enums.BenutzerRolle.RESELLER) {
if (user.rolle !== Enums.BenutzerRolle.ADMIN) {
result =
await prisma.$queryRaw`SELECT id, updated_at FROM "VerbrauchsausweisWohnen" WHERE benutzer_id = ${user.id} UNION ALL
SELECT id, updated_at FROM "VerbrauchsausweisGewerbe" WHERE benutzer_id = ${user.id} UNION ALL
@@ -55,7 +55,3 @@ if (result.length > 0) {
return Astro.redirect(`/dashboard/objekte/${result[0].id}?p=${page}`)
}
---
<UserLayout title="Objekte" {user} besteller={null}>
<p>Keine Ausweise konnten gefunden werden.</p>
</UserLayout>