Backend-Arbeitsstand: ERP-Sync, Lieferlebenszyklus, Reports + config.toml
Bringt das Backend vom initialen Skeleton auf den aktuellen Arbeitsstand (Clean Architecture: domain → application → infrastructure → api). Wesentliche Bereiche: - ERP-Anbindung (MSSQL-Pull der Touren, Import-Scheduler, Rückschreiben) - Lieferlebenszyklus: Scan/Hold/Cancel/Complete, Gutschriften, Notizen, Bild-Anhänge, Unterschriften, PDF-Lieferreport → DOCUframe - Stammdaten: Kunden, Artikel, Lager, Zahlungsarten, Services - Keycloak-JWT-Gate + Fahrer-Provisionierung via Admin-API - Admin-API-Key-Gate (X-Admin-Api-Key) für Maschinen-Endpunkte Jüngste Änderungen dieser Session: - Belegspezifische Kontaktdaten: alle ERP-Adressen (Beleg-/Liefer-/ Rechnungsadresse, Ansprechpartner, Kundenstamm) mit Telefon/Mobil/ E-Mail werden gesynct (Migration 0029, MSSQL-Query, TourDetails) - Konfiguration von .env (envy/dotenvy) auf config.toml (toml/serde) umgestellt; Vorlage config.example.toml, Pfad via HOLZLEITNER_CONFIG Nicht im Repo (per .gitignore): config.toml (Secrets), data/ (Laufzeit-/ Kundendaten), demo.mp4, .claude/, variocontrol-ai/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
40
crates/application/src/dto/complete.rs
Normal file
40
crates/application/src/dto/complete.rs
Normal file
@ -0,0 +1,40 @@
|
||||
//! Eingabe für den Lieferungs-Abschluss (`POST /deliveries/{id}/complete`).
|
||||
//!
|
||||
//! Der Endpoint nimmt `multipart/form-data` entgegen — zwei Signatur-PNGs
|
||||
//! plus dieses JSON-Feld mit den Checkbox-Bestätigungen des Kunden. Die
|
||||
//! Antwort ist die frisch abgeschlossene `Delivery` (`DeliveryResponse`).
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Dokumentierte Bestätigungen des Kunden zum Abschlusszeitpunkt.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CompleteDeliveryAcknowledgements {
|
||||
/// „Ware im ordnungsgemäßen Zustand erhalten / Aufbau korrekt." — Pflicht.
|
||||
pub receipt_confirmed: bool,
|
||||
/// „Anmerkungen zur Lieferung zur Kenntnis genommen." — Pflicht nur, wenn
|
||||
/// Notizen existieren (das prüft der Server).
|
||||
#[serde(default)]
|
||||
pub notes_acknowledged: bool,
|
||||
/// Notiz-IDs, die zum Abschlusszeitpunkt sichtbar waren und mit-bestätigt
|
||||
/// wurden (Audit-Robustheit).
|
||||
#[serde(default)]
|
||||
pub acknowledged_note_ids: Vec<Uuid>,
|
||||
/// Inkasso-Bestätigung des Fahrers: „der offene Betrag wurde erhalten
|
||||
/// (bar) bzw. über das EC-Gerät abgerechnet." Pflicht nur, wenn beim
|
||||
/// Abschluss ein offener Betrag > 0 besteht UND die Methode ein Vor-Ort-
|
||||
/// Inkasso ist (Bar/EC) — das prüft der Server. Der kassierte Betrag wird
|
||||
/// server-seitig autoritativ berechnet (nicht vom Client übernommen).
|
||||
#[serde(default)]
|
||||
pub payment_collected: bool,
|
||||
/// Optionale Zahlungsmethode, die der Fahrer beim Abschluss gewählt hat.
|
||||
/// `None` = die am Beleg hinterlegte Methode bleibt. Falls gesetzt, muss
|
||||
/// sie existieren **und** aktiv sein (vom Server geprüft).
|
||||
#[serde(default)]
|
||||
pub payment_method_id: Option<Uuid>,
|
||||
/// Fahrzeug des Akteurs (Audit-Spur). Muss zum Account gehören.
|
||||
#[serde(default)]
|
||||
pub author_car_id: Option<Uuid>,
|
||||
}
|
||||
45
crates/application/src/dto/credit.rs
Normal file
45
crates/application/src/dto/credit.rs
Normal file
@ -0,0 +1,45 @@
|
||||
//! Request/Response für `POST /deliveries/{id}/credit` — die
|
||||
//! Betrags-Gutschrift (append-only, idempotent über `client_event_id`).
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use holzleitner_domain::DeliveryCredit;
|
||||
|
||||
/// Art des Gutschrift-Ereignisses.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CreditAction {
|
||||
/// Gutschrift setzen/ändern — `amount_cents` und `reason` Pflicht.
|
||||
Set,
|
||||
/// Gutschrift entfernen — `amount_cents`/`reason` werden ignoriert.
|
||||
Remove,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeliveryCreditEventRequest {
|
||||
/// Idempotenz-Schlüssel — pro erzeugtem Ereignis genau einmal vergeben.
|
||||
/// Ein Retry mit derselben Id wendet nichts erneut an.
|
||||
pub client_event_id: Uuid,
|
||||
pub action: CreditAction,
|
||||
/// Bei `Set` Pflicht: Betrag in Cent (> 0, ≤ 15000, Vielfaches von 1000).
|
||||
#[serde(default)]
|
||||
pub amount_cents: Option<i64>,
|
||||
/// Bei `Set` Pflicht: Begründung.
|
||||
#[serde(default)]
|
||||
pub reason: Option<String>,
|
||||
/// Fahrzeug des Akteurs (Audit-Spur). Muss zum Account gehören.
|
||||
#[serde(default)]
|
||||
pub author_car_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeliveryCreditResponse {
|
||||
/// Aktueller Stand nach dem Ereignis — `None`, wenn (zuletzt) entfernt.
|
||||
pub credit: Option<DeliveryCredit>,
|
||||
}
|
||||
149
crates/application/src/dto/delivery_report.rs
Normal file
149
crates/application/src/dto/delivery_report.rs
Normal file
@ -0,0 +1,149 @@
|
||||
//! DTO-Aggregat für den PDF-Lieferreport.
|
||||
//!
|
||||
//! Bündelt **alle** Informationen zu einer Lieferung inkl. der beiden
|
||||
//! Audit-Trails (`scan_audit`, `delivery_credit_audit`). Wird vom
|
||||
//! `DeliveryReportRepository` (DB) befüllt; die Bild-Bytes (Unterschriften,
|
||||
//! Anhänge) hängt der Use Case nachträglich aus dem lokalen Speicher an,
|
||||
//! damit der Renderer rein (ohne IO) bleibt.
|
||||
|
||||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DeliveryReportData {
|
||||
pub generated_at: DateTime<Utc>,
|
||||
// Kopf
|
||||
pub belegart_id: i64,
|
||||
/// Belegart-Kurzcode (z. B. „VL5"), falls vom Sync befüllt.
|
||||
pub belegart_code: Option<String>,
|
||||
/// Belegart-Klartext (z. B. „Lieferschein EH").
|
||||
pub belegart_name: Option<String>,
|
||||
pub belegnummer: String,
|
||||
pub state: String,
|
||||
pub tour_date: NaiveDate,
|
||||
pub driver_personalnummer: i64,
|
||||
pub driver_name: String,
|
||||
pub car_plate: Option<String>,
|
||||
pub payment_method: Option<String>,
|
||||
// Kunde + Adresse
|
||||
pub customer_number: i64,
|
||||
pub customer_name: String,
|
||||
pub address: String,
|
||||
pub desired_time: Option<String>,
|
||||
pub special_agreements: Option<String>,
|
||||
pub prepaid_amount: f64,
|
||||
pub current_credit_cents: i64,
|
||||
pub contacts: Vec<ReportContact>,
|
||||
pub items: Vec<ReportItem>,
|
||||
pub services: Vec<ReportService>,
|
||||
pub notes: Vec<ReportNote>,
|
||||
pub completion: Option<ReportCompletion>,
|
||||
pub scan_audit: Vec<ReportScanAudit>,
|
||||
pub credit_audit: Vec<ReportCreditAudit>,
|
||||
pub attachments: Vec<ReportAttachment>,
|
||||
// Bild-Bytes (vom Use Case aus dem lokalen Speicher nachgeladen):
|
||||
pub customer_signature_png: Option<Vec<u8>>,
|
||||
pub driver_signature_png: Option<Vec<u8>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportContact {
|
||||
pub name: String,
|
||||
pub detail: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportItem {
|
||||
pub belegzeilen_nr: i32,
|
||||
pub komponenten_artikel_nr: Option<String>,
|
||||
pub parent_artikel_nr: Option<String>,
|
||||
pub article_number: String,
|
||||
pub name: String,
|
||||
pub required_quantity: i32,
|
||||
pub credited_quantity: i32,
|
||||
pub scanned_quantity: i32,
|
||||
pub scan_status: String,
|
||||
pub unit_price: f64,
|
||||
pub warehouse_code: Option<String>,
|
||||
pub warehouse_name: Option<String>,
|
||||
}
|
||||
|
||||
impl ReportItem {
|
||||
pub fn is_component(&self) -> bool {
|
||||
self.komponenten_artikel_nr.is_some()
|
||||
}
|
||||
/// Tatsächlich ausgeliefert = Soll − Gutschrift.
|
||||
pub fn delivered(&self) -> i32 {
|
||||
(self.required_quantity - self.credited_quantity).max(0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportService {
|
||||
pub name: String,
|
||||
pub bool_value: Option<bool>,
|
||||
pub numeric_value: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportNote {
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub author_personalnummer: i64,
|
||||
pub text: Option<String>,
|
||||
pub image_attachment: Option<String>,
|
||||
pub is_amount_credit_note: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportCompletion {
|
||||
pub completed_at: DateTime<Utc>,
|
||||
pub completed_by_personalnummer: i64,
|
||||
pub receipt_confirmed: bool,
|
||||
pub notes_acknowledged: bool,
|
||||
pub customer_signature_path: String,
|
||||
pub driver_signature_path: String,
|
||||
/// Fahrer hat das Inkasso (Bar/EC) bestätigt.
|
||||
pub payment_collected: bool,
|
||||
/// Snapshot des kassierten offenen Betrags in Cent (None = kein Inkasso).
|
||||
pub collected_amount_cents: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportScanAudit {
|
||||
pub server_recorded_at: DateTime<Utc>,
|
||||
pub client_scanned_at: DateTime<Utc>,
|
||||
pub action: String,
|
||||
pub delta: i32,
|
||||
pub resulting_quantity: i32,
|
||||
pub resulting_status: String,
|
||||
pub reason: Option<String>,
|
||||
pub manual: bool,
|
||||
pub credit_delta: Option<i32>,
|
||||
pub actor_personalnummer: i64,
|
||||
pub belegzeilen_nr: i32,
|
||||
pub komponenten_artikel_nr: Option<String>,
|
||||
pub article_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportCreditAudit {
|
||||
pub recorded_at: DateTime<Utc>,
|
||||
pub action: String,
|
||||
pub amount_cents: i64,
|
||||
pub reason: Option<String>,
|
||||
pub author_personalnummer: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReportAttachment {
|
||||
pub filename: Option<String>,
|
||||
/// Speicher-Referenz (lokaler relativer Pfad) — zum Nachladen der Bytes.
|
||||
pub reference: String,
|
||||
pub mime_type: String,
|
||||
pub size_bytes: i64,
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub uploaded_at: DateTime<Utc>,
|
||||
pub uploaded_by: i64,
|
||||
/// Vom Use Case aus dem lokalen Speicher nachgeladen (fürs Einbetten).
|
||||
pub bytes: Option<Vec<u8>>,
|
||||
}
|
||||
@ -11,10 +11,15 @@
|
||||
//! zweite Schicht handgeschriebener API-DTOs.
|
||||
|
||||
pub mod car;
|
||||
pub mod complete;
|
||||
pub mod credit;
|
||||
pub mod delivery_action;
|
||||
pub mod delivery_report;
|
||||
pub mod delivery_order;
|
||||
pub mod note;
|
||||
pub mod payment_method;
|
||||
pub mod scan;
|
||||
pub mod service;
|
||||
pub mod tour_details;
|
||||
pub mod tour_summary;
|
||||
pub mod tour_sync;
|
||||
@ -22,14 +27,32 @@ pub mod tour_sync;
|
||||
pub use car::{
|
||||
AssignCarRequest, CarResponse, CarsList, CreateCarRequest, UpdateCarRequest,
|
||||
};
|
||||
pub use complete::CompleteDeliveryAcknowledgements;
|
||||
pub use credit::{CreditAction, DeliveryCreditEventRequest, DeliveryCreditResponse};
|
||||
pub use delivery_report::{
|
||||
DeliveryReportData, ReportAttachment, ReportCompletion, ReportContact, ReportCreditAudit,
|
||||
ReportItem, ReportNote, ReportScanAudit, ReportService,
|
||||
};
|
||||
pub use delivery_action::{CancelDeliveryRequest, DeliveryResponse, HoldDeliveryRequest};
|
||||
pub use delivery_order::{
|
||||
DeliveryOrderEntry, SetDeliveryOrderRequest, SetDeliveryOrderResponse,
|
||||
};
|
||||
pub use note::{CreateDeliveryNoteRequest, DeliveryNoteResponse};
|
||||
pub use note::{
|
||||
CreateDeliveryNoteRequest, DeliveryNoteResponse, UpdateDeliveryNoteRequest,
|
||||
};
|
||||
pub use payment_method::{
|
||||
CreatePaymentMethodRequest, PaymentMethodResponse, PaymentMethodsList,
|
||||
UpdatePaymentMethodRequest,
|
||||
};
|
||||
pub use scan::{
|
||||
ApplyScansRequest, ApplyScansResponse, ScanEvent, ScanResult, ScanResultStatus,
|
||||
};
|
||||
pub use service::{
|
||||
CreateServiceRequest, DeliveryServiceResponse, ServiceResponse, ServicesList,
|
||||
SetDeliveryServiceRequest, UpdateServiceRequest,
|
||||
};
|
||||
pub use tour_details::{DeliveryWithItems, TourDetails};
|
||||
pub use tour_summary::TourSummary;
|
||||
pub use tour_sync::{SyncDelivery, SyncDeliveryItem, SyncTourRequest};
|
||||
pub use tour_sync::{
|
||||
SyncContactChannel, SyncContactSource, SyncDelivery, SyncDeliveryItem, SyncTourRequest,
|
||||
};
|
||||
|
||||
@ -19,6 +19,27 @@ pub struct CreateDeliveryNoteRequest {
|
||||
/// Fahrzeug, das die Notiz erzeugt hat. Muss zum angemeldeten
|
||||
/// Account gehören. `None` ist erlaubt.
|
||||
pub author_car_id: Option<Uuid>,
|
||||
/// Optionaler Gutschrift-Bezug: die Belegzeile, für die diese Notiz als
|
||||
/// Gutschrift-Grund angelegt wird. Ermöglicht das gezielte Löschen beim
|
||||
/// Unremove. `None` für normale Notizen.
|
||||
#[serde(default)]
|
||||
pub credit_delivery_item_id: Option<Uuid>,
|
||||
/// `true` markiert die Notiz als Grund einer Betrags-Gutschrift
|
||||
/// (Lieferungs-Ebene). Default `false`.
|
||||
#[serde(default)]
|
||||
pub is_amount_credit_note: bool,
|
||||
}
|
||||
|
||||
/// Request für `PATCH /deliveries/{id}/notes/{note_id}`. Wie beim Create
|
||||
/// muss mindestens eines von `text` / `image_attachment` inhaltlich gefüllt
|
||||
/// sein — geprüft im Use Case.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateDeliveryNoteRequest {
|
||||
pub text: Option<String>,
|
||||
/// Object-Storage-Key oder URL eines vorab hochgeladenen Bildes.
|
||||
pub image_attachment: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
41
crates/application/src/dto/payment_method.rs
Normal file
41
crates/application/src/dto/payment_method.rs
Normal file
@ -0,0 +1,41 @@
|
||||
//! Request- und Antwort-Typen für die Payment-Methods-Endpoints.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use holzleitner_domain::PaymentMethod;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreatePaymentMethodRequest {
|
||||
/// Eindeutiger Programm-Identifier (z. B. `"paypal"`, `"klarna"`).
|
||||
pub code: String,
|
||||
/// Anzeige-Name in der UI.
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdatePaymentMethodRequest {
|
||||
/// Wenn gesetzt: neuer Anzeige-Name.
|
||||
pub name: Option<String>,
|
||||
/// Wenn gesetzt: aktiv/inaktiv. Inaktive Methoden bleiben für
|
||||
/// historische Lieferungen referenzierbar, tauchen aber im
|
||||
/// Default-Listing nicht auf.
|
||||
pub active: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PaymentMethodResponse {
|
||||
pub method: PaymentMethod,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PaymentMethodsList {
|
||||
pub methods: Vec<PaymentMethod>,
|
||||
}
|
||||
@ -27,6 +27,19 @@ pub struct ScanEvent {
|
||||
pub action: AuditAction,
|
||||
/// Pflicht bei `Hold` und `Remove`. Sonst ignoriert.
|
||||
pub reason: Option<String>,
|
||||
/// Menge für `Remove` / `Unremove` (Mengen-Gutschrift): wie viele Stück
|
||||
/// der Belegzeile gutgeschrieben bzw. wieder hergestellt werden.
|
||||
/// `None` = ganze Restmenge (abwärtskompatibel zum bisherigen
|
||||
/// „ganze Zeile entfernen"). Bei `Scan`/`Unscan`/`Hold`/`Unhold`
|
||||
/// ignoriert. Muss, wenn gesetzt, `> 0` sein.
|
||||
#[serde(default)]
|
||||
pub quantity: Option<i32>,
|
||||
/// `true`, wenn der Fahrer die Position **manuell** als geladen bestätigt
|
||||
/// hat (Fallback ohne Barcode-Scan). Wird nur im Audit (`scan_audit.manual`)
|
||||
/// festgehalten; an der Mengen-/Status-Logik ändert es nichts. Default
|
||||
/// `false` (regulärer Barcode-Scan).
|
||||
#[serde(default)]
|
||||
pub manual: bool,
|
||||
pub client_scanned_at: DateTime<Utc>,
|
||||
/// Fahrzeug, in dem der Scan gemacht wurde. Muss zum
|
||||
/// angemeldeten Account gehören. `None` ist erlaubt, schwächt
|
||||
|
||||
73
crates/application/src/dto/service.rs
Normal file
73
crates/application/src/dto/service.rs
Normal file
@ -0,0 +1,73 @@
|
||||
//! Request-/Antwort-Typen für die Services-Endpoints (Stammdaten-CRUD +
|
||||
//! Pro-Lieferung-Wert).
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use holzleitner_domain::{DeliveryServiceValue, Service, ServiceKind};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateServiceRequest {
|
||||
/// Eindeutiger Programm-Identifier (z. B. `"podium_setup"`).
|
||||
pub key: String,
|
||||
pub name: String,
|
||||
pub kind: ServiceKind,
|
||||
/// Nur bei `Numeric` sinnvoll.
|
||||
#[serde(default)]
|
||||
pub min_value: Option<i32>,
|
||||
#[serde(default)]
|
||||
pub max_value: Option<i32>,
|
||||
#[serde(default)]
|
||||
pub sort_order: Option<i32>,
|
||||
}
|
||||
|
||||
/// Teil-Update eines Service. `kind` ist bewusst **nicht** änderbar — ein
|
||||
/// Wechsel boolean↔numeric würde bestehende Pro-Lieferung-Werte ungültig
|
||||
/// machen (dann lieber deaktivieren + neu anlegen).
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateServiceRequest {
|
||||
pub name: Option<String>,
|
||||
pub min_value: Option<i32>,
|
||||
pub max_value: Option<i32>,
|
||||
pub active: Option<bool>,
|
||||
pub sort_order: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServiceResponse {
|
||||
pub service: Service,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServicesList {
|
||||
pub services: Vec<Service>,
|
||||
}
|
||||
|
||||
/// Setzt den Wert eines Service für eine Lieferung (Upsert). Es muss genau
|
||||
/// das zum `ServiceKind` passende Feld gesetzt sein (Use Case prüft das).
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SetDeliveryServiceRequest {
|
||||
#[serde(default)]
|
||||
pub bool_value: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub numeric_value: Option<i32>,
|
||||
#[serde(default)]
|
||||
pub author_car_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeliveryServiceResponse {
|
||||
pub value: DeliveryServiceValue,
|
||||
}
|
||||
@ -10,7 +10,8 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use holzleitner_domain::{
|
||||
Article, Customer, CustomerContact, Delivery, DeliveryItem, DeliveryNote, Tour, Warehouse,
|
||||
Article, ContactChannel, ContactSource, Customer, CustomerContact, Delivery, DeliveryCredit,
|
||||
DeliveryItem, DeliveryNote, DeliveryServiceValue, Service, Tour, Warehouse,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@ -27,6 +28,24 @@ pub struct TourDetails {
|
||||
/// Die App joint clientseitig per `delivery_id`. Reihenfolge:
|
||||
/// pro Lieferung aufsteigend nach `created_at`.
|
||||
pub notes: Vec<DeliveryNote>,
|
||||
/// Aktuelle Betrags-Gutschriften (jüngster Stand pro Lieferung), nur für
|
||||
/// Lieferungen, deren letztes Ereignis `set` war. Join per `delivery_id`.
|
||||
pub credits: Vec<DeliveryCredit>,
|
||||
/// Aktive Service-Definitionen (Stammdaten) — die App rendert daraus
|
||||
/// Phase 4. Bewusst hier mitgeliefert, damit die Detailseite alles aus
|
||||
/// dem Tour-Aggregat hat.
|
||||
pub services: Vec<Service>,
|
||||
/// Pro-Lieferung gesetzte Service-Werte. Join per `delivery_id` +
|
||||
/// `service_id`.
|
||||
pub delivery_services: Vec<DeliveryServiceValue>,
|
||||
/// Alle vom ERP gespiegelten Kontaktquellen aller Lieferungen dieser
|
||||
/// Tour. Die App joint clientseitig per `delivery_id` und gruppiert
|
||||
/// nach `role` (Lieferadresse / Rechnungsadresse / Ansprechpartner /
|
||||
/// Kundenstamm / Belegadresse).
|
||||
pub contact_sources: Vec<ContactSource>,
|
||||
/// Die zu `contact_sources` gehörenden Einzel-Kanäle (Telefon, Mobil,
|
||||
/// E-Mail, Web). Join per `source_id`.
|
||||
pub contact_channels: Vec<ContactChannel>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
use chrono::NaiveDate;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use holzleitner_domain::Address;
|
||||
use holzleitner_domain::{Address, ContactKind, ContactRole};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
@ -29,6 +29,12 @@ pub struct SyncTourRequest {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyncDelivery {
|
||||
pub belegart_id: i64,
|
||||
/// Belegart-Kurzcode (z. B. „VL5"), aus `Belegarten.Belegart` (getrimmt).
|
||||
#[serde(default)]
|
||||
pub belegart_code: Option<String>,
|
||||
/// Belegart-Klartext (z. B. „Lieferschein EH"), aus `Belegarten.Bezeichnung`.
|
||||
#[serde(default)]
|
||||
pub belegart_name: Option<String>,
|
||||
pub belegnummer: String,
|
||||
|
||||
pub erp_customer_id: i64,
|
||||
@ -44,7 +50,62 @@ pub struct SyncDelivery {
|
||||
pub desired_time: Option<String>,
|
||||
pub special_agreements: Option<String>,
|
||||
|
||||
/// Bei Bestellung schon bezahlter Betrag in EUR. Default `0.0`,
|
||||
/// wenn der Kunde alles bei Lieferung zahlt. Der ERP-Sync liefert
|
||||
/// den Wert mit.
|
||||
#[serde(default)]
|
||||
pub prepaid_amount: f64,
|
||||
|
||||
/// Für den Restbetrag gewählte Zahlungsart — Referenz per
|
||||
/// `code` (z. B. `"cash"`, `"invoice"`). Das ERP kennt seine
|
||||
/// Standard-Codes, der Sync-Code resolvet sie zur UUID. Wenn
|
||||
/// `None`, fällt der Backend-Code auf `"cash"` zurück.
|
||||
#[serde(default)]
|
||||
pub payment_method_code: Option<String>,
|
||||
|
||||
pub items: Vec<SyncDeliveryItem>,
|
||||
|
||||
/// Alle vom ERP an diesem Beleg hängenden Kontakt-Adressen (Beleg-/
|
||||
/// Liefer-/Rechnungsadresse, Ansprechpartner, Kundenstamm). Leere
|
||||
/// Quellen (kein einziger ausgefüllter Kanal *und* kein Name) lässt
|
||||
/// der Sync weg.
|
||||
#[serde(default)]
|
||||
pub contact_sources: Vec<SyncContactSource>,
|
||||
}
|
||||
|
||||
/// Eine Adress-Rolle eines Belegs mit Namensblock und allen ausgefüllten
|
||||
/// Telefon-/Mobil-/E-Mail-/Web-Einträgen.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyncContactSource {
|
||||
pub role: ContactRole,
|
||||
#[serde(default)]
|
||||
pub anrede: Option<String>,
|
||||
#[serde(default)]
|
||||
pub titel: Option<String>,
|
||||
#[serde(default)]
|
||||
pub name1: Option<String>,
|
||||
#[serde(default)]
|
||||
pub name2: Option<String>,
|
||||
#[serde(default)]
|
||||
pub name3: Option<String>,
|
||||
#[serde(default)]
|
||||
pub abteilung: Option<String>,
|
||||
#[serde(default)]
|
||||
pub funktion: Option<String>,
|
||||
#[serde(default)]
|
||||
pub channels: Vec<SyncContactChannel>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyncContactChannel {
|
||||
pub kind: ContactKind,
|
||||
/// 1-basiert: spiegelt ERP-Spaltenposition (Telefon → 1, Telefon2 → 2, …).
|
||||
pub position: i16,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
@ -53,7 +114,13 @@ pub struct SyncDelivery {
|
||||
pub struct SyncDeliveryItem {
|
||||
pub belegzeilen_nr: i32,
|
||||
/// Komponenten-Artikelnummer bei aufgelösten Stücklisten, sonst leer.
|
||||
/// Trägt die **eigene** Nummer der Komponente (eindeutig je Belegzeile).
|
||||
pub komponenten_artikel_nr: Option<String>,
|
||||
/// Artikelnummer des **Oberartikels**, zu dem diese Komponente gehört.
|
||||
/// `None` bei Oberartikeln/regulären Zeilen. Erlaubt der App, Komponenten
|
||||
/// unter ihrem Oberartikel einzurücken.
|
||||
#[serde(default)]
|
||||
pub parent_artikel_nr: Option<String>,
|
||||
|
||||
pub article_number: String,
|
||||
pub article_name: String,
|
||||
@ -65,4 +132,9 @@ pub struct SyncDeliveryItem {
|
||||
pub warehouse_name: String,
|
||||
|
||||
pub required_quantity: i32,
|
||||
|
||||
/// Stückpreis (brutto, EUR). Default `0.0`. Liefert der ERP-Sync mit;
|
||||
/// die App rechnet daraus den Warenwert.
|
||||
#[serde(default)]
|
||||
pub unit_price: f64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user