From ec2c55d058fbc4cd7832d6ccfa547503aeddd13d Mon Sep 17 00:00:00 2001 From: bsiggel Date: Sun, 25 Jan 2026 18:39:26 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Implement=20logging=20for=20Mietinkasso?= =?UTF-8?q?=20and=20K=C3=BCndigung=20actions=20in=20CVmhMietverhltnis=20se?= =?UTF-8?q?rvice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Custom/Services/CVmhMietverhltnis.php | 39 ++++++++++++++++++- data/config.php | 4 +- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/custom/Espo/Custom/Services/CVmhMietverhltnis.php b/custom/Espo/Custom/Services/CVmhMietverhltnis.php index 5d6cd9ea..3eabd4cf 100644 --- a/custom/Espo/Custom/Services/CVmhMietverhltnis.php +++ b/custom/Espo/Custom/Services/CVmhMietverhltnis.php @@ -4,6 +4,8 @@ namespace Espo\Custom\Services; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Exceptions\NotFound; +use Espo\Tools\Stream\Service as StreamService; +use Espo\Entities\Note; class CVmhMietverhltnis extends \Espo\Services\Record { @@ -189,7 +191,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record ->relate($contact); } - // 12. Commit transaction + // 12. Log to stream + $this->logToStream($mietverhaeltnis, 'CVmhMietverhltnis', $mietinkasso->getId(), 'CMietinkasso', 'Mietinkasso erstellen'); + + // 13. Commit transaction $this->entityManager->getTransactionManager()->commit(); return [ @@ -330,7 +335,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record ->relate($contact); } - // 11. Commit transaction + // 11. Log to stream + $this->logToStream($mietverhaeltnis, 'CVmhMietverhltnis', $kuendigung->getId(), 'CKuendigung', 'Kündigung erstellen'); + + // 12. Commit transaction $this->entityManager->getTransactionManager()->commit(); return [ @@ -343,4 +351,31 @@ class CVmhMietverhltnis extends \Espo\Services\Record throw $e; } } + + /** + * Log action to source entity stream + * + * @param object $sourceEntity Source entity (Mietverhältnis) + * @param string $sourceEntityType Entity type + * @param string $createdEntityId Created entity ID + * @param string $createdEntityType Created entity type + * @param string $actionLabel Label for the action + */ + private function logToStream($sourceEntity, string $sourceEntityType, string $createdEntityId, string $createdEntityType, string $actionLabel): void + { + // Create Note entity manually for custom message + $note = $this->entityManager->getEntity('Note'); + $note->set([ + 'type' => Note::TYPE_CREATE_RELATED, + 'parentType' => $sourceEntityType, + 'parentId' => $sourceEntity->getId(), + 'relatedType' => $createdEntityType, + 'relatedId' => $createdEntityId, + 'data' => [ + 'actionLabel' => $actionLabel + ] + ]); + + $this->entityManager->saveEntity($note); + } } diff --git a/data/config.php b/data/config.php index 33e181e8..a6693bbd 100644 --- a/data/config.php +++ b/data/config.php @@ -361,8 +361,8 @@ return [ 0 => 'youtube.com', 1 => 'google.com' ], - 'cacheTimestamp' => 1769362656, - 'microtime' => 1769362656.728453, + 'cacheTimestamp' => 1769362752, + 'microtime' => 1769362752.412734, 'siteUrl' => 'https://crm.bitbylaw.com', 'fullTextSearchMinLength' => 4, 'appTimestamp' => 1768843902,