forked from fahrPool/fahrPool
feat: FIN und FIN-Abgleich in Listen, Kanban, Auslastung, Auftragsdetail und PDF anzeigen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eebb9e0e01
commit
5f2af33e3e
|
|
@ -3,6 +3,8 @@ import Link from "next/link";
|
||||||
import { loadAuftrag, findeFolgeauftrag } from "@/lib/auftraege/queries";
|
import { loadAuftrag, findeFolgeauftrag } from "@/lib/auftraege/queries";
|
||||||
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
||||||
import { loadProfile } from "@/lib/auth/profile";
|
import { loadProfile } from "@/lib/auth/profile";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
|
import { finAbgleichText } from "@/lib/auftraege/fin-abgleich";
|
||||||
import { STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
import { STANDARD_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||||||
import { loadAuftragFotos, loadUnterschriftUrl } from "@/lib/auftraege/fotos";
|
import { loadAuftragFotos, loadUnterschriftUrl } from "@/lib/auftraege/fotos";
|
||||||
import { FotoGalerie } from "@/components/auftraege/FotoGalerie";
|
import { FotoGalerie } from "@/components/auftraege/FotoGalerie";
|
||||||
|
|
@ -72,8 +74,28 @@ export default async function AuftragDetailPage({
|
||||||
<dl className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
<dl className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||||
<div>
|
<div>
|
||||||
<dt className="text-sm text-asphalt-grey/70">Fahrzeug</dt>
|
<dt className="text-sm text-asphalt-grey/70">Fahrzeug</dt>
|
||||||
<dd className="text-asphalt-grey">{auftrag.fahrzeug.kennzeichen}</dd>
|
<dd className="text-asphalt-grey">{fahrzeugBezeichnung(auftrag.fahrzeug)}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
{auftrag.fahrzeug.fin && (
|
||||||
|
<div>
|
||||||
|
<dt className="text-sm text-asphalt-grey/70">FIN</dt>
|
||||||
|
<dd className="font-mono text-asphalt-grey">{auftrag.fahrzeug.fin}</dd>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{auftrag.start_fin_status && auftrag.start_fin && (
|
||||||
|
<div>
|
||||||
|
<dt className="text-sm text-asphalt-grey/70">FIN-Abgleich bei Fahrtbeginn</dt>
|
||||||
|
<dd
|
||||||
|
className={
|
||||||
|
auftrag.start_fin_status === "abweichend"
|
||||||
|
? "font-medium text-status-warning"
|
||||||
|
: "text-asphalt-grey"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{finAbgleichText(auftrag.start_fin_status, auftrag.start_fin)}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
<dt className="text-sm text-asphalt-grey/70">Abholort</dt>
|
<dt className="text-sm text-asphalt-grey/70">Abholort</dt>
|
||||||
<dd className="text-asphalt-grey">
|
<dd className="text-asphalt-grey">
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||||
import { createAuftrag, createOrtUndAuswaehlen, createFahrzeugUndAuswaehlen } from "./actions";
|
import { createAuftrag, createOrtUndAuswaehlen, createFahrzeugUndAuswaehlen } from "./actions";
|
||||||
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
||||||
import { loadProfile } from "@/lib/auth/profile";
|
import { loadProfile } from "@/lib/auth/profile";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
import { Card } from "@/components/ui/Card";
|
import { Card } from "@/components/ui/Card";
|
||||||
import { Button } from "@/components/ui/Button";
|
import { Button } from "@/components/ui/Button";
|
||||||
import { Alert } from "@/components/ui/Alert";
|
import { Alert } from "@/components/ui/Alert";
|
||||||
|
|
@ -248,7 +249,7 @@ export default async function NeuerAuftragPage({
|
||||||
</option>
|
</option>
|
||||||
{fahrzeuge.map((fahrzeug) => (
|
{fahrzeuge.map((fahrzeug) => (
|
||||||
<option key={fahrzeug.id} value={fahrzeug.id}>
|
<option key={fahrzeug.id} value={fahrzeug.id}>
|
||||||
{fahrzeug.kennzeichen}
|
{fahrzeugBezeichnung(fahrzeug)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
import type { Auftrag } from "@/lib/auftraege/queries";
|
import type { Auftrag } from "@/lib/auftraege/queries";
|
||||||
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
||||||
import { Card } from "@/components/ui/Card";
|
import { Card } from "@/components/ui/Card";
|
||||||
|
|
@ -43,7 +44,7 @@ export function AuftragListe({
|
||||||
<p className="text-asphalt-grey">
|
<p className="text-asphalt-grey">
|
||||||
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-1 text-sm text-asphalt-grey">{auftrag.fahrzeug.kennzeichen}</p>
|
<p className="mt-1 text-sm text-asphalt-grey">{fahrzeugBezeichnung(auftrag.fahrzeug)}</p>
|
||||||
<p className="mt-1 text-xs text-asphalt-grey/70">
|
<p className="mt-1 text-xs text-asphalt-grey/70">
|
||||||
{formatZeitplanung(auftrag.zeitplanung_typ, auftrag.zeitplanung_zeitpunkt)}
|
{formatZeitplanung(auftrag.zeitplanung_typ, auftrag.zeitplanung_zeitpunkt)}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Card } from "@/components/ui/Card";
|
import { Card } from "@/components/ui/Card";
|
||||||
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
import { formatSeit, istVorHeute, type FahrerAuslastung, type FahrerZustand } from "@/lib/auslastung/auslastung";
|
import { formatSeit, istVorHeute, type FahrerAuslastung, type FahrerZustand } from "@/lib/auslastung/auslastung";
|
||||||
|
|
||||||
const ZUSTAND_LABELS: Record<FahrerZustand, string> = {
|
const ZUSTAND_LABELS: Record<FahrerZustand, string> = {
|
||||||
|
|
@ -20,7 +21,7 @@ const ZUSTAND_CLASSES: Record<FahrerZustand, string> = {
|
||||||
export function FahrerKarte({ eintrag, jetzt }: { eintrag: FahrerAuslastung; jetzt: Date }) {
|
export function FahrerKarte({ eintrag, jetzt }: { eintrag: FahrerAuslastung; jetzt: Date }) {
|
||||||
const { fahrer, zustand, aktuellerAuftrag } = eintrag;
|
const { fahrer, zustand, aktuellerAuftrag } = eintrag;
|
||||||
const fahrzeug = aktuellerAuftrag
|
const fahrzeug = aktuellerAuftrag
|
||||||
? [aktuellerAuftrag.fahrzeug.kennzeichen, aktuellerAuftrag.fahrzeug.marke, aktuellerAuftrag.fahrzeug.modell]
|
? [fahrzeugBezeichnung(aktuellerAuftrag.fahrzeug), aktuellerAuftrag.fahrzeug.marke, aktuellerAuftrag.fahrzeug.modell]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(" ")
|
.join(" ")
|
||||||
: null;
|
: null;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Card } from "@/components/ui/Card";
|
import { Card } from "@/components/ui/Card";
|
||||||
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
import { formatZeitplanung } from "@/lib/auftraege/zeitplanung";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
import {
|
import {
|
||||||
findeTerminueberschneidungen,
|
findeTerminueberschneidungen,
|
||||||
gruppiereNachPlanung,
|
gruppiereNachPlanung,
|
||||||
|
|
@ -54,7 +55,7 @@ export function PlanungsListe({ liste, jetzt }: { liste: FahrerAuslastung[]; jet
|
||||||
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm text-status-neutral">
|
<span className="text-sm text-status-neutral">
|
||||||
{[auftrag.fahrzeug.kennzeichen, auftrag.fahrzeug.marke, auftrag.fahrzeug.modell]
|
{[fahrzeugBezeichnung(auftrag.fahrzeug), auftrag.fahrzeug.marke, auftrag.fahrzeug.modell]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(" ")}
|
.join(" ")}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import type { AuftragStatus } from "@/lib/auftraege/queries";
|
||||||
import type { KanbanAuftrag, KanbanSpalten } from "@/lib/dashboard/queries";
|
import type { KanbanAuftrag, KanbanSpalten } from "@/lib/dashboard/queries";
|
||||||
import type { Role } from "@/lib/auth/roles";
|
import type { Role } from "@/lib/auth/roles";
|
||||||
import { istDragErlaubt } from "@/lib/dashboard/kanban-permissions";
|
import { istDragErlaubt } from "@/lib/dashboard/kanban-permissions";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
import { uebernehmenVomBoard, stornierenVomBoard, zuweisenAnFahrer } from "@/app/dashboard/actions";
|
import { uebernehmenVomBoard, stornierenVomBoard, zuweisenAnFahrer } from "@/app/dashboard/actions";
|
||||||
import { Card } from "@/components/ui/Card";
|
import { Card } from "@/components/ui/Card";
|
||||||
import { StatusBadge } from "@/components/ui/StatusBadge";
|
import { StatusBadge } from "@/components/ui/StatusBadge";
|
||||||
|
|
@ -53,7 +54,12 @@ function KanbanKarte({ auftrag, rolle }: { auftrag: KanbanAuftrag; rolle: Role }
|
||||||
<p className="text-sm text-asphalt-grey">
|
<p className="text-sm text-asphalt-grey">
|
||||||
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-1 text-xs text-asphalt-grey/70">{auftrag.fahrzeug.kennzeichen}</p>
|
<p className="mt-1 text-xs text-asphalt-grey/70">{fahrzeugBezeichnung(auftrag.fahrzeug)}</p>
|
||||||
|
{auftrag.start_fin_status === "abweichend" && (
|
||||||
|
<p className="mt-1 inline-block rounded bg-amber-50 px-2 py-0.5 text-xs font-medium text-status-warning">
|
||||||
|
FIN weicht ab
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
{auftrag.zugewiesener_fahrer && (
|
{auftrag.zugewiesener_fahrer && (
|
||||||
<p className="mt-1 text-xs text-asphalt-grey/70">Fahrer: {auftrag.zugewiesener_fahrer.name}</p>
|
<p className="mt-1 text-xs text-asphalt-grey/70">Fahrer: {auftrag.zugewiesener_fahrer.name}</p>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export function FahrzeugZeile({ fahrzeug }: { fahrzeug: Fahrzeug }) {
|
||||||
>
|
>
|
||||||
<div role="cell">
|
<div role="cell">
|
||||||
<span className="text-xs font-medium text-asphalt-grey md:hidden">Kennzeichen</span>
|
<span className="text-xs font-medium text-asphalt-grey md:hidden">Kennzeichen</span>
|
||||||
<p className="text-asphalt-grey">{fahrzeug.kennzeichen}</p>
|
<p className="text-asphalt-grey">{fahrzeug.kennzeichen ?? "—"}</p>
|
||||||
</div>
|
</div>
|
||||||
<div role="cell" className="mt-2 md:mt-0">
|
<div role="cell" className="mt-2 md:mt-0">
|
||||||
<span className="text-xs font-medium text-asphalt-grey md:hidden">Marke</span>
|
<span className="text-xs font-medium text-asphalt-grey md:hidden">Marke</span>
|
||||||
|
|
@ -78,7 +78,7 @@ export function FahrzeugZeile({ fahrzeug }: { fahrzeug: Fahrzeug }) {
|
||||||
name="kennzeichen"
|
name="kennzeichen"
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
defaultValue={fahrzeug.kennzeichen}
|
defaultValue={fahrzeug.kennzeichen ?? ""}
|
||||||
className={FIELD_CLASSES}
|
className={FIELD_CLASSES}
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,20 @@ export function ProtokollDocument({ props }: { props: ProtokollProps }) {
|
||||||
<Text style={styles.h1}>Übergabeprotokoll {props.auftragsnummer}</Text>
|
<Text style={styles.h1}>Übergabeprotokoll {props.auftragsnummer}</Text>
|
||||||
<View style={styles.row}>
|
<View style={styles.row}>
|
||||||
<Text>Fahrzeug</Text>
|
<Text>Fahrzeug</Text>
|
||||||
<Text>{props.fahrzeugKennzeichen}</Text>
|
<Text>{props.fahrzeug}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
{props.fahrzeugFin && (
|
||||||
|
<View style={styles.row}>
|
||||||
|
<Text>FIN</Text>
|
||||||
|
<Text>{props.fahrzeugFin}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{props.finAbgleich && (
|
||||||
|
<View style={styles.row}>
|
||||||
|
<Text>FIN-Abgleich bei Fahrtbeginn</Text>
|
||||||
|
<Text>{props.finAbgleich}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
<View style={styles.row}>
|
<View style={styles.row}>
|
||||||
<Text>Abholort</Text>
|
<Text>Abholort</Text>
|
||||||
<Text>
|
<Text>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function makeAuftrag(overrides: Partial<Auftrag> = {}): Auftrag {
|
||||||
status: "abgeschlossen",
|
status: "abgeschlossen",
|
||||||
abholort: { id: "o1", adresse: "Hauptstr. 1, Musterstadt", ansprechpartner: "Frau Muster", telefon: null, email: null },
|
abholort: { id: "o1", adresse: "Hauptstr. 1, Musterstadt", ansprechpartner: "Frau Muster", telefon: null, email: null },
|
||||||
zielort: { id: "o2", adresse: "Nebenweg 2, Musterstadt", ansprechpartner: "Herr Beispiel", telefon: null, email: null },
|
zielort: { id: "o2", adresse: "Nebenweg 2, Musterstadt", ansprechpartner: "Herr Beispiel", telefon: null, email: null },
|
||||||
fahrzeug: { id: "f1", kennzeichen: "M-AB 123", marke: null, modell: null },
|
fahrzeug: { id: "f1", kennzeichen: "M-AB 123", fin: "WDB9066331S123456", marke: null, modell: null },
|
||||||
zugewiesen_an: "u1",
|
zugewiesen_an: "u1",
|
||||||
start_zeit: "2026-09-01T08:00:00Z",
|
start_zeit: "2026-09-01T08:00:00Z",
|
||||||
start_km: 1000,
|
start_km: 1000,
|
||||||
|
|
@ -23,6 +23,8 @@ function makeAuftrag(overrides: Partial<Auftrag> = {}): Auftrag {
|
||||||
created_at: "2026-09-01T07:00:00Z",
|
created_at: "2026-09-01T07:00:00Z",
|
||||||
erstellt_von: null,
|
erstellt_von: null,
|
||||||
zugewiesen_an_profil: { id: "u1", name: "Max Fahrer" },
|
zugewiesen_an_profil: { id: "u1", name: "Max Fahrer" },
|
||||||
|
start_fin: null,
|
||||||
|
start_fin_status: null,
|
||||||
...overrides,
|
...overrides,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +36,9 @@ describe("buildProtokollBasisdaten", () => {
|
||||||
auftragsnummer: "A-2026-0001",
|
auftragsnummer: "A-2026-0001",
|
||||||
abholort: { adresse: "Hauptstr. 1, Musterstadt", ansprechpartner: "Frau Muster" },
|
abholort: { adresse: "Hauptstr. 1, Musterstadt", ansprechpartner: "Frau Muster" },
|
||||||
zielort: { adresse: "Nebenweg 2, Musterstadt", ansprechpartner: "Herr Beispiel" },
|
zielort: { adresse: "Nebenweg 2, Musterstadt", ansprechpartner: "Herr Beispiel" },
|
||||||
fahrzeugKennzeichen: "M-AB 123",
|
fahrzeug: "M-AB 123",
|
||||||
|
fahrzeugFin: "WDB9066331S123456",
|
||||||
|
finAbgleich: null,
|
||||||
fahrerName: "Max Fahrer",
|
fahrerName: "Max Fahrer",
|
||||||
startZeit: "2026-09-01T08:00:00Z",
|
startZeit: "2026-09-01T08:00:00Z",
|
||||||
startKm: 1000,
|
startKm: 1000,
|
||||||
|
|
@ -53,4 +57,18 @@ describe("buildProtokollBasisdaten", () => {
|
||||||
const result = buildProtokollBasisdaten(makeAuftrag({ zugewiesen_an_profil: null }));
|
const result = buildProtokollBasisdaten(makeAuftrag({ zugewiesen_an_profil: null }));
|
||||||
expect(result.fahrerName).toBeNull();
|
expect(result.fahrerName).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("nutzt die FIN als Fahrzeug-Bezeichnung, wenn kein Kennzeichen da ist", () => {
|
||||||
|
const result = buildProtokollBasisdaten(
|
||||||
|
makeAuftrag({ fahrzeug: { id: "f1", kennzeichen: null, fin: "WDB9066331S123456", marke: null, modell: null } })
|
||||||
|
);
|
||||||
|
expect(result.fahrzeug).toBe("FIN WDB9066331S123456");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("beschreibt einen abweichenden FIN-Abgleich", () => {
|
||||||
|
const result = buildProtokollBasisdaten(
|
||||||
|
makeAuftrag({ start_fin: "WVWZZZ1KZAW999999", start_fin_status: "abweichend" })
|
||||||
|
);
|
||||||
|
expect(result.finAbgleich).toBe("abweichend – vor Ort: WVWZZZ1KZAW999999");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import type { Auftrag } from "./queries";
|
import type { Auftrag } from "./queries";
|
||||||
|
import { finAbgleichText } from "./fin-abgleich";
|
||||||
|
import { fahrzeugBezeichnung } from "@/lib/orte-fahrzeuge/fahrzeug-bezeichnung";
|
||||||
|
|
||||||
export type ProtokollFoto = {
|
export type ProtokollFoto = {
|
||||||
label: string;
|
label: string;
|
||||||
|
|
@ -11,7 +13,9 @@ export type ProtokollProps = {
|
||||||
auftragsnummer: string;
|
auftragsnummer: string;
|
||||||
abholort: { adresse: string; ansprechpartner: string };
|
abholort: { adresse: string; ansprechpartner: string };
|
||||||
zielort: { adresse: string; ansprechpartner: string };
|
zielort: { adresse: string; ansprechpartner: string };
|
||||||
fahrzeugKennzeichen: string;
|
fahrzeug: string;
|
||||||
|
fahrzeugFin: string | null;
|
||||||
|
finAbgleich: string | null;
|
||||||
fahrerName: string | null;
|
fahrerName: string | null;
|
||||||
startZeit: string | null;
|
startZeit: string | null;
|
||||||
startKm: number | null;
|
startKm: number | null;
|
||||||
|
|
@ -27,7 +31,12 @@ export function buildProtokollBasisdaten(auftrag: Auftrag): Omit<ProtokollProps,
|
||||||
auftragsnummer: auftrag.auftragsnummer,
|
auftragsnummer: auftrag.auftragsnummer,
|
||||||
abholort: { adresse: auftrag.abholort.adresse, ansprechpartner: auftrag.abholort.ansprechpartner },
|
abholort: { adresse: auftrag.abholort.adresse, ansprechpartner: auftrag.abholort.ansprechpartner },
|
||||||
zielort: { adresse: auftrag.zielort.adresse, ansprechpartner: auftrag.zielort.ansprechpartner },
|
zielort: { adresse: auftrag.zielort.adresse, ansprechpartner: auftrag.zielort.ansprechpartner },
|
||||||
fahrzeugKennzeichen: auftrag.fahrzeug.kennzeichen,
|
fahrzeug: fahrzeugBezeichnung(auftrag.fahrzeug),
|
||||||
|
fahrzeugFin: auftrag.fahrzeug.fin,
|
||||||
|
finAbgleich:
|
||||||
|
auftrag.start_fin_status && auftrag.start_fin
|
||||||
|
? finAbgleichText(auftrag.start_fin_status, auftrag.start_fin)
|
||||||
|
: null,
|
||||||
fahrerName: auftrag.zugewiesen_an_profil?.name ?? null,
|
fahrerName: auftrag.zugewiesen_an_profil?.name ?? null,
|
||||||
startZeit: auftrag.start_zeit,
|
startZeit: auftrag.start_zeit,
|
||||||
startKm: auftrag.start_km,
|
startKm: auftrag.start_km,
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,12 @@ export type Ort = {
|
||||||
email: string | null;
|
email: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
import type { FinAbgleich } from "./fin-abgleich";
|
||||||
|
|
||||||
export type Fahrzeug = {
|
export type Fahrzeug = {
|
||||||
id: string;
|
id: string;
|
||||||
kennzeichen: string;
|
kennzeichen: string | null;
|
||||||
|
fin: string | null;
|
||||||
marke: string | null;
|
marke: string | null;
|
||||||
modell: string | null;
|
modell: string | null;
|
||||||
};
|
};
|
||||||
|
|
@ -33,6 +36,8 @@ export type Auftrag = {
|
||||||
start_zeit: string | null;
|
start_zeit: string | null;
|
||||||
start_km: number | null;
|
start_km: number | null;
|
||||||
end_km: number | null;
|
end_km: number | null;
|
||||||
|
start_fin: string | null;
|
||||||
|
start_fin_status: FinAbgleich | null;
|
||||||
uebergabe_bestaetigt_at: string | null;
|
uebergabe_bestaetigt_at: string | null;
|
||||||
empfaenger_name: string | null;
|
empfaenger_name: string | null;
|
||||||
unterschrift_storage_path: string | null;
|
unterschrift_storage_path: string | null;
|
||||||
|
|
@ -43,7 +48,7 @@ export type Auftrag = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const AUFTRAG_SELECT =
|
const AUFTRAG_SELECT =
|
||||||
"id, auftragsnummer, zeitplanung_typ, zeitplanung_zeitpunkt, status, zugewiesen_an, start_zeit, start_km, end_km, uebergabe_bestaetigt_at, empfaenger_name, unterschrift_storage_path, vorgaenger_auftrag_id, created_at, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner, telefon, email), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner, telefon, email), fahrzeug:fahrzeuge(id, kennzeichen, marke, modell), erstellt_von:profiles!auftraege_erstellt_von_fkey(id, name), zugewiesen_an_profil:profiles!auftraege_zugewiesen_an_fkey(id, name)";
|
"id, auftragsnummer, zeitplanung_typ, zeitplanung_zeitpunkt, status, zugewiesen_an, start_zeit, start_km, end_km, start_fin, start_fin_status, uebergabe_bestaetigt_at, empfaenger_name, unterschrift_storage_path, vorgaenger_auftrag_id, created_at, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner, telefon, email), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner, telefon, email), fahrzeug:fahrzeuge(id, kennzeichen, fin, marke, modell), erstellt_von:profiles!auftraege_erstellt_von_fkey(id, name), zugewiesen_an_profil:profiles!auftraege_zugewiesen_an_fkey(id, name)";
|
||||||
|
|
||||||
export async function listOrte(): Promise<Ort[]> {
|
export async function listOrte(): Promise<Ort[]> {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
|
|
@ -58,8 +63,9 @@ export async function listFahrzeuge(): Promise<Fahrzeug[]> {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
.from("fahrzeuge")
|
.from("fahrzeuge")
|
||||||
.select("id, kennzeichen, marke, modell")
|
.select("id, kennzeichen, fin, marke, modell")
|
||||||
.order("kennzeichen");
|
.order("kennzeichen", { nullsFirst: false })
|
||||||
|
.order("fin");
|
||||||
return data ?? [];
|
return data ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ function auftrag(teil: Partial<AuslastungAuftrag> & { id: string }): AuslastungA
|
||||||
created_at: "2026-10-01T08:00:00Z",
|
created_at: "2026-10-01T08:00:00Z",
|
||||||
abholort: { adresse: "Abholstr. 1" },
|
abholort: { adresse: "Abholstr. 1" },
|
||||||
zielort: { adresse: "Zielstr. 2" },
|
zielort: { adresse: "Zielstr. 2" },
|
||||||
fahrzeug: { id: "v1", kennzeichen: "S-AB 123", marke: "Mercedes", modell: "Sprinter" },
|
fahrzeug: { id: "v1", kennzeichen: "S-AB 123", fin: null, marke: "Mercedes", modell: "Sprinter" },
|
||||||
...teil,
|
...teil,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export type AuslastungDaten = {
|
||||||
export type AuslastungErgebnis = { status: "ok"; daten: AuslastungDaten } | { status: "fehler" };
|
export type AuslastungErgebnis = { status: "ok"; daten: AuslastungDaten } | { status: "fehler" };
|
||||||
|
|
||||||
const AUFTRAG_SELECT =
|
const AUFTRAG_SELECT =
|
||||||
"id, auftragsnummer, status, zugewiesen_an, start_zeit, zeitplanung_typ, zeitplanung_zeitpunkt, created_at, abholort:orte!auftraege_abholort_id_fkey(adresse), zielort:orte!auftraege_zielort_id_fkey(adresse), fahrzeug:fahrzeuge(id, kennzeichen, marke, modell)";
|
"id, auftragsnummer, status, zugewiesen_an, start_zeit, zeitplanung_typ, zeitplanung_zeitpunkt, created_at, abholort:orte!auftraege_abholort_id_fkey(adresse), zielort:orte!auftraege_zielort_id_fkey(adresse), fahrzeug:fahrzeuge(id, kennzeichen, fin, marke, modell)";
|
||||||
|
|
||||||
// Ein fehlgeschlagener Teil-Request darf nicht als "keine Daten" erscheinen
|
// Ein fehlgeschlagener Teil-Request darf nicht als "keine Daten" erscheinen
|
||||||
// (wuerde wie "alle Fahrer frei" aussehen), daher Ergebnis-Union statt leerer Listen.
|
// (wuerde wie "alle Fahrer frei" aussehen), daher Ergebnis-Union statt leerer Listen.
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import { createClient } from "@/lib/supabase/server";
|
import { createClient } from "@/lib/supabase/server";
|
||||||
import type { AuftragStatus, Ort, Fahrzeug } from "@/lib/auftraege/queries";
|
import type { AuftragStatus, Ort, Fahrzeug } from "@/lib/auftraege/queries";
|
||||||
|
import type { FinAbgleich } from "@/lib/auftraege/fin-abgleich";
|
||||||
|
|
||||||
export type KanbanAuftrag = {
|
export type KanbanAuftrag = {
|
||||||
id: string;
|
id: string;
|
||||||
status: AuftragStatus;
|
status: AuftragStatus;
|
||||||
zugewiesen_an: string | null;
|
zugewiesen_an: string | null;
|
||||||
|
start_fin_status: FinAbgleich | null;
|
||||||
abholort: Ort;
|
abholort: Ort;
|
||||||
zielort: Ort;
|
zielort: Ort;
|
||||||
fahrzeug: Fahrzeug;
|
fahrzeug: Fahrzeug;
|
||||||
|
|
@ -14,7 +16,7 @@ export type KanbanAuftrag = {
|
||||||
export type KanbanSpalten = Record<AuftragStatus, KanbanAuftrag[]>;
|
export type KanbanSpalten = Record<AuftragStatus, KanbanAuftrag[]>;
|
||||||
|
|
||||||
const KANBAN_AUFTRAG_SELECT =
|
const KANBAN_AUFTRAG_SELECT =
|
||||||
"id, status, zugewiesen_an, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner), fahrzeug:fahrzeuge(id, kennzeichen, marke, modell), zugewiesener_fahrer:profiles!auftraege_zugewiesen_an_fkey(id, name)";
|
"id, status, zugewiesen_an, start_fin_status, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner), fahrzeug:fahrzeuge(id, kennzeichen, fin, marke, modell), zugewiesener_fahrer:profiles!auftraege_zugewiesen_an_fkey(id, name)";
|
||||||
|
|
||||||
const TERMINAL_LIMIT = 20;
|
const TERMINAL_LIMIT = 20;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue