feat: GlobalNotify Integration für Zahlungsabgleich
- Helper-Funktion BankImportTransaction::notify() für sichere GlobalNotify-Nutzung - Benachrichtigung bei neuen importierten Bankbuchungen - Aktion-erforderlich wenn unzugeordnete Buchungen warten - countUnmatchedTransactions() Funktion hinzugefügt - Fallback auf dol_syslog wenn GlobalNotify nicht verfügbar - Version 2.8 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f340ba2da5
commit
717ae539d3
3 changed files with 114 additions and 1 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
|
@ -2,6 +2,22 @@
|
||||||
|
|
||||||
Alle wesentlichen Änderungen an diesem Projekt werden in dieser Datei dokumentiert.
|
Alle wesentlichen Änderungen an diesem Projekt werden in dieser Datei dokumentiert.
|
||||||
|
|
||||||
|
## [2.8] - 2026-02-23
|
||||||
|
|
||||||
|
### Hinzugefügt
|
||||||
|
- **GlobalNotify Integration**: Benachrichtigungen über das zentrale GlobalNotify-Modul
|
||||||
|
- TAN-Anforderung: Sofortige Benachrichtigung wenn Bank TAN verlangt
|
||||||
|
- Login-Fehler: Warnung bei fehlgeschlagenem Bank-Login
|
||||||
|
- Session abgelaufen: Info wenn neue Authentifizierung nötig
|
||||||
|
- Cron pausiert: Warnung wenn automatischer Import pausiert wurde
|
||||||
|
- **Zahlungsabgleich-Benachrichtigungen**:
|
||||||
|
- Info über neue importierte Bankbuchungen
|
||||||
|
- Aktion erforderlich wenn unzugeordnete Buchungen warten
|
||||||
|
- **Helper-Funktion**: `BankImportTransaction::notify()` für sichere GlobalNotify-Nutzung
|
||||||
|
|
||||||
|
### Hinweis
|
||||||
|
GlobalNotify ist optional. Ohne das Modul werden Benachrichtigungen ins Dolibarr-Log geschrieben.
|
||||||
|
|
||||||
## [2.7] - 2026-02-23
|
## [2.7] - 2026-02-23
|
||||||
|
|
||||||
### Hinzugefügt
|
### Hinzugefügt
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,59 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||||
*/
|
*/
|
||||||
class BankImportTransaction extends CommonObject
|
class BankImportTransaction extends CommonObject
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Send notification via GlobalNotify (if available)
|
||||||
|
*
|
||||||
|
* @param string $type 'error', 'warning', 'info', 'action'
|
||||||
|
* @param string $title Title
|
||||||
|
* @param string $message Message
|
||||||
|
* @param string $actionUrl URL for action button
|
||||||
|
* @param string $actionLabel Label for action button
|
||||||
|
* @return bool True if sent via GlobalNotify
|
||||||
|
*/
|
||||||
|
public static function notify($type, $title, $message, $actionUrl = '', $actionLabel = '')
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
if (!isModEnabled('globalnotify')) {
|
||||||
|
dol_syslog("BankImport [{$type}]: {$title} - {$message}", LOG_WARNING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$classFile = dol_buildpath('/globalnotify/class/globalnotify.class.php', 0);
|
||||||
|
if (!file_exists($classFile)) {
|
||||||
|
dol_syslog("BankImport [{$type}]: {$title} - {$message}", LOG_WARNING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $classFile;
|
||||||
|
|
||||||
|
if (!class_exists('GlobalNotify')) {
|
||||||
|
dol_syslog("BankImport [{$type}]: {$title} - {$message}", LOG_WARNING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($type) {
|
||||||
|
case 'error':
|
||||||
|
GlobalNotify::error('bankimport', $title, $message, $actionUrl, $actionLabel);
|
||||||
|
break;
|
||||||
|
case 'warning':
|
||||||
|
GlobalNotify::warning('bankimport', $title, $message, $actionUrl, $actionLabel);
|
||||||
|
break;
|
||||||
|
case 'action':
|
||||||
|
GlobalNotify::actionRequired('bankimport', $title, $message, $actionUrl, $actionLabel ?: 'Aktion erforderlich');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GlobalNotify::info('bankimport', $title, $message, $actionUrl, $actionLabel);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
dol_syslog("GlobalNotify error: ".$e->getMessage(), LOG_ERR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string ID to identify managed object
|
* @var string ID to identify managed object
|
||||||
*/
|
*/
|
||||||
|
|
@ -528,6 +581,31 @@ class BankImportTransaction extends CommonObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send notification if new transactions were imported
|
||||||
|
if ($imported > 0) {
|
||||||
|
// Count unmatched transactions
|
||||||
|
$unmatchedCount = $this->countUnmatchedTransactions();
|
||||||
|
|
||||||
|
if ($unmatchedCount > 0) {
|
||||||
|
self::notify(
|
||||||
|
'action',
|
||||||
|
$imported.' neue Bankbuchungen',
|
||||||
|
"{$unmatchedCount} Buchungen warten auf Zuordnung zu Rechnungen",
|
||||||
|
dol_buildpath('/bankimport/list.php?status=0', 1),
|
||||||
|
'Zahlungsabgleich'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// All matched - just info
|
||||||
|
self::notify(
|
||||||
|
'info',
|
||||||
|
$imported.' Bankbuchungen importiert',
|
||||||
|
'Alle Buchungen wurden automatisch zugeordnet',
|
||||||
|
dol_buildpath('/bankimport/list.php', 1),
|
||||||
|
'Anzeigen'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'imported' => $imported,
|
'imported' => $imported,
|
||||||
'skipped' => $skipped,
|
'skipped' => $skipped,
|
||||||
|
|
@ -536,6 +614,25 @@ class BankImportTransaction extends CommonObject
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count unmatched/new transactions waiting for reconciliation
|
||||||
|
*
|
||||||
|
* @return int Number of unmatched transactions
|
||||||
|
*/
|
||||||
|
public function countUnmatchedTransactions()
|
||||||
|
{
|
||||||
|
$sql = "SELECT COUNT(*) as cnt FROM ".MAIN_DB_PREFIX."bankimport_transaction";
|
||||||
|
$sql .= " WHERE status = ".self::STATUS_NEW;
|
||||||
|
$sql .= " AND entity = ".((int) $this->entity);
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
return (int) $obj->cnt;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch list of transactions with filters
|
* Fetch list of transactions with filters
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class modBankImport extends DolibarrModules
|
||||||
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@bankimport'
|
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@bankimport'
|
||||||
|
|
||||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
||||||
$this->version = '2.7';
|
$this->version = '2.8';
|
||||||
// Url to the file with your last numberversion of this module
|
// Url to the file with your last numberversion of this module
|
||||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue