feat: Add termination functionality for rental agreements

- Introduced new entity `CKuendigung` for managing terminations.
- Added fields for termination details including date, reason, type, and status.
- Implemented backend service to initiate terminations from rental agreements.
- Created frontend handler for termination actions with confirmation dialog.
- Updated metadata and layouts for `CKuendigung` to support new functionality.
- Added internationalization support for English and German languages.
- Enhanced existing entities to establish relationships with terminations.
This commit is contained in:
2026-01-24 12:45:57 +01:00
parent e490e261b7
commit 0d2d35bca1
28 changed files with 1115 additions and 36 deletions

View File

@@ -0,0 +1,70 @@
define('custom:handlers/mietverhaeltnis/termination-action', [], function () {
class TerminationActionHandler {
constructor(view) {
this.view = view;
}
/**
* Setup-Methode wird automatisch aufgerufen
*/
initInitiateTermination() {
// Optional: Button-Logik nach Render
}
/**
* Action-Handler (wird bei Button-Click aufgerufen)
*/
actionInitiateTermination() {
console.log('actionInitiateTermination called');
const model = this.view.model;
// Confirmation Dialog
this.view.confirm(
this.view.translate('confirmTermination', 'messages', 'CVmhMietverhltnis'),
() => {
console.log('Confirmation accepted, initiating termination');
this.initiateTermination(model.id);
}
);
}
/**
* AJAX Request zum Backend
*/
initiateTermination(mietverhaeltnisId) {
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
Espo.Ajax.postRequest('CVmhMietverhltnis/action/initiateTermination', {
id: mietverhaeltnisId
})
.then(response => {
Espo.Ui.success(
this.view.translate('terminationCreated', 'messages', 'CVmhMietverhltnis')
);
// Navigation zur erstellten Kündigung
this.view.getRouter().navigate(
'#CKuendigung/view/' + response.id,
{trigger: true}
);
})
.catch(xhr => {
console.error('Termination initiation failed:', xhr);
let errorMessage = this.view.translate('terminationError', 'messages', 'CVmhMietverhltnis');
if (xhr.status === 403) {
errorMessage = this.view.translate('Access denied', 'messages');
} else if (xhr.status === 404) {
errorMessage = this.view.translate('Not found', 'messages');
}
Espo.Ui.error(errorMessage);
});
}
}
return TerminationActionHandler;
});