Simplify finance dashboard overview

This commit is contained in:
2026-06-04 10:42:11 +02:00
parent 37a175551b
commit 40805e0222
6 changed files with 815 additions and 1 deletions
@@ -0,0 +1,258 @@
# Sage Spanien Rclone Upload Anleitung
Stand: 2026-06-03
Ziel: Der Sage-Server in Spanien erzeugt die Sales-CSV lokal und lädt die Datei danach automatisch in den SharePoint-Ordner fuer den Dashboard-Import.
## Zielordner
SharePoint URL:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform/Shared%20Documents/Import/Finance/Spanien
```
Technischer Ordner:
```text
Shared Documents/Import/Finance/Spanien
```
Empfohlener rclone-Zielpfad:
```text
trafag-bi:Import/Finance/Spanien
```
Dabei zeigt `trafag-bi` auf die Dokumentbibliothek `Shared Documents` der SharePoint-Site:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform
```
## Benötigte Dateien Auf Dem Spanien-Server
Empfohlener Ordner:
```text
C:\Trafag\SageSpain
```
Dateien:
```text
Export-SageSpainSalesCsv.ps1
Run-SpainExportAndUpload.ps1
```
Die Dateien liegen im Paket:
```text
SageSpainFinalExportPackage.zip
```
## rclone Installieren
Falls `winget` vorhanden ist:
```powershell
winget install Rclone.Rclone
```
Alternativ rclone ZIP manuell installieren, z.B. nach:
```text
C:\Tools\rclone\rclone.exe
```
Danach testen:
```powershell
rclone version
```
Falls `rclone` nicht im PATH ist, später den vollständigen Pfad verwenden:
```powershell
C:\Tools\rclone\rclone.exe version
```
## rclone Remote Einrichten
Auf dem Spanien-Server:
```powershell
rclone config
```
Empfohlene Eingaben:
```text
n
name> trafag-bi
Storage> onedrive
```
Danach Microsoft Login durchführen.
Wichtig:
- Site: `WorldwideBIPlatform`
- Dokumentbibliothek: `Shared Documents`
- Der rclone-Remote `trafag-bi` soll auf die Dokumentbibliothek `Shared Documents` zeigen.
## rclone Testen
```powershell
rclone lsd trafag-bi:
rclone lsd trafag-bi:"Import"
rclone lsd trafag-bi:"Import/Finance"
rclone lsd trafag-bi:"Import/Finance/Spanien"
```
Wenn der letzte Befehl den Ordner ohne Fehler zeigt, ist der Zielpfad korrekt.
## Manueller Export Ohne Upload
Full Export 2025:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Export-SageSpainSalesCsv.ps1 -ExportMode Full -Year 2025 -OutputDirectory C:\Trafag\SageSpain\out
```
Delta/Range Export:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Export-SageSpainSalesCsv.ps1 -ExportMode Range -DateFilter LineRegistrationDate -FromDate "2026-06-02" -ToDate "2026-06-03" -OutputDirectory C:\Trafag\SageSpain\out
```
Hinweis:
- `ToDate` ist exklusiv.
- Der Zeitraum `"2026-06-02"` bis `"2026-06-03"` exportiert den 2. Juni.
- Für tägliche Deltas ist `LineRegistrationDate` sinnvoll, weil neue oder geänderte Zeilen nach Registrierungsdatum kommen.
## Export Und Upload Zusammen Starten
Standard: täglicher Delta-Lauf, gestern bis heute:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Run-SpainExportAndUpload.ps1
```
Expliziter Zeitraum:
```powershell
.\Run-SpainExportAndUpload.ps1 -ExportMode Range -DateFilter LineRegistrationDate -FromDate "2026-06-02" -ToDate "2026-06-03"
```
Full Export mit Upload:
```powershell
.\Run-SpainExportAndUpload.ps1 -ExportMode Full -Year 2025
```
Wenn rclone nicht im PATH ist:
```powershell
.\Run-SpainExportAndUpload.ps1 -RcloneExe "C:\Tools\rclone\rclone.exe"
```
Wenn der rclone-Remote anders heisst:
```powershell
.\Run-SpainExportAndUpload.ps1 -RcloneRemote "MEIN_REMOTE_NAME"
```
## Was Wird Hochgeladen?
Das Wrapper-Script lädt aus dem neuesten Exportordner:
```text
*.csv
*_summary.txt
```
Ziel:
```text
trafag-bi:Import/Finance/Spanien
```
Das Script ändert keine Daten in Sage und keine Daten in SQL Server.
## Windows Task Scheduler
Empfohlener täglicher Lauf, z.B. 02:00 Uhr:
```powershell
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Trafag\SageSpain\Run-SpainExportAndUpload.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 02:00
Register-ScheduledTask `
-TaskName "Trafag Spain Sage Export Upload" `
-Action $action `
-Trigger $trigger `
-Description "Exports Sage Spain sales CSV and uploads it to SharePoint via rclone"
```
Wenn rclone nicht im PATH ist:
```powershell
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Trafag\SageSpain\Run-SpainExportAndUpload.ps1 -RcloneExe C:\Tools\rclone\rclone.exe"
```
## Kontrolle Nach Dem Lauf
Lokal:
```powershell
Get-ChildItem C:\Trafag\SageSpain\out -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Get-ChildItem C:\Trafag\SageSpain\logs
```
SharePoint:
```powershell
rclone ls trafag-bi:"Import/Finance/Spanien"
```
Im Browser prüfen:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform/Shared%20Documents/Import/Finance/Spanien
```
## Fehlerbilder
`rclone: command not found`
- rclone ist nicht im PATH.
- Lösung: `-RcloneExe "C:\Tools\rclone\rclone.exe"` verwenden.
`directory not found`
- Remote zeigt nicht auf `Shared Documents` oder Zielordner ist anders.
- Mit `rclone lsd trafag-bi:` und `rclone lsd trafag-bi:"Import/Finance"` prüfen.
`Access denied`
- Microsoft Login oder SharePoint-Berechtigung fehlt.
- Der Windows-User des geplanten Tasks muss Zugriff auf rclone-Konfiguration und SharePoint haben.
Leere Delta-Datei:
- Zeitraum prüfen.
- `ToDate` ist exklusiv.
- Bei täglichem Lauf für gestern bis heute ist das korrekt.
@@ -0,0 +1,258 @@
# Sage Spain Rclone Upload Guide
Status: 2026-06-03
Purpose: The Sage server in Spain creates the sales CSV locally and then automatically uploads the file to the SharePoint folder used by the dashboard import.
## Target Folder
SharePoint URL:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform/Shared%20Documents/Import/Finance/Spanien
```
Technical folder:
```text
Shared Documents/Import/Finance/Spanien
```
Recommended rclone target path:
```text
trafag-bi:Import/Finance/Spanien
```
The rclone remote `trafag-bi` should point to the `Shared Documents` document library of this SharePoint site:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform
```
## Required Files On The Spain Server
Recommended folder:
```text
C:\Trafag\SageSpain
```
Required files:
```text
Export-SageSpainSalesCsv.ps1
Run-SpainExportAndUpload.ps1
```
The files are included in:
```text
SageSpainFinalExportPackage.zip
```
## Install rclone
If `winget` is available:
```powershell
winget install Rclone.Rclone
```
Alternatively, install the rclone ZIP manually, for example to:
```text
C:\Tools\rclone\rclone.exe
```
Test the installation:
```powershell
rclone version
```
If `rclone` is not in the PATH, use the full path later:
```powershell
C:\Tools\rclone\rclone.exe version
```
## Configure The rclone Remote
On the Spain server:
```powershell
rclone config
```
Recommended input:
```text
n
name> trafag-bi
Storage> onedrive
```
Then complete the Microsoft login.
Important:
- Site: `WorldwideBIPlatform`
- Document library: `Shared Documents`
- The rclone remote `trafag-bi` should point to the document library `Shared Documents`.
## Test rclone
```powershell
rclone lsd trafag-bi:
rclone lsd trafag-bi:"Import"
rclone lsd trafag-bi:"Import/Finance"
rclone lsd trafag-bi:"Import/Finance/Spanien"
```
If the last command lists the folder without an error, the target path is correct.
## Manual Export Without Upload
Full export for 2025:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Export-SageSpainSalesCsv.ps1 -ExportMode Full -Year 2025 -OutputDirectory C:\Trafag\SageSpain\out
```
Delta/range export:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Export-SageSpainSalesCsv.ps1 -ExportMode Range -DateFilter LineRegistrationDate -FromDate "2026-06-02" -ToDate "2026-06-03" -OutputDirectory C:\Trafag\SageSpain\out
```
Notes:
- `ToDate` is exclusive.
- The range `"2026-06-02"` to `"2026-06-03"` exports June 2.
- For daily delta exports, `LineRegistrationDate` is recommended because it captures newly registered or changed lines.
## Run Export And Upload Together
Default: daily delta run, yesterday until today:
```powershell
Set-ExecutionPolicy -Scope Process Bypass
cd C:\Trafag\SageSpain
.\Run-SpainExportAndUpload.ps1
```
Explicit date range:
```powershell
.\Run-SpainExportAndUpload.ps1 -ExportMode Range -DateFilter LineRegistrationDate -FromDate "2026-06-02" -ToDate "2026-06-03"
```
Full export with upload:
```powershell
.\Run-SpainExportAndUpload.ps1 -ExportMode Full -Year 2025
```
If rclone is not in the PATH:
```powershell
.\Run-SpainExportAndUpload.ps1 -RcloneExe "C:\Tools\rclone\rclone.exe"
```
If the rclone remote has another name:
```powershell
.\Run-SpainExportAndUpload.ps1 -RcloneRemote "YOUR_REMOTE_NAME"
```
## What Gets Uploaded?
The wrapper script uploads these files from the newest export folder:
```text
*.csv
*_summary.txt
```
Target:
```text
trafag-bi:Import/Finance/Spanien
```
The script does not change any data in Sage or SQL Server.
## Windows Task Scheduler
Recommended daily run, for example at 02:00:
```powershell
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Trafag\SageSpain\Run-SpainExportAndUpload.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 02:00
Register-ScheduledTask `
-TaskName "Trafag Spain Sage Export Upload" `
-Action $action `
-Trigger $trigger `
-Description "Exports Sage Spain sales CSV and uploads it to SharePoint via rclone"
```
If rclone is not in the PATH:
```powershell
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Trafag\SageSpain\Run-SpainExportAndUpload.ps1 -RcloneExe C:\Tools\rclone\rclone.exe"
```
## Check After The Run
Local output:
```powershell
Get-ChildItem C:\Trafag\SageSpain\out -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Get-ChildItem C:\Trafag\SageSpain\logs
```
SharePoint via rclone:
```powershell
rclone ls trafag-bi:"Import/Finance/Spanien"
```
Browser check:
```text
https://trafagag.sharepoint.com/sites/WorldwideBIPlatform/Shared%20Documents/Import/Finance/Spanien
```
## Common Issues
`rclone: command not found`
- rclone is not in the PATH.
- Use `-RcloneExe "C:\Tools\rclone\rclone.exe"`.
`directory not found`
- The remote may not point to `Shared Documents`, or the target folder may be different.
- Check with `rclone lsd trafag-bi:` and `rclone lsd trafag-bi:"Import/Finance"`.
`Access denied`
- Microsoft login or SharePoint permissions are missing.
- The Windows user running the scheduled task must have access to the rclone configuration and to SharePoint.
Empty delta file:
- Check the date range.
- `ToDate` is exclusive.
- For a daily run, yesterday until today is correct.