dolibarr.preisbot/README.md
data c478e5003b feat: Initial release of PreisBot module v1.0
Automatic sales price adjustment based on purchase prices and profit margin.

Features:
- Weekly cronjob for automatic price updates
- Configurable price source (cheapest/newest supplier)
- Configurable price direction (increase only / both)
- Minimum margin setting (default 20%)
- GlobalNotify integration for dashboard notifications
- Email reports with detailed price changes
- Extrafield "Gewinnaufschlag %" on products
- Price history entries with "PreisBot" label

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-03 12:13:44 +01:00

124 lines
4.1 KiB
Markdown
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PreisBot
Automatische Verkaufspreisanpassung basierend auf Einkaufspreisen und Gewinnaufschlag für Dolibarr ERP/CRM.
## Features
- **Automatische Preisberechnung**: Verkaufspreis = Einkaufspreis × (1 + Aufschlag/100)
- **Wöchentlicher Cronjob**: Läuft automatisch als geplante Aufgabe
- **Flexible Preisquelle**: Günstigster Lieferant oder neuester Lieferantenpreis
- **Sichere Preisanpassung**: Optional nur Preiserhöhungen oder beide Richtungen
- **E-Mail-Berichte**: Detaillierte Übersicht aller Preisänderungen per Mail
- **GlobalNotify Integration**: Dashboard-Benachrichtigungen bei Preisanpassungen (optional)
- **Preishistorie**: Alle Änderungen mit "PreisBot" Label in der Produktpreishistorie
## Anforderungen
- Dolibarr >= 19.0
- PHP >= 7.1
- Produkte müssen zum Verkauf aktiviert sein (tosell = 1)
- Mindestens ein aktiver Lieferantenpreis pro Produkt
## Installation
1. Modul nach `/custom/preisbot/` kopieren
2. In Dolibarr: **Einstellungen → Module → PreisBot** aktivieren
3. Das Extrafeld "Gewinnaufschlag %" wird automatisch auf Produkten erstellt
## Konfiguration
Nach der Aktivierung unter **Einstellungen → Module → PreisBot → Setup**:
### Preisberechnung
| Einstellung | Optionen | Beschreibung |
|-------------|----------|--------------|
| **Einkaufspreis-Quelle** | Günstigster Lieferant (Standard) | Der niedrigste aktive Lieferantenpreis |
| | Neuester Lieferantenpreis | Der zuletzt aktualisierte Lieferantenpreis |
| **Preisanpassung** | Nur Preiserhöhungen (Standard) | Verkaufspreis wird nur erhöht, nie gesenkt |
| | Beide Richtungen | Preis kann steigen und fallen |
| **Mindestaufschlag** | 20% (Standard) | Produkte mit niedrigerem Aufschlag werden ignoriert |
### Benachrichtigungen
| Einstellung | Beschreibung |
|-------------|--------------|
| **E-Mail für Preisbericht** | Empfänger für detaillierte HTML-Reports |
| **GlobalNotify** | Automatisch wenn GlobalNotify-Modul aktiv |
## Verwendung
### Gewinnaufschlag eintragen
1. Produkt öffnen (Produkte/Dienstleistungen → Produkt auswählen)
2. Tab "Weitere Attribute" oder direkt auf der Produktkarte
3. Feld **"Gewinnaufschlag %"** ausfüllen (mindestens 20%)
4. Speichern
**Wichtig:**
- Wert ab 20% eintragen → Produkt wird vom PreisBot verarbeitet
- Feld leer lassen → Produkt wird vom PreisBot ausgeschlossen
- Produkt muss "Zum Verkauf" aktiviert sein
### Beispielrechnung
| Einkaufspreis | Aufschlag | Berechnung | Verkaufspreis |
|---------------|-----------|------------|---------------|
| 100,00 € | 25% | 100 × 1,25 | 125,00 € |
| 50,00 € | 30% | 50 × 1,30 | 65,00 € |
| 200,00 € | 20% | 200 × 1,20 | 240,00 € |
### Cronjob
Der PreisBot läuft automatisch **wöchentlich** als Dolibarr-Cronjob.
Manueller Start möglich unter: **Einstellungen → Geplante Aufgaben → PreisBot - Verkaufspreise aktualisieren → Ausführen**
## E-Mail-Bericht
Bei Preisänderungen wird ein HTML-Report mit folgenden Informationen versendet:
- Zusammenfassung (Aktualisiert, Übersprungen, Fehler)
- Detaillierte Tabelle:
- Produktreferenz und Bezeichnung
- Einkaufspreis
- Aufschlag in %
- Alter und neuer Verkaufspreis
- Differenz in € und %
## Technische Details
### Extrafield
| Attribut | Wert |
|----------|------|
| Code | `preisbot_margin` |
| Typ | Double (10,2) |
| Element | product |
| Mindestens | 20% (durch Konfiguration) |
### Konstanten
| Konstante | Standard | Beschreibung |
|-----------|----------|--------------|
| `PREISBOT_PRICE_SOURCE` | cheapest | Preisquelle (cheapest/newest) |
| `PREISBOT_PRICE_DIRECTION` | up_only | Richtung (up_only/both) |
| `PREISBOT_MIN_MARGIN` | 20 | Mindestaufschlag in % |
| `PREISBOT_MAIL_TO` | (leer) | E-Mail-Empfänger |
### SQL-Abfrage Logik
Produkte werden verarbeitet wenn:
- `preisbot_margin IS NOT NULL`
- `preisbot_margin >= PREISBOT_MIN_MARGIN`
- `tosell = 1` (Zum Verkauf aktiviert)
- Mindestens ein aktiver Lieferantenpreis (`status = 1`, `unitprice > 0`)
## Support
- **Autor**: Alles Watt laeuft / Eduard Wisch
- **E-Mail**: data@data-it-solution.de
## Lizenz
GPLv3 oder (nach Ihrer Wahl) jede spätere Version. Siehe [COPYING](COPYING) für Details.