From f7a24b8aefb454c4793e36efb8c0c75ba7ecea1c Mon Sep 17 00:00:00 2001 From: bsiggel Date: Sun, 25 Jan 2026 11:56:10 +0100 Subject: [PATCH] Enhance CKndigung entity: add new fields, update layouts, and implement document synchronization hook --- .../Custom/Hooks/CKndigung/DocumentSync.php | 75 +++++++++++++++++++ .../Resources/i18n/de_DE/CKndigung.json | 16 +++- .../Resources/i18n/en_US/CKndigung.json | 16 +++- .../Resources/layouts/CKndigung/detail.json | 45 +++++++++-- .../CVmhMietverhltnis/bottomPanelsDetail.json | 12 ++- .../metadata/entityDefs/CKndigung.json | 49 ++++++++++++ data/config.php | 4 +- 7 files changed, 204 insertions(+), 13 deletions(-) create mode 100644 custom/Espo/Custom/Hooks/CKndigung/DocumentSync.php diff --git a/custom/Espo/Custom/Hooks/CKndigung/DocumentSync.php b/custom/Espo/Custom/Hooks/CKndigung/DocumentSync.php new file mode 100644 index 00000000..2e71044a --- /dev/null +++ b/custom/Espo/Custom/Hooks/CKndigung/DocumentSync.php @@ -0,0 +1,75 @@ +getLinkMultipleIdList('vmhMietverhltnises'); + if (empty($mietverhältnisList)) { + return; + } + + // Get EntityManager from entity + $entityManager = $entity->getEntityManager(); + + // Link the document to the Mietverhältnis + foreach ($mietverhältnisList as $mietverhältnisId) { + $mietverhältnis = $entityManager->getEntityById('CVmhMietverhltnis', $mietverhältnisId); + if (!$mietverhältnis) { + continue; + } + + // Link document to Mietverhältnis if not already linked + $repository = $entityManager->getRDBRepositoryByClass('CVmhMietverhltnis'); + $isRelated = $repository->getRelation($mietverhältnis, 'dokumentesvmhMietverhltnisse') + ->isRelatedById($foreignEntity->getId()); + + if (!$isRelated) { + $repository->getRelation($mietverhältnis, 'dokumentesvmhMietverhltnisse') + ->relateById($foreignEntity->getId()); + } + } + } + + /** + * After a document is unrelated from Kündigung, optionally unrelate from Mietverhältnis + * Note: We don't automatically unrelate from Mietverhältnis because the document might + * have been added to Mietverhältnis independently + */ + public function afterUnrelate(Entity $entity, string $relationName, Entity $foreignEntity, UnrelateOptions $options): void + { + // Only process when unrelating documents from Kündigung + if ($relationName !== 'dokumenteskuendigung') { + return; + } + + // Note: We intentionally do NOT remove documents from Mietverhältnis + // because they might have been added there independently. + // Users must manually remove documents from Mietverhältnis if needed. + } +} diff --git a/custom/Espo/Custom/Resources/i18n/de_DE/CKndigung.json b/custom/Espo/Custom/Resources/i18n/de_DE/CKndigung.json index 94aa015c..e10c8e59 100644 --- a/custom/Espo/Custom/Resources/i18n/de_DE/CKndigung.json +++ b/custom/Espo/Custom/Resources/i18n/de_DE/CKndigung.json @@ -38,8 +38,16 @@ "zustellart": "Zustellart", "sendungsverfolgungsnummer": "Sendungsverfolgungsnummer", "mietrueckstand": "Mietrückstand", + "mietkaution": "Mietkaution", + "nebenkostenvorauszahlungen": "Nebenkostenvorauszahlungen", "vorzeitigeRaeumungZulaessig": "Vorzeitige Räumung zulässig", - "beschreibungBesorgnisgrund": "Beschreibung Besorgnisgrund" + "beschreibungBesorgnisgrund": "Beschreibung Besorgnisgrund", + "gerichtsrubrum": "Gerichtsrubrum", + "gegenstandswert": "Gegenstandswert", + "kuendigungsservice": "Kündigungsservice", + "aussergerichtlicheGebuehren13": "Außergerichtliche Gebühren (1,3)", + "gerichtskosten1Instanz": "Gerichtskosten 1. Instanz", + "anwaltskosten1Instanz": "Anwaltskosten 1. Instanz" }, "options": { "beendigungsTatbestand": { @@ -91,7 +99,11 @@ "syncStatus": "Status der Synchronisation mit Advoware", "sendungsverfolgungsnummer": "Sendungsverfolgungsnummer für Einschreiben", "mietrueckstand": "Gesamthöhe des Mietrückstands (nur bei Kündigungsgrund Mietrückstand)", + "mietkaution": "Einbehaltene oder ausstehende Mietkaution", + "nebenkostenvorauszahlungen": "Rückständige Nebenkostenvorauszahlungen", "vorzeitigeRaeumungZulaessig": "Ist eine vorzeitige Räumung nach § 257 oder § 259 ZPO zulässig?", - "beschreibungBesorgnisgrund": "Beschreibung des Besorgnisgrunds für vorzeitige Räumung nach § 259 ZPO" + "beschreibungBesorgnisgrund": "Beschreibung des Besorgnisgrunds für vorzeitige Räumung nach § 259 ZPO", + "gerichtsrubrum": "Rubrum für gerichtliche Unterlagen", + "kuendigungsservice": "Wird Kündigungsservice in Anspruch genommen?" } } \ No newline at end of file diff --git a/custom/Espo/Custom/Resources/i18n/en_US/CKndigung.json b/custom/Espo/Custom/Resources/i18n/en_US/CKndigung.json index dfc102d9..d7ec2ca1 100644 --- a/custom/Espo/Custom/Resources/i18n/en_US/CKndigung.json +++ b/custom/Espo/Custom/Resources/i18n/en_US/CKndigung.json @@ -23,8 +23,16 @@ "zustellart": "Delivery Method", "sendungsverfolgungsnummer": "Tracking Number", "mietrueckstand": "Rent Arrears", + "mietkaution": "Security Deposit", + "nebenkostenvorauszahlungen": "Utility Advance Payments", "vorzeitigeRaeumungZulaessig": "Early Eviction Permitted", - "beschreibungBesorgnisgrund": "Description of Concern" + "beschreibungBesorgnisgrund": "Description of Concern", + "gerichtsrubrum": "Court Heading", + "gegenstandswert": "Value in Dispute", + "kuendigungsservice": "Termination Service", + "aussergerichtlicheGebuehren13": "Extrajudicial Fees (1.3)", + "gerichtskosten1Instanz": "Court Costs 1st Instance", + "anwaltskosten1Instanz": "Attorney Fees 1st Instance" }, "links": { "meetings": "Meetings", @@ -91,7 +99,11 @@ "syncStatus": "Synchronization status with Advoware", "sendungsverfolgungsnummer": "Tracking number for registered mail", "mietrueckstand": "Total amount of rent arrears (only for termination reason rent arrears)", + "mietkaution": "Withheld or outstanding security deposit", + "nebenkostenvorauszahlungen": "Outstanding utility advance payments", "vorzeitigeRaeumungZulaessig": "Is early eviction permitted under § 257 or § 259 ZPO?", - "beschreibungBesorgnisgrund": "Description of the concern for early eviction under § 259 ZPO" + "beschreibungBesorgnisgrund": "Description of the concern for early eviction under § 259 ZPO", + "gerichtsrubrum": "Heading for court documents", + "kuendigungsservice": "Is termination service being used?" } } diff --git a/custom/Espo/Custom/Resources/layouts/CKndigung/detail.json b/custom/Espo/Custom/Resources/layouts/CKndigung/detail.json index bf4ce53e..a7bad02a 100644 --- a/custom/Espo/Custom/Resources/layouts/CKndigung/detail.json +++ b/custom/Espo/Custom/Resources/layouts/CKndigung/detail.json @@ -48,13 +48,19 @@ ] }, { - "label": "Mietrückstand", + "label": "Finanzielle Details", "style": "default", "tabBreak": false, "rows": [ [ { "name": "mietrueckstand" + }, + { + "name": "mietkaution" + }, + { + "name": "nebenkostenvorauszahlungen" } ] ] @@ -67,9 +73,7 @@ [ { "name": "vorzeitigeRaeumungZulaessig" - } - ], - [ + }, { "name": "beschreibungBesorgnisgrund" } @@ -77,10 +81,41 @@ ] }, { - "label": "Advoware Sync", + "label": "Gerichtskosten", "style": "default", "tabBreak": true, "tabLabel": "Erweitert", + "rows": [ + [ + { + "name": "gerichtsrubrum" + } + ], + [ + { + "name": "gegenstandswert" + }, + { + "name": "kuendigungsservice" + } + ], + [ + { + "name": "aussergerichtlicheGebuehren13" + }, + { + "name": "gerichtskosten1Instanz" + }, + { + "name": "anwaltskosten1Instanz" + } + ] + ] + }, + { + "label": "Advoware Sync", + "style": "default", + "tabBreak": false, "rows": [ [ { diff --git a/custom/Espo/Custom/Resources/layouts/CVmhMietverhltnis/bottomPanelsDetail.json b/custom/Espo/Custom/Resources/layouts/CVmhMietverhltnis/bottomPanelsDetail.json index 6c8cd16c..6b861428 100644 --- a/custom/Espo/Custom/Resources/layouts/CVmhMietverhltnis/bottomPanelsDetail.json +++ b/custom/Espo/Custom/Resources/layouts/CVmhMietverhltnis/bottomPanelsDetail.json @@ -60,12 +60,20 @@ "mietinkassos": { "index": 11 }, - "_tabBreak_4": { + "_tabBreak_7": { "index": 12, "tabBreak": true, + "tabLabel": "Kündigungen" + }, + "kndigungen": { + "index": 13 + }, + "_tabBreak_4": { + "index": 14, + "tabBreak": true, "tabLabel": "Dokumente" }, "dokumentesvmhMietverhltnisse": { - "index": 13 + "index": 15 } } \ No newline at end of file diff --git a/custom/Espo/Custom/Resources/metadata/entityDefs/CKndigung.json b/custom/Espo/Custom/Resources/metadata/entityDefs/CKndigung.json index b78d066b..5159a060 100644 --- a/custom/Espo/Custom/Resources/metadata/entityDefs/CKndigung.json +++ b/custom/Espo/Custom/Resources/metadata/entityDefs/CKndigung.json @@ -90,6 +90,41 @@ "tooltip": true, "isCustom": true }, + "gerichtsrubrum": { + "type": "text", + "required": false, + "isCustom": true + }, + "gegenstandswert": { + "type": "currency", + "required": false, + "default": 0, + "isCustom": true + }, + "kuendigungsservice": { + "type": "bool", + "required": false, + "default": false, + "isCustom": true + }, + "aussergerichtlicheGebuehren13": { + "type": "currency", + "required": false, + "default": 0, + "isCustom": true + }, + "gerichtskosten1Instanz": { + "type": "currency", + "required": false, + "default": 0, + "isCustom": true + }, + "anwaltskosten1Instanz": { + "type": "currency", + "required": false, + "default": 0, + "isCustom": true + }, "beendigungsTatbestand": { "type": "enum", "required": true, @@ -209,6 +244,20 @@ "default": 0, "tooltip": true, "isCustom": true + }, + "mietkaution": { + "type": "currency", + "required": false, + "default": 0, + "tooltip": true, + "isCustom": true + }, + "nebenkostenvorauszahlungen": { + "type": "currency", + "required": false, + "default": 0, + "tooltip": true, + "isCustom": true } }, "links": { diff --git a/data/config.php b/data/config.php index dda5be80..1734caec 100644 --- a/data/config.php +++ b/data/config.php @@ -360,8 +360,8 @@ return [ 0 => 'youtube.com', 1 => 'google.com' ], - 'cacheTimestamp' => 1769337671, - 'microtime' => 1769337671.657132, + 'cacheTimestamp' => 1769338296, + 'microtime' => 1769338296.697606, 'siteUrl' => 'https://crm.bitbylaw.com', 'fullTextSearchMinLength' => 4, 'appTimestamp' => 1768843902,